[evolution-mapi/gnome-3-0] Bug #613147 - Recipients should not be discarded



commit 712adc35dd9b6479883156c246d90b32d3d6fe66
Author: Milan Crha <mcrha redhat com>
Date:   Thu May 5 12:03:55 2011 +0200

    Bug #613147 - Recipients should not be discarded

 src/addressbook/e-book-backend-mapi-contacts.c |    4 +-
 src/addressbook/e-book-backend-mapi.c          |    2 +-
 src/camel/camel-mapi-folder.c                  |    8 +-
 src/libexchangemapi/exchange-mapi-cal-utils.c  |    8 +-
 src/libexchangemapi/exchange-mapi-connection.c |   56 ++++++----
 src/libexchangemapi/exchange-mapi-connection.h |    3 +-
 src/libexchangemapi/exchange-mapi-mail-utils.c |   17 +--
 src/libexchangemapi/exchange-mapi-utils.c      |  144 +++++++++++++++++++-----
 src/libexchangemapi/exchange-mapi-utils.h      |    8 +-
 9 files changed, 176 insertions(+), 74 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi-contacts.c b/src/addressbook/e-book-backend-mapi-contacts.c
index fb6962b..a2b129e 100644
--- a/src/addressbook/e-book-backend-mapi-contacts.c
+++ b/src/addressbook/e-book-backend-mapi-contacts.c
@@ -367,11 +367,11 @@ mapi_book_write_props (ExchangeMapiConnection *conn, mapi_id_t fid, TALLOC_CTX *
 						members->lpbin[members->cValues].cb = string_to_bin (mem_ctx, g_hash_table_lookup (member_values, raw), &members->lpbin[members->cValues].lpb);
 						members->cValues++;
 					} else {
-						exchange_mapi_util_entryid_generate_oneoff (mem_ctx, &members->lpbin[members->cValues], nm ? nm : "", eml);
+						exchange_mapi_util_recip_entryid_generate_smtp (mem_ctx, &members->lpbin[members->cValues], nm ? nm : "", eml);
 						members->cValues++;
 					}
 
-					exchange_mapi_util_entryid_generate_oneoff (mem_ctx, &oneoff_members->lpbin[oneoff_members->cValues], nm ? nm : "", eml);
+					exchange_mapi_util_recip_entryid_generate_smtp (mem_ctx, &oneoff_members->lpbin[oneoff_members->cValues], nm ? nm : "", eml);
 					oneoff_members->cValues++;
 
 					list_size += MAX (oneoff_members->lpbin[oneoff_members->cValues - 1].cb, members->lpbin[members->cValues - 1].cb);
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 737641b..a90bad4 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -1869,7 +1869,7 @@ mapi_book_utils_contact_from_props (ExchangeMapiConnection *conn, mapi_id_t fid,
 
 			br.lpb = members->bin[i].lpb;
 			br.cb = members->bin[i].cb;
-			if (exchange_mapi_util_entryid_decode_oneoff (&br, &display_name, &email)) {
+			if (exchange_mapi_util_recip_entryid_decode (conn, &br, &display_name, &email)) {
 				EVCardAttribute *attr;
 				gchar *value;
 				CamelInternetAddress *addr;
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index e8015d4..9c8eca4 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -412,10 +412,10 @@ mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **ch
 				type = (uint32_t *) exchange_mapi_util_find_row_propval (aRow, PR_RECIPIENT_TYPE);
 
 				if (type) {
-					name = (const gchar *) exchange_mapi_util_find_row_propval (aRow, PR_DISPLAY_NAME_UNICODE);
-					name = name ? name : (const gchar *) exchange_mapi_util_find_row_propval (aRow, PR_RECIPIENT_DISPLAY_NAME_UNICODE);
-					name = name ? name : (const gchar *) exchange_mapi_util_find_row_propval (aRow,
-												 PR_7BIT_DISPLAY_NAME_UNICODE);
+					name = recip->display_name;
+					name = name ? name : exchange_mapi_util_find_row_propval (aRow, PR_DISPLAY_NAME_UNICODE);
+					name = name ? name : exchange_mapi_util_find_row_propval (aRow, PR_RECIPIENT_DISPLAY_NAME_UNICODE);
+					name = name ? name : exchange_mapi_util_find_row_propval (aRow, PR_7BIT_DISPLAY_NAME_UNICODE);
 					display_name = name ? name : recip->email_id;
 					formatted_id = camel_internet_address_format_address(display_name, recip->email_id ? recip->email_id : "");
 
diff --git a/src/libexchangemapi/exchange-mapi-cal-utils.c b/src/libexchangemapi/exchange-mapi-cal-utils.c
index d14d892..40fdd5d 100644
--- a/src/libexchangemapi/exchange-mapi-cal-utils.c
+++ b/src/libexchangemapi/exchange-mapi-cal-utils.c
@@ -517,7 +517,9 @@ ical_attendees_from_props (icalcomponent *ical_comp, GSList *recipients, gboolea
 			prop = icalproperty_new_organizer (val);
 
 			/* CN */
-			str = (const gchar *) exchange_mapi_util_find_row_propval (&recip->out_SRow, PR_RECIPIENT_DISPLAY_NAME_UNICODE);
+			str = recip->display_name;
+			if (!str || !*str)
+				str = (const gchar *) exchange_mapi_util_find_row_propval (&recip->out_SRow, PR_RECIPIENT_DISPLAY_NAME_UNICODE);
 			if (!str)
 				str = (const gchar *) exchange_mapi_util_find_row_propval (&recip->out_SRow, PR_DISPLAY_NAME_UNICODE);
 			if (str) {
@@ -528,7 +530,9 @@ ical_attendees_from_props (icalcomponent *ical_comp, GSList *recipients, gboolea
 			prop = icalproperty_new_attendee (val);
 
 			/* CN */
-			str = (const gchar *) exchange_mapi_util_find_row_propval (&recip->out_SRow, PR_RECIPIENT_DISPLAY_NAME_UNICODE);
+			str = recip->display_name;
+			if (!str || !*str)
+				str = (const gchar *) exchange_mapi_util_find_row_propval (&recip->out_SRow, PR_RECIPIENT_DISPLAY_NAME_UNICODE);
 			if (!str)
 				str = (const gchar *) exchange_mapi_util_find_row_propval (&recip->out_SRow, PR_DISPLAY_NAME_UNICODE);
 			if (str) {
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 152e073..3dbd158 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -784,7 +784,7 @@ set_recipient_properties (TALLOC_CTX *mem_ctx, struct SRow *aRow, ExchangeMAPIRe
 		dn = (dn) ? dn : "";
 		email = (const gchar *) exchange_mapi_util_find_SPropVal_array_propval (recipient->in.ext_lpProps, PR_SMTP_ADDRESS_UNICODE);
 		email = (email) ? email : "";
-		exchange_mapi_util_entryid_generate_oneoff (mem_ctx, &oneoff_eid, dn, email);
+		exchange_mapi_util_recip_entryid_generate_smtp (mem_ctx, &oneoff_eid, dn, email);
 		set_SPropValue_proptag (&sprop, PR_ENTRYID, (gconstpointer )(oneoff_eid));
 		SRow_addprop (aRow, sprop);
 #endif
@@ -1456,33 +1456,42 @@ exchange_mapi_util_get_recipients (ExchangeMapiConnection *conn, mapi_object_t *
 	}
 
 	for (i_row_recip = 0; i_row_recip < rows_recip.cRows; i_row_recip++) {
-		ExchangeMAPIRecipient	*recipient = g_new0 (ExchangeMAPIRecipient, 1);
+		ExchangeMAPIRecipient *recipient = g_new0 (ExchangeMAPIRecipient, 1);
+		gchar *display_name = NULL, *email = NULL;
+		const struct Binary_r *entryid;
 
 		recipient->mem_ctx = talloc_init ("ExchangeMAPI_GetRecipients");
 
-		recipient->email_id = talloc_steal (recipient->mem_ctx, (const gchar *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_SMTP_ADDRESS_UNICODE));
-		/* fallback */
-		if (!recipient->email_id) {
-			uint32_t fallback_props[] = {
-				PROP_TAG (PT_UNICODE, 0x6001), /* PigTagNickname for Recipients table */
-				PR_RECIPIENT_DISPLAY_NAME_UNICODE
-			};
-			gint ii;
-			const gchar *addrtype = exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_ADDRTYPE_UNICODE);
-
-			if (addrtype && !g_ascii_strcasecmp (addrtype, "SMTP"))
-				recipient->email_id = talloc_steal (recipient->mem_ctx, (const gchar *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_EMAIL_ADDRESS_UNICODE));
-
-			for (ii = 0; !recipient->email_id && ii < G_N_ELEMENTS (fallback_props); ii++) {
-				recipient->email_id = talloc_steal (recipient->mem_ctx, (const gchar *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), fallback_props[ii]));
+		entryid = exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_RECIPIENT_ENTRYID);
+		if (entryid && exchange_mapi_util_recip_entryid_decode (conn, entryid, &display_name, &email) && email) {
+			recipient->email_id = talloc_strdup (recipient->mem_ctx, email);
+			if (display_name)
+				recipient->display_name = talloc_strdup (recipient->mem_ctx, display_name);
+		} else {
+			recipient->email_id = talloc_steal (recipient->mem_ctx, (const gchar *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_SMTP_ADDRESS_UNICODE));
+			/* fallback */
+			if (!recipient->email_id) {
+				uint32_t fallback_props[] = {
+					PROP_TAG (PT_UNICODE, 0x6001), /* PidTagNickname for Recipients table */
+					PR_RECIPIENT_DISPLAY_NAME_UNICODE
+				};
+				gint ii;
+				const gchar *addrtype = exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_ADDRTYPE_UNICODE);
+
+				if (addrtype && !g_ascii_strcasecmp (addrtype, "SMTP"))
+					recipient->email_id = talloc_steal (recipient->mem_ctx, (const gchar *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_EMAIL_ADDRESS_UNICODE));
+
+				for (ii = 0; !recipient->email_id && ii < G_N_ELEMENTS (fallback_props); ii++) {
+					recipient->email_id = talloc_steal (recipient->mem_ctx, (const gchar *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), fallback_props[ii]));
+				}
 			}
-		}
 
-		if (recipient->email_id) {
-			const gchar *addrtype = exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_ADDRTYPE_UNICODE);
+			if (recipient->email_id) {
+				const gchar *addrtype = exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_ADDRTYPE_UNICODE);
 
-			if (addrtype && g_ascii_strcasecmp (addrtype, "EX") == 0)
-				recipient->email_id = exchange_mapi_connection_ex_to_smtp (conn, recipient->email_id, NULL, NULL);
+				if (addrtype && g_ascii_strcasecmp (addrtype, "EX") == 0)
+					recipient->email_id = talloc_strdup (recipient->mem_ctx, exchange_mapi_connection_ex_to_smtp (conn, recipient->email_id, NULL, NULL));
+			}
 		}
 
 		recipient->out_SRow.ulAdrEntryPad = rows_recip.aRow[i_row_recip].ulAdrEntryPad;
@@ -1490,6 +1499,9 @@ exchange_mapi_util_get_recipients (ExchangeMapiConnection *conn, mapi_object_t *
 		recipient->out_SRow.lpProps = talloc_steal ((TALLOC_CTX *)recipient->mem_ctx, rows_recip.aRow[i_row_recip].lpProps);
 
 		*recip_list = g_slist_append (*recip_list, recipient);
+
+		g_free (display_name);
+		g_free (email);
 	}
 
 cleanup:
diff --git a/src/libexchangemapi/exchange-mapi-connection.h b/src/libexchangemapi/exchange-mapi-connection.h
index 09e5ae7..d5eee38 100644
--- a/src/libexchangemapi/exchange-mapi-connection.h
+++ b/src/libexchangemapi/exchange-mapi-connection.h
@@ -85,8 +85,9 @@ typedef struct {
 
 typedef struct {
 	/* MANDATORY */
-	const gchar *email_id;
 	TALLOC_CTX *mem_ctx;
+	const gchar *email_id;
+	const gchar *display_name;
 
 	/* It is ideal to set all these properties on all recipients
 	 * as we never know if a recipient would be resolved or not. */
diff --git a/src/libexchangemapi/exchange-mapi-mail-utils.c b/src/libexchangemapi/exchange-mapi-mail-utils.c
index 5a4c06f..6eb2c1e 100644
--- a/src/libexchangemapi/exchange-mapi-mail-utils.c
+++ b/src/libexchangemapi/exchange-mapi-mail-utils.c
@@ -359,10 +359,11 @@ mapi_mime_set_recipient_list (ExchangeMapiConnection *conn, CamelMimeMessage *ms
 		aRow = &recip->out_SRow;
 
 		/*Name is probably available in one of these props.*/
-		name = (const gchar *) exchange_mapi_util_find_row_propval (aRow, PR_DISPLAY_NAME_UNICODE);
-		name = name ? name : (const gchar *) exchange_mapi_util_find_row_propval (aRow, PR_RECIPIENT_DISPLAY_NAME_UNICODE);
+		name = recip->display_name;
+		name = name ? name : exchange_mapi_util_find_row_propval (aRow, PR_DISPLAY_NAME_UNICODE);
+		name = name ? name : exchange_mapi_util_find_row_propval (aRow, PR_RECIPIENT_DISPLAY_NAME_UNICODE);
 		if (!name) {
-			name = (const gchar *) exchange_mapi_util_find_row_propval (aRow, PR_7BIT_DISPLAY_NAME_UNICODE);
+			name = exchange_mapi_util_find_row_propval (aRow, PR_7BIT_DISPLAY_NAME_UNICODE);
 			if (name && !strchr (name, '@')) {
 				gchar *to_free;
 
@@ -393,13 +394,9 @@ mapi_mime_set_recipient_list (ExchangeMapiConnection *conn, CamelMimeMessage *ms
 	}
 
 	/*Add to message*/
-	/*Note : To field is added from PR_TRANSPORT_MESSAGE_HEADERS
-	  But, in sent_items folder we don't get TRANSPORT_MESSAGE_HEADERS */
-	if (!item->header.transport_headers) {
-		camel_mime_message_set_recipients(msg, "To", to_addr);
-		camel_mime_message_set_recipients(msg, "Cc", cc_addr);
-		camel_mime_message_set_recipients(msg, "Bcc", bcc_addr);
-	}
+	camel_mime_message_set_recipients (msg, "To", to_addr);
+	camel_mime_message_set_recipients (msg, "Cc", cc_addr);
+	camel_mime_message_set_recipients (msg, "Bcc", bcc_addr);
 
 	g_object_unref (to_addr);
 	g_object_unref (cc_addr);
diff --git a/src/libexchangemapi/exchange-mapi-utils.c b/src/libexchangemapi/exchange-mapi-utils.c
index c4b20f7..0c93b48 100644
--- a/src/libexchangemapi/exchange-mapi-utils.c
+++ b/src/libexchangemapi/exchange-mapi-utils.c
@@ -663,14 +663,14 @@ bin_decode_string (const uint8_t *ptr, uint32_t sz, gchar **str, gboolean is_uni
 			break;
 	}
 
-	if (len >= sz || ptr[len] != 0x00 || (is_unicode && len + 1 >= sz && ptr[len + 1] != 0x00))
+	if (len >= sz || ptr[len] != 0x00 || (is_unicode && (len + 1 >= sz || ptr[len + 1] != 0x00)))
 		return 0;
 
 	if (is_unicode) {
 		*str = g_utf16_to_utf8 ((const gunichar2 *) ptr, len / 2, NULL, NULL, NULL);
 	} else {
 		*str = g_malloc0 (sizeof(gchar) * (1 + len));
-		strncpy (*str, (const gchar *) ptr, len - 1);
+		strncpy (*str, (const gchar *) ptr, len);
 	}
 
 	return len + 1 + (is_unicode ? 1 : 0);
@@ -727,7 +727,7 @@ static const uint8_t MAPI_ONE_OFF_UID[] = {
 #define MAPI_ONE_OFF_MYSTERY_FLAG 0x1000
 
 /**
- * e2k_entryid_generate_oneoff:
+ * exchange_mapi_util_recip_entryid_generate_smtp:
  * @entryid: entry ID to be filled
  * @display_name: the display name of the user
  * @email: the email address
@@ -739,7 +739,7 @@ static const uint8_t MAPI_ONE_OFF_UID[] = {
  * Return value: the recipient ENTRYID
  **/
 void
-exchange_mapi_util_entryid_generate_oneoff (TALLOC_CTX *mem_ctx, struct Binary_r *entryid, const gchar *display_name, const gchar *email)
+exchange_mapi_util_recip_entryid_generate_smtp (TALLOC_CTX *mem_ctx, struct Binary_r *entryid, const gchar *display_name, const gchar *email)
 {
 	g_return_if_fail (entryid != NULL);
 
@@ -752,8 +752,31 @@ exchange_mapi_util_entryid_generate_oneoff (TALLOC_CTX *mem_ctx, struct Binary_r
 	exchange_mapi_util_bin_append_unicode (mem_ctx, entryid, email);
 }
 
-gboolean
-exchange_mapi_util_entryid_decode_oneoff (const struct Binary_r *entryid, gchar **display_name, gchar **email)
+static const uint8_t MAPI_LOCAL_UID[] = {
+	0xdc, 0xa7, 0x40, 0xc8, 0xc0, 0x42, 0x10, 0x1a,
+	0xb4, 0xb9, 0x08, 0x00, 0x2b, 0x2f, 0xe1, 0x82
+};
+
+/**
+ * exchange_mapi_util_recip_entryid_generate_ex:
+ * @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.
+ **/
+void
+exchange_mapi_util_recip_entryid_generate_ex (TALLOC_CTX *mem_ctx, struct Binary_r *entryid, const gchar *exchange_dn)
+{
+	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);
+}
+
+static gboolean
+recip_entryid_decode_smtp (const struct Binary_r *entryid, gchar **display_name, gchar **email)
 {
 	uint32_t u32, sz, r;
 	uint16_t u16, flags;
@@ -834,35 +857,102 @@ exchange_mapi_util_entryid_decode_oneoff (const struct Binary_r *entryid, gchar
 	return TRUE;
 }
 
-static const uint8_t MAPI_LOCAL_UID[] = {
-	0xdc, 0xa7, 0x40, 0xc8, 0xc0, 0x42, 0x10, 0x1a,
-	0xb4, 0xb9, 0x08, 0x00, 0x2b, 0x2f, 0xe1, 0x82
-};
+static gboolean
+recip_entryid_decode_ex (const struct Binary_r *entryid, gchar **exchange_dn)
+{
+	uint32_t u32, sz, r;
+	uint8_t *ptr;
+
+	g_return_val_if_fail (entryid != NULL, FALSE);
+	g_return_val_if_fail (entryid->lpb != NULL, FALSE);
+	g_return_val_if_fail (exchange_dn != NULL, FALSE);
+
+	*exchange_dn = NULL;
+
+	ptr = entryid->lpb;
+	sz = entryid->cb;
+
+	u32 = 1;
+	r = bin_decode_uint32 (ptr, sz, &u32);
+	if (!r || u32 != 0)
+		return FALSE;
+
+	ptr += r;
+	sz -= r;
+
+	for (r = 0; r < G_N_ELEMENTS (MAPI_LOCAL_UID) && r < sz; r++) {
+		if (ptr[r] != MAPI_LOCAL_UID[r])
+			return FALSE;
+	}
+
+	if (r != G_N_ELEMENTS (MAPI_LOCAL_UID))
+		return FALSE;
+
+	ptr += r;
+	sz -= r;
+
+	/* version */
+	u32 = 0;
+	r = bin_decode_uint32 (ptr, sz, &u32);
+	if (!r)
+		return FALSE;
+	ptr += r;
+	sz -= r;
+
+	/* type */
+	u32 = 0;
+	r = bin_decode_uint32 (ptr, sz, &u32);
+	if (!r)
+		return FALSE;
+	ptr += r;
+	sz -= r;
+
+	r = bin_decode_string (ptr, sz, exchange_dn, FALSE);
+	if (!r || !*exchange_dn)
+		return FALSE;
+
+	return TRUE;
+}
 
 /**
- * e2k_entryid_generate_local:
- * @exchange_dn: the Exchange 5.5-style DN of the local user
+ * exchange_mapi_util_recip_entryid_decode:
+ * @conn: ExchangeMapiCOnnection to resolve names, if required
+ * @entryid: recipient's ENTRYID to decode
+ * @display_name: (out): stored display name, if any; can be NULL
+ * @email: (out): email or exchange DN; cannot be NULL
  *
- * 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
+ * Returns: Whether was able to decode recipient information from the @entryid.
  **/
-struct Binary_r *
-exchange_mapi_util_entryid_generate_local (TALLOC_CTX *mem_ctx, const gchar *exchange_dn)
+gboolean
+exchange_mapi_util_recip_entryid_decode (ExchangeMapiConnection *conn, const struct Binary_r *entryid, gchar **display_name, gchar **email)
 {
-	struct Binary_r *entryid;
+	gchar *dispnm = NULL, *exchange_dn = NULL;
 
-	entryid = talloc_zero (mem_ctx, struct Binary_r);
+	g_return_val_if_fail (conn != NULL, FALSE);
+	g_return_val_if_fail (entryid != NULL, FALSE);
+	g_return_val_if_fail (email != NULL, FALSE);
 
-	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);
+	*email = NULL;
+	if (display_name)
+		*display_name = NULL;
+
+	if (recip_entryid_decode_smtp (entryid, &dispnm, email)) {
+		if (display_name)
+			*display_name = dispnm;
+		else
+			g_free (dispnm);
+
+		return TRUE;
+	}
+
+	if (recip_entryid_decode_ex (entryid, &exchange_dn)) {
+		*email = exchange_mapi_connection_ex_to_smtp (conn, exchange_dn, display_name, NULL);
+		g_free (exchange_dn);
+
+		return *email != NULL;
+	}
 
-	return entryid;
+	return FALSE;
 }
 
 /**
diff --git a/src/libexchangemapi/exchange-mapi-utils.h b/src/libexchangemapi/exchange-mapi-utils.h
index 0c5fc7d..daaab96 100644
--- a/src/libexchangemapi/exchange-mapi-utils.h
+++ b/src/libexchangemapi/exchange-mapi-utils.h
@@ -59,11 +59,9 @@ exchange_mapi_util_free_stream_list (GSList **stream_list);
 void
 exchange_mapi_debug_property_dump (struct mapi_SPropValue_array *properties);
 
-void exchange_mapi_util_entryid_generate_oneoff (TALLOC_CTX *mem_ctx, struct Binary_r *entryid, const gchar *display_name, const gchar *email);
-gboolean exchange_mapi_util_entryid_decode_oneoff (const struct Binary_r *entyrid, gchar **display_name, gchar **email);
-
-struct Binary_r *
-exchange_mapi_util_entryid_generate_local (TALLOC_CTX *mem_ctx, const gchar *exchange_dn);
+void	 exchange_mapi_util_recip_entryid_generate_smtp (TALLOC_CTX *mem_ctx, struct Binary_r *entryid, const gchar *display_name, const gchar *email);
+void	 exchange_mapi_util_recip_entryid_generate_ex  (TALLOC_CTX *mem_ctx, struct Binary_r *entryid, const gchar *exchange_dn);
+gboolean exchange_mapi_util_recip_entryid_decode (ExchangeMapiConnection *conn, const struct Binary_r *entyrid, gchar **display_name, gchar **email);
 
 gchar *
 exchange_lf_to_crlf (const gchar *in);



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