[evolution-mapi] A bit of code movement and renames



commit cb2e3690e55220937f703c0f5826bbeeb53c0379
Author: Milan Crha <mcrha redhat com>
Date:   Fri Nov 4 15:34:58 2011 +0100

    A bit of code movement and renames

 src/libexchangemapi/e-mapi-cal-utils.c     |    4 +-
 src/libexchangemapi/e-mapi-connection.c    |  124 +++++++++++++++++++++-------
 src/libexchangemapi/e-mapi-connection.h    |   68 ++++++++++++++-
 src/libexchangemapi/e-mapi-fast-transfer.c |    8 +-
 src/libexchangemapi/e-mapi-fast-transfer.h |   54 +------------
 5 files changed, 164 insertions(+), 94 deletions(-)
---
diff --git a/src/libexchangemapi/e-mapi-cal-utils.c b/src/libexchangemapi/e-mapi-cal-utils.c
index 3f080f0..fdefba3 100644
--- a/src/libexchangemapi/e-mapi-cal-utils.c
+++ b/src/libexchangemapi/e-mapi-cal-utils.c
@@ -2066,7 +2066,7 @@ static gboolean
 emcu_check_id_exists_cb (EMapiConnection *conn,
 			 mapi_id_t fid,
 			 TALLOC_CTX *mem_ctx,
-			 const ListItemsData *item_data,
+			 const ListObjectsData *item_data,
 			 guint32 item_index,
 			 guint32 items_total,
 			 gpointer user_data,
@@ -2092,7 +2092,7 @@ e_mapi_cal_util_get_new_appt_id (EMapiConnection *conn, mapi_id_t fid)
 		id = g_random_int ();
 		if (id) {
 			unused = TRUE;
-			if (!e_mapi_connection_list_items (conn, fid, 0, emcu_build_restriction, &id, emcu_check_id_exists_cb, &unused, NULL, NULL))
+			if (!e_mapi_connection_list_objects (conn, fid, 0, emcu_build_restriction, &id, emcu_check_id_exists_cb, &unused, NULL, NULL))
 				break;
 		}
 	};
diff --git a/src/libexchangemapi/e-mapi-connection.c b/src/libexchangemapi/e-mapi-connection.c
index f04efa3..95a80aa 100644
--- a/src/libexchangemapi/e-mapi-connection.c
+++ b/src/libexchangemapi/e-mapi-connection.c
@@ -1715,25 +1715,25 @@ foreach_tablerow (EMapiConnection *conn, mapi_id_t fid, TALLOC_CTX *mem_ctx, map
 	return ms;
 }
 
-struct ListItemsInternalData
+struct ListObjectsInternalData
 {
-	ListItemsCB cb;
+	ListObjectsCB cb;
 	gpointer user_data;
 };
 
 static gboolean
-list_items_internal_cb (EMapiConnection *conn,
-			mapi_id_t fid,
-			TALLOC_CTX *mem_ctx,
-			struct SRow *srow,
-			guint32 row_index,
-			guint32 rows_total,
-			gpointer user_data,
-			GCancellable *cancellable,
-			GError **perror)
+list_objects_internal_cb (EMapiConnection *conn,
+			  mapi_id_t fid,
+			  TALLOC_CTX *mem_ctx,
+			  struct SRow *srow,
+			  guint32 row_index,
+			  guint32 rows_total,
+			  gpointer user_data,
+			  GCancellable *cancellable,
+			  GError **perror)
 {
-	struct ListItemsInternalData *lii_data = user_data;
-	ListItemsData lid;
+	struct ListObjectsInternalData *loi_data = user_data;
+	ListObjectsData lod;
 	const mapi_id_t	*pmid;
 	const uint32_t *pmsg_flags;
 	struct SPropValue *last_modified;
@@ -1748,34 +1748,34 @@ list_items_internal_cb (EMapiConnection *conn,
 	pmsg_flags = get_SPropValue_SRow_data (srow, PR_MESSAGE_FLAGS);
 	last_modified = get_SPropValue_SRow (srow, PR_LAST_MODIFICATION_TIME);
 
-	lid.mid = pmid ? *pmid : 0;
-	lid.msg_flags = pmsg_flags ? *pmsg_flags : 0;
+	lod.mid = pmid ? *pmid : 0;
+	lod.msg_flags = pmsg_flags ? *pmsg_flags : 0;
 
 	if (last_modified && get_mapi_SPropValue_date_timeval (&t, *last_modified) == MAPI_E_SUCCESS)
-		lid.last_modified = t.tv_sec;
+		lod.last_modified = t.tv_sec;
 	else
-		lid.last_modified = 0;
+		lod.last_modified = 0;
 
-	return lii_data->cb (conn, fid, mem_ctx, &lid, row_index, rows_total, lii_data->user_data, cancellable, perror);
+	return loi_data->cb (conn, fid, mem_ctx, &lod, row_index, rows_total, loi_data->user_data, cancellable, perror);
 }
 
 gboolean
-e_mapi_connection_list_items (EMapiConnection *conn,
-			      mapi_id_t fid,
-			      guint32 options,
-			      BuildRestrictionsCB build_rs_cb,
-			      gpointer build_rs_cb_data,
-			      ListItemsCB cb,
-			      gpointer user_data,
-			      GCancellable *cancellable,
-			      GError **perror)
+e_mapi_connection_list_objects (EMapiConnection *conn,
+				mapi_id_t fid,
+				guint32 options,
+				BuildRestrictionsCB build_rs_cb,
+				gpointer build_rs_cb_data,
+				ListObjectsCB cb,
+				gpointer user_data,
+				GCancellable *cancellable,
+				GError **perror)
 {
 	enum MAPISTATUS ms;
 	TALLOC_CTX *mem_ctx;
 	mapi_object_t obj_folder;
 	mapi_object_t obj_table;
 	struct SPropTagArray *propTagArray;
-	struct ListItemsInternalData lii_data;
+	struct ListObjectsInternalData loi_data;
 
 	CHECK_CORRECT_CONN_AND_GET_PRIV (conn, FALSE);
 	e_return_val_mapi_error_if_fail (priv->session != NULL, MAPI_E_INVALID_PARAMETER, FALSE);
@@ -1845,10 +1845,10 @@ e_mapi_connection_list_items (EMapiConnection *conn,
 		}
 	}
 
-	lii_data.cb = cb;
-	lii_data.user_data = user_data;
+	loi_data.cb = cb;
+	loi_data.user_data = user_data;
 
-	ms = foreach_tablerow (conn, fid, mem_ctx, &obj_table, list_items_internal_cb, &lii_data, cancellable, perror);
+	ms = foreach_tablerow (conn, fid, mem_ctx, &obj_table, list_objects_internal_cb, &loi_data, cancellable, perror);
 
  cleanup:
 	mapi_object_release (&obj_folder);
@@ -1860,6 +1860,68 @@ e_mapi_connection_list_items (EMapiConnection *conn,
 }
 
 gboolean
+e_mapi_connection_transfer_objects (EMapiConnection *conn,
+				    mapi_id_t fid,
+				    guint32 options,
+				    const GSList *mids,
+				    TransferObjectCB cb,
+				    gpointer cb_user_data,
+				    GCancellable *cancellable,
+				    GError **perror)
+{
+	enum MAPISTATUS ms;
+	TALLOC_CTX *mem_ctx;
+	mapi_object_t obj_folder;
+	mapi_id_array_t ids;
+	const GSList *iter;
+
+	CHECK_CORRECT_CONN_AND_GET_PRIV (conn, FALSE);
+	e_return_val_mapi_error_if_fail (priv->session != NULL, MAPI_E_INVALID_PARAMETER, FALSE);
+	e_return_val_mapi_error_if_fail (cb != NULL, MAPI_E_INVALID_PARAMETER, FALSE);
+
+	LOCK ();
+	mem_ctx = talloc_new (priv->session);
+	mapi_object_init (&obj_folder);
+
+	ms = mapi_id_array_init (priv->mapi_ctx, &ids);
+	if (ms != MAPI_E_SUCCESS) {
+		make_mapi_error (perror, "mapi_id_array_init", ms);
+		goto cleanup;
+	}
+
+	for (iter = mids; iter; iter = iter->next) {
+		mapi_id_t *pmid = iter->data;
+
+		if (pmid)
+			mapi_id_array_add_id (&ids, *pmid);
+	}
+
+	/* Attempt to open the folder */
+	ms = open_folder (conn, 0, &fid, options, &obj_folder, perror);
+	if (ms != MAPI_E_SUCCESS) {
+		mapi_id_array_release (&ids);
+		goto cleanup;
+	}
+
+	if (g_cancellable_set_error_if_cancelled (cancellable, perror)) {
+		ms = MAPI_E_USER_CANCEL;
+		mapi_id_array_release (&ids);
+		goto cleanup;
+	}
+
+	ms = e_mapi_fast_transfer_objects (conn, mem_ctx, &obj_folder, &ids, cb, cb_user_data, cancellable, perror);
+
+	mapi_id_array_release (&ids);
+
+ cleanup:
+	mapi_object_release (&obj_folder);
+	talloc_free (mem_ctx);
+	UNLOCK ();
+
+	return ms == MAPI_E_SUCCESS;
+}
+
+gboolean
 e_mapi_connection_fetch_items  (EMapiConnection *conn,
 				mapi_id_t fid,
 				BuildRestrictionsCB build_rs_cb,
diff --git a/src/libexchangemapi/e-mapi-connection.h b/src/libexchangemapi/e-mapi-connection.h
index 4eaa370..de189b0 100644
--- a/src/libexchangemapi/e-mapi-connection.h
+++ b/src/libexchangemapi/e-mapi-connection.h
@@ -146,8 +146,49 @@ typedef struct {
 	mapi_id_t mid; /* message ID, from PR_MID */
 	uint32_t msg_flags; /* MAPI MSGFLAG_* bit OR, from PR_MESSAGE_FLAGS */
 	time_t last_modified; /* PR_LAST_MODIFICATION_TIME as UTC */
-} ListItemsData;
+} ListObjectsData;
 
+struct _EMapiObject;
+struct _EMapiRecipient;
+struct _EMapiAttachment;
+
+typedef struct _EMapiObject EMapiObject;
+typedef struct _EMapiRecipient EMapiRecipient;
+typedef struct _EMapiAttachment EMapiAttachment;
+
+struct _EMapiRecipient
+{
+	struct mapi_SPropValue_array properties;
+
+	EMapiRecipient *next;
+};
+
+struct _EMapiAttachment
+{
+	struct mapi_SPropValue_array properties;
+	EMapiObject *embeded_object;
+
+	EMapiAttachment *next;
+};
+
+struct _EMapiObject {
+	struct mapi_SPropValue_array properties;
+	EMapiRecipient *recipients; /* NULL when none */
+	EMapiAttachment *attachments; /* NULL when none */
+
+	EMapiObject *parent; /* chain up to parent's object, if this is embeded attachment */
+};
+
+EMapiRecipient *	e_mapi_recipient_new	(TALLOC_CTX *mem_ctx);
+void			e_mapi_recipient_free	(EMapiRecipient *recipient);
+
+EMapiAttachment *	e_mapi_attachment_new	(TALLOC_CTX *mem_ctx);
+void			e_mapi_attachment_free	(EMapiAttachment *attachment);
+
+EMapiObject *		e_mapi_object_new	(TALLOC_CTX *mem_ctx);
+void			e_mapi_object_free	(EMapiObject *object);
+
+/* callbacks return whether to continue in transfer of the next object */
 typedef gboolean (*FetchCallback)		(FetchItemsCallbackData *item_data,
 						 gpointer data,
 						 GCancellable *cancellable,
@@ -181,15 +222,23 @@ typedef gboolean (*BuildRestrictionsCB)		(EMapiConnection *conn,
 						 gpointer user_data,
 						 GCancellable *cancellable,
 						 GError **perror);
-typedef gboolean (*ListItemsCB)			(EMapiConnection *conn,
+typedef gboolean (*ListObjectsCB)		(EMapiConnection *conn,
 						 mapi_id_t fid,
 						 TALLOC_CTX *mem_ctx,
-						 const ListItemsData *item_data,
+						 const ListObjectsData *item_data,
 						 guint32 item_index,
 						 guint32 items_total,
 						 gpointer user_data,
 						 GCancellable *cancellable,
 						 GError **perror);
+typedef gboolean (*TransferObjectCB)		(EMapiConnection *conn,
+						 TALLOC_CTX *mem_ctx,
+						 /* const */ EMapiObject *object,
+						 guint32 obj_index,
+						 guint32 obj_total,
+						 gpointer user_data,
+						 GCancellable *cancellable,
+						 GError **perror);
 typedef gboolean (*GetFolderPropertiesCB)	(EMapiConnection *conn,
 						 mapi_id_t fid,
 						 TALLOC_CTX *mem_ctx,
@@ -240,16 +289,25 @@ gboolean		e_mapi_connection_get_folder_properties	(EMapiConnection *conn,
 								 GCancellable *cancellable,
 								 GError **perror);
 
-gboolean		e_mapi_connection_list_items		(EMapiConnection *conn,
+gboolean		e_mapi_connection_list_objects		(EMapiConnection *conn,
 								 mapi_id_t fid,
 								 guint32 options,
 								 BuildRestrictionsCB build_rs_cb,
 								 gpointer build_rs_cb_data,
-								 ListItemsCB cb,
+								 ListObjectsCB cb,
 								 gpointer user_data,
 								 GCancellable *cancellable,
 								 GError **perror);
 
+gboolean		e_mapi_connection_transfer_objects	(EMapiConnection *conn,
+								 mapi_id_t fid,
+								 guint32 options,
+								 const GSList *mids,
+								 TransferObjectCB cb,
+								 gpointer cb_user_data,
+								 GCancellable *cancellable,
+								 GError **perror);
+
 gboolean		e_mapi_connection_fetch_object_props	(EMapiConnection *conn,
 								 mapi_object_t *obj_folder,
 								 mapi_id_t fid,
diff --git a/src/libexchangemapi/e-mapi-fast-transfer.c b/src/libexchangemapi/e-mapi-fast-transfer.c
index ab6bb1f..57be53e 100644
--- a/src/libexchangemapi/e-mapi-fast-transfer.c
+++ b/src/libexchangemapi/e-mapi-fast-transfer.c
@@ -37,7 +37,7 @@ typedef struct _EMapiFXParserClosure EMapiFXParserClosure;
 struct _EMapiFXParserClosure {
 	EMapiConnection *conn;
 	TALLOC_CTX *mem_ctx;
-	EMapiFastTransferCB cb;
+	TransferObjectCB cb;
 	gpointer cb_user_data;
 	GCancellable *cancellable;
 	GError **perror;
@@ -413,7 +413,7 @@ parse_property_cb (struct SPropValue prop, void *closure)
 static enum MAPISTATUS
 e_mapi_fast_transfer_internal (EMapiConnection *conn,
 			       TALLOC_CTX *mem_ctx,
-			       EMapiFastTransferCB cb,
+			       TransferObjectCB cb,
 			       gpointer cb_user_data,
 			       gint objects_total,
 			       gboolean expect_start_message,
@@ -493,7 +493,7 @@ e_mapi_fast_transfer_objects (EMapiConnection *conn,
 			      TALLOC_CTX *mem_ctx,
 			      mapi_object_t *obj_folder,
 			      mapi_id_array_t *ids,
-			      EMapiFastTransferCB cb,
+			      TransferObjectCB cb,
 			      gpointer cb_user_data,
 			      GCancellable *cancellable,
 			      GError **perror)
@@ -520,7 +520,7 @@ e_mapi_fast_transfer_object (EMapiConnection *conn,
 			     TALLOC_CTX *mem_ctx,
 			     mapi_object_t *object,
 			     guint32 transfer_flags, /* bit or of EMapiFastTransferFlags */
-			     EMapiFastTransferCB cb,
+			     TransferObjectCB cb,
 			     gpointer cb_user_data,
 			     GCancellable *cancellable,
 			     GError **perror)
diff --git a/src/libexchangemapi/e-mapi-fast-transfer.h b/src/libexchangemapi/e-mapi-fast-transfer.h
index 7255990..7e1d4fb 100644
--- a/src/libexchangemapi/e-mapi-fast-transfer.h
+++ b/src/libexchangemapi/e-mapi-fast-transfer.h
@@ -33,61 +33,11 @@
 
 G_BEGIN_DECLS
 
-struct _EMapiObject;
-struct _EMapiRecipient;
-struct _EMapiAttachment;
-
-typedef struct _EMapiObject EMapiObject;
-typedef struct _EMapiRecipient EMapiRecipient;
-typedef struct _EMapiAttachment EMapiAttachment;
-
-/* returns whether continue in transfer of the next object */
-typedef gboolean	(*EMapiFastTransferCB)		(EMapiConnection *conn,
-							 TALLOC_CTX *mem_ctx,
-							 /* const */ EMapiObject *object,
-							 guint32 obj_index,
-							 guint32 obj_total,
-							 gpointer user_data,
-							 GCancellable *cancellable,
-							 GError **perror);
-
-struct _EMapiRecipient
-{
-	struct mapi_SPropValue_array properties;
-
-	EMapiRecipient *next;
-};
-
-struct _EMapiAttachment
-{
-	struct mapi_SPropValue_array properties;
-	EMapiObject *embeded_object;
-
-	EMapiAttachment *next;
-};
-
-struct _EMapiObject {
-	struct mapi_SPropValue_array properties;
-	EMapiRecipient *recipients; /* NULL when none */
-	EMapiAttachment *attachments; /* NULL when none */
-
-	EMapiObject *parent; /* chain up to parent's object, if this is embeded attachment */
-};
-
-EMapiRecipient *	e_mapi_recipient_new		(TALLOC_CTX *mem_ctx);
-void			e_mapi_recipient_free		(EMapiRecipient *recipient);
-
-EMapiAttachment *	e_mapi_attachment_new		(TALLOC_CTX *mem_ctx);
-void			e_mapi_attachment_free		(EMapiAttachment *attachment);
-
-EMapiObject *		e_mapi_object_new		(TALLOC_CTX *mem_ctx);
-void			e_mapi_object_free		(EMapiObject *object);
-
 enum MAPISTATUS		e_mapi_fast_transfer_objects	(EMapiConnection *conn,
 							 TALLOC_CTX *mem_ctx,
 							 mapi_object_t *obj_folder,
 							 mapi_id_array_t *ids,
-							 EMapiFastTransferCB cb,
+							 TransferObjectCB cb,
 							 gpointer cb_user_data,
 							 GCancellable *cancellable,
 							 GError **perror);
@@ -103,7 +53,7 @@ enum MAPISTATUS		e_mapi_fast_transfer_object	(EMapiConnection *conn,
 							 TALLOC_CTX *mem_ctx,
 							 mapi_object_t *object,
 							 guint32 transfer_flags, /* bit OR of EMapiFastTransferFlags */
-							 EMapiFastTransferCB cb,
+							 TransferObjectCB cb,
 							 gpointer cb_user_data,
 							 GCancellable *cancellable,
 							 GError **perror);



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