evolution-data-server r9704 - branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi



Author: jjohnny
Date: Fri Oct 24 10:49:57 2008
New Revision: 9704
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9704&view=rev

Log:
camel/mapi : Use fids for system folder check - Part 2.

Modified:
   branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c
   branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c

Modified: branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c	Fri Oct 24 10:49:57 2008
@@ -435,11 +435,10 @@
 
 	if (deleted_items) {
 		CAMEL_SERVICE_REC_LOCK (mapi_store, connect_lock);
-
-		if (!strcmp (folder->full_name, "Deleted Items")) {
+		if (mapi_folder->type & CAMEL_FOLDER_TYPE_TRASH) {
 			exchange_mapi_remove_items (0, fid, deleted_items);
 		} else {
-			exchange_mapi_util_mapi_id_from_string (camel_mapi_store_folder_id_lookup (mapi_store, "Deleted Items"), &deleted_items_fid);
+			exchange_mapi_util_mapi_id_from_string (camel_mapi_store_system_folder_fid (mapi_store, olFolderDeletedItems), &deleted_items_fid);
 			exchange_mapi_move_items(fid, deleted_items_fid, deleted_items);
 		}
 
@@ -1187,8 +1186,7 @@
 	folder_id =  g_strdup (camel_mapi_store_folder_id_lookup (mapi_store, folder->full_name)) ;
 	exchange_mapi_util_mapi_id_from_string (folder_id, &fid);
 
-	if (!strcmp (folder->full_name, "Deleted Items")) {
-
+	if (mapi_folder->type & CAMEL_FOLDER_TYPE_TRASH) {
 		CAMEL_SERVICE_REC_LOCK (mapi_store, connect_lock);
 		status = exchange_mapi_empty_folder (fid);
 		CAMEL_SERVICE_REC_UNLOCK (mapi_store, connect_lock);
@@ -1463,10 +1461,7 @@
 			continue;
 
 		if (!strcmp(folder_name, camel_mapi_store_info_full_name (mapi_store->summary, si))) {
-			if (si->flags & CAMEL_MAPI_FOLDER_PUBLIC)
-				mapi_folder->type = MAPI_FAVOURITE_FOLDER;
-			else if (si->flags & CAMEL_MAPI_FOLDER_PERSONAL)
-				mapi_folder->type = MAPI_PERSONAL_FOLDER;
+			mapi_folder->type = si->flags;
 		}
 
 		camel_store_summary_info_free((CamelStoreSummary *)mapi_store->summary, si);

Modified: branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c	Fri Oct 24 10:49:57 2008
@@ -78,7 +78,7 @@
 	GHashTable *id_hash; /*get names from ids*/
 	GHashTable *name_hash;/*get ids from names*/
 	GHashTable *parent_hash;
-	GSList *default_folder_ids;
+	GHashTable *default_folders; /*Default Type : Folder ID*/
 };
 
 static CamelOfflineStoreClass *parent_class = NULL;
@@ -245,7 +245,7 @@
 	priv->id_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 	priv->name_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 	priv->parent_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-	priv->default_folder_ids = NULL;
+	priv->default_folders = g_hash_table_new_full (g_int_hash, g_str_equal, g_free, g_free);
 
 	store->flags &= ~CAMEL_STORE_VJUNK;
 	store->flags &= ~CAMEL_STORE_VTRASH;
@@ -384,12 +384,27 @@
 	return NULL;
 }
 
+
+static gboolean 
+hash_check_fid_presence (gpointer key, gpointer value, gpointer folder_id)
+{
+	return (g_ascii_strcasecmp (value, folder_id) == 0);
+}
+
 static gboolean
 mapi_fid_is_system_folder (CamelMapiStore *mapi_store, const char *fid)
 {
 	CamelMapiStorePrivate *priv = mapi_store->priv;
 
-	return (g_slist_find_custom (priv->default_folder_ids, fid, g_ascii_strcasecmp) != NULL);
+	return (g_hash_table_find (priv->default_folders, hash_check_fid_presence, fid) != NULL);
+}
+
+static const gchar*
+mapi_system_folder_fid (CamelMapiStore *mapi_store, int folder_type)
+{ 
+	CamelMapiStorePrivate *priv = mapi_store->priv;
+
+	return g_hash_table_lookup (priv->default_folders, &folder_type); 
 }
 
 static CamelFolder *
@@ -1105,12 +1120,6 @@
 		url = temp_url;
 	}
 	
-	if (priv->default_folder_ids) {
-		g_slist_foreach (priv->default_folder_ids, (GFunc) g_free, NULL);
-		g_slist_free (priv->default_folder_ids);
-		priv->default_folder_ids = NULL;
-	}
-
 	/*populate the hash table for finding the mapping from container id <-> folder name*/
 	for (;temp_list != NULL ; temp_list = g_slist_next (temp_list) ) {
 		const char *name;
@@ -1129,9 +1138,12 @@
 		/*parent_hash returns the parent container id, given an id*/
 		g_hash_table_insert (priv->parent_hash, g_strdup(fid), g_strdup(parent_id));
 
-		if (((ExchangeMAPIFolder *)(temp_list->data))->is_default)
-			priv->default_folder_ids = g_slist_append (priv->default_folder_ids,
-								   g_strdup (fid));
+		if (((ExchangeMAPIFolder *)(temp_list->data))->is_default) {
+			guint *type = g_new0 (guint, 1);
+			*type = ((ExchangeMAPIFolder *)(temp_list->data))->default_type;
+			g_hash_table_insert (priv->default_folders, type,
+					     g_strdup(fid));
+		}
 	}
 
 	for (;folder_list != NULL; folder_list = g_slist_next (folder_list)) {
@@ -1210,6 +1222,12 @@
 }
 
 const gchar *
+camel_mapi_store_system_folder_fid (CamelMapiStore *mapi_store, guint folder_type)
+{
+	return mapi_system_folder_fid (mapi_store, folder_type);
+}
+
+const gchar *
 camel_mapi_store_folder_lookup (CamelMapiStore *mapi_store, const char *folder_id)
 {
 	CamelMapiStorePrivate *priv = mapi_store->priv;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]