[evolution-mapi] Add fetching of folder properties



commit f568a21b9d4836cf48517c71ede3e12831210ace
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 31 13:49:21 2011 +0100

    Add fetching of folder properties

 src/libexchangemapi/e-mapi-connection.c |   84 +++++++++++++++++++++++++++++++
 src/libexchangemapi/e-mapi-connection.h |   37 ++++++++++++--
 2 files changed, 116 insertions(+), 5 deletions(-)
---
diff --git a/src/libexchangemapi/e-mapi-connection.c b/src/libexchangemapi/e-mapi-connection.c
index 7216601..69dd0b8 100644
--- a/src/libexchangemapi/e-mapi-connection.c
+++ b/src/libexchangemapi/e-mapi-connection.c
@@ -1542,6 +1542,90 @@ open_folder (EMapiConnection *conn, uint32_t olFolder, mapi_id_t *fid, guint32 f
 	return ms;
 }
 
+gboolean
+e_mapi_connection_get_folder_properties (EMapiConnection *conn,
+					 mapi_id_t fid,
+					 guint32 options,
+					 BuildReadPropsCB brp_cb,
+					 gpointer brp_cb_user_data,
+					 GetFolderPropertiesCB cb,
+					 gpointer cb_user_data,
+					 GError **perror)
+{
+	enum MAPISTATUS ms;
+	TALLOC_CTX *mem_ctx;
+	mapi_object_t obj_folder;
+	struct SPropTagArray *spropTagArray = NULL;
+	struct mapi_SPropValue_array *properties = NULL;
+	gboolean res = FALSE;
+
+	CHECK_CORRECT_CONN_AND_GET_PRIV (conn, FALSE);
+	e_return_val_mapi_error_if_fail (priv->session != NULL, MAPI_E_INVALID_PARAMETER, FALSE);
+
+	LOCK ();
+	mem_ctx = talloc_init ("EMAPI_GetFolderProperties");
+	mapi_object_init (&obj_folder);
+
+	/* Attempt to open the folder */
+	ms = open_folder (conn, 0, &fid, options, &obj_folder, perror);
+	if (ms != MAPI_E_SUCCESS) {
+		goto cleanup;
+	}
+
+	spropTagArray = set_SPropTagArray (mem_ctx, 1, PR_FID);
+	if (brp_cb) {
+		if (!brp_cb (conn, fid, mem_ctx, spropTagArray, brp_cb_user_data)) {
+			goto cleanup;
+		}
+	} else {
+		talloc_free (spropTagArray);
+		spropTagArray = NULL;
+	}
+
+	properties = talloc_zero (mem_ctx, struct mapi_SPropValue_array);
+	if (spropTagArray && spropTagArray->cValues) {
+		struct SPropValue *lpProps;
+		uint32_t prop_count = 0, k, ll;
+
+		lpProps = talloc_zero (mem_ctx, struct SPropValue);
+
+		ms = GetProps (&obj_folder, MAPI_PROPS_SKIP_NAMEDID_CHECK | MAPI_UNICODE, spropTagArray, &lpProps, &prop_count);
+		if (ms != MAPI_E_SUCCESS) {
+			make_mapi_error (perror, "GetProps", ms);
+			goto cleanup;
+		}
+
+		/* Conversion from SPropValue to mapi_SPropValue. (no padding here) */
+		properties->cValues = prop_count;
+		properties->lpProps = talloc_zero_array (mem_ctx, struct mapi_SPropValue, prop_count + 1);
+		for (k = 0, ll = 0; k < prop_count; k++, ll++) {
+			if (may_skip_property (lpProps[k].ulPropTag)) {
+				ll--;
+				properties->cValues--;
+			} else {
+				cast_mapi_SPropValue (mem_ctx, &properties->lpProps[ll], &lpProps[k]);
+			}
+		}
+	} else {
+		ms = GetPropsAll (&obj_folder, MAPI_PROPS_SKIP_NAMEDID_CHECK | MAPI_UNICODE, properties);
+		if (ms != MAPI_E_SUCCESS) {
+			make_mapi_error (perror, "GetPropsAll", ms);
+			goto cleanup;
+		}
+	}
+
+	res = cb (conn, fid, mem_ctx, properties, cb_user_data, perror);
+
+ cleanup:
+	mapi_object_release (&obj_folder);
+	talloc_free (spropTagArray);
+	talloc_free (properties);
+	talloc_free (mem_ctx);
+	UNLOCK();
+
+	return res;
+}
+
 GSList *
 e_mapi_connection_check_restriction (EMapiConnection *conn, mapi_id_t fid, guint32 fid_options, struct mapi_SRestriction *res, GError **perror)
 {
diff --git a/src/libexchangemapi/e-mapi-connection.h b/src/libexchangemapi/e-mapi-connection.h
index 6ff6ca6..8a68ed4 100644
--- a/src/libexchangemapi/e-mapi-connection.h
+++ b/src/libexchangemapi/e-mapi-connection.h
@@ -147,11 +147,33 @@ typedef struct {
 	time_t last_modified; /* PR_LAST_MODIFICATION_TIME as UTC */
 } ListItemsData;
 
-typedef gboolean (*FetchCallback)	(FetchItemsCallbackData *item_data, gpointer data);
-typedef gboolean (*FetchGALCallback)	(EMapiConnection *conn, uint32_t row_index, uint32_t n_rows, struct SRow *aRow, gpointer data);
-typedef gboolean (*BuildWritePropsCB)	(EMapiConnection *conn, mapi_id_t fid, TALLOC_CTX *mem_ctx, struct SPropValue **values, uint32_t *n_values, gpointer data);
-typedef gboolean (*BuildReadPropsCB)	(EMapiConnection *conn, mapi_id_t fid, TALLOC_CTX *mem_ctx, struct SPropTagArray *props, gpointer data);
-typedef gboolean (*ListItemsCB)		(EMapiConnection *conn, mapi_id_t fid, TALLOC_CTX *mem_ctx, const ListItemsData *item_data, guint32 item_index, guint32 items_total, gpointer user_data, GError **perror);
+typedef gboolean (*FetchCallback)		(FetchItemsCallbackData *item_data, gpointer data);
+typedef gboolean (*FetchGALCallback)		(EMapiConnection *conn, uint32_t row_index, uint32_t n_rows, struct SRow *aRow, gpointer data);
+typedef gboolean (*BuildWritePropsCB)		(EMapiConnection *conn,
+						 mapi_id_t fid,
+						 TALLOC_CTX *mem_ctx,
+						 struct SPropValue **values,
+						 uint32_t *n_values,
+						 gpointer data);
+typedef gboolean (*BuildReadPropsCB)		(EMapiConnection *conn,
+						 mapi_id_t fid,
+						 TALLOC_CTX *mem_ctx,
+						 struct SPropTagArray *props,
+						 gpointer data);
+typedef gboolean (*ListItemsCB)			(EMapiConnection *conn,
+						 mapi_id_t fid,
+						 TALLOC_CTX *mem_ctx,
+						 const ListItemsData *item_data,
+						 guint32 item_index,
+						 guint32 items_total,
+						 gpointer user_data,
+						 GError **perror);
+typedef gboolean (*GetFolderPropertiesCB)	(EMapiConnection *conn,
+						 mapi_id_t fid,
+						 TALLOC_CTX *mem_ctx,
+						 /* const */ struct mapi_SPropValue_array *properties,
+						 gpointer user_data,
+						 GError **perror);
 
 struct _EMapiConnection {
 	GObject parent;
@@ -172,6 +194,11 @@ gboolean		e_mapi_connection_reconnect (EMapiConnection *conn, const gchar *passw
 gboolean		e_mapi_connection_close (EMapiConnection *conn);
 gboolean		e_mapi_connection_connected (EMapiConnection *conn);
 
+gboolean		e_mapi_connection_get_folder_properties (EMapiConnection *conn, mapi_id_t fid, guint32 options,
+					BuildReadPropsCB brp_cb, gpointer brp_cb_user_data,
+					GetFolderPropertiesCB cb, gpointer cb_user_data,
+					GError **perror);
+
 gboolean		e_mapi_connection_list_items (EMapiConnection *conn, mapi_id_t fid, guint32 options,
 					ListItemsCB cb, gpointer user_data, GError **perror);
 



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