mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-01 01:39:30 +00:00
Monotone-Parent: a9886e6c9acfb5c097b185a254e620a6a0094f1f
Monotone-Revision: 9109f0600492701322f24fb53d86a39821e26dc4 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-09-30T20:01:50 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -28,11 +28,13 @@
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/NSDictionary+Utilities.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserManager.h>
|
||||
#import <Mailer/SOGoDraftObject.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import "MAPIStoreContext.h"
|
||||
#import "MAPIStoreTypes.h"
|
||||
#import "NSData+MAPIStore.h"
|
||||
#import "NSObject+MAPIStore.h"
|
||||
#import "NSString+MAPIStore.h"
|
||||
|
||||
@@ -92,14 +94,17 @@ typedef void (*getMessageData_inMemCtx_) (MAPIStoreMessage *, SEL,
|
||||
- (void) getMessageData: (struct mapistore_message **) dataPtr
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
struct SRowSet *recipients;
|
||||
NSArray *to;
|
||||
NSInteger count, max;
|
||||
NSString *text;
|
||||
NSInteger count, max, p;
|
||||
NSString *username, *cn, *email;
|
||||
NSData *entryId;
|
||||
NSDictionary *contactInfos;
|
||||
SOGoUserManager *mgr;
|
||||
NSDictionary *headers;
|
||||
NGMailAddress *currentAddress;
|
||||
NGMailAddressParser *parser;
|
||||
struct mapistore_message *msgData;
|
||||
struct mapistore_message_recipient *recipient;
|
||||
getMessageData_inMemCtx_ superMethod;
|
||||
|
||||
if ([sogoObject isKindOfClass: SOGoDraftObjectK])
|
||||
@@ -117,53 +122,99 @@ typedef void (*getMessageData_inMemCtx_) (MAPIStoreMessage *, SEL,
|
||||
|
||||
to = [headers objectForKey: @"to"];
|
||||
max = [to count];
|
||||
recipients = talloc_zero (msgData, struct SRowSet);
|
||||
recipients->cRows = max;
|
||||
recipients->aRow = talloc_array (recipients, struct SRow, max);
|
||||
for (count = 0; count < max; count++)
|
||||
|
||||
msgData->columns = set_SPropTagArray (msgData, 9,
|
||||
PR_OBJECT_TYPE,
|
||||
PR_DISPLAY_TYPE,
|
||||
PR_7BIT_DISPLAY_NAME_UNICODE,
|
||||
PR_SMTP_ADDRESS_UNICODE,
|
||||
PR_SEND_INTERNET_ENCODING,
|
||||
PR_RECIPIENT_DISPLAY_NAME_UNICODE,
|
||||
PR_RECIPIENT_FLAGS,
|
||||
PR_RECIPIENT_ENTRYID,
|
||||
PR_RECIPIENT_TRACKSTATUS);
|
||||
|
||||
if (max > 0)
|
||||
{
|
||||
recipients->aRow[count].ulAdrEntryPad = 0;
|
||||
recipients->aRow[count].cValues = 3;
|
||||
recipients->aRow[count].lpProps = talloc_array (recipients->aRow,
|
||||
struct SPropValue,
|
||||
4);
|
||||
|
||||
// TODO (0x01 = primary recipient)
|
||||
set_SPropValue_proptag (recipients->aRow[count].lpProps + 0,
|
||||
PR_RECIPIENT_TYPE,
|
||||
MAPILongValue (recipients->aRow, 0x01));
|
||||
|
||||
set_SPropValue_proptag (recipients->aRow[count].lpProps + 1,
|
||||
PR_ADDRTYPE_UNICODE,
|
||||
[@"SMTP" asUnicodeInMemCtx: recipients->aRow]);
|
||||
|
||||
parser = [NGMailAddressParser
|
||||
mailAddressParserWithString: [to objectAtIndex: count]];
|
||||
currentAddress = [parser parse];
|
||||
if ([currentAddress isKindOfClass: NGMailAddressK])
|
||||
mgr = [SOGoUserManager sharedUserManager];
|
||||
msgData->recipients_count = max;
|
||||
msgData->recipients = talloc_array (msgData, struct mapistore_message_recipient *, max);
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
// text = [currentAddress personalName];
|
||||
// if (![text length])
|
||||
text = [currentAddress address];
|
||||
if (!text)
|
||||
text = @"";
|
||||
set_SPropValue_proptag (recipients->aRow[count].lpProps + 2,
|
||||
PR_EMAIL_ADDRESS_UNICODE,
|
||||
[text asUnicodeInMemCtx: recipients->aRow]);
|
||||
|
||||
text = [currentAddress displayName];
|
||||
if ([text length] > 0)
|
||||
msgData->recipients[count]
|
||||
= talloc_zero (msgData, struct mapistore_message_recipient);
|
||||
recipient = msgData->recipients[count];
|
||||
recipient->data = talloc_array (msgData, void *, msgData->columns->cValues);
|
||||
memset (recipient->data, 0, msgData->columns->cValues * sizeof (void *));
|
||||
|
||||
email = nil;
|
||||
cn = nil;
|
||||
|
||||
parser = [NGMailAddressParser
|
||||
mailAddressParserWithString: [to objectAtIndex: count]];
|
||||
currentAddress = [parser parse];
|
||||
if ([currentAddress isKindOfClass: NGMailAddressK])
|
||||
{
|
||||
recipients->aRow[count].cValues++;
|
||||
set_SPropValue_proptag (recipients->aRow[count].lpProps + 3,
|
||||
PR_DISPLAY_NAME_UNICODE,
|
||||
[text asUnicodeInMemCtx: recipients->aRow]);
|
||||
email = [currentAddress address];
|
||||
cn = [currentAddress displayName];
|
||||
contactInfos = [mgr contactInfosForUserWithUIDorEmail: email];
|
||||
|
||||
// PR_ACCOUNT_UNICODE
|
||||
if (contactInfos)
|
||||
{
|
||||
username = [contactInfos objectForKey: @"c_uid"];
|
||||
recipient->username = [username asUnicodeInMemCtx: msgData];
|
||||
entryId = MAPIStoreInternalEntryId (username);
|
||||
}
|
||||
else
|
||||
entryId = MAPIStoreExternalEntryId (cn, email);
|
||||
}
|
||||
else
|
||||
{
|
||||
entryId = nil;
|
||||
[self warnWithFormat: @"address could not be parsed"
|
||||
@" properly (ignored)"];
|
||||
}
|
||||
recipient->type = MAPI_TO;
|
||||
|
||||
/* properties */
|
||||
p = 0;
|
||||
recipient->data = talloc_array (msgData, void *, msgData->columns->cValues);
|
||||
memset (recipient->data, 0, msgData->columns->cValues * sizeof (void *));
|
||||
|
||||
// PR_OBJECT_TYPE = MAPI_MAILUSER (see MAPI_OBJTYPE)
|
||||
recipient->data[p] = MAPILongValue (msgData, MAPI_MAILUSER);
|
||||
p++;
|
||||
|
||||
// PR_DISPLAY_TYPE = DT_MAILUSER (see MS-NSPI)
|
||||
recipient->data[p] = MAPILongValue (msgData, 0);
|
||||
p++;
|
||||
|
||||
// PR_7BIT_DISPLAY_NAME_UNICODE
|
||||
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
||||
p++;
|
||||
|
||||
// PR_SMTP_ADDRESS_UNICODE
|
||||
recipient->data[p] = [email asUnicodeInMemCtx: msgData];
|
||||
p++;
|
||||
|
||||
// PR_SEND_INTERNET_ENCODING = 0x00060000 (plain text, see OXCMAIL)
|
||||
recipient->data[p] = MAPILongValue (msgData, 0x00060000);
|
||||
p++;
|
||||
|
||||
// PR_RECIPIENT_DISPLAY_NAME_UNICODE
|
||||
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
||||
p++;
|
||||
|
||||
// PR_RECIPIENT_FLAGS
|
||||
recipient->data[p] = NULL;
|
||||
p++;
|
||||
|
||||
// PR_RECIPIENT_ENTRYID
|
||||
recipient->data[p] = [entryId asShortBinaryInMemCtx: msgData];
|
||||
p++;
|
||||
}
|
||||
else
|
||||
[self warnWithFormat: @"address could not be parsed properly (ignored)"];
|
||||
}
|
||||
msgData->recipients = recipients;
|
||||
*dataPtr = msgData;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user