evolution-data-server r9029 - in branches/EXCHANGE_MAPI_BRANCH: addressbook/backends/galldap addressbook/backends/mapi calendar/backends/mapi camel/providers/mapi servers/mapi
- From: msuman svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9029 - in branches/EXCHANGE_MAPI_BRANCH: addressbook/backends/galldap addressbook/backends/mapi calendar/backends/mapi camel/providers/mapi servers/mapi
- Date: Mon, 23 Jun 2008 04:56:28 +0000 (UTC)
Author: msuman
Date: Mon Jun 23 04:56:28 2008
New Revision: 9029
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9029&view=rev
Log:
API change for create/modify item, re-design of ExchangeMAPIRecipient, related changes.
Added:
branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-recur-utils.c
branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-recur-utils.h
Modified:
branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/galldap/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/galldap/e-book-backend-galldap.c
branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/e-book-backend-mapi.c
branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-transport.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-defs.h
branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c
Modified: branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/galldap/e-book-backend-galldap.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/galldap/e-book-backend-galldap.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/galldap/e-book-backend-galldap.c Mon Jun 23 04:56:28 2008
@@ -2213,10 +2213,10 @@
time_t t1, t2;
int diff;
- char *t = e_book_backend_db_cache_get_time (be->priv->file_db);
+ char *cache_time = e_book_backend_db_cache_get_time (be->priv->file_db);
printf("Cache is populated, check if refresh is required \n");
- if (t && *t)
- t1 = atoi (t);
+ if (cache_time && *cache_time)
+ t1 = atoi (cache_time);
else
t1=0;
t2 = time (NULL);
Modified: branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/e-book-backend-mapi.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/e-book-backend-mapi.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/e-book-backend-mapi.c Mon Jun 23 04:56:28 2008
@@ -534,7 +534,7 @@
case GNOME_Evolution_Addressbook_MODE_REMOTE :
contact = e_contact_new_from_vcard(vcard);
- status = exchange_mapi_create_item (olFolderContacts, priv->fid, mapi_book_build_name_id, contact, mapi_book_build_props, contact, NULL, NULL, NULL);
+ status = exchange_mapi_create_item (olFolderContacts, priv->fid, mapi_book_build_name_id, contact, mapi_book_build_props, contact, NULL, NULL, NULL, 0);
if (!status) {
e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
return;
@@ -642,7 +642,7 @@
exchange_mapi_util_mapi_ids_from_uid (tmp, &fid, &mid);
printf("modify id %s\n", tmp);
- status = exchange_mapi_modify_item (olFolderContacts, priv->fid, mid, mapi_book_build_name_id, contact, mapi_book_build_props, contact, NULL, NULL);
+ status = exchange_mapi_modify_item (olFolderContacts, priv->fid, mid, mapi_book_build_name_id, contact, mapi_book_build_props, contact, NULL, NULL, 0);
printf("getting %016llX\n", status);
if (!status) {
e_data_book_respond_modify(book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
Added: branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-recur-utils.c
==============================================================================
--- (empty file)
+++ branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-recur-utils.c Mon Jun 23 04:56:28 2008
@@ -0,0 +1,419 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Suman Manjunath <msuman novell com>
+ * Copyright (C) 2007 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+
+#include "e-cal-backend-mapi.h"
+//#include "e-cal-backend-mapi-constants.h"
+#include "e-cal-backend-mapi-recur-utils.h"
+
+#define ZERO_BYTE 0x00
+
+/* preamble */
+#define PREAMBLE 0x30043004
+
+/** Pattern termination **/
+#define REPEAT_UNTIL 0x00002021
+#define REPEAT_FOR_N 0x00002022
+#define REPEAT_FOREVER 0x00002023
+
+/** Outlook version indicator (?) **/
+#define VERSION_PREAMBLE 0x00003006
+/* This version-id is equivalent to Outlook 2007 */
+#define VERSION_ID 0x00003009
+
+
+/* terminal sequence (should add twice) */
+#define TERMINAL_SEQ 0x00000000
+
+struct icaltimetype dt1601;
+struct icaltimetype dt1970;
+
+static icalrecurrencetype_weekday
+get_ical_weekday (uint32_t olWeekday) {
+ switch (olWeekday) {
+ case olSunday:
+ return ICAL_SUNDAY_WEEKDAY;
+ case olMonday:
+ return ICAL_MONDAY_WEEKDAY;
+ case olTuesday:
+ return ICAL_TUESDAY_WEEKDAY;
+ case olWednesday:
+ return ICAL_WEDNESDAY_WEEKDAY;
+ case olThursday:
+ return ICAL_THURSDAY_WEEKDAY;
+ case olFriday:
+ return ICAL_FRIDAY_WEEKDAY;
+ case olSaturday:
+ return ICAL_SATURDAY_WEEKDAY;
+ default:
+ return ICAL_SUNDAY_WEEKDAY;
+ }
+}
+
+gboolean
+e_cal_backend_mapi_util_bin_to_rrule (GByteArray *ba, ECalComponent *comp)
+{
+ struct icalrecurrencetype rt;
+ guint16 flag16;
+ guint32 flag32;
+ guint8 *ptr = ba->data;
+ GSList l;
+ gint i;
+
+ icalrecurrencetype_clear (&rt);
+
+ /* Major version */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (PREAMBLE != flag32)
+ return FALSE;
+
+ /* FREQUENCY */
+ flag16 = *((guint16 *)ptr);
+ ptr += sizeof (guint16);
+ if (flag16 == 0x200A) {
+ rt.freq = ICAL_DAILY_RECURRENCE;
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32 == 0x0) {
+ /* Daily every N days */
+
+ /* some crappy mod here */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ /* INTERVAL */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.interval = (short) (flag32 / (24 * 60));
+
+ /* some constant 0 for the stuff we handle */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32)
+ return FALSE;
+ } else if (flag32 == 0x1) {
+ /* Daily every weekday */
+
+ /* NOTE: Evolution does not handle daily-every-weekday any different
+ * from a weekly recurrence.
+ */
+ rt.freq = ICAL_WEEKLY_RECURRENCE;
+
+ /* some crappy mod here */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ /* INTERVAL */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.interval = (short) (flag32);
+
+ /* some constant 0 for the stuff we handle */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32)
+ return FALSE;
+
+ /* BITMASK */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ i = 0;
+ if (flag32 & olSunday)
+ rt.by_day[i++] = ICAL_SUNDAY_WEEKDAY;
+ if (flag32 & olMonday)
+ rt.by_day[i++] = ICAL_MONDAY_WEEKDAY;
+ if (flag32 & olTuesday)
+ rt.by_day[i++] = ICAL_TUESDAY_WEEKDAY;
+ if (flag32 & olWednesday)
+ rt.by_day[i++] = ICAL_WEDNESDAY_WEEKDAY;
+ if (flag32 & olThursday)
+ rt.by_day[i++] = ICAL_THURSDAY_WEEKDAY;
+ if (flag32 & olFriday)
+ rt.by_day[i++] = ICAL_FRIDAY_WEEKDAY;
+ if (flag32 & olSaturday)
+ rt.by_day[i++] = ICAL_SATURDAY_WEEKDAY;
+ }
+
+ } else if (flag16 == 0x200B) {
+ rt.freq = ICAL_WEEKLY_RECURRENCE;
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32 == 0x1) {
+ /* weekly every N weeks (for all events and non-regenerating tasks) */
+
+ /* some crappy mod here */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ /* INTERVAL */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.interval = (short) (flag32);
+
+ /* some constant 0 */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32)
+ return FALSE;
+
+ /* BITMASK */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ i = 0;
+ if (flag32 & olSunday)
+ rt.by_day[i++] = ICAL_SUNDAY_WEEKDAY;
+ if (flag32 & olMonday)
+ rt.by_day[i++] = ICAL_MONDAY_WEEKDAY;
+ if (flag32 & olTuesday)
+ rt.by_day[i++] = ICAL_TUESDAY_WEEKDAY;
+ if (flag32 & olWednesday)
+ rt.by_day[i++] = ICAL_WEDNESDAY_WEEKDAY;
+ if (flag32 & olThursday)
+ rt.by_day[i++] = ICAL_THURSDAY_WEEKDAY;
+ if (flag32 & olFriday)
+ rt.by_day[i++] = ICAL_FRIDAY_WEEKDAY;
+ if (flag32 & olSaturday)
+ rt.by_day[i++] = ICAL_SATURDAY_WEEKDAY;
+ } else if (flag32 == 0x0) {
+ /* weekly every N weeks (for all regenerating tasks) */
+
+ /* FIXME: we don't handle regenerating tasks */
+ return FALSE;
+ }
+
+ } else if (flag16 == 0x200C) {
+ rt.freq = ICAL_MONTHLY_RECURRENCE;
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ if (flag32 == 0x2) {
+ /* Monthly every N months on day D */
+
+ /* some crappy mod here */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ /* INTERVAL */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.interval = (short) (flag32);
+
+ /* some constant 0 for the stuff we handle */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32)
+ return FALSE;
+
+ /* MONTH_DAY */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.by_month_day[0] = (short) (flag32);
+ } else if (flag32 == 0x3) {
+ /* Monthly every N months on the Xth Y */
+
+ /* some crappy mod here */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ /* INTERVAL */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.interval = (short) (flag32);
+
+ /* some constant 0 for the stuff we handle */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32)
+ return FALSE;
+
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32 > 4)
+
+ }
+
+ } else if (flag16 == 0x200D) {
+ rt.freq = ICAL_YEARLY_RECURRENCE;
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ if (flag32 == 0x2) {
+ /* Yearly on day D of month M */
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ /* INTERVAL */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.interval = (short) (flag32 / 12);
+
+ /* some constant 0 for the stuff we handle */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32)
+ return FALSE;
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ } else if (flag32 == 0x3) {
+ /* Yearly on the Xth Y of month M */
+ g_warning ("Encountered a recurrence pattern Evolution cannot handle");
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ /* INTERVAL */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.interval = (short) (flag32 / 12);
+
+ /* some constant 0 */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32)
+ return FALSE;
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ /* TODO: Add support for this kinda recurrence in Evolution */
+ return FALSE;
+ }
+ } else
+ return FALSE;
+
+ /* repeat */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32 == REPEAT_UNTIL) {
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ } else if (flag32 == REPEAT_FOR_N) {
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+
+ rt.count = flag32;
+ } else if (flag32 == REPEAT_FOREVER) {
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32)
+ return FALSE;
+ }
+
+ /* week_start */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ rt.week_start = get_ical_weekday (flag32);
+g_print ("week start %x\n", flag32);
+
+ /* number of exceptions */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ /* fixme: exceptions */
+ if (flag32)
+ ptr += flag32 * sizeof (guint32);
+g_print ("excpt no %x\n", flag32);
+
+ /* number of changed exceptions */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ /* fixme: exceptions */
+ if (flag32)
+ ptr += flag32 * sizeof (guint32);
+g_print ("changed excpt %x\n", flag32);
+
+ /* start date */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+g_print ("start date %x\n", flag32);
+
+ /* end date */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+g_print ("end date %x\n", flag32);
+
+ /* some constant */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32 != VERSION_PREAMBLE)
+ return FALSE;
+g_print ("constant %x\n", flag32);
+
+ /* version info */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32 != VERSION_ID)
+ return FALSE;
+g_print ("ver info %x\n", flag32);
+
+ /* start time in mins */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+g_print ("start time in mins %x\n", flag32);
+
+ /* end time in mins */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+g_print ("end time in mins %x\n", flag32);
+
+ /* exceptions */
+ flag16 = *((guint16 *)ptr);
+ ptr += sizeof (guint16);
+ if (flag16 != 0x0)
+ return FALSE;
+g_print ("excpt no %x\n", flag16);
+
+ /* term seq */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32 != TERMINAL_SEQ)
+ return FALSE;
+g_print ("term seq 1 %x\n", flag32);
+
+ /* term seq */
+ flag32 = *((guint32 *)ptr);
+ ptr += sizeof (guint32);
+ if (flag32 != TERMINAL_SEQ)
+ return FALSE;
+
+ /* Set the recurrence */
+
+ l.data = &rt;
+ l.next = NULL;
+
+ e_cal_component_set_rrule_list (comp, &l);
+
+ g_print ("\n\nyipppeee... parsed the blob..\n\n");
+
+ return TRUE;
+}
Added: branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-recur-utils.h
==============================================================================
--- (empty file)
+++ branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-recur-utils.h Mon Jun 23 04:56:28 2008
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Suman Manjunath <msuman novell com>
+ * Copyright (C) 2007 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+
+#ifndef E_CAL_BACKEND_MAPI_RECUR_UTILS_H
+#define E_CAL_BACKEND_MAPI_RECUR_UTILS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gboolean
+e_cal_backend_mapi_util_bin_to_rrule (GByteArray *ba, ECalComponent *comp);
+
+G_END_DECLS
+
+#endif
+
Modified: branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-transport.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-transport.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-transport.c Mon Jun 23 04:56:28 2008
@@ -396,7 +396,12 @@
ExchangeMAPIRecipient *recipient = g_new0 (ExchangeMAPIRecipient, 1);
recipient->email_id = recipients;
- recipient->type = type;
+
+ /* this memory should be freed somewhere, perhaps in the existing
+ * exchange_mapi_util_free_recipient_list() */
+ recipient->in.req_lpProps = g_new0 (struct SPropValue, 1);
+ recipient->in.req_cValues = 1;
+ set_SPropValue_proptag (&(recipient->in.req_lpProps[0]), PR_RECIPIENT_TYPE, (const void *) &type);
*recipient_list = g_slist_append (*recipient_list, recipient);
}
@@ -406,7 +411,7 @@
{
guint64 fid = 0;
- exchange_mapi_create_item (olFolderOutbox, fid, NULL, NULL, mail_build_props, item, recipients, item->attachments, item->generic_streams);
+ exchange_mapi_create_item (olFolderOutbox, fid, NULL, NULL, mail_build_props, item, recipients, item->attachments, item->generic_streams, 0);
return 0;
}
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 Jun 23 04:56:28 2008
@@ -788,33 +788,13 @@
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;
recipient->email_id = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_SMTP_ADDRESS);
- if (recipient->email_id)
- recipient->email_type = "SMTP";
- else {
- recipient->email_id = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_EMAIL_ADDRESS);
- recipient->email_type = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_ADDRTYPE);
- if (!g_utf8_collate (recipient->email_type, "EX")) {
- const gchar *smtp_addr = exchange_mapi_util_ex_to_smtp (recipient->email_id);
- if (smtp_addr) {
- recipient->email_type = "SMTP";
- recipient->email_id = smtp_addr;
- }
- }
- }
-
- recipient->name = (const char *) exchange_mapi_util_find_row_propval(&rows_recip.aRow[i_row_recip], PR_RECIPIENT_DISPLAY_NAME);
- ui32 = (const uint32_t *) find_SPropValue_data(&rows_recip.aRow[i_row_recip], PR_RECIPIENTS_FLAGS);
- if (ui32)
- recipient->flags = *ui32;
- ui32 = (const uint32_t *) find_SPropValue_data(&rows_recip.aRow[i_row_recip], PR_RECIPIENT_TYPE);
- if (ui32)
- recipient->type = *ui32;
- ui32 = (const uint32_t *) find_SPropValue_data(&rows_recip.aRow[i_row_recip], PR_RECIPIENT_TRACKSTATUS);
- if (ui32)
- recipient->trackstatus = *ui32;
+ if (!recipient->email_id)
+ g_warning ("%s:%d %s() - object has a recipient without a PR_SMTP_ADDRESS\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+
+ recipient->out.all_lpProps = rows_recip.aRow[i_row_recip].lpProps;
+ recipient->out.all_cValues = rows_recip.aRow[i_row_recip].cValues;
*recip_list = g_slist_append (*recip_list, recipient);
}
@@ -828,96 +808,99 @@
return status;
}
-static gboolean
-set_external_recipient (TALLOC_CTX *mem_ctx, struct SRowSet *SRowSet, ExchangeMAPIRecipient *recipient)
+static void
+set_recipient_properties (struct SRow *aRow, ExchangeMAPIRecipient *recipient, gboolean is_external)
{
- uint32_t last;
- struct SPropValue SPropValue;
-
- g_return_val_if_fail (recipient != NULL, FALSE);
- g_return_val_if_fail (recipient->email_id != NULL, FALSE);
-
- SRowSet->aRow = talloc_realloc(mem_ctx, SRowSet->aRow, struct SRow, SRowSet->cRows + 2);
- last = SRowSet->cRows;
- SRowSet->aRow[last].cValues = 0;
- SRowSet->aRow[last].lpProps = talloc_zero(mem_ctx, struct SPropValue);
-
- /* PR_OBJECT_TYPE */
- SPropValue.ulPropTag = PR_OBJECT_TYPE;
- SPropValue.value.l = MAPI_MAILUSER;
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
-
- /* PR_DISPLAY_TYPE */
- SPropValue.ulPropTag = PR_DISPLAY_TYPE;
- SPropValue.value.l = 0;
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
-
- /* PR_SEND_INTERNET_ENCODING */
- SPropValue.ulPropTag = PR_SEND_INTERNET_ENCODING;
- SPropValue.value.l = 0;
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
-
- /* PR_GIVEN_NAME */
- SPropValue.ulPropTag = PR_GIVEN_NAME;
- SPropValue.value.lpszA = recipient->name ? recipient->name : recipient->email_id;
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
-
- /* PR_DISPLAY_NAME */
- SPropValue.ulPropTag = PR_DISPLAY_NAME;
- SPropValue.value.lpszA = recipient->name ? recipient->name : recipient->email_id;
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
-
- /* PR_7BIT_DISPLAY_NAME */
- SPropValue.ulPropTag = PR_7BIT_DISPLAY_NAME;
- SPropValue.value.lpszA = recipient->name ? recipient->name : recipient->email_id;
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
-
- /* PR_ADDRTYPE */
- SPropValue.ulPropTag = PR_ADDRTYPE;
- SPropValue.value.lpszA = recipient->email_type ? recipient->email_type : "SMTP";
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
-
- /* PR_EMAIL_ADDRESS */
- SPropValue.ulPropTag = PR_EMAIL_ADDRESS;
- SPropValue.value.lpszA = recipient->email_id;
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
-
- if (recipient->email_type && !g_ascii_strcasecmp (recipient->email_type, "SMTP")) {
- /* PR_SMTP_ADDRESS */
- SPropValue.ulPropTag = PR_SMTP_ADDRESS;
- SPropValue.value.lpszA = recipient->email_id;
- SRow_addprop(&(SRowSet->aRow[last]), SPropValue);
- }
-
- SetRecipientType(&(SRowSet->aRow[last]), recipient->type);
+ uint32_t i;
- SRowSet->cRows += 1;
+ if (is_external)
+ for (i = 0; i < recipient->in.ext_cValues; ++i)
+ SRow_addprop (aRow, recipient->in.ext_lpProps[i]);
- return TRUE;
+ for (i = 0; i < recipient->in.req_cValues; ++i)
+ SRow_addprop (aRow, recipient->in.req_lpProps[i]);
}
+/* DON'T fucking touch this function. */
static void
exchange_mapi_util_modify_recipients (TALLOC_CTX *mem_ctx, mapi_object_t *obj_message , GSList *recipients)
{
enum MAPISTATUS retval;
+ struct SPropTagArray *SPropTagArray = NULL;
struct SRowSet *SRowSet = NULL;
+ struct FlagList *FlagList = NULL;
GSList *l;
+ const char **users = NULL;
+ uint32_t i, j, count = 0;
+
+ SPropTagArray = set_SPropTagArray(mem_ctx, 0x6,
+ PR_DISPLAY_TYPE,
+ PR_OBJECT_TYPE,
+// PR_ADDRTYPE,
+// PR_EMAIL_ADDRESS,
+ PR_SMTP_ADDRESS,
+ PR_DISPLAY_NAME,
+ PR_GIVEN_NAME,
+ PR_SURNAME);
+// PR_ENTRYID,
+// PR_SEARCH_KEY,
+// PR_TRANSMITTABLE_DISPLAY_NAME);
SRowSet = talloc_zero(mem_ctx, struct SRowSet);
+ FlagList = talloc_zero(mem_ctx, struct FlagList);
+ count = g_slist_length (recipients);
+ users = g_new0 (const char *, count + 1);
+
+ for (i = 0, l = recipients; (i < count && l != NULL); ++i, l = l->next) {
+ ExchangeMAPIRecipient *recipient = (ExchangeMAPIRecipient *)(l->data);
+ users[i] = recipient->email_id;
+ }
+
+ /* Attempt to resolve names from the server */
+ retval = ResolveNames (users, SPropTagArray, &SRowSet, &FlagList, 0);
+ if (retval != MAPI_E_SUCCESS) {
+ mapi_errstr("ResolveNames", GetLastError());
+ goto cleanup;
+ }
+
+ g_assert (count == FlagList->cFlags);
- for (l = recipients; l != NULL; l = l->next) {
+ for (i = 0, l = recipients, j = 0; (i < count && l != NULL); ++i, l = l->next) {
ExchangeMAPIRecipient *recipient = (ExchangeMAPIRecipient *)(l->data);
- /* FIXME: Not all recipients are external recipients. We need to use
- * IABContainer::ResolveNames() to find internal recipients and use the
- * data obtained. This also has some effect on how the mails are sent
- * (whether or not TNEF is used).
- */
- set_external_recipient (mem_ctx, SRowSet, recipient);
+ uint32_t last;
+
+ switch (FlagList->ulFlags[i]) {
+ case MAPI_AMBIGUOUS:
+ /* We should never get an ambiguous resolution as we use the email-id for resolving.
+ * However, if we do still get an ambiguous entry, we can't handle it :-( */
+ g_warning ("%s:%d %s() - '%s' is ambiguous \n", __FILE__, __LINE__, __PRETTY_FUNCTION__, recipient->email_id);
+ break;
+ case MAPI_UNRESOLVED:
+ /* This is currently a bug in libmapi that unresolved recipients are not added to the SRowSet.
+ * Julien knows about it and would fix it. */
+ SRowSet->aRow = talloc_realloc(mem_ctx, SRowSet->aRow, struct SRow, SRowSet->cRows + 1);
+ last = SRowSet->cRows;
+ SRowSet->aRow[last].cValues = 0;
+ SRowSet->aRow[last].lpProps = talloc_zero(mem_ctx, struct SPropValue);
+ set_recipient_properties (&SRowSet->aRow[last], recipient, TRUE);
+ SRowSet->cRows += 1;
+ break;
+ case MAPI_RESOLVED:
+ set_recipient_properties (&SRowSet->aRow[j], recipient, FALSE);
+ j += 1;
+ break;
+ }
}
+ /* Modify the recipient table */
retval = ModifyRecipients (obj_message, SRowSet);
- if (retval != MAPI_E_SUCCESS)
+ if (retval != MAPI_E_SUCCESS) {
mapi_errstr("ModifyRecpients", GetLastError());
+// goto cleanup;
+ }
+
+cleanup:
+ g_free (users);
}
// FIXME: May be we need to support Restrictions/Filters here. May be after libmapi-0.7.
@@ -1510,7 +1493,8 @@
exchange_mapi_create_item (uint32_t olFolder, mapi_id_t fid,
BuildNameID build_name_id, gpointer ni_data,
BuildProps build_props, gpointer p_data,
- GSList *recipients, GSList *attachments, GSList *generic_streams)
+ GSList *recipients, GSList *attachments, GSList *generic_streams,
+ uint32_t options)
{
enum MAPISTATUS retval;
TALLOC_CTX *mem_ctx;
@@ -1618,7 +1602,7 @@
goto cleanup;
}
- if (recipients) {
+ if (recipients && !(options & MAPI_OPTIONS_DONT_SUBMIT)) {
/* Mark message as ready to be sent */
retval = SubmitMessage(&obj_message);
if (retval != MAPI_E_SUCCESS) {
@@ -1646,7 +1630,8 @@
exchange_mapi_modify_item (uint32_t olFolder, mapi_id_t fid, mapi_id_t mid,
BuildNameID build_name_id, gpointer ni_data,
BuildProps build_props, gpointer p_data,
- GSList *recipients, GSList *attachments)
+ GSList *recipients, GSList *attachments,
+ uint32_t options)
{
enum MAPISTATUS retval;
TALLOC_CTX *mem_ctx;
@@ -1741,7 +1726,7 @@
goto cleanup;
}
- if (recipients) {
+ if (recipients && !(options & MAPI_OPTIONS_DONT_SUBMIT)) {
/* Mark message as ready to be sent */
retval = SubmitMessage(&obj_message);
if (retval != MAPI_E_SUCCESS) {
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 Jun 23 04:56:28 2008
@@ -30,7 +30,8 @@
MAPI_OPTIONS_FETCH_ATTACHMENTS = 1<<0,
MAPI_OPTIONS_FETCH_RECIPIENTS = 1<<1,
MAPI_OPTIONS_FETCH_BODY_STREAM = 1<<2,
- MAPI_OPTIONS_FETCH_GENERIC_STREAMS = 1<<3
+ MAPI_OPTIONS_FETCH_GENERIC_STREAMS = 1<<3,
+ MAPI_OPTIONS_DONT_SUBMIT = 1<<4
} ExchangeMapiOptions;
#define MAPI_OPTIONS_FETCH_ALL MAPI_OPTIONS_FETCH_ATTACHMENTS | \
@@ -57,12 +58,29 @@
} ExchangeMAPIBodyStream;
typedef struct {
+ /* MANDATORY */
const char *email_id;
- const char *email_type;
- const char *name;
- uint32_t trackstatus;
- uint32_t flags;
- OlMailRecipientType type;
+
+ /* It is ideal to set all these properties on all recipients
+ * as we never know if a recipient would be resolved or not. */
+ struct {
+ /* These are properties which would be set on the
+ * recipients regardless if the recipient is resolved or not */
+ uint32_t req_cValues;
+ struct SPropValue *req_lpProps;
+
+ /* These are properties which would be set on the
+ * recipients only if the recipient is MAPI_UNRESOLVED */
+ uint32_t ext_cValues;
+ struct SPropValue *ext_lpProps;
+ } in;
+
+ struct {
+ /* These are properties which would be set on the
+ * recipients after GetRecipientTable() */
+ uint32_t all_cValues;
+ struct SPropValue *all_lpProps;
+ } out;
} ExchangeMAPIRecipient;
struct id_list {
@@ -107,13 +125,14 @@
exchange_mapi_create_item (uint32_t olFolder, mapi_id_t fid,
BuildNameID build_name_id, gpointer ni_data,
BuildProps build_props, gpointer p_data,
- GSList *recipients, GSList *attachments,
- GSList *generic_streams);
+ GSList *recipients, GSList *attachments, GSList *generic_streams,
+ uint32_t options);
gboolean
exchange_mapi_modify_item (uint32_t olFolder, mapi_id_t fid, mapi_id_t mid,
BuildNameID build_name_id, gpointer ni_data,
BuildProps build_props, gpointer p_data,
- GSList *recipients, GSList *attachments);
+ GSList *recipients, GSList *attachments,
+ uint32_t options);
gboolean
exchange_mapi_set_flags (uint32_t olFolder, mapi_id_t fid, GSList *mid_list, uint32_t flag);
Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h (original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h Mon Jun 23 04:56:28 2008
@@ -39,7 +39,7 @@
olFriday = 32,
olSaturday = 64
} OlDaysOfWeek;
-
+
typedef enum
{
olNormal = 0,
@@ -47,34 +47,71 @@
olPrivate = 2,
olConfidential = 3
} OlSensitivity;
-
+
typedef enum
{
olImportanceLow = 0,
olImportanceNormal = 1,
olImportanceHigh = 2
} OlImportance;
-
+
typedef enum
{
- olOriginator = 0,
- olTo = 1,
- olCC = 2,
+ olOriginator = 0,
+ olTo = 1,
+ olCC = 2,
olBCC = 3
} OlMailRecipientType;
-
+
+typedef enum
+{
+ olEditorText = 1,
+ olEditorHTML = 2,
+ olEditorRTF = 3,
+ olEditorWord = 4
+} OlEditorType; /* PR_MESSAGE_EDITOR_FORMAT type */
+
+#if 0
+typedef enum
+{
+ olFolderDeletedItems = 3,
+ olFolderOutbox = 4,
+ olFolderSentMail = 5,
+ olFolderInbox = 6,
+ olFolderCalendar = 9,
+ olFolderContacts = 10,
+ olFolderJournal = 11,
+ olFolderNotes = 12,
+ olFolderTasks = 13,
+ olFolderDrafts = 16,
+ olPublicFoldersAllPublicFolders = 18,
+ olFolderConflicts = 19,
+ olFolderSyncIssues = 20,
+ olFolderLocalFailures = 21,
+ olFolderServerFailures = 22,
+ olFolderJunk = 23,
+ olFolderRssFeeds = 25,
+ olFolderToDo = 28,
+ olFolderManagedEmail = 29
+} OlDefaultFolders;
+
+#define olFolderTopInformationStore 1
+#define olFolderCommonView 8
+#define olFolderFinder 24
+#define olFolderPublicRoot 25
+#define olFolderPublicIPMSubtree 26
+#endif
+
+
/* APPOINTMENTS */
- /*
- * Appointment flags with PR_APPOINTMENT_BUSY_STATUS
- */
typedef enum
{
olFree = 0,
olTentative = 1,
olBusy = 2,
olOutOfOffice = 3
-} OlBusyStatus;
-
+} OlBusyStatus; /* Appointment flags with PR_APPOINTMENT_BUSY_STATUS */
+
typedef enum
{
olOrganizer = 0,
@@ -82,24 +119,34 @@
olOptional = 2,
olResource = 3
} OlMeetingRecipientType;
-
+
typedef enum
{
olMeetingTentative = 2,
olMeetingAccepted = 3,
olMeetingDeclined = 4
} OlMeetingResponse;
-
-typedef enum
+
+typedef enum
{
- olResponseNone = 0,
- olResponseOrganized = 1,
- olResponseTentative = 2,
- olResponseAccepted = 3,
- olResponseDeclined = 4,
+ olResponseNone = 0,
+ olResponseOrganized = 1,
+ olResponseTentative = 2,
+ olResponseAccepted = 3,
+ olResponseDeclined = 4,
olResponseNotResponded = 5
} OlResponseStatus;
-
+
+typedef enum
+{
+ mtgEmpty = 0x00000000,
+ mtgRequest = 0x00000001,
+ mtgFull = 0x00010000,
+ mtgInfo = 0x00020000,
+ mtgOutOfDate = 0x00080000,
+ mtgDelegatorCopy = 0x00100000
+} MeetingType;
+
typedef enum
{
olNonMeeting = 0,
@@ -107,14 +154,15 @@
olMeetingReceived = 3,
olMeetingCanceled = 5
} OlMeetingStatus;
-
+
typedef enum
{
olNetMeeting = 0,
olNetShow = 1,
olChat = 2
} OlNetMeetingType;
-
+
+
/* TASKS */
typedef enum
{
@@ -131,7 +179,7 @@
olDelegatedTask = 1,
olOwnTask = 2
} OlTaskOwnership;
-#endif
+#endif
typedef enum
{
@@ -161,16 +209,17 @@
/* NOTES */
#if 0
-typedef enum
+typedef enum
{
- olBlue = 0,
- olGreen = 1,
- olPink = 2,
- olYellow = 3,
+ olBlue = 0,
+ olGreen = 1,
+ olPink = 2,
+ olYellow = 3,
olWhite = 4
} OlNoteColor;
#endif
+
/* RECURRENCE (APPOINTMENTS/MEETINGS/TASKS) */
typedef enum
{
@@ -191,59 +240,6 @@
} OlRecurrenceType;
-/*
- * PR_MESSAGE_EDITOR_FORMAT type
- */
-typedef enum
-{
- olEditorText = 1,
- olEditorHTML = 2,
- olEditorRTF = 3,
- olEditorWord = 4
-} OlEditorType;
-
-/*
- * Default folders
- */
-#if 0
-typedef enum {
- olFolderDeletedItems = 3,
- olFolderOutbox = 4,
- olFolderSentMail = 5,
- olFolderInbox = 6,
- olFolderCalendar = 9,
- olFolderContacts = 10,
- olFolderJournal = 11,
- olFolderNotes = 12,
- olFolderTasks = 13,
- olFolderDrafts = 16,
- olPublicFoldersAllPublicFolders = 18,
- olFolderConflicts = 19,
- olFolderSyncIssues = 20,
- olFolderLocalFailures = 21,
- olFolderServerFailures = 22,
- olFolderJunk = 23,
- olFolderRssFeeds = 25,
- olFolderToDo = 28,
- olFolderManagedEmail = 29
-} OlDefaultFolders;
-
-#define olFolderTopInformationStore 1
-#define olFolderCommonView 8
-#define olFolderFinder 24
-#define olFolderPublicRoot 25
-#define olFolderPublicIPMSubtree 26
-#endif
-
-/*
- * Priority
- */
-
-#define PRIORITY_LOW -1
-#define PRIORITY_NORMAL 0
-#define PRIORITY_HIGH 1
-
G_END_DECLS
#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 Jun 23 04:56:28 2008
@@ -216,8 +216,13 @@
for (; l != NULL; l = l->next) {
ExchangeMAPIRecipient *recipient = (ExchangeMAPIRecipient *) (l->data);
- g_free (recipient);
- recipient = NULL;
+ if (recipient->in.ext_cValues)
+ g_free (recipient->in.ext_lpProps);
+ if (recipient->in.req_cValues)
+ g_free (recipient->in.req_lpProps);
+/* if (recipient->out.all_cValues)
+ g_free (recipient->out.all_lpProps);
+*/ g_free (recipient);
}
g_slist_free (l);
l = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]