Monotone-Parent: e38c570559610854b85c2c517053417779a76964
Monotone-Revision: 419d3afdcfcc1cddf8eef1f0311d418b03b0d1a0 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-11-17T16:15:38 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
53e125bd7a
commit
6f13029d21
|
@ -1,3 +1,10 @@
|
||||||
|
2011-11-17 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* OpenChange/MAPIStoreMessage.m (MAPIStoreInternalEntryId): now
|
||||||
|
takes a ldb_context * parameter pointing to the samdb, which
|
||||||
|
enables us: 1) to return the real legacyExchangeDN 2) to make use
|
||||||
|
of sAMAccountName as search parameter for the username.
|
||||||
|
|
||||||
2011-11-16 Ludovic Marcotte <lmarcotte@inverse.ca>
|
2011-11-16 Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||||
|
|
||||||
* SoObjects/SOGo/SOGoSieveManager.m (-updateFiltersForLogin:...)
|
* SoObjects/SOGo/SOGoSieveManager.m (-updateFiltersForLogin:...)
|
||||||
|
|
|
@ -39,6 +39,7 @@ extern NSTimeZone *utcTZ;
|
||||||
|
|
||||||
@interface MAPIStoreAppointmentWrapper : NSObject
|
@interface MAPIStoreAppointmentWrapper : NSObject
|
||||||
{
|
{
|
||||||
|
struct mapistore_connection_info *connInfo;
|
||||||
iCalCalendar *calendar;
|
iCalCalendar *calendar;
|
||||||
iCalEvent *event;
|
iCalEvent *event;
|
||||||
NSTimeZone *timeZone;
|
NSTimeZone *timeZone;
|
||||||
|
@ -56,11 +57,13 @@ extern NSTimeZone *utcTZ;
|
||||||
+ (id) wrapperWithICalEvent: (iCalEvent *) newEvent
|
+ (id) wrapperWithICalEvent: (iCalEvent *) newEvent
|
||||||
andUser: (SOGoUser *) newUser
|
andUser: (SOGoUser *) newUser
|
||||||
andSenderEmail: (NSString *) newSenderEmail
|
andSenderEmail: (NSString *) newSenderEmail
|
||||||
inTimeZone: (NSTimeZone *) newTimeZone;
|
inTimeZone: (NSTimeZone *) newTimeZone
|
||||||
|
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo;
|
||||||
- (id) initWithICalEvent: (iCalEvent *) newEvent
|
- (id) initWithICalEvent: (iCalEvent *) newEvent
|
||||||
andUser: (SOGoUser *) newUser
|
andUser: (SOGoUser *) newUser
|
||||||
andSenderEmail: (NSString *) newSenderEmail
|
andSenderEmail: (NSString *) newSenderEmail
|
||||||
inTimeZone: (NSTimeZone *) newTimeZone;
|
inTimeZone: (NSTimeZone *) newTimeZone
|
||||||
|
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo;
|
||||||
|
|
||||||
/* getters */
|
/* getters */
|
||||||
- (void) fillMessageData: (struct mapistore_message *) dataPtr
|
- (void) fillMessageData: (struct mapistore_message *) dataPtr
|
||||||
|
|
|
@ -80,13 +80,15 @@ static NSCharacterSet *hexCharacterSet = nil;
|
||||||
andUser: (SOGoUser *) newUser
|
andUser: (SOGoUser *) newUser
|
||||||
andSenderEmail: (NSString *) newSenderEmail
|
andSenderEmail: (NSString *) newSenderEmail
|
||||||
inTimeZone: (NSTimeZone *) newTimeZone
|
inTimeZone: (NSTimeZone *) newTimeZone
|
||||||
|
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
|
||||||
{
|
{
|
||||||
MAPIStoreAppointmentWrapper *wrapper;
|
MAPIStoreAppointmentWrapper *wrapper;
|
||||||
|
|
||||||
wrapper = [[self alloc] initWithICalEvent: newEvent
|
wrapper = [[self alloc] initWithICalEvent: newEvent
|
||||||
andUser: newUser
|
andUser: newUser
|
||||||
andSenderEmail: newSenderEmail
|
andSenderEmail: newSenderEmail
|
||||||
inTimeZone: newTimeZone];
|
inTimeZone: newTimeZone
|
||||||
|
withConnectionInfo: newConnInfo];
|
||||||
[wrapper autorelease];
|
[wrapper autorelease];
|
||||||
|
|
||||||
return wrapper;
|
return wrapper;
|
||||||
|
@ -96,6 +98,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
|
connInfo = NULL;
|
||||||
calendar = nil;
|
calendar = nil;
|
||||||
event = nil;
|
event = nil;
|
||||||
timeZone = nil;
|
timeZone = nil;
|
||||||
|
@ -178,9 +181,11 @@ static NSCharacterSet *hexCharacterSet = nil;
|
||||||
andUser: (SOGoUser *) newUser
|
andUser: (SOGoUser *) newUser
|
||||||
andSenderEmail: (NSString *) newSenderEmail
|
andSenderEmail: (NSString *) newSenderEmail
|
||||||
inTimeZone: (NSTimeZone *) newTimeZone
|
inTimeZone: (NSTimeZone *) newTimeZone
|
||||||
|
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
|
||||||
{
|
{
|
||||||
if ((self = [self init]))
|
if ((self = [self init]))
|
||||||
{
|
{
|
||||||
|
connInfo = newConnInfo;
|
||||||
ASSIGN (event, newEvent);
|
ASSIGN (event, newEvent);
|
||||||
ASSIGN (calendar, [event parent]);
|
ASSIGN (calendar, [event parent]);
|
||||||
ASSIGN (timeZone, newTimeZone);
|
ASSIGN (timeZone, newTimeZone);
|
||||||
|
@ -256,7 +261,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
||||||
{
|
{
|
||||||
username = [contactInfos objectForKey: @"c_uid"];
|
username = [contactInfos objectForKey: @"c_uid"];
|
||||||
recipient->username = [username asUnicodeInMemCtx: msgData];
|
recipient->username = [username asUnicodeInMemCtx: msgData];
|
||||||
entryId = MAPIStoreInternalEntryId (username);
|
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -357,7 +362,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
||||||
{
|
{
|
||||||
username = [contactInfos objectForKey: @"c_uid"];
|
username = [contactInfos objectForKey: @"c_uid"];
|
||||||
recipient->username = [username asUnicodeInMemCtx: msgData];
|
recipient->username = [username asUnicodeInMemCtx: msgData];
|
||||||
entryId = MAPIStoreInternalEntryId (username);
|
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -727,7 +732,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
||||||
if (contactInfos)
|
if (contactInfos)
|
||||||
{
|
{
|
||||||
username = [contactInfos objectForKey: @"c_uid"];
|
username = [contactInfos objectForKey: @"c_uid"];
|
||||||
entryId = MAPIStoreInternalEntryId (username);
|
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entryId = MAPIStoreExternalEntryId (cn, email);
|
entryId = MAPIStoreExternalEntryId (cn, email);
|
||||||
|
|
|
@ -104,15 +104,18 @@
|
||||||
- (MAPIStoreAppointmentWrapper *) appointmentWrapper
|
- (MAPIStoreAppointmentWrapper *) appointmentWrapper
|
||||||
{
|
{
|
||||||
iCalEvent *event;
|
iCalEvent *event;
|
||||||
|
MAPIStoreContext *context;
|
||||||
|
|
||||||
if (!appointmentWrapper)
|
if (!appointmentWrapper)
|
||||||
{
|
{
|
||||||
event = [sogoObject component: NO secure: NO];
|
event = [sogoObject component: NO secure: NO];
|
||||||
|
context = [self context];
|
||||||
ASSIGN (appointmentWrapper,
|
ASSIGN (appointmentWrapper,
|
||||||
[MAPIStoreAppointmentWrapper wrapperWithICalEvent: event
|
[MAPIStoreAppointmentWrapper wrapperWithICalEvent: event
|
||||||
andUser: [[self context] activeUser]
|
andUser: [context activeUser]
|
||||||
andSenderEmail: nil
|
andSenderEmail: nil
|
||||||
inTimeZone: [self ownerTimeZone]]);
|
inTimeZone: [self ownerTimeZone]
|
||||||
|
withConnectionInfo: [context connectionInfo]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return appointmentWrapper;
|
return appointmentWrapper;
|
||||||
|
|
|
@ -263,6 +263,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
|
||||||
iCalCalendar *calendar;
|
iCalCalendar *calendar;
|
||||||
iCalEvent *event;
|
iCalEvent *event;
|
||||||
NSString *stringValue, *senderEmail;
|
NSString *stringValue, *senderEmail;
|
||||||
|
MAPIStoreContext *context;
|
||||||
|
|
||||||
if (!appointmentWrapper)
|
if (!appointmentWrapper)
|
||||||
{
|
{
|
||||||
|
@ -280,11 +281,13 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
|
||||||
senderEmail = [[from objectAtIndex: 0] email];
|
senderEmail = [[from objectAtIndex: 0] email];
|
||||||
else
|
else
|
||||||
senderEmail = nil;
|
senderEmail = nil;
|
||||||
|
context = [self context];
|
||||||
appointmentWrapper = [MAPIStoreAppointmentWrapper
|
appointmentWrapper = [MAPIStoreAppointmentWrapper
|
||||||
wrapperWithICalEvent: event
|
wrapperWithICalEvent: event
|
||||||
andUser: [[self context] activeUser]
|
andUser: [context activeUser]
|
||||||
andSenderEmail: senderEmail
|
andSenderEmail: senderEmail
|
||||||
inTimeZone: [self ownerTimeZone]];
|
inTimeZone: [self ownerTimeZone]
|
||||||
|
withConnectionInfo: [context connectionInfo]];
|
||||||
[appointmentWrapper retain];
|
[appointmentWrapper retain];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -721,6 +724,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
|
||||||
NSDictionary *contactInfos;
|
NSDictionary *contactInfos;
|
||||||
NGMailAddress *ngAddress;
|
NGMailAddress *ngAddress;
|
||||||
NSData *entryId;
|
NSData *entryId;
|
||||||
|
struct ldb_context *samCtx;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (fullMail)
|
if (fullMail)
|
||||||
|
@ -743,7 +747,8 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
|
||||||
if (contactInfos)
|
if (contactInfos)
|
||||||
{
|
{
|
||||||
username = [contactInfos objectForKey: @"c_uid"];
|
username = [contactInfos objectForKey: @"c_uid"];
|
||||||
entryId = MAPIStoreInternalEntryId (username);
|
samCtx = [[self context] connectionInfo]->sam_ctx;
|
||||||
|
entryId = MAPIStoreInternalEntryId (samCtx, username);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entryId = MAPIStoreExternalEntryId (cn, email);
|
entryId = MAPIStoreExternalEntryId (cn, email);
|
||||||
|
@ -1349,9 +1354,11 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
|
||||||
NSData *entryId;
|
NSData *entryId;
|
||||||
NSDictionary *contactInfos;
|
NSDictionary *contactInfos;
|
||||||
SOGoUserManager *mgr;
|
SOGoUserManager *mgr;
|
||||||
|
struct ldb_context *samCtx;
|
||||||
struct mapistore_message *msgData;
|
struct mapistore_message *msgData;
|
||||||
struct mapistore_message_recipient *recipient;
|
struct mapistore_message_recipient *recipient;
|
||||||
|
|
||||||
|
samCtx = [[self context] connectionInfo]->sam_ctx;
|
||||||
[super getMessageData: &msgData inMemCtx: memCtx];
|
[super getMessageData: &msgData inMemCtx: memCtx];
|
||||||
|
|
||||||
if (!headerSetup)
|
if (!headerSetup)
|
||||||
|
@ -1397,7 +1404,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
|
||||||
{
|
{
|
||||||
username = [contactInfos objectForKey: @"c_uid"];
|
username = [contactInfos objectForKey: @"c_uid"];
|
||||||
recipient->username = [username asUnicodeInMemCtx: msgData];
|
recipient->username = [username asUnicodeInMemCtx: msgData];
|
||||||
entryId = MAPIStoreInternalEntryId (username);
|
entryId = MAPIStoreInternalEntryId (samCtx, username);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -249,10 +249,13 @@ static NSString *recTypes[] = { @"orig", @"to", @"cc", @"bcc" };
|
||||||
NSData *entryId;
|
NSData *entryId;
|
||||||
NSDictionary *allRecipients, *dict, *contactInfos;
|
NSDictionary *allRecipients, *dict, *contactInfos;
|
||||||
SOGoUserManager *mgr;
|
SOGoUserManager *mgr;
|
||||||
|
struct ldb_context *samCtx;
|
||||||
struct mapistore_message *msgData;
|
struct mapistore_message *msgData;
|
||||||
struct mapistore_message_recipient *recipient;
|
struct mapistore_message_recipient *recipient;
|
||||||
enum ulRecipClass type;
|
enum ulRecipClass type;
|
||||||
|
|
||||||
|
samCtx = [[self context] connectionInfo]->sam_ctx;
|
||||||
|
|
||||||
[super getMessageData: &msgData inMemCtx: memCtx];
|
[super getMessageData: &msgData inMemCtx: memCtx];
|
||||||
|
|
||||||
allRecipients = [[sogoObject properties] objectForKey: @"recipients"];
|
allRecipients = [[sogoObject properties] objectForKey: @"recipients"];
|
||||||
|
@ -295,7 +298,7 @@ static NSString *recTypes[] = { @"orig", @"to", @"cc", @"bcc" };
|
||||||
{
|
{
|
||||||
username = [contactInfos objectForKey: @"c_uid"];
|
username = [contactInfos objectForKey: @"c_uid"];
|
||||||
recipient->username = [username asUnicodeInMemCtx: msgData];
|
recipient->username = [username asUnicodeInMemCtx: msgData];
|
||||||
entryId = MAPIStoreInternalEntryId (username);
|
entryId = MAPIStoreInternalEntryId (samCtx, username);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,9 +35,11 @@
|
||||||
@class MAPIStoreAttachmentTable;
|
@class MAPIStoreAttachmentTable;
|
||||||
@class MAPIStoreFolder;
|
@class MAPIStoreFolder;
|
||||||
|
|
||||||
|
struct ldb_context;
|
||||||
|
|
||||||
#import "MAPIStoreObject.h"
|
#import "MAPIStoreObject.h"
|
||||||
|
|
||||||
extern NSData *MAPIStoreInternalEntryId (NSString *username);
|
extern NSData *MAPIStoreInternalEntryId (struct ldb_context *, NSString *username);
|
||||||
extern NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email);
|
extern NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email);
|
||||||
|
|
||||||
@interface MAPIStoreMessage : MAPIStoreObject
|
@interface MAPIStoreMessage : MAPIStoreObject
|
||||||
|
|
|
@ -55,14 +55,18 @@
|
||||||
static NSString *resourcesDir = nil;
|
static NSString *resourcesDir = nil;
|
||||||
|
|
||||||
NSData *
|
NSData *
|
||||||
MAPIStoreInternalEntryId (NSString *username)
|
MAPIStoreInternalEntryId (struct ldb_context *samCtx, NSString *username)
|
||||||
{
|
{
|
||||||
NSMutableData *entryId;
|
NSMutableData *entryId = nil;
|
||||||
static uint8_t providerUid[] = { 0xdc, 0xa7, 0x40, 0xc8,
|
TALLOC_CTX *memCtx;
|
||||||
0xc0, 0x42, 0x10, 0x1a,
|
struct ldb_result *res = NULL;
|
||||||
0xb4, 0xb9, 0x08, 0x00,
|
const char * const attrs[] = { "legacyExchangeDN", NULL };
|
||||||
0x2b, 0x2f, 0xe1, 0x82 };
|
const char *legacyDn;
|
||||||
NSString *x500dn;
|
int ret;
|
||||||
|
static const uint8_t const providerUid[] = { 0xdc, 0xa7, 0x40, 0xc8,
|
||||||
|
0xc0, 0x42, 0x10, 0x1a,
|
||||||
|
0xb4, 0xb9, 0x08, 0x00,
|
||||||
|
0x2b, 0x2f, 0xe1, 0x82 };
|
||||||
|
|
||||||
/* structure:
|
/* structure:
|
||||||
flags: 32
|
flags: 32
|
||||||
|
@ -71,20 +75,28 @@ MAPIStoreInternalEntryId (NSString *username)
|
||||||
type: 32
|
type: 32
|
||||||
X500DN: variable */
|
X500DN: variable */
|
||||||
|
|
||||||
entryId = [NSMutableData dataWithCapacity: 256];
|
memCtx = talloc_zero(NULL, TALLOC_CTX);
|
||||||
[entryId appendUInt32: 0]; // flags
|
|
||||||
[entryId appendBytes: providerUid length: 16]; // provideruid
|
|
||||||
[entryId appendUInt32: 1]; // version
|
|
||||||
[entryId appendUInt32: 0]; // type (local mail user)
|
|
||||||
|
|
||||||
/* X500DN */
|
/* Search mapistoreURI given partial URI */
|
||||||
/* FIXME: the DN will likely work on DEMO installations for now but we
|
ret = ldb_search (samCtx, memCtx, &res, ldb_get_default_basedn(samCtx),
|
||||||
really should get the dn prefix from the server */
|
LDB_SCOPE_SUBTREE, attrs,
|
||||||
x500dn = [NSString stringWithFormat: @"/O=FIRST ORGANIZATION"
|
"(&(objectClass=user)(sAMAccountName=%s))",
|
||||||
@"/OU=FIRST ADMINISTRATIVE GROUP"
|
[username UTF8String]);
|
||||||
@"/CN=RECIPIENTS/CN=%@", username];
|
if (ret == LDB_SUCCESS && res->count == 1)
|
||||||
[entryId appendData: [x500dn dataUsingEncoding: NSISOLatin1StringEncoding]];
|
{
|
||||||
[entryId appendUInt8: 0];
|
legacyDn = ldb_msg_find_attr_as_string (res->msgs[0], attrs[0], NULL);
|
||||||
|
if (legacyDn)
|
||||||
|
{
|
||||||
|
entryId = [NSMutableData dataWithCapacity: 256];
|
||||||
|
[entryId appendUInt32: 0]; // flags
|
||||||
|
[entryId appendBytes: providerUid length: 16]; // provideruid
|
||||||
|
[entryId appendUInt32: 1]; // version
|
||||||
|
[entryId appendUInt32: 0]; // type (local mail user)
|
||||||
|
[entryId appendBytes: legacyDn length: strlen (legacyDn) + 1]; // x500dn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
talloc_free(memCtx);
|
||||||
|
|
||||||
return entryId;
|
return entryId;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue