Monotone-Parent: a1f0f7f1bc0ae64c5342d0d87ffd1ff8e7e3272c

Monotone-Revision: 4ce6162defbc430cacd1a414c9d9b8a3d7e9940e

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-10-28T13:10:47
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2011-10-28 13:10:47 +00:00
parent 8329414509
commit 1ba0d4daa1
7 changed files with 71 additions and 98 deletions

View File

@@ -1,5 +1,11 @@
2011-10-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreSOGo.m (sogo_message_modify_recipients):
adapted backend function to the new prototype, where the message
recipients are preparsed and now passed an array of "struct
mapistore_message_recipient", rather than a struct
ModifyRecipientRow.
* OpenChange/MAPIStoreTypes.m (NSObjectFromValuePointer): new
function returning an instance of an appropriate class based on a
property tag and a corresponding value passed as void *.

View File

@@ -239,12 +239,10 @@ static NSCharacterSet *hexCharacterSet = nil;
{
mgr = [SOGoUserManager sharedUserManager];
msgData->recipients_count = max + 1;
msgData->recipients = talloc_array (msgData, struct mapistore_message_recipient *, max + 1);
msgData->recipients = talloc_array (msgData, struct mapistore_message_recipient, max + 1);
for (count = 0; count < max; count++)
{
msgData->recipients[count]
= talloc_zero (msgData, struct mapistore_message_recipient);
recipient = msgData->recipients[count];
recipient = msgData->recipients + count;
person = [attendees objectAtIndex: count];
cn = [person cn];
@@ -260,7 +258,10 @@ static NSCharacterSet *hexCharacterSet = nil;
entryId = MAPIStoreInternalEntryId (username);
}
else
entryId = MAPIStoreExternalEntryId (cn, email);
{
recipient->username = NULL;
entryId = MAPIStoreExternalEntryId (cn, email);
}
recipient->type = MAPI_TO;
/* properties */
@@ -344,9 +345,7 @@ static NSCharacterSet *hexCharacterSet = nil;
/* On with the organizer: */
{
msgData->recipients[max]
= talloc_zero (msgData, struct mapistore_message_recipient);
recipient = msgData->recipients[max];
recipient = msgData->recipients + max;
person = [event organizer];
cn = [person cn];
@@ -360,7 +359,10 @@ static NSCharacterSet *hexCharacterSet = nil;
entryId = MAPIStoreInternalEntryId (username);
}
else
entryId = MAPIStoreExternalEntryId (cn, email);
{
recipient->username = NULL;
entryId = MAPIStoreExternalEntryId (cn, email);
}
recipient->type = MAPI_TO;
p = 0;

View File

@@ -798,7 +798,7 @@
if (value)
{
NSArray *recipients;
NSDictionary *dict, *recipientProperties;
NSDictionary *dict;
iCalPerson *person;
iCalPersonPartStat newPartStat;
NSNumber *flags, *trackStatus;
@@ -819,9 +819,7 @@
for (i = 0; i < [recipients count]; i++)
{
dict = [recipients objectAtIndex: i];
recipientProperties = [dict objectForKey: @"properties"];
flags = [recipientProperties
objectForKey: MAPIPropertyKey (PR_RECIPIENT_FLAGS)];
flags = [dict objectForKey: MAPIPropertyKey (PR_RECIPIENT_FLAGS)];
if (!flags)
{
[self logWithFormat: @"no recipient flags specified"];
@@ -837,7 +835,7 @@
else
{
trackStatus
= [recipientProperties
= [dict
objectForKey: MAPIPropertyKey (PR_RECIPIENT_TRACKSTATUS)];
/* FIXME: we should provide a data converter between OL

View File

@@ -1374,12 +1374,10 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
{
mgr = [SOGoUserManager sharedUserManager];
msgData->recipients_count = max;
msgData->recipients = talloc_array (msgData, struct mapistore_message_recipient *, max);
msgData->recipients = talloc_array (msgData, struct mapistore_message_recipient, max);
for (count = 0; count < max; count++)
{
msgData->recipients[count]
= talloc_zero (msgData, struct mapistore_message_recipient);
recipient = msgData->recipients[count];
recipient = msgData->recipients + count;
currentAddress = [to objectAtIndex: count];
cn = [currentAddress personalName];
@@ -1395,7 +1393,10 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
entryId = MAPIStoreInternalEntryId (username);
}
else
entryId = MAPIStoreExternalEntryId (cn, email);
{
recipient->username = NULL;
entryId = MAPIStoreExternalEntryId (cn, email);
}
recipient->type = MAPI_TO;
/* properties */

View File

@@ -50,9 +50,9 @@ extern NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email);
- (void) getMessageData: (struct mapistore_message **) dataPtr
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) modifyRecipientsWithRows: (struct ModifyRecipientRow *) rows
andCount: (NSUInteger) max
andColumns: (struct SPropTagArray *) columns;
- (int) modifyRecipientsWithRecipients: (struct mapistore_message_recipient *) recipients
andCount: (NSUInteger) max
andColumns: (struct SPropTagArray *) columns;
- (NSArray *) attachmentKeys;
- (NSArray *) attachmentKeysMatchingQualifier: (EOQualifier *) qualifier
andSortOrderings: (NSArray *) sortOrderings;

View File

@@ -49,7 +49,8 @@
#include <mapistore/mapistore_errors.h>
#include <mapistore/mapistore_nameid.h>
NSData *MAPIStoreInternalEntryId (NSString *username)
NSData *
MAPIStoreInternalEntryId (NSString *username)
{
NSMutableData *entryId;
static uint8_t providerUid[] = { 0xdc, 0xa7, 0x40, 0xc8,
@@ -83,7 +84,8 @@ NSData *MAPIStoreInternalEntryId (NSString *username)
return entryId;
}
NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email)
NSData *
MAPIStoreExternalEntryId (NSString *cn, NSString *email)
{
NSMutableData *entryId;
static uint8_t providerUid[] = { 0x81, 0x2b, 0x1f, 0xa4,
@@ -203,107 +205,73 @@ NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email)
*dataPtr = msgData;
}
- (NSDictionary *) _convertRecipientFromRow: (struct RecipientRow *) row
andColumns: (struct SPropTagArray *) columns
- (NSDictionary *) _convertRecipient: (struct mapistore_message_recipient *) recipient
andColumns: (struct SPropTagArray *) columns
{
NSMutableDictionary *recipient, *recipientProperties;
NSMutableDictionary *recipientProperties;
SOGoUser *recipientUser;
NSUInteger count, dataPos;
struct mapi_SPropValue mapiValue;
NSUInteger count;
id value;
TALLOC_CTX *memCtx;
recipient = [NSMutableDictionary dictionaryWithCapacity: 5];
recipientProperties = [NSMutableDictionary dictionaryWithCapacity: columns->cValues + 2];
if ((row->RecipientFlags & 0x07) == 1)
if (recipient->username)
{
value = [NSString stringWithUTF8String: row->X500DN.recipient_x500name];
[recipient setObject: value forKey: @"x500dn"];
value = [NSString stringWithUTF8String: recipient->username];
[recipientProperties setObject: value forKey: @"x500dn"];
recipientUser = [SOGoUser userWithLogin: [value lowercaseString]];
if (recipientUser)
{
value = [recipientUser cn];
if ([value length] > 0)
[recipient setObject: value forKey: @"fullName"];
[recipientProperties setObject: value forKey: @"fullName"];
value = [[recipientUser allEmails] objectAtIndex: 0];
if ([value length] > 0)
[recipient setObject: value forKey: @"email"];
[recipientProperties setObject: value forKey: @"email"];
}
}
else
{
switch ((row->RecipientFlags & 0x208))
if (recipient->data[0])
{
case 0x08:
// TODO: we cheat
value = [NSString stringWithUTF8String: row->EmailAddress.lpszA];
break;
case 0x208:
value = [NSString stringWithUTF8String: row->EmailAddress.lpszW];
break;
default:
value = nil;
value = [NSString stringWithUTF8String: recipient->data[0]];
if ([value length] > 0)
[recipientProperties setObject: value forKey: @"fullName"];
}
if (value)
[recipient setObject: value forKey: @"email"];
switch ((row->RecipientFlags & 0x210))
if (recipient->data[1])
{
case 0x10:
// TODO: we cheat
value = [NSString stringWithUTF8String: row->DisplayName.lpszA];
break;
case 0x210:
value = [NSString stringWithUTF8String: row->DisplayName.lpszW];
break;
default:
value = nil;
value = [NSString stringWithUTF8String: recipient->data[1]];
if ([value length] > 0)
[recipientProperties setObject: value forKey: @"email"];
}
if (value)
[recipient setObject: value forKey: @"fullName"];
}
recipientProperties = [NSMutableDictionary new];
[recipient setObject: recipientProperties forKey: @"properties"];
dataPos = 0;
memCtx = talloc_zero (NULL, TALLOC_CTX);
for (count = 0; count < columns->cValues; count++)
{
mapiValue.ulPropTag = columns->aulPropTag[count];
if (row->layout)
if (recipient->data[count])
{
if (row->prop_values.data[dataPos])
{
dataPos += 5;
continue;
}
else
dataPos++;
value = NSObjectFromValuePointer (columns->aulPropTag[count],
recipient->data[count]);
if (value)
[recipientProperties setObject: value
forKey: MAPIPropertyKey (columns->aulPropTag[count])];
}
set_mapi_SPropValue_sogo (memCtx, &mapiValue, row->prop_values.data + dataPos);
value = NSObjectFromMAPISPropValue (&mapiValue);
dataPos += get_mapi_property_size (&mapiValue);
if (value)
[recipientProperties setObject: value forKey: MAPIPropertyKey (columns->aulPropTag[count])];
}
[recipientProperties release];
talloc_free (memCtx);
return recipient;
return recipientProperties;
}
- (int) modifyRecipientsWithRows: (struct ModifyRecipientRow *) rows
andCount: (NSUInteger) max
andColumns: (struct SPropTagArray *) columns
- (int) modifyRecipientsWithRecipients: (struct mapistore_message_recipient *) newRecipients
andCount: (NSUInteger) max
andColumns: (struct SPropTagArray *) columns;
{
static NSString *recTypes[] = { @"orig", @"to", @"cc", @"bcc" };
NSDictionary *recipientProperties;
NSMutableDictionary *recipients;
NSMutableArray *list;
NSString *recType;
struct ModifyRecipientRow *currentRow;
struct mapistore_message_recipient *recipient;
NSUInteger count;
[self logWithFormat: @"METHOD '%s'", __FUNCTION__];
@@ -315,12 +283,11 @@ NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email)
for (count = 0; count < max; count++)
{
currentRow = rows + count;
recipient = newRecipients + count;
if (currentRow->RecipClass >= MAPI_ORIG
&& currentRow->RecipClass <= MAPI_BCC)
if (recipient->type >= MAPI_ORIG && recipient->type <= MAPI_BCC)
{
recType = recTypes[currentRow->RecipClass];
recType = recTypes[recipient->type];
list = [recipients objectForKey: recType];
if (!list)
{
@@ -329,8 +296,7 @@ NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email)
[list release];
}
[list addObject:
[self _convertRecipientFromRow: &(currentRow->RecipientRow)
andColumns: columns]];
[self _convertRecipient: recipient andColumns: columns]];
}
}
[self addProperties: recipientProperties];

View File

@@ -679,8 +679,8 @@ sogo_message_get_attachment_table (void *message_object, TALLOC_CTX *mem_ctx, vo
static int
sogo_message_modify_recipients (void *message_object,
struct SPropTagArray *columns,
struct ModifyRecipientRow *recipients,
uint16_t count)
uint16_t count,
struct mapistore_message_recipient *recipients)
{
struct MAPIStoreTallocWrapper *wrapper;
NSAutoreleasePool *pool;
@@ -694,9 +694,9 @@ sogo_message_modify_recipients (void *message_object,
wrapper = message_object;
message = wrapper->MAPIStoreSOGoObject;
pool = [NSAutoreleasePool new];
rc = [message modifyRecipientsWithRows: recipients
andCount: count
andColumns: columns];
rc = [message modifyRecipientsWithRecipients: recipients
andCount: count
andColumns: columns];
// [context tearDownRequest];
[pool release];
}