evolution-data-server r9656 - in branches/EXCHANGE_MAPI_BRANCH: camel/providers/mapi servers/mapi



Author: jjohnny
Date: Fri Oct 10 11:08:37 2008
New Revision: 9656
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9656&view=rev

Log:
Use IsMailboxFolder for identifying default folders.

Modified:
   branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-store.c
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-folder.h

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 10 11:08:37 2008
@@ -389,6 +389,8 @@
 static gboolean
 mapi_is_system_folder (const char *folder_name)
 {
+	/*Fixme : Do not use names.*/
+
 	if (!strcmp (folder_name, "Inbox") ||
 	    !strcmp (folder_name, "Deleted Items") ||
 	    !strcmp (folder_name, "All Public Folders") ||
@@ -851,19 +853,8 @@
 	else
 		name++;
 
-/* 	/\*Exclude the parent and check; FIXME! *\/ */
-/* 	excl_parent = strchr(fi->full_name , '/'); */
-/* 	excl_parent ++; */
-
-/* 	if (!strcmp (excl_parent, "Sent Items")) */
-/* 		fi->flags |= CAMEL_FOLDER_TYPE_SENT; */
-/* 	else if (!strcmp (excl_parent, "Inbox")) */
-/* 		fi->flags |= CAMEL_FOLDER_TYPE_INBOX; */
-/* 	else if (!strcmp (excl_parent, "Deleted Items")) */
-/* 		fi->flags |= CAMEL_FOLDER_TYPE_TRASH; */
-/* 	else if (!strcmp (excl_parent, "Junk Mail")) */
-/* 		fi->flags |= CAMEL_FOLDER_TYPE_JUNK; */
-		
+	/*Fixme : Mark system folders.*/
+
 	fi->name = g_strdup(name);
 	return fi;
 }
@@ -983,15 +974,25 @@
 		
 	fi = g_new0 (CamelFolderInfo, 1);
 
-	if (!strcmp (name, "Sent Items"))
-		fi->flags |= CAMEL_FOLDER_TYPE_SENT;
-	else if (!strcmp (name, "Inbox"))
-		fi->flags |= CAMEL_FOLDER_TYPE_INBOX;
-	else if (!strcmp (name, "Deleted Items"))
-		fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
-	else if (!strcmp (name, "Junk Mail"))
-		fi->flags |= CAMEL_FOLDER_TYPE_JUNK;
+	if (folder->is_default) {
+		switch (folder->default_type) {
+		case olFolderTopInformationStore:
+			fi->flags |= CAMEL_FOLDER_NOSELECT;
+			break;
+		case olFolderInbox:
+			fi->flags |= CAMEL_FOLDER_TYPE_INBOX;
+			break;
+		case olFolderSentMail:
+			fi->flags |= CAMEL_FOLDER_TYPE_SENT;
+			break;
+		case olFolderDeletedItems:
+			fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
+			break;
+		/*TODO : case olFolderJunkMail */
+		}
 
+		fi->flags |= CAMEL_FOLDER_SYSTEM;
+	}
 
 	if (folder->category == MAPI_PERSONAL_FOLDER) {
 		fi->flags |= CAMEL_MAPI_FOLDER_PERSONAL;

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c	Fri Oct 10 11:08:37 2008
@@ -2459,33 +2459,18 @@
 	return result;
 }
 
-/* FIXME: doesn't take a geek to tell that this is inefficient */
 static void 
 set_default_folders (mapi_object_t *obj_store, GSList **mapi_folders)
 {
-	enum MAPISTATUS retval;
-	mapi_id_t	id, i;
-	/* NOTE: you may add anything else you need here */
-	mapi_id_t 	defaults[] = 	{ olFolderTopInformationStore, 
-					  olFolderSentMail, 
-					  olFolderCalendar, 
-					  olFolderContacts, 
-					  olFolderNotes, 
-					  olFolderTasks, 
-					  olFolderDrafts, 
-					  0 };
-
-	for (i=0; defaults[i]; ++i) {
-		GSList *tmp = *mapi_folders;
-		retval = GetDefaultFolder(obj_store, &id, defaults[i]);
-		if (retval != MAPI_E_SUCCESS) {
-			mapi_errstr("GetDefaultFolder", GetLastError());
-			continue;
-		}
-		for (; tmp; tmp = tmp->next) {
-			ExchangeMAPIFolder *folder = (ExchangeMAPIFolder *)(tmp->data);
-			if (folder->folder_id == id)
-				folder->is_default = TRUE;
+	GSList *folder_list = *mapi_folders;
+	
+	while (folder_list = g_slist_next (folder_list)) {
+		ExchangeMAPIFolder *folder = NULL;
+		guint32 default_type = 0;
+		folder = folder_list->data;
+		if (IsMailboxFolder (obj_store,folder->folder_id, &default_type )) {
+			folder->is_default = true; /* TODO : Clean up. Redundant.*/
+			folder->default_type = default_type;
 		}
 	}
 }

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-folder.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-folder.h	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-folder.h	Fri Oct 10 11:08:37 2008
@@ -54,6 +54,7 @@
 
 	/* Need this info - default calendars/address books/notes folders can't be deleted */
 	gboolean is_default;
+	guint32 default_type;
 
 	gchar *folder_name;
 	ExchangeMAPIFolderType container_class;



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