Index: camel/camel-store.c
===================================================================
--- camel/camel-store.c	(revision 8147)
+++ camel/camel-store.c	(working copy)
@@ -34,6 +34,8 @@
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 
+#include <gconf/gconf-client.h>
+
 #include "camel-debug.h"
 #include "camel-exception.h"
 #include "camel-folder.h"
@@ -56,7 +58,10 @@
 
 static CamelFolder *get_trash (CamelStore *store, CamelException *ex);
 static CamelFolder *get_junk (CamelStore *store, CamelException *ex);
+static CamelFolder *get_archived (CamelStore *store, CamelException *ex);
+static CamelFolder *get_archived_real_folder (CamelStore *store, char *archived_folder_name, CamelException *ex);
 
+
 static CamelFolderInfo *create_folder (CamelStore *store,
 				       const char *parent_name,
 				       const char *folder_name,
@@ -99,6 +104,8 @@
 	camel_store_class->get_inbox = get_inbox;
 	camel_store_class->get_trash = get_trash;
 	camel_store_class->get_junk = get_junk;
+ 	camel_store_class->get_archived = get_archived; 
+ 	camel_store_class->get_archived_real_folder = get_archived_real_folder; 
 	camel_store_class->create_folder = create_folder;
 	camel_store_class->delete_folder = delete_folder;
 	camel_store_class->rename_folder = rename_folder;
@@ -258,6 +265,13 @@
 			folder = CS_CLASS(store)->get_trash(store, ex);
 		} else if ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0) {
 			folder = CS_CLASS(store)->get_junk(store, ex);
+		} else if ((store->flags & CAMEL_STORE_VARCHIVED) && strcmp(folder_name, CAMEL_VARCHIVED_NAME) == 0) {
+			folder = CS_CLASS(store)->get_archived(store, ex);
+		}
+		else if (g_strrstr (folder_name, ".Archived")){
+			printf("Can get archived physical folder here in. \n");
+			
+			folder = CS_CLASS(store)->get_archived_real_folder(store, folder_name, ex);
 		} else {
 			folder = CS_CLASS (store)->get_folder(store, folder_name, flags, ex);
 			if (folder) {
@@ -335,7 +349,8 @@
 
 	if ((parent_name == NULL || parent_name[0] == 0)
 	    && (((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0)
-		|| ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0))) {
+		|| ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0)
+		|| ((store->flags & CAMEL_STORE_VARCHIVED) && strcmp(folder_name, CAMEL_VARCHIVED_NAME) == 0))){
 		camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_INVALID,
 				     _("Cannot create folder: %s: folder exists"), folder_name);
 		return NULL;
@@ -370,6 +385,12 @@
 			camel_object_unref(vfolder);
 		}
 
+		if ((store->flags & CAMEL_STORE_VARCHIVED)
+		    && (vfolder = camel_object_bag_get(store->folders, CAMEL_VARCHIVED_NAME))) {
+			camel_vee_folder_remove_folder(vfolder, folder);
+			camel_object_unref(vfolder);
+		}
+
 		camel_folder_delete(folder);
 
 		camel_object_bag_remove(store->folders, folder);
@@ -399,7 +420,8 @@
 
 	/* TODO: should probably be a parameter/bit on the storeinfo */
 	if (((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0)
-	    || ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0)) {
+	    || ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0)
+	    || ((store->flags & CAMEL_STORE_VARCHIVED) && strcmp(folder_name, CAMEL_VARCHIVED_NAME) == 0)){
 		camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
 				     _("Cannot delete folder: %s: Invalid operation"), folder_name);
 		return;
@@ -449,7 +471,8 @@
 		return;
 
 	if (((store->flags & CAMEL_STORE_VTRASH) && strcmp(old_namein, CAMEL_VTRASH_NAME) == 0)
-	    || ((store->flags & CAMEL_STORE_VJUNK) && strcmp(old_namein, CAMEL_VJUNK_NAME) == 0)) {
+	    || ((store->flags & CAMEL_STORE_VJUNK) && strcmp(old_namein, CAMEL_VJUNK_NAME) == 0)
+	    || ((store->flags & CAMEL_STORE_VARCHIVED) && strcmp(old_namein, CAMEL_VARCHIVED_NAME) == 0)){
 		camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
 				     _("Cannot rename folder: %s: Invalid operation"), old_namein);
 		return;
@@ -576,6 +599,16 @@
 	}
 	g_ptr_array_free(folders, TRUE);
 
+	/* Setting now the archived physical folders */
+	/*folders = camel_object_bag_list(store->priv->archived_folders); */
+	/*for (i=0;i<folders->len;i++) { */
+	/*	if (!CAMEL_IS_VTRASH_FOLDER(folders->pdata[i])){ */
+	/*       	camel_vee_folder_add_folder((CamelVeeFolder *)folder, (CamelFolder *)folders->pdata[i]); */
+	/* 	} */
+	/* 	camel_object_unref(folders->pdata[i]); */
+	/*} */
+	/*g_ptr_array_free(folders, TRUE); */
+	
 	return folder;
 }
 
@@ -591,7 +624,62 @@
 	return get_special(store, CAMEL_VTRASH_FOLDER_JUNK);
 }
 
+/* This returns you virtual folder */
+static CamelFolder *
+get_archived(CamelStore *store, CamelException *ex)
+{
+	return get_special(store, CAMEL_VTRASH_FOLDER_ARCHIVED); 
+}
+
+/* This returns you physical folder */
+static CamelFolder *
+get_archived_real_folder(CamelStore *store, char * archived_folder_name, CamelException *ex)
+{
+	w(g_warning ("CamelStore::create_folder not implemented for `%s'",
+		     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))));
+	
+	camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_INVALID,
+			      _("Cannot create folder: Invalid operation on this store"));
+	
+	return NULL;
+}
+
 /** 
+ * camel_store_get_real_archived:
+ * @store: a #CamelStore object
+ * @ex: a #CamelException
+ *
+ * Returns the folder in the store into which trash is delivered, or
+ * %NULL if no such folder exists.
+ **/
+CamelFolder *
+camel_store_get_archived_real_folder (CamelStore *store, char * folder_name, CamelException *ex)
+{
+	char * real_folder_name ;
+	sprintf(real_folder_name, "%s", folder_name);
+	
+	return camel_store_get_folder(store, real_folder_name, 0, ex);
+}
+
+
+/** 
+ * camel_store_get_archived:
+ * @store: a #CamelStore object
+ * @ex: a #CamelException
+ *
+ * Returns the folder in the store into which trash is delivered, or
+ * %NULL if no such folder exists.
+ **/
+CamelFolder *
+camel_store_get_archived (CamelStore *store, CamelException *ex)
+{
+	if ((store->flags & CAMEL_STORE_VARCHIVED) == 0)
+		return CS_CLASS(store)->get_archived (store, ex);
+	else
+		return camel_store_get_folder(store, CAMEL_VARCHIVED_NAME, 0, ex);
+}
+
+/** 
  * camel_store_get_trash:
  * @store: a #CamelStore object
  * @ex: a #CamelException
@@ -796,8 +884,12 @@
 		if (info->uri && (store->flags & CAMEL_STORE_VJUNK))
 			/* the name of the Junk folder, used for spam messages */
 			add_special_info (store, info, CAMEL_VJUNK_NAME, _("Junk"), TRUE, CAMEL_FOLDER_VIRTUAL|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VTRASH|CAMEL_FOLDER_TYPE_JUNK);
+
+		if (info->uri && (store->flags & CAMEL_STORE_VARCHIVED))
+		/* Lucky : Adding An Archived folder for archived messasges */
+			add_special_info (store, info, CAMEL_VARCHIVED_NAME, _("Archived"), TRUE, CAMEL_FOLDER_VIRTUAL|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VARCHIVED|CAMEL_FOLDER_TYPE_ARCHIVED); 
 	}
-
+	
 	if (camel_debug_start("store:folder_info")) {
 		char *url = camel_url_to_string(((CamelService *)store)->url, CAMEL_URL_HIDE_ALL);
 		printf("Get folder info(%p:%s, '%s') =\n", store, url, top?top:"<null>");
@@ -1169,6 +1261,69 @@
 	CAMEL_STORE_UNLOCK(store, folder_lock);
 }
 
+/**
+ * camel_store_archive_messages:
+ * @store: a #CamelStore object
+ * @ex: a #CamelException
+ *
+ * Subscribe to the folder described by @folder_name.
+ **/
+int
+camel_store_archive_messages(CamelStore *store, CamelException *ex)
+{
+	/* g_return_if_fail (CAMEL_IS_STORE (store)); */
+
+	GPtrArray *folder_list = camel_object_bag_list(store->folders);
+	GPtrArray *messages;
+	time_t t = time(NULL);
+	CamelFolder *folder;
+	CamelMessageInfoBase * info;
+	int i, j, count=0, older_than_day=60, days_week_months_int=0;
+	char *days_week_months;
+
+	/* Reading gconf settings */
+	GConfClient *gconf;
+
+	gconf = mail_config_get_gconf_client ();
+	
+	older_than_day = gconf_client_get_int (gconf, "/apps/evolution/mail/archive/no_of_days", NULL);
+	days_week_months = (char *) gconf_client_get_string (gconf, "/apps/evolution/mail/archive/days_weeks_months", NULL);
+	if(! strcmp(days_week_months, "Weeks"))
+		days_week_months_int = 7;
+	else if(! strcmp(days_week_months, "Days"))
+		days_week_months_int = 1;
+	if(! strcmp(days_week_months, "Months"))
+		days_week_months_int = 30;
+
+
+	for (i=0; i<folder_list->len; i++){
+		folder = (CamelFolder *) folder_list->pdata[i];
+		
+		if(g_str_has_prefix(folder->name , ".Archvied"))
+			continue;
+		
+		messages = folder->summary->messages;
+		
+		camel_folder_freeze (folder);
+		for(j=0 ;j<messages->len ; j++){
+			info = (CamelMessageInfoBase*) messages->pdata[j];
+			
+			/* This is fixed to archived messages less than 3 days */
+			/* TO DO : Please read settings from gconf */
+			/* No junk message / previously archived message 
+			   And received date less than this particular date will be archived */
+			if(((older_than_day*(60*60*24)*days_week_months_int) <= (t - info->date_received)) && (!(info->flags & (CAMEL_MESSAGE_ARCHIVED|CAMEL_MESSAGE_JUNK)))){
+				camel_folder_set_message_flags(folder, info->uid, CAMEL_MESSAGE_ARCHIVED|CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_ARCHIVED);
+				count ++;
+			}
+		}
+		camel_folder_thaw (folder);
+	}
+
+	return count;
+}
+
+
 static void
 noop (CamelStore *store, CamelException *ex)
 {
Index: camel/camel-store.h
===================================================================
--- camel/camel-store.h	(revision 8147)
+++ camel/camel-store.h	(working copy)
@@ -75,6 +75,8 @@
 #define CAMEL_FOLDER_SHARED_TO_ME (1<<8)
 /* a folder that i'm sharing */
 #define CAMEL_FOLDER_SHARED_BY_ME (1<<9)
+/* an archived folder */
+#define CAMEL_FOLDER_VARCHIVED (8 << 10)
 
 /* use 3 bits as a hint for a folder type */
 #define CAMEL_FOLDER_TYPE_MASK (7 << 10)
@@ -91,6 +93,8 @@
 #define CAMEL_FOLDER_TYPE_JUNK (4 << 10)
 /* a sent-items folder */
 #define CAMEL_FOLDER_TYPE_SENT (5 << 10)
+/* an archived folder */
+#define CAMEL_FOLDER_TYPE_ARCHIVED (6 << 10)
 
 /* next bit is 1<<13 */
 
@@ -115,6 +119,7 @@
 #define CAMEL_STORE_FILTER_INBOX	(1 << 2)
 #define CAMEL_STORE_VJUNK		(1 << 3)
 #define CAMEL_STORE_PROXY		(1 << 4)
+#define CAMEL_STORE_VARCHIVED		(1 << 5)
 
 struct _CamelStore {
 	CamelService parent_object;
@@ -153,6 +158,10 @@
 	CamelFolder *   (*get_inbox)                (CamelStore *store, CamelException *ex);	
 	CamelFolder *   (*get_trash)                (CamelStore *store, CamelException *ex);
 	CamelFolder *   (*get_junk)                 (CamelStore *store, CamelException *ex);
+	CamelFolder *   (*get_archived)             (CamelStore *store, CamelException *ex);
+	CamelFolder *   (*get_archived_real_folder)  (CamelStore *store, 
+						      char * archived_folder_name, 
+						      CamelException *ex);
 	
 	CamelFolderInfo *(*create_folder)           (CamelStore *store,
 						     const char *parent_name,
@@ -201,6 +210,11 @@
 						 CamelException *ex);
 CamelFolder *    camel_store_get_junk           (CamelStore *store,
 						 CamelException *ex);
+CamelFolder *    camel_store_get_archived       (CamelStore *store,
+						 CamelException *ex);
+CamelFolder*     camel_store_get_archived_real_folder (CamelStore *store, 
+						       char * folder_name, 
+						       CamelException *ex);
 
 CamelFolderInfo *camel_store_create_folder      (CamelStore *store,
 						 const char *parent_name,
Index: camel/providers/groupwise/camel-groupwise-summary.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-summary.c	(revision 8147)
+++ camel/providers/groupwise/camel-groupwise-summary.c	(working copy)
@@ -248,7 +248,21 @@
 {
 	guint32 old;
 	CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info;
+	CamelFolder *folder;
+	CamelException *ex;
 
+	if(set & CAMEL_MESSAGE_ARCHIVED)
+	{
+		folder = mi->summary->folder;
+		
+		/* Download message for arhiving */
+		/* Will only download messages if message are getting marked as archved adn not at unarchiving messages */
+		if(camel_folder_get_message (folder, mi->uid, ex))
+			printf("==========UID %s Got message for archiving purpose=============.\n", mi->uid);
+		else
+			printf("==========UID %s UNABLE TO GET THE MESSAGE for Archived =============.\n", mi->uid);
+	}
+
 	/* TODO: locking? */
 
 	old = mi->flags;
Index: camel/providers/groupwise/camel-groupwise-store.h
===================================================================
--- camel/providers/groupwise/camel-groupwise-store.h	(revision 8147)
+++ camel/providers/groupwise/camel-groupwise-store.h	(working copy)
@@ -73,6 +73,7 @@
 /*IMplemented*/
 const char *camel_groupwise_store_container_id_lookup (CamelGroupwiseStore *gw_store, const char *folder_name);
 const char *camel_groupwise_store_folder_lookup (CamelGroupwiseStore *gw_store, const char *container_id);
+static void camel_groupwise_store_insert_all_hash (CamelGroupwiseStore *gw_store, const char *full_name);
 EGwConnection *cnc_lookup (CamelGroupwiseStorePrivate *priv);
 char *storage_path_lookup (CamelGroupwiseStorePrivate *priv);
 const char *groupwise_base_url_lookup (CamelGroupwiseStorePrivate *priv);
Index: camel/providers/groupwise/camel-groupwise-folder.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-folder.c	(revision 8147)
+++ camel/providers/groupwise/camel-groupwise-folder.c	(working copy)
@@ -58,7 +58,7 @@
 #include "camel-groupwise-journal.h"
 #include "camel-groupwise-private.h"
 #include "camel-groupwise-store.h"
-#include "camel-groupwise-store.h"
+#include "camel-groupwise-store-summary.h"
 #include "camel-groupwise-summary.h"
 #include "camel-groupwise-utils.h"
 #include "camel-groupwise-utils.h"
@@ -422,7 +422,7 @@
 	g_free (folders);
 
 	summary_path = g_strdup_printf ("%s/summary", folder_dir);
-
+	
 	CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 	g_free (gw_folder->cache->path);
 	gw_folder->cache->path = g_strdup (folder_dir);
@@ -560,6 +560,34 @@
 }
 
 static void 
+move_to_archived (CamelFolder *source, CamelMessageInfo *info, const char * archived_folder_name, CamelException *ex)
+{
+	CamelFolder *dest;
+	GPtrArray *uids;
+	CamelFolderInfo *fi;
+	const char *uid = camel_message_info_uid (info); 
+
+	uids = g_ptr_array_new ();
+	g_ptr_array_add (uids, (gpointer) uid);
+	
+	dest = camel_store_get_folder (source->parent_store, archived_folder_name, 0, ex);
+	if(!dest){
+		fi = create_archived_folder (source->parent_store, archived_folder_name);
+		dest = camel_store_get_folder (source->parent_store, archived_folder_name, 0, ex);
+		if (!dest)
+			g_warning ("Could not get Archived folder message not moved");
+		else
+			groupwise_transfer_messages_to (source, uids, dest, NULL, FALSE, ex);
+	}
+	else
+		groupwise_transfer_messages_to (source, uids, dest, NULL, FALSE, ex);
+
+	printf(" ==================================== Messages moved to archived message folders ======================== \n");
+}
+
+
+
+static void 
 move_to_junk (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex)
 {
 	CamelFolder *dest;
@@ -620,8 +648,9 @@
 	}
 	cnc = cnc_lookup (priv);
 
-	container_id =  camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
+	container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
 
+	/* printf("Constainer id = %s folder = %s\n", container_id, folder->full_name); */
 	CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 	if (!camel_groupwise_store_connected (gw_store, ex)) {
 		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
@@ -657,7 +686,7 @@
 			camel_data_cache_remove (gw_folder->cache, "cache", camel_message_info_uid(info), NULL);
 			continue;
 		}
-
+		
 		if (gw_info && (gw_info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) {
 			do_flags_diff (&diff, gw_info->server_flags, gw_info->info.flags);
 			do_flags_diff (&unset_flags, flags, gw_info->server_flags);
@@ -714,7 +743,6 @@
 						if (status == E_GW_CONNECTION_STATUS_OK) {
 							char *uid;
 							while (deleted_items) {
-								uid = (char *)deleted_items->data;
 								CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 								camel_folder_summary_remove_uid (folder->summary, uid);
 								camel_data_cache_remove(gw_folder->cache, "cache", uid, NULL);
@@ -749,6 +777,7 @@
 			char *uid;
 			while (deleted_items) {
 				uid = (char *)deleted_items->data;
+
 				CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 				camel_folder_summary_remove_uid (folder->summary, uid);
 				camel_data_cache_remove(gw_folder->cache, "cache", uid, NULL);
@@ -1937,6 +1966,17 @@
 		}
 
 		if (!temp) {
+	 		printf ("==========GW_MESSAGE: Message is deleted from the server.============\n");
+			if(((CamelMessageInfoBase*) info)->flags & CAMEL_MESSAGE_ARCHIVED){
+				printf("*********** The deleted message is archived message uid=%s ********\n", info->uid);
+				char * archived_folder_name = g_malloc (sizeof(char)*1000);
+				sprintf(archived_folder_name, ".Archived/%s", folder->name); 
+				move_to_archived (folder, info, archived_folder_name, ex); 
+					
+				/* Third argument flag is delete from source */
+				/* camel_folder_transfer_messages_to (folder, uids, dest, NULL, 0, ex); */
+			}
+
 			CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 			camel_folder_summary_remove_uid (folder->summary, info->uid);
 			camel_data_cache_remove (gw_folder->cache, "cache", info->uid, NULL);
@@ -2090,8 +2130,17 @@
 		source_container_id = camel_groupwise_store_container_id_lookup (gw_store, source->full_name) ;
 	else
 		source_container_id = NULL;
-	dest_container_id = camel_groupwise_store_container_id_lookup (gw_store, destination->full_name) ;
 
+	printf("*********root->container = %s************\n", gw_store->root_container) ;
+
+	printf(" soruce cont id=%s ,", source_container_id);
+	dest_container_id = camel_groupwise_store_container_id_lookup (gw_store, destination->full_name) ; 
+	printf("destination_cont id = %s\n",  dest_container_id);
+	/* 	if(dest_container_id==NULL) */
+	/* 		dest_container_id = g_strdup(gw_store->root_container); */
+	/* g_strdup (source_container_id) ; */
+
+	
 	CAMEL_SERVICE_REC_LOCK (source->parent_store, connect_lock);
 	/* check for offline operation */
 	if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
Index: camel/providers/groupwise/camel-groupwise-store.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-store.c	(revision 8147)
+++ camel/providers/groupwise/camel-groupwise-store.c	(working copy)
@@ -79,6 +79,7 @@
 static void groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex);
 static int match_path(const char *path, const char *name);
 
+static CamelFolderInfo* groupwise_create_folder(CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
 
 
 static void
@@ -115,6 +116,14 @@
 	if (!priv->storage_path)
 		return;
 	
+	/* Setting Groupwise for showing virtual archived folder */
+	store->flags |= CAMEL_STORE_VARCHIVED;
+
+	/* Setting up the physical archived folder */
+	char * archived_folder_name = ".Archived";
+	char * folder_dir = e_path_to_physical (priv->storage_path, archived_folder_name);
+	CamelFolderInfo *new_folder = camel_gw_folder_new (groupwise_store, archived_folder_name, folder_dir, ex); 
+	
 	/*store summary*/
 	path = g_alloca (strlen (priv->storage_path) + 32);
 	sprintf (path, "%s/.summary", priv->storage_path);
@@ -155,6 +164,9 @@
 
 	store->flags &= ~CAMEL_STORE_VJUNK;
 	store->flags &= ~CAMEL_STORE_VTRASH;
+
+/* 	g_free (archived_folder_name); */
+/* 	g_free (folder_dir); */
 }
 
 static guint
@@ -529,8 +541,11 @@
 	CamelFolder *folder;
 	char *folder_dir, *storage_path;
 
+	
 	storage_path = g_strdup_printf("%s/folders", priv->storage_path);
+	
 	folder_dir = e_path_to_physical (storage_path, folder_name);
+	printf ("FOLDER DIR = %s\n", folder_dir);
 	g_free(storage_path);
 	if (!folder_dir || g_access (folder_dir, F_OK) != 0) {
 		g_free (folder_dir);
@@ -1176,6 +1191,49 @@
 
 /* To create a junk mail folder in case  we want it and it isn't there*/
 CamelFolderInfo *
+create_archived_folder (CamelStore *store, char * archived_folder_name)
+{
+	CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
+	CamelGroupwiseStorePrivate  *priv = groupwise_store->priv;
+	CamelFolderInfo *root = NULL;
+	char *parent_name, *container_id, *child_container_id, *parent_id;
+	int status;
+
+	parent_name = "";
+	parent_id = "";
+	/* TODO: check for offlining*/
+		
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+	root = groupwise_build_folder_info (groupwise_store, parent_name, archived_folder_name);
+	camel_store_summary_save((CamelStoreSummary *)groupwise_store->summary);
+	
+	char * short_name = strrchr (archived_folder_name, '/');
+	if (short_name)
+		short_name++;
+	else
+		short_name = archived_folder_name;
+	
+	container_id = e_gw_connection_get_container_id (priv->cnc, short_name); 
+	if (!container_id) 
+		g_warning("failed to retrieve id for archived folder"); 
+	
+	child_container_id = g_malloc(sizeof(char)*1000);
+	sprintf(child_container_id, "%s%s", archived_folder_name, container_id);
+
+	/* printf (" What is the container id and %s === %s \n", container_id, child_container_id); */
+	
+	g_hash_table_insert (priv->id_hash, g_strdup(child_container_id), g_strdup(archived_folder_name)); 
+	g_hash_table_insert (priv->name_hash, g_strdup(archived_folder_name), g_strdup(child_container_id));
+	g_hash_table_insert (priv->parent_hash, g_strdup(child_container_id), g_strdup(parent_id));
+	camel_object_trigger_event (CAMEL_OBJECT (store), "folder_created", root);
+
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
+
+	return root;
+}
+
+/* To create a junk mail folder in case  we want it and it isn't there*/
+CamelFolderInfo *
 create_junk_folder (CamelStore *store)
 {
 	CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
@@ -1253,6 +1311,7 @@
 	status = e_gw_connection_create_folder(priv->cnc,parent_id,folder_name, &child_container_id);
 	if (status == E_GW_CONNECTION_STATUS_OK) {
 		root = groupwise_build_folder_info(groupwise_store, parent_name,folder_name);
+		printf("===================ARCHIVED FOLDER Name in groupwise = %s parent %s prent_id=%s, child_id=%s ==================\n", folder_name, parent_name, parent_id, child_container_id); 
 		camel_store_summary_save((CamelStoreSummary *)groupwise_store->summary);
 
 		g_hash_table_insert (priv->id_hash, g_strdup(child_container_id), g_strdup(folder_name)); 
@@ -1388,7 +1447,6 @@
 	return g_hash_table_lookup (priv->id_hash, container_id);
 }
 
-
 EGwConnection *
 cnc_lookup (CamelGroupwiseStorePrivate *priv)
 {
@@ -1423,6 +1481,45 @@
 		return NULL;
 }
 
+/* Lucky : Implementing get_archived  (for virtual archived folder ) */
+static CamelFolder *
+groupwise_get_archived(CamelStore *store, CamelException *ex)
+{
+	CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_archived(store, ex);
+
+	if (folder) {
+		char *state = g_build_filename(((CamelGroupwiseStore *)store)->priv->storage_path, "system", "Archived", "cmeta", NULL);
+		
+		camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state, NULL);
+		g_free(state);
+		/* no defaults? */
+		camel_object_state_read(folder);
+	}
+
+	return folder;
+}
+
+/* Lucky: Implementing get_real_archived  (for real/physical archived folder ) */
+static CamelFolder *
+groupwise_get_archived_real_folder(CamelStore *store, char * archived_folder_name, CamelException *ex)
+{
+	CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
+	CamelFolder *folder=NULL;
+	int i=0;
+	
+	/* folder = groupwise_get_folder_from_disk (store, archived_folder_name, 0, ex); */
+	
+	char * folder_dir = e_path_to_physical (groupwise_store->priv->storage_path, archived_folder_name);  
+	printf("ARCHIVED FOLDER Name %s\n", archived_folder_name); 
+	groupwise_create_folder (store, folder_dir, archived_folder_name, ex); 
+	folder = camel_gw_folder_new (groupwise_store, archived_folder_name, folder_dir, ex);   
+	
+	g_free (folder_dir);  
+	
+	/* camel_object_ref (folder); */
+	return folder;
+}
+
 /*
  * Function to check if we are both connected and are _actually_
  * online. Based on an equivalient function in IMAP
@@ -1491,6 +1588,8 @@
 	camel_store_class->get_folder_info = groupwise_get_folder_info;
 	camel_store_class->free_folder_info = camel_store_free_folder_info_full;
 	camel_store_class->get_trash = groupwise_get_trash;
+	camel_store_class->get_archived = groupwise_get_archived;
+	camel_store_class->get_archived_real_folder = groupwise_get_archived_real_folder;
 }
 
 
Index: camel/providers/imap/camel-imap-store.c
===================================================================
--- camel/providers/imap/camel-imap-store.c	(revision 8147)
+++ camel/providers/imap/camel-imap-store.c	(working copy)
@@ -98,6 +98,8 @@
 static void imap_noop (CamelStore *store, CamelException *ex);
 static CamelFolder *imap_get_junk(CamelStore *store, CamelException *ex);
 static CamelFolder *imap_get_trash(CamelStore *store, CamelException *ex);
+static CamelFolder *imap_get_archived(CamelStore *store,CamelException *ex);
+static CamelFolder *imap_get_archived_real_folder(CamelStore *store, char * archived_folder_name, CamelException *ex);
 static GList *query_auth_types (CamelService *service, CamelException *ex);
 static guint hash_folder_name (gconstpointer key);
 static gint compare_folder_name (gconstpointer a, gconstpointer b);
@@ -162,6 +164,8 @@
 	camel_store_class->noop = imap_noop;
 	camel_store_class->get_trash = imap_get_trash;
 	camel_store_class->get_junk = imap_get_junk;
+	camel_store_class->get_archived = imap_get_archived;
+	camel_store_class->get_archived_real_folder = imap_get_archived_real_folder;
 	
 	camel_disco_store_class->can_work_offline = can_work_offline;
 	camel_disco_store_class->connect_online = imap_connect_online;
@@ -303,12 +307,24 @@
 		imap_store->custom_headers = g_strdup(camel_url_get_param (url, "imap_custom_headers"));
 	}
 
+	/* Setting IMAP for showing virtual archived folder */
+	store->flags |= CAMEL_STORE_VARCHIVED;
 
 	/* setup journal*/
 	path = g_strdup_printf ("%s/journal", imap_store->storage_path);
 	disco_store->diary = camel_disco_diary_new (disco_store, path, ex);
 	g_free (path);
 
+	/* Setting up the physical archived folder */
+	char * archived_folder_name = ".Archived";
+	char * folder_dir = imap_path_to_physical (imap_store->storage_path, archived_folder_name);
+	CamelFolder *new_folder = camel_imap_folder_new (imap_store, archived_folder_name, folder_dir, ex);
+	
+	/* Creating inbox folder by default */
+	archived_folder_name = g_strdup(".Archived/INBOX");
+	folder_dir = imap_path_to_physical (imap_store->storage_path, archived_folder_name);
+	new_folder = camel_imap_folder_new (imap_store, archived_folder_name, folder_dir, ex);
+
 	/* setup/load the store summary */
 	tmp = alloca(strlen(imap_store->storage_path)+32);
 	sprintf(tmp, "%s/.ev-store-summary", imap_store->storage_path);
@@ -333,6 +349,8 @@
 		imap_store->capabilities = is->capabilities;
 		imap_set_server_level(imap_store);
 	}
+	g_free (archived_folder_name);
+	g_free (folder_dir);
 }
 
 static int
@@ -1716,6 +1734,40 @@
 	return folder;
 }
 
+/* Lucky : Implementing get_archived  (for virtual archived folder ) */
+static CamelFolder *
+imap_get_archived(CamelStore *store, CamelException *ex)
+{
+	CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_archived(store, ex);
+
+	if (folder) {
+		char *state = g_build_filename(((CamelImapStore *)store)->storage_path, "system", "Archived.cmeta", NULL);
+
+		camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state, NULL);
+		g_free(state);
+		/* no defaults? */
+		camel_object_state_read(folder);
+	}
+
+	return folder;
+}
+
+/* Lucky: Implementing get_real_archived  (for real/physical archived folder ) */
+static CamelFolder *
+imap_get_archived_real_folder(CamelStore *store, char * archived_folder_name, CamelException *ex)
+{
+	CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
+	CamelFolder *folder=NULL;
+	int i=0;
+
+	char * folder_dir = imap_path_to_physical (imap_store->storage_path, archived_folder_name);
+	printf(" ARCHIVED FOLDER Name %s in dir=%s\n", archived_folder_name, folder_dir);
+	folder = camel_imap_folder_new (imap_store, archived_folder_name, folder_dir, ex);
+	g_free (folder_dir);
+	
+	return folder;
+}
+
 static guint
 hash_folder_name (gconstpointer key)
 {
Index: camel/providers/imap/camel-imap-folder.c
===================================================================
--- camel/providers/imap/camel-imap-folder.c	(revision 8147)
+++ camel/providers/imap/camel-imap-folder.c	(working copy)
@@ -1524,26 +1524,36 @@
 	char *uidset;
 	int uid = 0, last=0, i;
 	
-	while (uid < uids->len && !camel_exception_is_set (ex)) {
-		uidset = imap_uid_array_to_set (source->summary, uids, uid, UID_SET_LIMIT, &uid);
+ 	if(g_strrstr (destination->full_name, ".Archived")){ 
+		CamelMimeMessage *message;
+		CamelMessageInfo *mi;
+		char *uid;
+		int i;
 
-		if ((store->capabilities & IMAP_CAPABILITY_XGWMOVE) && delete_originals) {
-			response = camel_imap_command (store, source, ex, "UID XGWMOVE %s %F", uidset, destination->full_name);
-			/* TODO: EXPUNGE returns??? */
-			camel_imap_response_free (store, response);
-		} else {
-			response = camel_imap_command (store, source, ex, "UID COPY %s %F", uidset, destination->full_name);
-			if (response && (store->capabilities & IMAP_CAPABILITY_UIDPLUS))
-				handle_copyuid (response, source, destination);
-			camel_imap_response_free (store, response);
-
-			if (!camel_exception_is_set(ex) && delete_originals) {
-				for (i=last;i<uid;i++)
-					camel_folder_delete_message(source, uids->pdata[i]);
-				last = uid;
+		imap_transfer_offline (source, uids, destination, NULL, delete_originals, ex) ;
+		printf(" FOUND .archived while moving .. \n"); 
+	}else{
+		while (uid < uids->len && !camel_exception_is_set (ex)) {
+			uidset = imap_uid_array_to_set (source->summary, uids, uid, UID_SET_LIMIT, &uid);
+			
+			if ((store->capabilities & IMAP_CAPABILITY_XGWMOVE) && delete_originals) {
+				response = camel_imap_command (store, source, ex, "UID XGWMOVE %s %F", uidset, destination->full_name);
+				/* TODO: EXPUNGE returns??? */
+				camel_imap_response_free (store, response);
+			} else {
+				response = camel_imap_command (store, source, ex, "UID COPY %s %F", uidset, destination->full_name);
+				if (response && (store->capabilities & IMAP_CAPABILITY_UIDPLUS))
+					handle_copyuid (response, source, destination);
+				camel_imap_response_free (store, response);
+				
+				if (!camel_exception_is_set(ex) && delete_originals) {
+					for (i=last;i<uid;i++)
+						camel_folder_delete_message(source, uids->pdata[i]);
+					last = uid;
+				}
 			}
+			g_free (uidset);
 		}
-		g_free (uidset);
 	}
 }
 
@@ -2654,6 +2664,30 @@
 				continue;
 			}
 			
+			if(((CamelImapMessageInfo *)info)->info.flags & CAMEL_MESSAGE_ARCHIVED) {
+				char * dest_folder_uri = g_malloc(strlen("imap://wlakke@blr-dsmaster1/.Archived/")+strlen(folder->name)+1);
+				/* char * dest_folder_uri = g_malloc(300); */
+				GPtrArray * uids=g_ptr_array_new ();
+				CamelFolder *dest;
+
+				/* sprintf(dest_folder_uri, "imap://wlakke@blr-dsmaster1/.Archived/%s", folder->name);   */
+				sprintf(dest_folder_uri, ".Archived/%s", folder->name);
+				/* free (dest_folder_name); */
+				
+				g_ptr_array_add (uids, info->uid);
+				/* uids = message_list_get_selected(emfv->list); */
+				
+				printf(" WHAT FOLDER FROM MESAGE LIST=%s\n", dest_folder_uri);
+				/* dest = mail_tool_uri_to_folder (dest_folder_uri, 0, ex); */
+				dest = camel_store_get_archived_real_folder (folder->parent_store, dest_folder_uri, ex); 
+				
+				/* Third flag is delete from source */
+				camel_folder_transfer_messages_to (folder, uids, dest, NULL, 0, ex);
+
+				printf("||||||||||||| Message archived but deleted from this folder=%s. MOVING TO ARCHIVEED FOLDER ||||||||||\n", info->uid);
+				g_free (dest_folder_uri);
+			}
+
 			camel_folder_change_info_remove_uid (changes, camel_message_info_uid (info));
 			CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
 			camel_imap_message_cache_remove (imap_folder->cache, camel_message_info_uid (info));
Index: camel/camel-folder.c
===================================================================
--- camel/camel-folder.c	(revision 8147)
+++ camel/camel-folder.c	(working copy)
@@ -610,6 +610,25 @@
 	return count;
 }
 
+/**
+ * camel_folder_get_archived_message_count:
+ * @folder: a #CamelFolder object
+ *
+ * Returns the number of archived messages in the folder, or %-1 if
+ * unknown
+ **/
+int
+camel_folder_get_archived_message_count (CamelFolder *folder)
+{
+	int count = -1;
+
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
+
+	camel_object_get(folder, NULL, CAMEL_FOLDER_ARCHIVED, &count, 0);
+
+	return count;
+}
+
 static void
 append_message (CamelFolder *folder, CamelMimeMessage *message,
 		const CamelMessageInfo *info, char **appended_uid,
Index: camel/camel-folder.h
===================================================================
--- camel/camel-folder.h	(revision 8147)
+++ camel/camel-folder.h	(working copy)
@@ -48,6 +48,7 @@
 	CAMEL_FOLDER_ARG_UNREAD, /* unread messages */
 	CAMEL_FOLDER_ARG_DELETED, /* deleted messages */
 	CAMEL_FOLDER_ARG_JUNKED, /* junked messages */
+	CAMEL_FOLDER_ARG_ARCHIVED, /* archived messages */
 	CAMEL_FOLDER_ARG_VISIBLE, /* visible !(deleted or junked) */
 	CAMEL_FOLDER_ARG_UID_ARRAY,
 	CAMEL_FOLDER_ARG_INFO_ARRAY,
@@ -64,6 +65,7 @@
 	CAMEL_FOLDER_UNREAD = CAMEL_FOLDER_ARG_UNREAD | CAMEL_ARG_INT,
 	CAMEL_FOLDER_DELETED = CAMEL_FOLDER_ARG_DELETED | CAMEL_ARG_INT,
 	CAMEL_FOLDER_JUNKED = CAMEL_FOLDER_ARG_JUNKED | CAMEL_ARG_INT,
+	CAMEL_FOLDER_ARCHIVED = CAMEL_FOLDER_ARG_ARCHIVED | CAMEL_ARG_INT,
 	CAMEL_FOLDER_VISIBLE = CAMEL_FOLDER_ARG_VISIBLE | CAMEL_ARG_INT,
 
 	CAMEL_FOLDER_UID_ARRAY = CAMEL_FOLDER_ARG_UID_ARRAY | CAMEL_ARG_PTR,
@@ -106,6 +108,7 @@
 #define CAMEL_FOLDER_IS_TRASH               (1<<4)
 #define CAMEL_FOLDER_IS_JUNK                (1<<5)
 #define CAMEL_FOLDER_FILTER_JUNK  	    (1<<6)
+#define CAMEL_FOLDER_IS_ARCHIVED            (1<<7)
 
 typedef struct {
 	CamelObjectClass parent_class;
@@ -274,6 +277,7 @@
 #endif
 
 int                camel_folder_get_deleted_message_count (CamelFolder *folder);
+int                camel_folder_get_archived_message_count (CamelFolder *folder);
 
 GPtrArray *        camel_folder_get_summary           (CamelFolder *folder);
 void               camel_folder_free_summary          (CamelFolder *folder,
Index: camel/camel-vtrash-folder.c
===================================================================
--- camel/camel-vtrash-folder.c	(revision 8147)
+++ camel/camel-vtrash-folder.c	(working copy)
@@ -53,6 +53,8 @@
 	  N_("Cannot copy messages to the Trash folder") },
 	{ CAMEL_VJUNK_NAME, N_("Junk"), "(match-all (system-flag \"Junk\"))", CAMEL_MESSAGE_JUNK, CAMEL_FOLDER_IS_JUNK,
 	  N_("Cannot copy messages to the Junk folder") },
+	{ CAMEL_VARCHIVED_NAME, N_("Archived"), "(match-all (system-flag \"Archived\"))", CAMEL_MESSAGE_ARCHIVED, CAMEL_FOLDER_IS_ARCHIVED,
+	  N_("Cannot copy messages to the Junk folder") },
 };
 
 static CamelVeeFolderClass *camel_vtrash_folder_parent;
@@ -119,7 +121,7 @@
 	CamelFolder *folder = (CamelFolder *)object;
 	int i;
 	guint32 tag;
-	int unread = -1, deleted = 0, junked = 0, visible = 0, count = -1;
+	int unread = -1, deleted = 0, junked = 0, archived = 0, visible = 0, count = -1;
 
 	for (i=0;i<args->argc;i++) {
 		CamelArgGet *arg = &args->argv[i];
@@ -132,6 +134,7 @@
 		case CAMEL_FOLDER_ARG_UNREAD:
 		case CAMEL_FOLDER_ARG_DELETED:
 		case CAMEL_FOLDER_ARG_JUNKED:
+		case CAMEL_FOLDER_ARG_ARCHIVED:
 		case CAMEL_FOLDER_ARG_VISIBLE:
 			/* This is so we can get the values atomically, and also so we can calculate them only once */
 			if (unread == -1) {
@@ -150,6 +153,8 @@
 							deleted++;
 						if (flags & CAMEL_MESSAGE_JUNK)
 							junked++;
+						if (flags & CAMEL_MESSAGE_ARCHIVED)
+							archived++;
 						if ((flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
 							visible++;
 						camel_message_info_free(info);
@@ -167,6 +172,9 @@
 			case CAMEL_FOLDER_ARG_JUNKED:
 				count = junked;
 				break;
+			case CAMEL_FOLDER_ARG_ARCHIVED:
+				count = archived;
+				break;
 			case CAMEL_FOLDER_ARG_VISIBLE:
 				count = visible;
 				break;
Index: camel/camel-vtrash-folder.h
===================================================================
--- camel/camel-vtrash-folder.h	(revision 8147)
+++ camel/camel-vtrash-folder.h	(working copy)
@@ -38,10 +38,12 @@
 
 #define CAMEL_VTRASH_NAME ".#evolution/Trash"
 #define CAMEL_VJUNK_NAME ".#evolution/Junk"
+#define CAMEL_VARCHIVED_NAME ".#evolution/Archived"
 
 typedef enum _camel_vtrash_folder_t {
 	CAMEL_VTRASH_FOLDER_TRASH,
 	CAMEL_VTRASH_FOLDER_JUNK,
+	CAMEL_VTRASH_FOLDER_ARCHIVED,
 	CAMEL_VTRASH_FOLDER_LAST
 } camel_vtrash_folder_t;
 
Index: camel/camel-folder-summary.c
===================================================================
--- camel/camel-folder-summary.c	(revision 8147)
+++ camel/camel-folder-summary.c	(working copy)
@@ -2658,6 +2658,7 @@
 	{ "attachments", CAMEL_MESSAGE_ATTACHMENTS },
 	{ "junk", CAMEL_MESSAGE_JUNK },
 	{ "secure", CAMEL_MESSAGE_SECURE },
+	{ "archived", CAMEL_MESSAGE_ARCHIVED },
 	{ NULL, 0 }
 };
 
@@ -3056,7 +3057,21 @@
 {
 	guint32 old;
 	CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info;
+	CamelException *ex=NULL;
+	CamelFolder *folder;
 
+	if(set & CAMEL_MESSAGE_ARCHIVED)
+	{
+		folder = mi->summary->folder;
+		
+		/* Download message for arhiving */
+		/* Will only download messages if message are getting marked as archved adn not at unarchiving messages */
+		if(camel_folder_get_message (folder, mi->uid, ex))
+			printf("==========UID %s Got message for archiving purpose=============.\n", mi->uid);
+		else
+			printf("==========UID %s UNABLE TO GET THE MESSAGE for Archived =============.\n", mi->uid);
+	}
+
 	/* TODO: locking? */
 
 	old = mi->flags;
Index: camel/camel-folder-summary.h
===================================================================
--- camel/camel-folder-summary.h	(revision 8147)
+++ camel/camel-folder-summary.h	(working copy)
@@ -75,6 +75,7 @@
 	CAMEL_MESSAGE_SECURE = 1<<8,
 	CAMEL_MESSAGE_USER_NOT_DELETABLE = 1<<9,
 	CAMEL_MESSAGE_HIDDEN = 1<<10,
+	CAMEL_MESSAGE_ARCHIVED = 1<<11,
 	
 	/* following flags are for the folder, and are not really permanent flags */
 	CAMEL_MESSAGE_FOLDER_FLAGGED = 1<<16, /* for use by the folder implementation */
