On Sat, 2008-04-05 at 05:19 +0200, Julien Kerihuel wrote:
> I have some small but (headache style) changes to apply to libmapi in
> order to support this improvement -- should be able to push this change
> on trunk during the week-end. More likely on Sunday evening rather than
> Saturday afternoon though.

I've fixed the OpenMessage IDL and libmapi related code. I have also
noticed a bug while creating the SRow array from the recipients header
which took me a little longer to fix.

Note that the attached patch is not yet perfect. If you get a closer
look to the GetRecipientTable for an original message and a message
pushed using ocpf-dump, you'll notice some of the string values don't
seem to be associated with the correct property. Anyway, this should be
trivial to fix and I'll do it in another commit.

In the meantime, let me know if it fix the bug for you so I can apply
the patch to the trunk and move forward on the remaining part of this
issue.

Cheers,
Julien.

-- 
Julien Kerihuel
[EMAIL PROTECTED]
OpenChange Project Manager

GPG Fingerprint: 0B55 783D A781 6329 108A  B609 7EF6 FE11 A35F 1F79

Index: exchange.idl
===================================================================
--- exchange.idl	(revision 414)
+++ exchange.idl	(working copy)
@@ -817,6 +817,7 @@
 	typedef  [flag(NDR_NOALIGN)]struct {
 		uint8		organization_length;
 		addr_type	addr_type;
+		astring		username;
 	} RecipExchange;
 
 	typedef [flag(NDR_NOALIGN)] struct {
@@ -828,41 +829,41 @@
 		[default];
 	} recipient_type;
 
-	/* Bit 5: always UTF8 encoded */
 	typedef [nodiscriminant, flag(NDR_NOALIGN)] union {
-		[case(0x400)] astring		lpszA;
+		[case(0x0)];
+		[case(0x400)] astring				lpszA;
+		[case(0x600)][flag(STR_NULLTERM)] string	lpszW;
 		[default];
-	} recipient_displayname_7bit;
+	} recipient_displayname;
 
-	/* Bit 10 */
 	typedef [nodiscriminant, flag(NDR_NOALIGN)] union {
+		[case(0x0)];
 		[case(0x20)] astring				lpszA;
 		[case(0x220)][flag(STR_NULLTERM)] string	lpszW;
 		[default];
-	} recipient_email;
+	} recipient_firstname;
 
-	/* Bit 11 */
-	/* First Name = PR_GIVEN_NAME */
 	typedef [nodiscriminant, flag(NDR_NOALIGN)] union {
+		[case(0x0)];
 		[case(0x10)] astring				lpszA;
 		[case(0x210)][flag(STR_NULLTERM)] string	lpszW;
 		[default];
-	} recipient_firstname;
+	} recipient_accountname;
 
-	/* Bit 15 */
 	typedef [nodiscriminant, flag(NDR_NOALIGN)] union {
-		[case(0x1)] astring				lpszA;
-		[case(0x201)][flag(STR_NULLTERM)] string	lpszW;
+		[case(0x0)];
+		[case(0x8)] astring				lpszA;
+		[case(0x208)][flag(STR_NULLTERM)] string	lpszW;
 		[default];
-	} recipient_displayname;
+	} recipient_email;
 
 	typedef [flag(NDR_NOALIGN)] struct {
 		uint16							bitmask;
 		[switch_is(bitmask & 0xA)]   recipient_type		type;
-		[switch_is(bitmask & 0x400)] recipient_displayname_7bit	username;
-		[switch_is(bitmask & 0x210)] recipient_firstname       	firstname;
-		[switch_is(bitmask & 0x201)] recipient_displayname	displayname;
-		[switch_is(bitmask & 0x220)] recipient_email   		email_address;
+		[switch_is(bitmask & 0x600)] recipient_displayname     	displayname;
+		[switch_is(bitmask & 0x220)] recipient_firstname       	firstname;
+		[switch_is(bitmask & 0x210)] recipient_accountname    	accountname;
+		[switch_is(bitmask & 0x208)] recipient_email		email;
 		uint16							prop_count;
 		uint8							layout;
 		[flag(NDR_REMAINING)] DATA_BLOB				prop_values;
Index: libmapi/IStoreFolder.c
===================================================================
--- libmapi/IStoreFolder.c	(revision 414)
+++ libmapi/IStoreFolder.c	(working copy)
@@ -129,6 +129,7 @@
 
 	for (i = 0; i < reply->recipient_count; i++) {
 		emsmdb_get_SRow((TALLOC_CTX *)message, &(message->SRowSet.aRow[i]), &message->SPropTagArray, 
+				reply->recipients[i].recipients_headers.prop_count,
 				&reply->recipients[i].recipients_headers.prop_values,
 				reply->recipients[i].recipients_headers.layout, 1);
 
Index: libmapi/emsmdb.c
===================================================================
--- libmapi/emsmdb.c	(revision 414)
+++ libmapi/emsmdb.c	(working copy)
@@ -511,25 +511,28 @@
 }
 
 
-void emsmdb_get_SRow(TALLOC_CTX *mem_ctx, struct SRow *aRow, struct SPropTagArray *proptags, DATA_BLOB *content, uint8_t layout, uint8_t align)
+void emsmdb_get_SRow(TALLOC_CTX *mem_ctx, struct SRow *aRow, struct SPropTagArray *proptags, uint16_t propcount, DATA_BLOB *content, uint8_t layout, uint8_t align)
 {
 	uint32_t		i;
 	uint32_t		offset = 0;
+	uint32_t		aulPropTag = 0;
 	const void		*data;
 
-	aRow->cValues = proptags->cValues;
-	aRow->lpProps = talloc_array(mem_ctx, struct SPropValue, proptags->cValues);
+	aRow->cValues = propcount;
+	aRow->lpProps = talloc_array(mem_ctx, struct SPropValue, propcount);
 
-	for (i = 0; i < proptags->cValues; i++) {
+	for (i = 0; i < propcount; i++) {
+		aulPropTag = proptags->aulPropTag[i];
 		if (layout) {
 			if (((uint8_t)(*(content->data + offset))) == PT_ERROR) {
-				proptags->aulPropTag[i] &= 0xFFFF0000;
-				proptags->aulPropTag[i] |= 0xA;			
+				aulPropTag &= 0xFFFF0000;
+				aulPropTag |= 0xA;			
 			}
 			offset += align;
-		}
-		data = pull_emsmdb_property(mem_ctx, &offset, proptags->aulPropTag[i], content);
-		aRow->lpProps[i].ulPropTag = proptags->aulPropTag[i];
+		} 
+
+		data = pull_emsmdb_property(mem_ctx, &offset, aulPropTag, content);
+		aRow->lpProps[i].ulPropTag = aulPropTag;
 		aRow->lpProps[i].dwAlignPad = 0x0;
 		set_SPropValue(&(aRow->lpProps[i]), data);
 	}
Index: libmapi/IMessage.c
===================================================================
--- libmapi/IMessage.c	(revision 414)
+++ libmapi/IMessage.c	(working copy)
@@ -380,43 +380,55 @@
 		}
 	} else {
 		/* (Bit 8) doesn't seem to work if unset */
-		bitmask |= 0x80;
+		bitmask |= 0x81;
 	}
 
-	/* (Bit 5) recipient_displayname_7bit: always UTF8 encoded? */
-	/* this could also be PR_RECIPIENT_DISPLAY_NAME */
-	lpProp = get_SPropValue_SRow(aRow, PR_7BIT_DISPLAY_NAME);
+	/* Bit 15: DISPLAY_NAME */
+	lpProp = get_SPropValue_SRow(aRow, PR_DISPLAY_NAME);
 	if (lpProp && lpProp->value.lpszA) {
 		bitmask |= 0x400;
 	}
 
-	lpProp = get_SPropValue_SRow(aRow, PR_7BIT_DISPLAY_NAME_UNICODE);
+	lpProp = get_SPropValue_SRow(aRow, PR_DISPLAY_NAME_UNICODE);
 	if (lpProp && lpProp->value.lpszW) {
 		bitmask |= 0x600;
 	}
 
-	/* (Bit 11) recipient_firstname: PR_GIVEN_NAME fits here */
+	/* Bit 6: PR_GIVEN_NAME */
 	lpProp = get_SPropValue_SRow(aRow, PR_GIVEN_NAME);
 	if (lpProp && lpProp->value.lpszA) {
-		bitmask |= 0x10;
-	} 
+		bitmask |= 0x20;
+	}
 
 	lpProp = get_SPropValue_SRow(aRow, PR_GIVEN_NAME_UNICODE);
 	if (lpProp && lpProp->value.lpszW) {
-		bitmask |= 0x210;
+		bitmask |= 0x220;
 	}
 
-	/* (Bit 15) from: recipient_displayname: PR_DISPLAY_NAME */
-	lpProp = get_SPropValue_SRow(aRow, PR_DISPLAY_NAME);
+	/* Bit 5. PR_7BIT_DISPLAY_NAME */
+	lpProp = get_SPropValue_SRow(aRow, PR_7BIT_DISPLAY_NAME);
 	if (lpProp && lpProp->value.lpszA) {
-		bitmask |= 0x1;
+		bitmask |= 0x10;
 	}
 
-	lpProp = get_SPropValue_SRow(aRow, PR_DISPLAY_NAME_UNICODE);
+	lpProp = get_SPropValue_SRow(aRow, PR_7BIT_DISPLAY_NAME_UNICODE);
 	if (lpProp && lpProp->value.lpszW) {
-		bitmask |= 0x201;
+		bitmask |= 0x210;
 	}
 
+	/* Bit 4: PR_EMAIL_ADDRESS */
+	if (bitmask & 0xA) {
+		lpProp = get_SPropValue_SRow(aRow, PR_SMTP_ADDRESS);
+		if (lpProp && lpProp->value.lpszA) {
+			bitmask |= 0x8;
+		}
+		
+		lpProp = get_SPropValue_SRow(aRow, PR_SMTP_ADDRESS_UNICODE);
+		if (lpProp && lpProp->value.lpszW) {
+			bitmask |= 0x208;
+		}
+	}
+
 	return bitmask;
 }
 
@@ -518,33 +530,35 @@
 		case 0x1: 
 			headers->type.EXCHANGE.organization_length = mapi_recipients_get_org_length(mapi_ctx->session->profile);
 			headers->type.EXCHANGE.addr_type = 0;
-			size += sizeof(uint32_t);
+			headers->type.EXCHANGE.username = (const char *) find_SPropValue_data(aRow, PR_7BIT_DISPLAY_NAME);
+			size += sizeof(uint32_t) + strlen(headers->type.EXCHANGE.username) + 1;
 			break;
 		case 0xB:
 			size += sizeof(uint16_t);
 			break;
 		}
 		
-		/* displayname 7bit == username */
-		switch (headers->bitmask & 0x400) {
+		/* Bit 15: PR_DISPLAY_NAME */
+		switch(headers->bitmask & 0x600) {
 		case (0x400):
-			headers->username.lpszA = (const char *) find_SPropValue_data(aRow, PR_7BIT_DISPLAY_NAME);
-			if (!headers->username.lpszA) {
-				headers->username.lpszA = (const char *) find_SPropValue_data(aRow, PR_7BIT_DISPLAY_NAME_UNICODE);
-			}
-			size += strlen(headers->username.lpszA) + 1;
+			headers->displayname.lpszA = (const char *) find_SPropValue_data(aRow, PR_DISPLAY_NAME);
+			size += strlen(headers->displayname.lpszA) + 1;
 			break;
+		case (0x600):
+			headers->displayname.lpszW = (const char *) find_SPropValue_data(aRow, PR_DISPLAY_NAME_UNICODE);
+			size += strlen(headers->displayname.lpszW) * 2 + 2;
+			break;
 		default:
 			break;
 		}
-		
-		/* first name */
-		switch (headers->bitmask & 0x210) {
-		case (0x10):
+
+		/* Bit 6: PR_GIVEN_NAME */
+		switch (headers->bitmask & 0x220) {
+		case (0x20):
 			headers->firstname.lpszA = (const char *) find_SPropValue_data(aRow, PR_GIVEN_NAME);
 			size += strlen(headers->firstname.lpszA) + 1;
 			break;
-		case (0x210):
+		case (0x220):
 			headers->firstname.lpszW = (const char *) find_SPropValue_data(aRow, PR_GIVEN_NAME_UNICODE);
 			size += strlen(headers->firstname.lpszW) * 2 + 2;
 			break;
@@ -552,19 +566,34 @@
 			break;
 		}
 
-		/* display name */
-		switch (headers->bitmask & 0x201) {
-		case (0x1):
-			headers->displayname.lpszA = (const char *) find_SPropValue_data(aRow, PR_DISPLAY_NAME);
-			size += strlen(headers->displayname.lpszA) + 1;
+		/* Bit 5: PR_7BIT_DISPLAY_NAME */
+		switch (headers->bitmask & 0x210) {
+		case (0x10):
+			headers->accountname.lpszA = (const char *) find_SPropValue_data(aRow, PR_7BIT_DISPLAY_NAME);
+			size += strlen(headers->accountname.lpszA) + 1;
 			break;
-		case (0x201):
-			headers->displayname.lpszW = (const char *) find_SPropValue_data(aRow, PR_DISPLAY_NAME_UNICODE);
-			size += strlen(headers->displayname.lpszW) * 2 + 2;
+		case (0x210):
+			headers->accountname.lpszW = (const char *) find_SPropValue_data(aRow, PR_7BIT_DISPLAY_NAME_UNICODE);
+			size += strlen(headers->accountname.lpszW) * 2 + 2;
+			break;
 		default:
 			break;
 		}
-		  
+
+		/* Bit 4: PR_SMTP_ADDRESS */
+		switch (headers->bitmask & 0x208) {
+		case (0x8):
+			headers->email.lpszA = (const char *) find_SPropValue_data(aRow, PR_SMTP_ADDRESS);
+			size += strlen(headers->email.lpszA) + 1;
+			break;
+		case (0x208):
+			headers->email.lpszW = (const char *) find_SPropValue_data(aRow, PR_SMTP_ADDRESS_UNICODE);
+			size += strlen(headers->email.lpszW) * 2 + 2;
+			break;
+		default:
+			break;
+		}
+		
 		headers->prop_count = request.prop_count;
 		size += sizeof(uint16_t);
 		headers->layout = 0;

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel

Reply via email to