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



Author: jjohnny
Date: Mon Apr 21 11:03:43 2008
New Revision: 8668
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8668&view=rev

Log:
Initial Impl for Public 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-connection.h
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c

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	Mon Apr 21 11:03:43 2008
@@ -187,19 +187,24 @@
 */
 static void camel_mapi_store_init(CamelMapiStore *store, CamelMapiStoreClass *klass)
 {
+	CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
 	CamelMapiStorePrivate *priv = g_new0 (CamelMapiStorePrivate, 1);
 
-	store->summary = NULL;
+	mapi_store->summary = NULL;
 
 	priv->storage_path = NULL;
 	priv->base_url = NULL;
+
+	((CamelStore *)mapi_store)->flags |= CAMEL_STORE_SUBSCRIPTIONS;
+
+	mapi_store->priv = priv;
+
 /* 	store->camel_url = NULL; */
 /* 	store->fi = NULL; */
 /* 	store->trash_name = NULL; */
 /* 	store->folders = NULL; */
 /* 	store->folders_lock = NULL; */
 /* 	store->connect_lock = NULL; */
-	store->priv = priv;
 }
 
 static void camel_mapi_store_finalize(CamelObject *object)
@@ -1088,7 +1093,7 @@
 		top_folder = g_hash_table_lookup (priv->name_hash, top);
 		/* 'top' is a valid path, but doesnt have a container id
 		 *  return NULL */
-/*		if (!top_folder) {
+		/*if (!top_folder) {
 			camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 					_("You must be working online to complete this operation"));
 			return NULL;

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	Mon Apr 21 11:03:43 2008
@@ -1708,6 +1708,94 @@
 	return result;
 }
 
+static gboolean
+get_child_folders_pf(TALLOC_CTX *mem_ctx, mapi_object_t *parent, mapi_id_t folder_id, GSList **mapi_folders)
+{
+	enum MAPISTATUS		retval;
+	bool			ret;
+	mapi_object_t		obj_folder;
+	mapi_object_t		obj_htable;
+	struct SPropTagArray	*SPropTagArray;
+	struct SRowSet		rowset;
+	const char	       	*name;
+	char			*newname;
+	const uint32_t		*child;
+	uint32_t		index;
+	const uint64_t		*fid;
+	int			i;
+	gboolean 		result = FALSE;
+
+	/* sanity check */
+	g_return_val_if_fail (mem_ctx != NULL, FALSE);
+	g_return_val_if_fail (parent != NULL, FALSE);
+
+	mapi_object_init(&obj_folder);
+	mapi_object_init(&obj_htable);
+
+	retval = OpenFolder(parent, folder_id, &obj_folder);
+	if (retval != MAPI_E_SUCCESS)  {
+		mapi_errstr("OpenFolder", GetLastError());
+		goto cleanup;
+	}
+
+	retval = GetHierarchyTable(&obj_folder, &obj_htable);
+	if (retval != MAPI_E_SUCCESS) {
+		mapi_errstr("GetHierarchyTable", GetLastError());
+		goto cleanup;
+	}
+
+	SPropTagArray = set_SPropTagArray(mem_ctx, 0x4,
+					  PR_DISPLAY_NAME,
+					  PR_FID,
+					  PR_CONTAINER_CLASS,
+					  PR_FOLDER_CHILD_COUNT);
+
+	retval = SetColumns(&obj_htable, SPropTagArray);
+	MAPIFreeBuffer (SPropTagArray);
+
+	if (retval != MAPI_E_SUCCESS) {
+		mapi_errstr("SetColumns", GetLastError());
+		goto cleanup;
+	}
+
+	while ((retval = QueryRows(&obj_htable, 0x32, TBL_ADVANCE, &rowset) != MAPI_E_NOT_FOUND) && rowset.cRows) {
+		for (index = 0; index < rowset.cRows; index++) {
+			ExchangeMAPIFolder *folder = NULL;
+			gchar *newname = NULL;
+
+			const uint64_t *fid = (const uint64_t *)find_SPropValue_data(&rowset.aRow[index], PR_FID);
+			const char *class = (const char *)find_SPropValue_data(&rowset.aRow[index], PR_CONTAINER_CLASS);
+			const char *name = (const char *)find_SPropValue_data(&rowset.aRow[index], PR_DISPLAY_NAME);
+			const uint32_t *child = (const uint32_t *)find_SPropValue_data(&rowset.aRow[index], PR_FOLDER_CHILD_COUNT);
+
+			// HACK : We should ignore this if we are not able identify ? Learn more.
+			if (!class)
+				class = IPF_NOTE;
+
+			newname = utf8tolinux(name);
+
+			d(printf("|---+ %-15s - %s \n ", newname, class);)
+
+			//Fixme :
+			folder = exchange_mapi_folder_new (newname, NULL, class, MAPI_FAVOURITE_FOLDER, 
+							   *fid, folder_id, 0, 0, 0);
+			g_free (newname);
+
+			*mapi_folders = g_slist_prepend (*mapi_folders, folder);
+
+			if (child && *child) {
+				result = get_child_folders_pf(mem_ctx, &obj_folder, *fid, mapi_folders);
+			}
+			
+		}
+	}
+cleanup:
+	mapi_object_release (&obj_folder);
+	mapi_object_release (&obj_htable);
+
+	return result;
+}
+
 /* why on earth does ExchangeMAPIFolder store parent_name? */
 /* recursive call - so better pass TALLOC_CTX */
 static gboolean
@@ -1869,7 +1957,6 @@
 	const char 		*mailbox_user_name = NULL;
 
 	d(g_print("%s(%d): Entering %s \n", __FILE__, __LINE__, __PRETTY_FUNCTION__));
-
 	LOCK ();
 	mem_ctx = talloc_init("ExchangeMAPI_GetFoldersList");
 	mapi_object_init(&obj_store);
@@ -1942,6 +2029,47 @@
 	return result;
 }
 
+gboolean 
+exchange_mapi_get_pf_folders_list (GSList **mapi_folders)
+{
+	TALLOC_CTX *mem_ctx;
+	mapi_object_t obj_store;
+	enum MAPISTATUS retval;
+	mapi_id_t id_mailbox;
+	gboolean result = FALSE;
+
+	LOCK ();
+
+	mem_ctx = talloc_init("ExchangeMAPI_PF_GetFoldersList");
+	mapi_object_init(&obj_store);
+
+	retval = OpenPublicFolder(&obj_store);
+	if (retval != MAPI_E_SUCCESS) {
+		mapi_errstr("OpenPublicFolder", GetLastError());
+		UNLOCK ();
+		goto cleanup;
+	}
+
+	/* IPM_SUBTREE is what we want.  */
+	retval = GetDefaultPublicFolder(&obj_store, &id_mailbox, olFolderPublicIPMSubtree);
+	if (retval != MAPI_E_SUCCESS) {
+		mapi_errstr(__PRETTY_FUNCTION__, GetLastError());				
+		UNLOCK ();
+		goto cleanup;
+	}
+
+	get_child_folders_pf(mem_ctx, &obj_store, id_mailbox, mapi_folders);
+
+	result = TRUE;
+
+cleanup:
+	mapi_object_release(&obj_store);
+	talloc_free (mem_ctx);
+	UNLOCK ();
+
+	return result;
+}
+
 static char**
 mapi_parse_recipients(TALLOC_CTX *mem_ctx, const char *recipients)
 {

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h	Mon Apr 21 11:03:43 2008
@@ -127,5 +127,6 @@
 exchange_mapi_remove_items (uint32_t olFolder, mapi_id_t fid, GSList *mids);
 
 gboolean exchange_mapi_get_folders_list (GSList **mapi_folders); 
+gboolean exchange_mapi_get_pf_folders_list (GSList **mapi_folders); 
 
 #endif

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c	Mon Apr 21 11:03:43 2008
@@ -37,6 +37,8 @@
 	TALLOC_CTX 	*mem_ctx;
 	gchar		*newstr, *retval = NULL;
 
+	g_return_val_if_fail (wstring != NULL, NULL);
+
 	mem_ctx = talloc_init ("ExchangeMAPI_utf8tolinux");
 
 	newstr = windows_to_utf8(mem_ctx, wstring);



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