evolution-data-server r8448 - branches/EXCHANGE_MAPI_BRANCH/servers/mapi
- From: msuman svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8448 - branches/EXCHANGE_MAPI_BRANCH/servers/mapi
- Date: Fri, 1 Feb 2008 04:58:54 +0000 (GMT)
Author: msuman
Date: Fri Feb 1 04:58:53 2008
New Revision: 8448
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8448&view=rev
Log:
DeleteAttach and GetRecipientTable handling (will not affect libmapi-0.6 users). Fixed some memory leaks.
Modified:
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-folder.h
branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c
branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h
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 Feb 1 04:58:53 2008
@@ -39,10 +39,10 @@
static struct mapi_session *global_mapi_session= NULL;
static GStaticRecMutex connect_lock = G_STATIC_REC_MUTEX_INIT;
-#define LOCK() printf("%s(%d): %s: lock(connect_lock) \n", __FILE__, __LINE__, __PRETTY_FUNCTION__);g_static_rec_mutex_lock(&connect_lock)
-#define UNLOCK() printf("%s(%d): %s: unlock(connect_lock) \n", __FILE__, __LINE__, __PRETTY_FUNCTION__);g_static_rec_mutex_unlock(&connect_lock)
+#define LOCK() g_message("%s(%d): %s: lock(connect_lock)", __FILE__, __LINE__, __PRETTY_FUNCTION__);g_static_rec_mutex_lock(&connect_lock)
+#define UNLOCK() g_message("%s(%d): %s: unlock(connect_lock)", __FILE__, __LINE__, __PRETTY_FUNCTION__);g_static_rec_mutex_unlock(&connect_lock)
#define LOGALL() lp_set_cmdline(global_loadparm, "log level", "10"); global_mapi_ctx->dumpdata = TRUE;
-#define LOGNONE() lp_set_cmdline(global_loadparm, "log level", "0"); global_mapi_ctx->dumpdata = FALSE;
+#define LOGNONE() lp_set_cmdline(global_loadparm, "log level", "0"); global_mapi_ctx->dumpdata = FALSE;
//#define ENABLE_VERBOSE_LOG() global_mapi_ctx->dumpdata = TRUE;
#define ENABLE_VERBOSE_LOG()
@@ -377,8 +377,81 @@
static gboolean
exchange_mapi_util_delete_attachments (mapi_object_t *obj_message)
{
- /* FIXME: write the code after API is implemented in libmapi */
+ enum MAPISTATUS retval;
+ TALLOC_CTX *mem_ctx;
+ mapi_object_t obj_tb_attach;
+ struct SPropTagArray *proptags;
+ struct SRowSet rows_attach;
+ uint32_t attach_count;
+ uint32_t i_row_attach;
+ gboolean status = TRUE;
+
+ /* FIXME: remove this line once you upgrade to libmapi rev 327 or higher */
return TRUE;
+ /* also uncomment the line with the DeleteAttach call */
+
+ mem_ctx = talloc_init ("ExchangeMAPI_DeleteAttachments");
+
+ proptags = set_SPropTagArray(mem_ctx, 0x7,
+ PR_ATTACH_NUM,
+ PR_INSTANCE_KEY,
+ PR_RECORD_KEY,
+ PR_RENDERING_POSITION,
+ PR_ATTACH_FILENAME,
+ PR_ATTACH_LONG_FILENAME,
+ PR_ATTACH_SIZE);
+
+ mapi_object_init(&obj_tb_attach);
+
+ /* open attachment table */
+ retval = GetAttachmentTable(obj_message, &obj_tb_attach);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("GetAttachmentTable", GetLastError());
+ goto cleanup;
+ }
+
+ retval = SetColumns(&obj_tb_attach, proptags);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("SetColumns", GetLastError());
+ goto cleanup;
+ }
+
+ retval = GetRowCount(&obj_tb_attach, &attach_count);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("GetRowCount", GetLastError());
+ goto cleanup;
+ }
+
+ retval = QueryRows(&obj_tb_attach, attach_count, TBL_ADVANCE, &rows_attach);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("QueryRows", GetLastError());
+ goto cleanup;
+ }
+
+ /* foreach attachment, delete by PR_ATTACH_NUM */
+ for (i_row_attach = 0; i_row_attach < rows_attach.cRows; i_row_attach++) {
+ const uint32_t *num_attach;
+
+ num_attach = (const uint32_t *) get_SPropValue_SRow_data(&rows_attach.aRow[i_row_attach], PR_ATTACH_NUM);
+
+// retval = DeleteAttach(obj_message, *num_attach);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("DeleteAttach", GetLastError());
+ goto loop_cleanup;
+ }
+
+ loop_cleanup:
+ if (retval != MAPI_E_SUCCESS)
+ status = FALSE;
+ }
+
+cleanup:
+ if (retval != MAPI_E_SUCCESS)
+ status = FALSE;
+ mapi_object_release(&obj_tb_attach);
+ talloc_free (mem_ctx);
+
+ return status;
}
/* Returns TRUE if all attachments were written succcesfully, else returns FALSE */
@@ -591,8 +664,6 @@
}
}
- /* FIXME: should we utf8tolinux (buf_data) ??*/
-
if (retval == MAPI_E_SUCCESS) {
ExchangeMAPIAttachment *attachment = g_new0 (ExchangeMAPIAttachment, 1);
@@ -623,6 +694,57 @@
return status;
}
+/* Returns TRUE if all recipients were read succcesfully, else returns FALSE */
+static gboolean
+exchange_mapi_util_get_recipients (mapi_object_t *obj_message, GSList **recip_list)
+{
+ enum MAPISTATUS retval;
+// TALLOC_CTX *mem_ctx;
+ struct SPropTagArray proptags;
+ struct SRowSet rows_recip;
+ uint32_t i_row_recip;
+ gboolean status = TRUE;
+
+ /* FIXME: remove this line once you upgrade to libmapi rev 340 or higher */
+ return TRUE;
+ /* also uncomment the line with the GetRecipientTable call */
+
+// mem_ctx = talloc_init ("ExchangeMAPI_GetRecipients");
+
+ /* fetch recipient table */
+// retval = GetRecipientTable(obj_message, &rows_recip, &proptags);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("GetRecipientTable", GetLastError());
+ goto cleanup;
+ }
+
+ for (i_row_recip = 0; i_row_recip < rows_recip.cRows; i_row_recip++) {
+ if (retval == MAPI_E_SUCCESS) {
+ ExchangeMAPIRecipient *recipient = g_new0 (ExchangeMAPIRecipient, 1);
+ const uint32_t *ui32;
+
+ /* FIXME: fallback on EX address type */
+ recipient->email_id = (const char *) find_SPropValue_data (&(rows_recip.aRow[i_row_recip]), PR_SMTP_ADDRESS_UNICODE);
+ recipient->email_type = "SMTP";
+ /* FIXME: fallback on other usable props */
+ recipient->name = (const char *) find_SPropValue_data(&rows_recip.aRow[i_row_recip], PR_RECIPIENT_DISPLAY_NAME_UNICODE);
+ ui32 = (const uint32_t *) find_SPropValue_data(&rows_recip.aRow[i_row_recip], PR_RECIPIENTS_FLAGS);
+ recipient->flags = *ui32;
+ ui32 = (const uint32_t *) find_SPropValue_data(&rows_recip.aRow[i_row_recip], PR_RECIPIENT_TYPE);
+ recipient->type = *ui32;
+
+ *recip_list = g_slist_append (*recip_list, recipient);
+ }
+ }
+
+cleanup:
+ if (retval != MAPI_E_SUCCESS)
+ status = FALSE;
+// talloc_free (mem_ctx);
+
+ return status;
+}
+
// FIXME: May be we need to support Restrictions/Filters here. May be after libmapi-0.7.
gboolean
exchange_mapi_connection_fetch_items (mapi_id_t fid,
@@ -783,9 +905,7 @@
if (has_attach && *has_attach)
exchange_mapi_util_get_attachments (&obj_message, &attach_list);
- if (disclose_recipients && *disclose_recipients) {
- //TODO : RecipientTable handling.
- }
+ exchange_mapi_util_get_recipients (&obj_message, &recip_list);
/* get the main body stream no matter what */
exchange_mapi_util_read_body_stream (&obj_message, &stream_list);
@@ -832,8 +952,8 @@
if (attach_list)
exchange_mapi_util_free_attachment_list (&attach_list);
- if (recip_list) {
- }
+ if (recip_list)
+ exchange_mapi_util_free_recipient_list (&recip_list);
if (stream_list)
exchange_mapi_util_free_stream_list (&stream_list);
@@ -944,8 +1064,8 @@
/* Fetch attachments */
exchange_mapi_util_get_attachments (&obj_message, &attach_list);
- /* TODO: RecipientTable handling */
-
+ /* Fetch recipients */
+ exchange_mapi_util_get_recipients (&obj_message, &recip_list);
/* get the main body stream no matter what */
exchange_mapi_util_read_body_stream (&obj_message, &stream_list);
@@ -987,8 +1107,8 @@
if (attach_list)
exchange_mapi_util_free_attachment_list (&attach_list);
- if (recip_list) {
- }
+ if (recip_list)
+ exchange_mapi_util_free_recipient_list (&recip_list);
if (stream_list)
exchange_mapi_util_free_stream_list (&stream_list);
@@ -1020,7 +1140,7 @@
d(printf("%s(%d): Entering %s \n", __FILE__, __LINE__, __PRETTY_FUNCTION__));
LOCK ();
- LOGALL ();
+// LOGALL ();
mapi_object_init(&obj_store);
mapi_object_init(&obj_top);
mapi_object_init(&obj_folder);
@@ -1084,7 +1204,7 @@
mapi_object_release(&obj_folder);
mapi_object_release(&obj_top);
mapi_object_release(&obj_store);
- LOGNONE();
+// LOGNONE();
UNLOCK ();
d(printf("%s(%d): Leaving %s \n", __FILE__, __LINE__, __PRETTY_FUNCTION__));
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 Fri Feb 1 04:58:53 2008
@@ -26,9 +26,10 @@
#include <libmapi/libmapi.h>
typedef enum {
- RECIPIENT_TO,
- RECIPIENT_CC,
- RECIPIENT_BCC
+ RECIPIENT_ORIG = 0x0,
+ RECIPIENT_TO = 0x1,
+ RECIPIENT_CC = 0x2,
+ RECIPIENT_BCC = 0x3
} ExchangeMAPIRecipientType;
/* FIXME: need to accomodate rendering position */
@@ -49,8 +50,9 @@
} ExchangeMAPIBodyStream;
typedef struct {
- gchar *email_id;
- gchar *name;
+ const char *email_id;
+ const char *email_type;
+ const char *name;
guint32 flags;
ExchangeMAPIRecipientType type;
} ExchangeMAPIRecipient;
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 Feb 1 04:58:53 2008
@@ -39,15 +39,15 @@
MAPI_FOREIGN_FOLDER
} ExchangeMAPIFolderCategory;
typedef struct _ExchangeMAPIFolder {
- char *folder_name;
- char *parent_folder_name;
+ gchar *folder_name;
+ gchar *parent_folder_name;
ExchangeMAPIFolderType container_class;
ExchangeMAPIFolderCategory category;
- uint64_t folder_id;
- uint64_t parent_folder_id;
- uint32_t child_count;
- guint unread_count;
- guint total;
+ guint64 folder_id;
+ guint64 parent_folder_id;
+ guint32 child_count;
+ guint32 unread_count;
+ guint32 total;
/* reserved */
gpointer reserved1;
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 Fri Feb 1 04:58:53 2008
@@ -186,6 +186,25 @@
ExchangeMAPIAttachment *attachment = (ExchangeMAPIAttachment *) (l->data);
g_byte_array_free (attachment->value, TRUE);
attachment->value = NULL;
+ g_free (attachment);
+ attachment = NULL;
+ }
+ g_slist_free (l);
+ l = NULL;
+}
+
+void
+exchange_mapi_util_free_recipient_list (GSList **recip_list)
+{
+ GSList *l = *recip_list;
+
+ if(!l)
+ return;
+
+ for (; l != NULL; l = l->next) {
+ ExchangeMAPIRecipient *recipient = (ExchangeMAPIRecipient *) (l->data);
+ g_free (recipient);
+ recipient = NULL;
}
g_slist_free (l);
l = NULL;
@@ -203,6 +222,8 @@
ExchangeMAPIStream *stream = (ExchangeMAPIStream *) (l->data);
g_byte_array_free (stream->value, TRUE);
stream->value = NULL;
+ g_free (stream);
+ stream = NULL;
}
g_slist_free (l);
l = NULL;
Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h (original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h Fri Feb 1 04:58:53 2008
@@ -51,6 +51,8 @@
void
exchange_mapi_util_free_attachment_list (GSList **attach_list);
void
+exchange_mapi_util_free_recipient_list (GSList **recip_list);
+void
exchange_mapi_util_free_stream_list (GSList **stream_list);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]