evolution-data-server r8960 - in branches/EXCHANGE_MAPI_BRANCH: calendar/backends/mapi camel/providers/mapi servers/mapi
- From: msuman svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8960 - in branches/EXCHANGE_MAPI_BRANCH: calendar/backends/mapi camel/providers/mapi servers/mapi
- Date: Tue, 10 Jun 2008 04:44:12 +0000 (UTC)
Author: msuman
Date: Tue Jun 10 04:44:12 2008
New Revision: 8960
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8960&view=rev
Log:
Added servers/mapi/exchange-mapi-defs.h to accomodate missing enumerations, related changes.
Added:
branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h
Removed:
branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-constants.h
Modified:
branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-tz-utils.c
branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.c
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/Makefile.am
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
branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h
Modified: branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-tz-utils.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-tz-utils.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-tz-utils.c Tue Jun 10 04:44:12 2008
@@ -21,7 +21,6 @@
#include "e-cal-backend-mapi.h"
-#include "e-cal-backend-mapi-constants.h"
#include "e-cal-backend-mapi-tz-utils.h"
#define d(x)
Modified: branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.c Tue Jun 10 04:44:12 2008
@@ -33,19 +33,11 @@
#include <fcntl.h>
#include "e-cal-backend-mapi.h"
-#include "e-cal-backend-mapi-constants.h"
#include "e-cal-backend-mapi-utils.h"
#include "e-cal-backend-mapi-tz-utils.h"
#if 0
#include "e-cal-backend-mapi-recur-utils.h"
#endif
-/*
- * Priority
- */
-
-#define PRIORITY_LOW -1
-#define PRIORITY_NORMAL 0
-#define PRIORITY_HIGH 1
static void appt_build_name_id (struct mapi_nameid *nameid);
static void task_build_name_id (struct mapi_nameid *nameid);
@@ -185,14 +177,14 @@
#define MEET_ATTENDEE PARTICIPANT << 0x8
static icalparameter_role
-get_role_from_type (ExchangeMAPIRecipientType type)
+get_role_from_type (OlMailRecipientType type)
{
switch (type) {
- case RECIPIENT_ORIG :
- case RECIPIENT_TO :
- case RECIPIENT_BCC : return ICAL_ROLE_REQPARTICIPANT;
- case RECIPIENT_CC : return ICAL_ROLE_OPTPARTICIPANT;
- default : return ICAL_ROLE_REQPARTICIPANT;
+ case olOriginator :
+ case olTo :
+ case olBCC : return ICAL_ROLE_REQPARTICIPANT;
+ case olCC : return ICAL_ROLE_OPTPARTICIPANT;
+ default : return ICAL_ROLE_REQPARTICIPANT;
}
}
@@ -843,7 +835,7 @@
text = NULL;
/* we don't support HTML event/task/memo editor */
- flag32 = EDITOR_FORMAT_PLAINTEXT;
+ flag32 = olEditorText;
set_SPropValue_proptag(&props[i++], PR_MSG_EDITOR_FORMAT, &flag32); /* prop count: 5 */
/* it'd be better to convert, then set it in unicode */
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 Tue Jun 10 04:44:12 2008
@@ -72,7 +72,7 @@
void set_store(CamelStore *);
static void
-mapi_item_add_recipient (const char *recipients, ExchangeMAPIRecipientType type, GSList **recipient_list);
+mapi_item_add_recipient (const char *recipients, OlMailRecipientType type, GSList **recipient_list);
static int
mapi_message_item_send (MapiItem *item, GSList *attachments, GSList *recipients);
@@ -250,17 +250,17 @@
to = camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_TO);
for (i = 0; camel_internet_address_get(to, i, &namep, &addressp); i++){
- mapi_item_add_recipient (addressp, RECIPIENT_TO, &recipient_list);
+ mapi_item_add_recipient (addressp, olTo, &recipient_list);
}
cc = camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_CC);
for (i = 0; camel_internet_address_get(cc, i, &namep, &addressp); i++) {
- mapi_item_add_recipient (addressp, RECIPIENT_CC, &recipient_list);
+ mapi_item_add_recipient (addressp, olCC, &recipient_list);
}
bcc = camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_BCC);
for (i = 0; camel_internet_address_get(bcc, i, &namep, &addressp); i++) {
- mapi_item_add_recipient (addressp, RECIPIENT_BCC, &recipient_list);
+ mapi_item_add_recipient (addressp, olBCC, &recipient_list);
}
if (camel_mime_message_get_subject(message)) {
@@ -388,7 +388,7 @@
}
static void
-mapi_item_add_recipient (const char *recipients, ExchangeMAPIRecipientType type, GSList **recipient_list)
+mapi_item_add_recipient (const char *recipients, OlMailRecipientType type, GSList **recipient_list)
{
if (!recipients)
return ;
Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/Makefile.am
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/Makefile.am (original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/Makefile.am Tue Jun 10 04:44:12 2008
@@ -10,6 +10,7 @@
lib_LTLIBRARIES = libexchangemapi-1.0.la
libexchangemapi_1_0_la_SOURCES = \
+ exchange-mapi-defs.h \
exchange-mapi-folder.c \
exchange-mapi-folder.h \
exchange-mapi-connection.c \
@@ -24,6 +25,7 @@
libexchangemapiincludedir = $(privincludedir)/mapi
libexchangemapiinclude_HEADERS = \
+ exchange-mapi-defs.h \
exchange-mapi-folder.h \
exchange-mapi-connection.h \
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 Tue Jun 10 04:44:12 2008
@@ -39,18 +39,23 @@
static struct mapi_session *global_mapi_session= NULL;
static GStaticRecMutex connect_lock = G_STATIC_REC_MUTEX_INIT;
-#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 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_mapi_ctx->lp_ctx, "log level", "10"); global_mapi_ctx->dumpdata = TRUE;
#define LOGNONE() lp_set_cmdline(global_mapi_ctx->lp_ctx, "log level", "0"); global_mapi_ctx->dumpdata = FALSE;
#define ENABLE_VERBOSE_LOG() global_mapi_ctx->dumpdata = TRUE;
-#define ENABLE_VERBOSE_LOG() global_mapi_ctx->dumpdata = FALSE;
+#define DISABLE_VERBOSE_LOG() global_mapi_ctx->dumpdata = FALSE;
+#if 0
#define LOGALL()
#define LOGNONE()
+#define ENABLE_VERBOSE_LOG()
+#define DISABLE_VERBOSE_LOG()
+#endif
+
/* Specifies READ/WRITE sizes to be used while handling attachment streams */
#define ATTACH_MAX_READ_SIZE 0x1000
#define ATTACH_MAX_WRITE_SIZE 0x1000
@@ -293,7 +298,7 @@
editor = (const uint32_t *) find_SPropValue_data(&aRow, PR_MSG_EDITOR_FORMAT);
/* if PR_MSG_EDITOR_FORMAT doesn't exist, set it to PLAINTEXT */
if (!editor) {
- dflt = EDITOR_FORMAT_PLAINTEXT;
+ dflt = olEditorText;
editor = &dflt;
}
@@ -303,7 +308,7 @@
retval = -1;
switch (*editor) {
- case EDITOR_FORMAT_PLAINTEXT:
+ case olEditorText:
if ((data = (const char *) find_SPropValue_data (&aRow, PR_BODY)) != NULL)
proptag = PR_BODY;
else if ((data = (const char *) find_SPropValue_data (&aRow, PR_BODY_UNICODE)) != NULL)
@@ -315,7 +320,7 @@
retval = MAPI_E_SUCCESS;
}
break;
- case EDITOR_FORMAT_HTML:
+ case olEditorHTML:
if ((data = (const char *) find_SPropValue_data (&aRow, PR_BODY_HTML)) != NULL)
proptag = PR_BODY_HTML;
else if ((data = (const char *) find_SPropValue_data (&aRow, PR_BODY_HTML_UNICODE)) != NULL)
@@ -329,7 +334,7 @@
retval = MAPI_E_SUCCESS;
}
break;
- case EDITOR_FORMAT_RTF:
+ case olEditorRTF:
rtf_in_sync = (const bool *)find_SPropValue_data (&aRow, PR_RTF_IN_SYNC);
// if (!(rtf_in_sync && *rtf_in_sync)) {
mapi_object_init(&obj_stream);
@@ -802,11 +807,14 @@
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);
- recipient->flags = *ui32;
+ if (ui32)
+ recipient->flags = *ui32;
ui32 = (const uint32_t *) find_SPropValue_data(&rows_recip.aRow[i_row_recip], PR_RECIPIENT_TYPE);
- recipient->type = *ui32;
+ if (ui32)
+ recipient->type = *ui32;
ui32 = (const uint32_t *) find_SPropValue_data(&rows_recip.aRow[i_row_recip], PR_RECIPIENT_TRACKSTATUS);
- recipient->trackstatus = *ui32;
+ if (ui32)
+ recipient->trackstatus = *ui32;
*recip_list = g_slist_append (*recip_list, recipient);
}
@@ -889,7 +897,7 @@
}
static void
-exchange_mapi_set_recipients (TALLOC_CTX *mem_ctx, mapi_object_t *obj_message , GSList *recipients)
+exchange_mapi_util_modify_recipients (TALLOC_CTX *mem_ctx, mapi_object_t *obj_message , GSList *recipients)
{
enum MAPISTATUS retval;
struct SRowSet *SRowSet = NULL;
@@ -907,10 +915,7 @@
set_external_recipient (mem_ctx, SRowSet, recipient);
}
- LOGALL();
retval = ModifyRecipients (obj_message, SRowSet);
- LOGNONE();
-
if (retval != MAPI_E_SUCCESS)
mapi_errstr("ModifyRecpients", GetLastError());
}
@@ -1585,14 +1590,12 @@
}
}
- LOGALL();
/* set properties for the item */
retval = SetProps(&obj_message, props, propslen);
if (retval != MAPI_E_SUCCESS) {
mapi_errstr("SetProps", GetLastError());
goto cleanup;
}
- LOGNONE();
if (generic_streams) {
exchange_mapi_util_set_generic_streams (&obj_message, generic_streams);
@@ -1605,7 +1608,7 @@
/* Set recipients if any */
if (recipients) {
- exchange_mapi_set_recipients (mem_ctx, &obj_message, recipients);
+ exchange_mapi_util_modify_recipients (mem_ctx, &obj_message, recipients);
}
/* Finally, save all changes */
@@ -1728,7 +1731,7 @@
/* Set recipients if any */
if (recipients) {
- //exchange_mapi_util_set_attachments (&obj_message, attachments, TRUE);
+ exchange_mapi_util_modify_recipients (mem_ctx, &obj_message, recipients);
}
/* Finally, save all changes */
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 Tue Jun 10 04:44:12 2008
@@ -24,13 +24,7 @@
#define EXCHANGE_MAPI_CONNECTION_H
#include <libmapi/libmapi.h>
-
-typedef enum {
- RECIPIENT_ORIG = 0x0,
- RECIPIENT_TO = 0x1,
- RECIPIENT_CC = 0x2,
- RECIPIENT_BCC = 0x3
-} ExchangeMAPIRecipientType;
+#include "exchange-mapi-defs.h"
typedef enum _ExchangeMapiOptions {
MAPI_OPTIONS_FETCH_ATTACHMENTS = 1<<0,
@@ -67,8 +61,8 @@
const char *email_type;
const char *name;
uint32_t trackstatus;
- guint32 flags;
- ExchangeMAPIRecipientType type;
+ uint32_t flags;
+ OlMailRecipientType type;
} ExchangeMAPIRecipient;
struct id_list {
Added: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h
==============================================================================
--- (empty file)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h Tue Jun 10 04:44:12 2008
@@ -0,0 +1,249 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Authors:
+ * Suman Manjunath <msuman novell com>
+ * Copyright (C) 2008 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.
+ */
+
+
+/* Someday, all these definitions should be pushed in libmapi/mapidefs.h */
+/* NOTE: Some of the enumerations are commented out since they conflict with libmapi/mapidefs.h */
+
+#ifndef EXCHANGE_MAPI_DEFS_H
+#define EXCHANGE_MAPI_DEFS_H
+
+G_BEGIN_DECLS
+
+/* GENERAL */
+typedef enum
+{
+ olSunday = 1,
+ olMonday = 2,
+ olTuesday = 4,
+ olWednesday = 8,
+ olThursday = 16,
+ olFriday = 32,
+ olSaturday = 64
+} OlDaysOfWeek;
+
+typedef enum
+{
+ olNormal = 0,
+ olPersonal = 1,
+ olPrivate = 2,
+ olConfidential = 3
+} OlSensitivity;
+
+typedef enum
+{
+ olImportanceLow = 0,
+ olImportanceNormal = 1,
+ olImportanceHigh = 2
+} OlImportance;
+
+typedef enum
+{
+ olOriginator = 0,
+ olTo = 1,
+ olCC = 2,
+ olBCC = 3
+} OlMailRecipientType;
+
+/* APPOINTMENTS */
+ /*
+ * Appointment flags with PR_APPOINTMENT_BUSY_STATUS
+ */
+typedef enum
+{
+ olFree = 0,
+ olTentative = 1,
+ olBusy = 2,
+ olOutOfOffice = 3
+} OlBusyStatus;
+
+typedef enum
+{
+ olOrganizer = 0,
+ olRequired = 1,
+ olOptional = 2,
+ olResource = 3
+} OlMeetingRecipientType;
+
+typedef enum
+{
+ olMeetingTentative = 2,
+ olMeetingAccepted = 3,
+ olMeetingDeclined = 4
+} OlMeetingResponse;
+
+typedef enum
+{
+ olResponseNone = 0,
+ olResponseOrganized = 1,
+ olResponseTentative = 2,
+ olResponseAccepted = 3,
+ olResponseDeclined = 4,
+ olResponseNotResponded = 5
+} OlResponseStatus;
+
+typedef enum
+{
+ olNonMeeting = 0,
+ olMeeting = 1,
+ olMeetingReceived = 3,
+ olMeetingCanceled = 5
+} OlMeetingStatus;
+
+typedef enum
+{
+ olNetMeeting = 0,
+ olNetShow = 1,
+ olChat = 2
+} OlNetMeetingType;
+
+/* TASKS */
+typedef enum
+{
+ olTaskNotDelegated = 0,
+ olTaskDelegationUnknown = 1,
+ olTaskDelegationAccepted = 2,
+ olTaskDelegationDeclined = 3
+} OlTaskDelegationState;
+
+#if 0
+typedef enum
+{
+ olNewTask = 0,
+ olDelegatedTask = 1,
+ olOwnTask = 2
+} OlTaskOwnership;
+#endif
+
+typedef enum
+{
+ olUpdate = 2,
+ olFinalStatus = 3
+} OlTaskRecipientType;
+
+typedef enum
+{
+ olTaskSimple = 0,
+ olTaskAssign = 1,
+ olTaskAccept = 2,
+ olTaskDecline = 3
+} OlTaskResponse;
+
+#if 0
+typedef enum
+{
+ olTaskNotStarted = 0,
+ olTaskInProgress = 1,
+ olTaskComplete = 2,
+ olTaskWaiting = 3,
+ olTaskDeferred = 4
+} OlTaskStatus;
+#endif
+
+
+/* NOTES */
+#if 0
+typedef enum
+{
+ olBlue = 0,
+ olGreen = 1,
+ olPink = 2,
+ olYellow = 3,
+ olWhite = 4
+} OlNoteColor;
+#endif
+
+/* RECURRENCE (APPOINTMENTS/MEETINGS/TASKS) */
+typedef enum
+{
+ olApptNotRecurring = 0,
+ olApptMaster = 1,
+ olApptOccurrence = 2,
+ olApptException = 3
+} OlRecurrenceState;
+
+typedef enum
+{
+ olRecursDaily = 0,
+ olRecursWeekly = 1,
+ olRecursMonthly = 2,
+ olRecursMonthNth = 3,
+ olRecursYearly = 5,
+ olRecursYearNth = 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 Tue Jun 10 04:44:12 2008
@@ -35,6 +35,7 @@
#endif
#include "exchange-mapi-utils.h"
+#include <stdint.h>
/* Converts a string from Windows-UTF8 to classic-UTF8.
@@ -338,3 +339,151 @@
}
}
}
+
+
+/* Attention: Devs at work ;-) */
+
+static void
+exchange_mapi_util_bin_append_uint16 (TALLOC_CTX *mem_ctx, struct SBinary *bin, const uint16_t val)
+{
+ uint8_t *ptr = NULL;
+
+ bin->lpb = talloc_realloc (mem_ctx, bin->lpb, uint8_t, bin->cb + 2);
+ bin->cb += 2;
+
+ ptr = bin->lpb + bin->cb - 2;
+
+ *ptr++ = ( val & 0xFF);
+ *ptr++ = ((val >> 8) & 0xFF);
+}
+
+static void
+exchange_mapi_util_bin_append_uint32 (TALLOC_CTX *mem_ctx, struct SBinary *bin, const uint32_t val)
+{
+ uint8_t *ptr = NULL;
+
+ bin->lpb = talloc_realloc (mem_ctx, bin->lpb, uint8_t, bin->cb + 4);
+ bin->cb += 4;
+
+ ptr = bin->lpb + bin->cb - 4;
+
+ *ptr++ = ( val & 0xFF);
+ *ptr++ = ((val >> 8) & 0xFF);
+ *ptr++ = ((val >> 16) & 0xFF);
+ *ptr++ = ((val >> 24) & 0xFF);
+}
+
+static void
+exchange_mapi_util_bin_append_string (TALLOC_CTX *mem_ctx, struct SBinary *bin, const char *val)
+{
+ size_t len = strlen (val);
+ char *ptr = NULL;
+
+ bin->lpb = talloc_realloc (mem_ctx, bin->lpb, uint8_t, bin->cb + (len + 1));
+ bin->cb += (len + 1);
+
+ ptr = (char *) bin->lpb + bin->cb - (len + 1);
+
+ strcpy (ptr, val);
+}
+
+static void
+exchange_mapi_util_bin_append_unicode (TALLOC_CTX *mem_ctx, struct SBinary *bin, const char *val)
+{
+ /* WRITE ME */
+}
+
+static void
+exchange_mapi_util_bin_append_val (TALLOC_CTX *mem_ctx, struct SBinary *bin, const uint8_t *val, size_t len)
+{
+ uint8_t *ptr = NULL;
+
+ bin->lpb = talloc_realloc (mem_ctx, bin->lpb, uint8_t, bin->cb + len);
+ bin->cb += len;
+
+ ptr = bin->lpb + bin->cb - len;
+
+ memcpy (ptr, val, len);
+}
+
+static const uint8_t MAPI_ONE_OFF_UID[] = {
+ 0x81, 0x2b, 0x1f, 0xa4, 0xbe, 0xa3, 0x10, 0x19,
+ 0x9d, 0x6e, 0x00, 0xdd, 0x01, 0x0f, 0x54, 0x02
+};
+
+#define MAPI_ONE_OFF_UNICODE 0x8000
+#define MAPI_ONE_OFF_NO_RICH_INFO 0x0001
+#define MAPI_ONE_OFF_MYSTERY_FLAG 0x1000
+
+/**
+ * e2k_entryid_generate_oneoff:
+ * @display_name: the display name of the user
+ * @email: the email address
+ * @unicode: %TRUE to generate a Unicode ENTRYID (in which case
+ * @display_name should be UTF-8), %FALSE for an ASCII ENTRYID.
+ *
+ * Constructs a "one-off" ENTRYID value that can be used as a MAPI
+ * recipient (eg, for a message forwarding server-side rule),
+ * corresponding to @display_name and @email.
+ *
+ * Return value: the recipient ENTRYID
+ **/
+struct SBinary *
+exchange_mapi_util_entryid_generate_oneoff (TALLOC_CTX *mem_ctx, const char *display_name, const char *email, gboolean unicode)
+{
+ struct SBinary *entryid;
+
+ entryid = talloc_zero (mem_ctx, struct SBinary);
+
+ exchange_mapi_util_bin_append_uint32 (mem_ctx, entryid, 0);
+ exchange_mapi_util_bin_append_val (mem_ctx, entryid, MAPI_ONE_OFF_UID, sizeof(MAPI_ONE_OFF_UID));
+ exchange_mapi_util_bin_append_uint16 (mem_ctx, entryid, 0);
+ exchange_mapi_util_bin_append_uint16 (mem_ctx, entryid,
+ MAPI_ONE_OFF_NO_RICH_INFO |
+ MAPI_ONE_OFF_MYSTERY_FLAG |
+ (unicode ? MAPI_ONE_OFF_UNICODE : 0));
+
+ if (unicode) {
+ exchange_mapi_util_bin_append_unicode (mem_ctx, entryid, display_name);
+ exchange_mapi_util_bin_append_unicode (mem_ctx, entryid, "SMTP");
+ exchange_mapi_util_bin_append_unicode (mem_ctx, entryid, email);
+ } else {
+ exchange_mapi_util_bin_append_string (mem_ctx, entryid, display_name);
+ exchange_mapi_util_bin_append_string (mem_ctx, entryid, "SMTP");
+ exchange_mapi_util_bin_append_string (mem_ctx, entryid, email);
+ }
+
+ return entryid;
+}
+
+static const uint8_t MAPI_LOCAL_UID[] = {
+ 0xdc, 0xa7, 0x40, 0xc8, 0xc0, 0x42, 0x10, 0x1a,
+ 0xb4, 0xb9, 0x08, 0x00, 0x2b, 0x2f, 0xe1, 0x82
+};
+
+/**
+ * e2k_entryid_generate_local:
+ * @exchange_dn: the Exchange 5.5-style DN of the local user
+ *
+ * Constructs an ENTRYID value that can be used as a MAPI
+ * recipient (eg, for a message forwarding server-side rule),
+ * corresponding to the local user identified by @exchange_dn.
+ *
+ * Return value: the recipient ENTRYID
+ **/
+struct SBinary *
+exchange_mapi_util_entryid_generate_local (TALLOC_CTX *mem_ctx, const char *exchange_dn)
+{
+ struct SBinary *entryid;
+
+ entryid = talloc_zero (mem_ctx, struct SBinary);
+
+ exchange_mapi_util_bin_append_uint32 (mem_ctx, entryid, 0);
+ exchange_mapi_util_bin_append_val (mem_ctx, entryid, MAPI_LOCAL_UID, sizeof(MAPI_LOCAL_UID));
+ exchange_mapi_util_bin_append_uint16 (mem_ctx, entryid, 1);
+ exchange_mapi_util_bin_append_uint16 (mem_ctx, entryid, 0);
+ exchange_mapi_util_bin_append_string (mem_ctx, entryid, exchange_dn);
+
+ return entryid;
+}
+
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 Tue Jun 10 04:44:12 2008
@@ -61,4 +61,9 @@
void
exchange_mapi_debug_property_dump (struct mapi_SPropValue_array *properties);
+struct SBinary *
+exchange_mapi_util_entryid_generate_oneoff (TALLOC_CTX *mem_ctx, const char *display_name, const char *email, gboolean unicode);
+struct SBinary *
+exchange_mapi_util_entryid_generate_local (TALLOC_CTX *mem_ctx, const char *exchange_dn);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]