reindentation

Monotone-Parent: 215f30784ae8904703b5fa172c7a563bf8f3b464
Monotone-Revision: 2f37714ba202d0c2f6bc3c888440ea82ee601d66

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-10-01T20:35:29
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2010-10-01 20:35:29 +00:00
parent 43568edc76
commit e4b127bb53
11 changed files with 1376 additions and 1283 deletions

View file

@ -1,6 +1,6 @@
/* MAPIApplication.m - this file is part of $PROJECT_NAME_HERE$ /* MAPIApplication.m - this file is part of SOGo
* *
* Copyright (C) 2010 Wolfgang Sourdeau * Copyright (C) 2010 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
@ -35,9 +35,9 @@ MAPIApplication *MAPIApp = nil;
@interface UnixSignalHandler : NSObject @interface UnixSignalHandler : NSObject
+ sharedHandler; + (id) sharedHandler;
- (void)removeObserver:(id)observer; - (void) removeObserver: (id) observer;
@end @end
@ -45,61 +45,62 @@ MAPIApplication *MAPIApp = nil;
- (id) init - (id) init
{ {
SOGoProductLoader *loader; SOGoProductLoader *loader;
NSUserDefaults *ud; NSUserDefaults *ud;
SOGoSystemDefaults *sd; SOGoSystemDefaults *sd;
if (!MAPIApp) { if (!MAPIApp)
/* Here we work around a bug in GNUstep which decodes XML user {
defaults using the system encoding rather than honouring /* Here we work around a bug in GNUstep which decodes XML user
the encoding specified in the file. */ defaults using the system encoding rather than honouring
putenv ("GNUSTEP_STRING_ENCODING=NSUTF8StringEncoding"); the encoding specified in the file. */
putenv ("GNUSTEP_STRING_ENCODING=NSUTF8StringEncoding");
sd = [SOGoSystemDefaults sharedSystemDefaults]; sd = [SOGoSystemDefaults sharedSystemDefaults];
// /* We force the plugin to base its configuration on the SOGo tree. */ // /* We force the plugin to base its configuration on the SOGo tree. */
ud = [NSUserDefaults standardUserDefaults]; ud = [NSUserDefaults standardUserDefaults];
[ud registerDefaults: [ud persistentDomainForName: @"sogod"]]; [ud registerDefaults: [ud persistentDomainForName: @"sogod"]];
NSLog (@"(config check) imap server: %@", [sd imapServer]); NSLog (@"(config check) imap server: %@", [sd imapServer]);
// TODO publish // TODO publish
loader = [SOGoProductLoader productLoader]; loader = [SOGoProductLoader productLoader];
[loader loadProducts: [NSArray arrayWithObjects: [loader loadProducts: [NSArray arrayWithObjects:
@"Contacts.SOGo", @"Contacts.SOGo",
@"Appointments.SOGo", @"Appointments.SOGo",
@"Mailer.SOGo", @"Mailer.SOGo",
nil]]; nil]];
// TODO publish // TODO publish
[iCalEntityObject initializeSOGoExtensions]; [iCalEntityObject initializeSOGoExtensions];
MAPIApp = [super init]; MAPIApp = [super init];
[MAPIApp retain]; [MAPIApp retain];
/* This is a hack to revert what is done in [WOCoreApplication /* This is a hack to revert what is done in [WOCoreApplication
init] */ init] */
[[NSClassFromString(@"UnixSignalHandler") sharedHandler] [[NSClassFromString(@"UnixSignalHandler") sharedHandler]
removeObserver: self]; removeObserver: self];
} }
return MAPIApp; return MAPIApp;
} }
- (void) dealloc - (void) dealloc
{ {
[mapiContext release]; [mapiContext release];
[super dealloc]; [super dealloc];
} }
- (void) setMAPIStoreContext: (MAPIStoreContext *) newMAPIStoreContext - (void) setMAPIStoreContext: (MAPIStoreContext *) newMAPIStoreContext
{ {
ASSIGN (mapiContext, newMAPIStoreContext); ASSIGN (mapiContext, newMAPIStoreContext);
} }
- (id) authenticatorInContext: (id) context - (id) authenticatorInContext: (id) context
{ {
return [mapiContext authenticator]; return [mapiContext authenticator];
} }
@end @end

View file

@ -1,6 +1,6 @@
/* MAPIStoreAuthenticator.m - this file is part of SOGo /* MAPIStoreAuthenticator.m - this file is part of SOGo
* *
* Copyright (C) 2010 Wolfgang Sourdeau * Copyright (C) 2010 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *

View file

@ -41,22 +41,22 @@ static Class SOGoUserFolderK;
+ (void) initialize + (void) initialize
{ {
SOGoUserFolderK = [SOGoUserFolderK class]; SOGoUserFolderK = [SOGoUserFolder class];
} }
- (void) setupModuleFolder - (void) setupModuleFolder
{ {
id userFolder; id userFolder;
userFolder = [SOGoUserFolderK objectWithName: [authenticator username] userFolder = [SOGoUserFolderK objectWithName: [authenticator username]
inContainer: MAPIApp]; inContainer: MAPIApp];
[woContext setClientObject: userFolder]; [woContext setClientObject: userFolder];
[userFolder retain]; // LEAK [userFolder retain]; // LEAK
moduleFolder = [userFolder lookupName: @"Calendar" moduleFolder = [userFolder lookupName: @"Calendar"
inContext: woContext inContext: woContext
acquire: NO]; acquire: NO];
[moduleFolder retain]; [moduleFolder retain];
} }
- (int) getMessageTableChildproperty: (void **) data - (int) getMessageTableChildproperty: (void **) data
@ -65,97 +65,98 @@ static Class SOGoUserFolderK;
inFolder: (SOGoFolder *) folder inFolder: (SOGoFolder *) folder
withFID: (uint64_t) fid withFID: (uint64_t) fid
{ {
uint32_t *longValue; uint32_t *longValue;
uint8_t *boolValue; uint8_t *boolValue;
// id child; // id child;
id event; id event;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
case PR_ICON_INDEX: // TODO {
longValue = talloc_zero(memCtx, uint32_t); case PR_ICON_INDEX: // TODO
*longValue = 0x00000400; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */ longValue = talloc_zero(memCtx, uint32_t);
// *longValue = 0x00000401 for recurring event *longValue = 0x00000400; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
// *longValue = 0x00000402 for meeting // *longValue = 0x00000401 for recurring event
// *longValue = 0x00000403 for recurring meeting // *longValue = 0x00000402 for meeting
// *longValue = 0x00000404 for invitation // *longValue = 0x00000403 for recurring meeting
*data = longValue; // *longValue = 0x00000404 for invitation
break; *data = longValue;
case PR_MESSAGE_CLASS_UNICODE: break;
*data = talloc_strdup(memCtx, "IPM.Appointment"); case PR_MESSAGE_CLASS_UNICODE:
break; *data = talloc_strdup(memCtx, "IPM.Appointment");
case 0x818f0040: // DTSTART break;
event = [[self lookupObject: childURL] component: NO secure: NO]; case 0x818f0040: // DTSTART
*data = [[event startDate] asFileTimeInMemCtx: memCtx]; event = [[self lookupObject: childURL] component: NO secure: NO];
break; *data = [[event startDate] asFileTimeInMemCtx: memCtx];
case 0x818a0040: // DTEND break;
event = [[self lookupObject: childURL] component: NO secure: NO]; case 0x818a0040: // DTEND
*data = [[event endDate] asFileTimeInMemCtx: memCtx]; event = [[self lookupObject: childURL] component: NO secure: NO];
break; *data = [[event endDate] asFileTimeInMemCtx: memCtx];
case 0x82410003: // LABEL idx, should be saved in an X- property break;
longValue = talloc_zero(memCtx, uint32_t); case 0x82410003: // LABEL idx, should be saved in an X- property
*longValue = 0; longValue = talloc_zero(memCtx, uint32_t);
*data = longValue; *longValue = 0;
break; *data = longValue;
case PR_SUBJECT_UNICODE: // SUMMARY break;
case PR_NORMALIZED_SUBJECT_UNICODE: case PR_SUBJECT_UNICODE: // SUMMARY
case PR_CONVERSATION_TOPIC_UNICODE: case PR_NORMALIZED_SUBJECT_UNICODE:
event = [[self lookupObject: childURL] component: NO secure: NO]; case PR_CONVERSATION_TOPIC_UNICODE:
*data = [[event summary] asUnicodeInMemCtx: memCtx]; event = [[self lookupObject: childURL] component: NO secure: NO];
break; *data = [[event summary] asUnicodeInMemCtx: memCtx];
case 0x810c001f: // LOCATION break;
event = [[self lookupObject: childURL] component: NO secure: NO]; case 0x810c001f: // LOCATION
*data = [[event location] asUnicodeInMemCtx: memCtx]; event = [[self lookupObject: childURL] component: NO secure: NO];
break; *data = [[event location] asUnicodeInMemCtx: memCtx];
case 0x8224000b: // private (bool), should depend on CLASS break;
boolValue = talloc_zero(memCtx, uint8_t); case 0x8224000b: // private (bool), should depend on CLASS
*boolValue = NO; boolValue = talloc_zero(memCtx, uint8_t);
*data = boolValue; *boolValue = NO;
break; *data = boolValue;
case PR_SENSITIVITY: // not implemented, depends on CLASS break;
// normal = 0, private = 2 case PR_SENSITIVITY: // not implemented, depends on CLASS
longValue = talloc_zero(memCtx, uint32_t); // normal = 0, private = 2
*longValue = 0; longValue = talloc_zero(memCtx, uint32_t);
*data = longValue; *longValue = 0;
break; *data = longValue;
break;
// case PR_VD_NAME_UNICODE: // case PR_VD_NAME_UNICODE:
// *data = talloc_strdup(memCtx, "PR_VD_NAME_UNICODE"); // *data = talloc_strdup(memCtx, "PR_VD_NAME_UNICODE");
// break; // break;
// case PR_EMS_AB_DXA_REMOTE_CLIENT_UNICODE: "Home:" ??? // case PR_EMS_AB_DXA_REMOTE_CLIENT_UNICODE: "Home:" ???
// *data = talloc_strdup(memCtx, "PR_EMS..."); // *data = talloc_strdup(memCtx, "PR_EMS...");
// break; // break;
default: default:
rc = [super getMessageTableChildproperty: data rc = [super getMessageTableChildproperty: data
atURL: childURL atURL: childURL
withTag: proptag withTag: proptag
inFolder: folder inFolder: folder
withFID: fid]; withFID: fid];
} }
// #define PR_REPLY_TIME PROP_TAG(PT_SYSTIME , 0x0030) /* 0x00300040 */ // #define PR_REPLY_TIME PROP_TAG(PT_SYSTIME , 0x0030) /* 0x00300040 */
// #define PR_MESSAGE_FLAGS PROP_TAG(PT_LONG , 0x0e07) /* 0x0e070003 */ // #define PR_MESSAGE_FLAGS PROP_TAG(PT_LONG , 0x0e07) /* 0x0e070003 */
// #define PR_MSG_STATUS PROP_TAG(PT_LONG , 0x0e17) /* 0x0e170003 */ // #define PR_MSG_STATUS PROP_TAG(PT_LONG , 0x0e17) /* 0x0e170003 */
// #define PR_INTERNET_MESSAGE_ID_UNICODE PROP_TAG(PT_UNICODE , 0x1035) /* 0x1035001f */ // #define PR_INTERNET_MESSAGE_ID_UNICODE PROP_TAG(PT_UNICODE , 0x1035) /* 0x1035001f */
// #define PR_FLAG_STATUS PROP_TAG(PT_LONG , 0x1090) /* 0x10900003 */ // #define PR_FLAG_STATUS PROP_TAG(PT_LONG , 0x1090) /* 0x10900003 */
// #define PR_CREATION_TIME PROP_TAG(PT_SYSTIME , 0x3007) /* 0x30070040 */ // #define PR_CREATION_TIME PROP_TAG(PT_SYSTIME , 0x3007) /* 0x30070040 */
// #define PR_SEARCH_KEY PROP_TAG(PT_BINARY , 0x300b) /* 0x300b0102 */ // #define PR_SEARCH_KEY PROP_TAG(PT_BINARY , 0x300b) /* 0x300b0102 */
// #define PR_EMS_AB_INCOMING_MSG_SIZE_LIMIT PROP_TAG(PT_LONG , 0x8190) /* 0x81900003 */ // #define PR_EMS_AB_INCOMING_MSG_SIZE_LIMIT PROP_TAG(PT_LONG , 0x8190) /* 0x81900003 */
// Not found: 81930003 // ? // Not found: 81930003 // ?
// Not found: 80fa000b // ? // Not found: 80fa000b // ?
// Not found: 81c4000b // ? // Not found: 81c4000b // ?
// Not found: 81e7000b // ? // Not found: 81e7000b // ?
// Not found: 81ee000b // ? // Not found: 81ee000b // ?
// Not found: 81f80003 // // Not found: 81f80003 //
// Not found: 82020102 // // Not found: 82020102 //
// Not found: 818b0102 // // Not found: 818b0102 //
// Not found: 81d1001f // // Not found: 81d1001f //
return rc; return rc;
} }
// - (int) getFolderTableChildproperty: (void **) data // - (int) getFolderTableChildproperty: (void **) data

View file

@ -45,22 +45,22 @@ static Class SOGoUserFolderK;
+ (void) initialize + (void) initialize
{ {
SOGoUserFolderK = [SOGoUserFolderK class]; SOGoUserFolderK = [SOGoUserFolder class];
} }
- (void) setupModuleFolder - (void) setupModuleFolder
{ {
id userFolder; id userFolder;
userFolder = [SOGoUserFolderK objectWithName: [authenticator username] userFolder = [SOGoUserFolderK objectWithName: [authenticator username]
inContainer: MAPIApp]; inContainer: MAPIApp];
[woContext setClientObject: userFolder]; [woContext setClientObject: userFolder];
[userFolder retain]; // LEAK [userFolder retain]; // LEAK
moduleFolder = [userFolder lookupName: @"Contacts" moduleFolder = [userFolder lookupName: @"Contacts"
inContext: woContext inContext: woContext
acquire: NO]; acquire: NO];
[moduleFolder retain]; [moduleFolder retain];
} }
// - (int) getCommonTableChildproperty: (void **) data // - (int) getCommonTableChildproperty: (void **) data
@ -120,7 +120,7 @@ static Class SOGoUserFolderK;
} }
if (!phone) if (!phone)
phone = @""; phone = @"";
return phone; return phone;
} }
@ -131,166 +131,168 @@ static Class SOGoUserFolderK;
inFolder: (SOGoFolder *) folder inFolder: (SOGoFolder *) folder
withFID: (uint64_t) fid withFID: (uint64_t) fid
{ {
NSString *stringValue; NSString *stringValue;
uint32_t *longValue; uint32_t *longValue;
id child; id child;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
case PR_ICON_INDEX: // TODO {
longValue = talloc_zero(memCtx, uint32_t); case PR_ICON_INDEX: // TODO
*longValue = 0x00000200; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */ longValue = talloc_zero(memCtx, uint32_t);
*data = longValue; *longValue = 0x00000200; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
break; *data = longValue;
case PR_MESSAGE_CLASS_UNICODE: break;
*data = talloc_strdup(memCtx, "IPM.Contact"); case PR_MESSAGE_CLASS_UNICODE:
break; *data = talloc_strdup(memCtx, "IPM.Contact");
// case PR_VD_NAME_UNICODE: break;
// *data = talloc_strdup(memCtx, "PR_VD_NAME_UNICODE"); // case PR_VD_NAME_UNICODE:
// break; // *data = talloc_strdup(memCtx, "PR_VD_NAME_UNICODE");
// case PR_EMS_AB_DXA_REMOTE_CLIENT_UNICODE: "Home:" ??? // break;
// *data = talloc_strdup(memCtx, "PR_EMS..."); // case PR_EMS_AB_DXA_REMOTE_CLIENT_UNICODE: "Home:" ???
// break; // *data = talloc_strdup(memCtx, "PR_EMS...");
case PR_SUBJECT_UNICODE: // break;
*data = talloc_strdup(memCtx, "PR_SUBJECT..."); case PR_SUBJECT_UNICODE:
break; *data = talloc_strdup(memCtx, "PR_SUBJECT...");
case PR_OAB_NAME_UNICODE: break;
*data = talloc_strdup(memCtx, "PR_OAB_NAME_UNICODE"); case PR_OAB_NAME_UNICODE:
break; *data = talloc_strdup(memCtx, "PR_OAB_NAME_UNICODE");
case PR_OAB_LANGID: break;
longValue = talloc_zero(memCtx, uint32_t); case PR_OAB_LANGID:
*longValue = 1033; /* English US */ longValue = talloc_zero(memCtx, uint32_t);
*data = longValue; *longValue = 1033; /* English US */
break; *data = longValue;
break;
case PR_TITLE_UNICODE: case PR_TITLE_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
stringValue = [[child vCard] title]; stringValue = [[child vCard] title];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
break; break;
case PR_COMPANY_NAME_UNICODE: case PR_COMPANY_NAME_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
/* that's buggy but it's for the demo */ /* that's buggy but it's for the demo */
stringValue = [[[child vCard] org] componentsJoinedByString: @", "]; stringValue = [[[child vCard] org] componentsJoinedByString: @", "];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
break; break;
case 0x3001001f: // Full Name case 0x3001001f: // Full Name
case 0x81c2001f: // contact block title name case 0x81c2001f: // contact block title name
rc = [super getMessageTableChildproperty: data rc = [super getMessageTableChildproperty: data
atURL: childURL atURL: childURL
withTag: PR_DISPLAY_NAME_UNICODE withTag: PR_DISPLAY_NAME_UNICODE
inFolder: folder inFolder: folder
withFID: fid]; withFID: fid];
break; break;
case 0x81b0001f: // E-mail case 0x81b0001f: // E-mail
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
stringValue = [[child vCard] preferredEMail]; stringValue = [[child vCard] preferredEMail];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
break; break;
case PR_BODY_UNICODE: case PR_BODY_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
stringValue = [[child vCard] note]; stringValue = [[child vCard] note];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
break; break;
case PR_OFFICE_TELEPHONE_NUMBER_UNICODE: case PR_OFFICE_TELEPHONE_NUMBER_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
stringValue = [self _phoneOfType: @"work" stringValue = [self _phoneOfType: @"work"
excluding: @"fax" excluding: @"fax"
inCard: [child vCard]]; inCard: [child vCard]];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
break; break;
case PR_HOME_TELEPHONE_NUMBER_UNICODE: case PR_HOME_TELEPHONE_NUMBER_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
stringValue = [self _phoneOfType: @"home" stringValue = [self _phoneOfType: @"home"
excluding: @"fax" excluding: @"fax"
inCard: [child vCard]]; inCard: [child vCard]];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
break; break;
case PR_MOBILE_TELEPHONE_NUMBER_UNICODE: case PR_MOBILE_TELEPHONE_NUMBER_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
stringValue = [self _phoneOfType: @"cell" stringValue = [self _phoneOfType: @"cell"
excluding: nil excluding: nil
inCard: [child vCard]]; inCard: [child vCard]];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
break; break;
case PR_PRIMARY_TELEPHONE_NUMBER_UNICODE: case PR_PRIMARY_TELEPHONE_NUMBER_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
stringValue = [self _phoneOfType: @"pref" stringValue = [self _phoneOfType: @"pref"
excluding: nil excluding: nil
inCard: [child vCard]]; inCard: [child vCard]];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
break; break;
// case PR_POSTAL_ADDRESS_UNICODE: // case PR_POSTAL_ADDRESS_UNICODE:
// case PR_INTERNET_MESSAGE_ID_UNICODE: // case PR_INTERNET_MESSAGE_ID_UNICODE:
// case PR_CAR_TELEPHONE_NUMBER_UNICODE: // case PR_CAR_TELEPHONE_NUMBER_UNICODE:
// case PR_OTHER_TELEPHONE_NUMBER_UNICODE: // case PR_OTHER_TELEPHONE_NUMBER_UNICODE:
// case PR_BUSINESS_FAX_NUMBER_UNICODE: // case PR_BUSINESS_FAX_NUMBER_UNICODE:
// case PR_HOME_FAX_NUMBER_UNICODE: // case PR_HOME_FAX_NUMBER_UNICODE:
// case PR_COMPANY_MAIN_PHONE_NUMBER_UNICODE: // case PR_COMPANY_MAIN_PHONE_NUMBER_UNICODE:
// case PR_EMS_AB_GROUP_BY_ATTR_4_UNICODE: // case PR_EMS_AB_GROUP_BY_ATTR_4_UNICODE:
// case PR_CALLBACK_TELEPHONE_NUMBER_UNICODE: // case PR_CALLBACK_TELEPHONE_NUMBER_UNICODE:
// case PR_DEPARTMENT_NAME_UNICODE: // case PR_DEPARTMENT_NAME_UNICODE:
// case PR_OFFICE2_TELEPHONE_NUMBER_UNICODE: // case PR_OFFICE2_TELEPHONE_NUMBER_UNICODE:
// case PR_RADIO_TELEPHONE_NUMBER_UNICODE: // case PR_RADIO_TELEPHONE_NUMBER_UNICODE:
// case PR_PAGER_TELEPHONE_NUMBER_UNICODE: // case PR_PAGER_TELEPHONE_NUMBER_UNICODE:
// case PR_PRIMARY_FAX_NUMBER_UNICODE: // case PR_PRIMARY_FAX_NUMBER_UNICODE:
// case PR_TELEX_NUMBER_UNICODE: // case PR_TELEX_NUMBER_UNICODE:
// case PR_ISDN_NUMBER_UNICODE: // case PR_ISDN_NUMBER_UNICODE:
// case PR_ASSISTANT_TELEPHONE_NUMBER_UNICODE: // case PR_ASSISTANT_TELEPHONE_NUMBER_UNICODE:
// case PR_HOME2_TELEPHONE_NUMBER_UNICODE: // case PR_HOME2_TELEPHONE_NUMBER_UNICODE:
// case PR_TTYTDD_PHONE_NUMBER_UNICODE: // case PR_TTYTDD_PHONE_NUMBER_UNICODE:
// case PR_BUSINESS_HOME_PAGE_UNICODE: // case PR_BUSINESS_HOME_PAGE_UNICODE:
// *data = talloc_strdup(memCtx, "[Generic and fake unicode value]"); // *data = talloc_strdup(memCtx, "[Generic and fake unicode value]");
// break; // break;
// (18:54:45) Wolfgang-: 0x80a7001f ( Business: ) -> don't ask me which "business" // (18:54:45) Wolfgang-: 0x80a7001f ( Business: ) -> don't ask me which "business"
// (18:55:05) Wolfgang-: 0x809c001f ( Other: ) // (18:55:05) Wolfgang-: 0x809c001f ( Other: )
// (18:55:58) Wolfgang-: 0x81b5001f: E-mail 2 // (18:55:58) Wolfgang-: 0x81b5001f: E-mail 2
// #define PR_REPLY_TIME PROP_TAG(PT_SYSTIME , 0x0030) /* 0x00300040 */ // #define PR_REPLY_TIME PROP_TAG(PT_SYSTIME , 0x0030) /* 0x00300040 */
// #define PR_SENSITIVITY PROP_TAG(PT_LONG , 0x0036) /* 0x00360003 */ // #define PR_SENSITIVITY PROP_TAG(PT_LONG , 0x0036) /* 0x00360003 */
// #define PR_FOLLOWUP_ICON PROP_TAG(PT_LONG , 0x1095) /* 0x10950003 */ // #define PR_FOLLOWUP_ICON PROP_TAG(PT_LONG , 0x1095) /* 0x10950003 */
// #define PR_SEARCH_KEY PROP_TAG(PT_BINARY , 0x300b) /* 0x300b0102 */ // #define PR_SEARCH_KEY PROP_TAG(PT_BINARY , 0x300b) /* 0x300b0102 */
// #define PR_VIEW_STYLE PROP_TAG(PT_LONG , 0x6834) /* 0x68340003 */ // #define PR_VIEW_STYLE PROP_TAG(PT_LONG , 0x6834) /* 0x68340003 */
// #define PR_VD_VERSION PROP_TAG(PT_LONG , 0x7007) /* 0x70070003 */ // #define PR_VD_VERSION PROP_TAG(PT_LONG , 0x7007) /* 0x70070003 */
default: default:
rc = [super getMessageTableChildproperty: data rc = [super getMessageTableChildproperty: data
atURL: childURL atURL: childURL
withTag: proptag withTag: proptag
inFolder: folder inFolder: folder
withFID: fid]; withFID: fid];
} }
return rc; return rc;
} }
- (int) getFolderTableChildproperty: (void **) data // - (int) getFolderTableChildproperty: (void **) data
atURL: (NSString *) childURL // atURL: (NSString *) childURL
withTag: (uint32_t) proptag // withTag: (uint32_t) proptag
inFolder: (SOGoFolder *) folder // inFolder: (SOGoFolder *) folder
withFID: (uint64_t) fid // withFID: (uint64_t) fid
{ // {
int rc; // int rc;
[self logWithFormat: @"XXXXX unexpected!!!!!!!!!"]; // [self logWithFormat: @"XXXXX unexpected!!!!!!!!!"];
rc = MAPI_E_SUCCESS; // rc = MAPI_E_SUCCESS;
switch (proptag) { // switch (proptag)
default: // {
rc = [super getFolderTableChildproperty: data // default:
atURL: childURL // rc = [super getFolderTableChildproperty: data
withTag: proptag // atURL: childURL
inFolder: folder // withTag: proptag
withFID: fid]; // inFolder: folder
} // withFID: fid];
// }
return rc; // return rc;
} // }
@end @end

View file

@ -42,13 +42,15 @@
@interface MAPIStoreContext : NSObject @interface MAPIStoreContext : NSObject
{ {
NSMutableDictionary *objectCache; NSMutableDictionary *objectCache;
MAPIStoreAuthenticator *authenticator; MAPIStoreAuthenticator *authenticator;
WOContext *woContext; WOContext *woContext;
NSMutableDictionary *messageCache; NSMutableDictionary *messageCache;
NSMutableDictionary *subfolderCache; NSMutableDictionary *subfolderCache;
SOGoFolder *moduleFolder; SOGoFolder *moduleFolder;
void *memCtx; void *memCtx;
NSString *lastObjectURL;
id lastObject;
} }
+ (id) contextFromURI: (const char *) newUri; + (id) contextFromURI: (const char *) newUri;

File diff suppressed because it is too large Load diff

View file

@ -39,32 +39,41 @@
static Class SOGoUserFolderK; static Class SOGoUserFolderK;
@implementation SOGoObject (LeakD)
- (void) dealloc
{
[super dealloc];
}
@end
@implementation MAPIStoreMailContext @implementation MAPIStoreMailContext
+ (void) initialize + (void) initialize
{ {
SOGoUserFolderK = [SOGoUserFolderK class]; SOGoUserFolderK = [SOGoUserFolder class];
} }
- (void) setupModuleFolder - (void) setupModuleFolder
{ {
id userFolder, accountsFolder; id userFolder, accountsFolder;
userFolder = [SOGoUserFolderK objectWithName: [authenticator username] userFolder = [SOGoUserFolderK objectWithName: [authenticator username]
inContainer: MAPIApp]; inContainer: MAPIApp];
[woContext setClientObject: userFolder]; [woContext setClientObject: userFolder];
[userFolder retain]; // LEAK [userFolder retain]; // LEAK
accountsFolder = [userFolder lookupName: @"Mail" accountsFolder = [userFolder lookupName: @"Mail"
inContext: woContext inContext: woContext
acquire: NO]; acquire: NO];
[woContext setClientObject: accountsFolder]; [woContext setClientObject: accountsFolder];
[accountsFolder retain]; // LEAK [accountsFolder retain]; // LEAK
moduleFolder = [accountsFolder lookupName: @"0" moduleFolder = [accountsFolder lookupName: @"0"
inContext: woContext inContext: woContext
acquire: NO]; acquire: NO];
[moduleFolder retain]; [moduleFolder retain];
} }
// - (int) getCommonTableChildproperty: (void **) data // - (int) getCommonTableChildproperty: (void **) data
@ -94,88 +103,89 @@ static Class SOGoUserFolderK;
inFolder: (SOGoFolder *) folder inFolder: (SOGoFolder *) folder
withFID: (uint64_t) fid withFID: (uint64_t) fid
{ {
uint8_t *boolValue; uint8_t *boolValue;
uint32_t *longValue; uint32_t *longValue;
SOGoMailObject *child; SOGoMailObject *child;
NSCalendarDate *offsetDate; NSCalendarDate *offsetDate;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
case PR_ICON_INDEX: // TODO {
longValue = talloc_zero(memCtx, uint32_t); case PR_ICON_INDEX: // TODO
*longValue = 0x00000100; /* read mail, see http://msdn.microsoft.com/en-us/library/cc815472.aspx */ longValue = talloc_zero(memCtx, uint32_t);
*data = longValue; *longValue = 0x00000100; /* read mail, see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
break; *data = longValue;
case PR_SUBJECT_UNICODE: break;
child = [self lookupObject: childURL]; case PR_SUBJECT_UNICODE:
*data = [[child decodedSubject] asUnicodeInMemCtx: memCtx]; child = [self lookupObject: childURL];
break; *data = [[child decodedSubject] asUnicodeInMemCtx: memCtx];
case PR_MESSAGE_CLASS_UNICODE: break;
*data = talloc_strdup(memCtx, "IPM.Note"); case PR_MESSAGE_CLASS_UNICODE:
break; *data = talloc_strdup(memCtx, "IPM.Note");
case PR_HASATTACH: break;
boolValue = talloc_zero(memCtx, uint8_t); case PR_HASATTACH:
*boolValue = NO; boolValue = talloc_zero(memCtx, uint8_t);
*data = boolValue; *boolValue = NO;
break; *data = boolValue;
case PR_MESSAGE_DELIVERY_TIME: break;
child = [self lookupObject: childURL]; case PR_MESSAGE_DELIVERY_TIME:
offsetDate = [[child date] addYear: -1 month: 0 day: 0 child = [self lookupObject: childURL];
hour: 0 minute: 0 second: 0]; offsetDate = [[child date] addYear: -1 month: 0 day: 0
*data = [offsetDate asFileTimeInMemCtx: memCtx]; hour: 0 minute: 0 second: 0];
break; *data = [offsetDate asFileTimeInMemCtx: memCtx];
// case PR_ROW_TYPE: // TODO: DOUBT break;
// longValue = talloc_zero(memCtx, uint32_t); // case PR_ROW_TYPE: // TODO: DOUBT
// *longValue = 1; // longValue = talloc_zero(memCtx, uint32_t);
// *data = longValue; // *longValue = 1;
// break; // *data = longValue;
case PR_FLAG_STATUS: // TODO // break;
case PR_MSG_STATUS: // TODO case PR_FLAG_STATUS: // TODO
case PR_MESSAGE_FLAGS: // TODO case PR_MSG_STATUS: // TODO
case PR_SENSITIVITY: // TODO case PR_MESSAGE_FLAGS: // TODO
longValue = talloc_zero(memCtx, uint32_t); case PR_SENSITIVITY: // TODO
*longValue = 0; longValue = talloc_zero(memCtx, uint32_t);
*data = longValue; *longValue = 0;
break; *data = longValue;
case PR_IMPORTANCE: break;
longValue = talloc_zero(memCtx, uint32_t); case PR_IMPORTANCE:
*longValue = 1; longValue = talloc_zero(memCtx, uint32_t);
*data = longValue; *longValue = 1;
break; *data = longValue;
case PR_MESSAGE_SIZE: // TODO break;
child = [self lookupObject: childURL]; case PR_MESSAGE_SIZE: // TODO
longValue = talloc_zero(memCtx, uint32_t); child = [self lookupObject: childURL];
/* TODO: choose another name for that method */ longValue = talloc_zero(memCtx, uint32_t);
*longValue = [[child davContentLength] intValue]; /* TODO: choose another name for that method */
*data = longValue; *longValue = [[child davContentLength] intValue];
break; *data = longValue;
// #define PR_REPLY_TIME PROP_TAG(PT_SYSTIME , 0x0030) /* 0x00300040 */ break;
// #define PR_EXPIRY_TIME PROP_TAG(PT_SYSTIME , 0x0015) /* 0x00150040 */ // #define PR_REPLY_TIME PROP_TAG(PT_SYSTIME , 0x0030) /* 0x00300040 */
// #define PR_MESSAGE_DELIVERY_TIME PROP_TAG(PT_SYSTIME , 0x0e06) /* 0x0e060040 */ // #define PR_EXPIRY_TIME PROP_TAG(PT_SYSTIME , 0x0015) /* 0x00150040 */
// #define PR_FOLLOWUP_ICON PROP_TAG(PT_LONG , 0x1095) /* 0x10950003 */ // #define PR_MESSAGE_DELIVERY_TIME PROP_TAG(PT_SYSTIME , 0x0e06) /* 0x0e060040 */
// #define PR_ITEM_TEMPORARY_FLAGS PROP_TAG(PT_LONG , 0x1097) /* 0x10970003 */ // #define PR_FOLLOWUP_ICON PROP_TAG(PT_LONG , 0x1095) /* 0x10950003 */
// #define PR_SEARCH_KEY PROP_TAG(PT_BINARY , 0x300b) /* 0x300b0102 */ // #define PR_ITEM_TEMPORARY_FLAGS PROP_TAG(PT_LONG , 0x1097) /* 0x10970003 */
// #define PR_SEARCH_KEY PROP_TAG(PT_BINARY , 0x300b) /* 0x300b0102 */
case PR_SENT_REPRESENTING_NAME_UNICODE: case PR_SENT_REPRESENTING_NAME_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
*data = [[child from] asUnicodeInMemCtx: memCtx]; *data = [[child from] asUnicodeInMemCtx: memCtx];
break; break;
case PR_INTERNET_MESSAGE_ID_UNICODE: case PR_INTERNET_MESSAGE_ID_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
*data = [[child messageId] asUnicodeInMemCtx: memCtx]; *data = [[child messageId] asUnicodeInMemCtx: memCtx];
break; break;
default: default:
rc = [super getMessageTableChildproperty: data rc = [super getMessageTableChildproperty: data
atURL: childURL atURL: childURL
withTag: proptag withTag: proptag
inFolder: folder inFolder: folder
withFID: fid]; withFID: fid];
} }
return rc; return rc;
} }
- (int) getFolderTableChildproperty: (void **) data - (int) getFolderTableChildproperty: (void **) data
@ -184,28 +194,29 @@ static Class SOGoUserFolderK;
inFolder: (SOGoFolder *) folder inFolder: (SOGoFolder *) folder
withFID: (uint64_t) fid withFID: (uint64_t) fid
{ {
uint32_t *longValue; uint32_t *longValue;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
case PR_CONTENT_UNREAD: {
longValue = talloc_zero(memCtx, uint32_t); case PR_CONTENT_UNREAD:
*longValue = 0; longValue = talloc_zero(memCtx, uint32_t);
*data = longValue; *longValue = 0;
break; *data = longValue;
case PR_CONTAINER_CLASS_UNICODE: break;
*data = talloc_strdup(memCtx, "IPF.Note"); case PR_CONTAINER_CLASS_UNICODE:
break; *data = talloc_strdup(memCtx, "IPF.Note");
default: break;
rc = [super getFolderTableChildproperty: data default:
atURL: childURL rc = [super getFolderTableChildproperty: data
withTag: proptag atURL: childURL
inFolder: folder withTag: proptag
withFID: fid]; inFolder: folder
} withFID: fid];
}
return rc;
return rc;
} }
@end @end

View file

@ -1,4 +1,4 @@
/* MAPIStoreMapping.m - this file is part of $PROJECT_NAME_HERE$ /* MAPIStoreMapping.m - this file is part of SOGo
* *
* Copyright (C) 2010 Inverse inc. * Copyright (C) 2010 Inverse inc.
* *
@ -35,102 +35,111 @@ static uint64_t idCounter = 0x200001;
- (id) init - (id) init
{ {
if ((self = [super init])) { if ((self = [super init]))
mapping = [NSMutableDictionary new]; {
reverseMapping = [NSMutableDictionary new]; mapping = [NSMutableDictionary new];
} reverseMapping = [NSMutableDictionary new];
}
return self;
return self;
} }
- (void) dealloc - (void) dealloc
{ {
[mapping release]; [mapping release];
[reverseMapping release]; [reverseMapping release];
[super dealloc]; [super dealloc];
} }
- (NSString *) urlFromID: (uint64_t) idNbr - (NSString *) urlFromID: (uint64_t) idNbr
{ {
NSNumber *key; NSNumber *key;
key = [NSNumber numberWithUnsignedLongLong: idNbr]; key = [NSNumber numberWithUnsignedLongLong: idNbr];
return [mapping objectForKey: key]; return [mapping objectForKey: key];
} }
- (uint64_t) idFromURL: (NSString *) url - (uint64_t) idFromURL: (NSString *) url
{ {
NSNumber *idKey; NSNumber *idKey;
uint64_t idNbr; uint64_t idNbr;
idKey = [reverseMapping objectForKey: url]; idKey = [reverseMapping objectForKey: url];
if (idKey) if (idKey)
idNbr = [idKey unsignedLongLongValue]; idNbr = [idKey unsignedLongLongValue];
else else
idNbr = NSNotFound; idNbr = NSNotFound;
return idNbr; return idNbr;
} }
- (BOOL) registerURL: (NSString *) urlString - (BOOL) registerURL: (NSString *) urlString
withID: (uint64_t) idNbr withID: (uint64_t) idNbr
{ {
NSNumber *idKey; NSNumber *idKey;
BOOL rc; BOOL rc;
idKey = [NSNumber numberWithUnsignedLongLong: idNbr]; idKey = [NSNumber numberWithUnsignedLongLong: idNbr];
if ([mapping objectForKey: idKey] || [reverseMapping objectForKey: urlString]) { if ([mapping objectForKey: idKey]
[self errorWithFormat: @"attempt to double register an entry ('%@', %lld)", || [reverseMapping objectForKey: urlString])
urlString, idNbr]; {
rc = NO; [self errorWithFormat: @"attempt to double register an entry ('%@', %lld)",
} urlString, idNbr];
else { rc = NO;
[mapping setObject: urlString forKey: idKey]; }
[reverseMapping setObject: idKey forKey: urlString]; else
rc = YES; {
[self logWithFormat: @"registered url '%@' with id %lld (0x%.8x)", [mapping setObject: urlString forKey: idKey];
urlString, idNbr, (uint32_t) idNbr]; [reverseMapping setObject: idKey forKey: urlString];
} rc = YES;
[self logWithFormat: @"registered url '%@' with id %lld (0x%.8x)",
urlString, idNbr, (uint32_t) idNbr];
}
return rc; return rc;
} }
- (void) registerURL: (NSString *) urlString - (void) registerURL: (NSString *) urlString
{ {
uint64_t idNbr; uint64_t idNbr;
// newID = openchangedb_get_new_folderID(); // newID = openchangedb_get_new_folderID();
if (![reverseMapping objectForKey: urlString]) { if (![reverseMapping objectForKey: urlString])
if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderINBOX"]) { {
idNbr = 0x160001; if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderINBOX"])
if (![self registerURL: urlString withID: idNbr]) {
[self errorWithFormat: @"Unable to register root folder: %@", idNbr = 0x160001;
urlString]; if (![self registerURL: urlString withID: idNbr])
} [self errorWithFormat: @"Unable to register root folder: %@",
// else if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderSent"]) { urlString];
// idNbr = 0x140001;
// idCounter = idNbr;
// }
else if ([urlString isEqualToString: @"sogo://openchange:openchange@contacts/personal"]) {
idNbr = 0x1a0001;
if (![self registerURL: urlString withID: idNbr])
[self errorWithFormat: @"Unable to register root folder: %@",
urlString];
}
else if ([urlString isEqualToString: @"sogo://openchange:openchange@calendar/personal"]) {
idNbr = 0x190001;
if (![self registerURL: urlString withID: idNbr])
[self errorWithFormat: @"Unable to register root folder: %@",
urlString];
}
else {
idCounter += idIncrement;
while (![self registerURL: urlString withID: idCounter])
idCounter += idIncrement;
}
// [self _registerURL: urlString withID: newID];
} }
// else if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderSent"]) {
// idNbr = 0x140001;
// idCounter = idNbr;
// }
else if ([urlString isEqualToString: @"sogo://openchange:openchange@contacts/personal"])
{
idNbr = 0x1a0001;
if (![self registerURL: urlString withID: idNbr])
[self errorWithFormat: @"Unable to register root folder: %@",
urlString];
}
else if ([urlString isEqualToString: @"sogo://openchange:openchange@calendar/personal"])
{
idNbr = 0x190001;
if (![self registerURL: urlString withID: idNbr])
[self errorWithFormat: @"Unable to register root folder: %@",
urlString];
}
else
{
idCounter += idIncrement;
while (![self registerURL: urlString withID: idCounter])
idCounter += idIncrement;
}
// [self _registerURL: urlString withID: newID];
}
} }
@end @end

View file

@ -1,25 +1,27 @@
/* /* MAPIStoreSOGo.m - this file is part of SOGo
OpenChange Storage Abstraction Layer library *
SOGo backend * Copyright (C) 2010 Inverse inc.
*
OpenChange Project * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
Copyright (C) * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify * the Free Software Foundation; either version 2, or (at your option)
it under the terms of the GNU General Public License as published by * any later version.
the Free Software Foundation; either version 3 of the License, or *
(at your option) any later version. * This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
This program is distributed in the hope that it will be useful, * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
but WITHOUT ANY WARRANTY; without even the implied warranty of * GNU General Public License for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
GNU General Public License for more details. * You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
You should have received a copy of the GNU General Public License * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
along with this program. If not, see <http://www.gnu.org/licenses/>. * Boston, MA 02111-1307, USA.
*/ */
/* OpenChange SOGo storage backend */
#import <Foundation/NSAutoreleasePool.h> #import <Foundation/NSAutoreleasePool.h>
#import "MAPIApplication.h" #import "MAPIApplication.h"
@ -36,13 +38,13 @@
*/ */
static int sogo_init(void) static int sogo_init(void)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
[MAPIApplication new]; [MAPIApplication new];
[pool release]; [pool release];
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
/** /**
@ -51,29 +53,29 @@ static int sogo_init(void)
\param mem_ctx pointer to the memory context \param mem_ctx pointer to the memory context
\param uri pointer to the sogo path \param uri pointer to the sogo path
\param private_data pointer to the private backend context \param private_data pointer to the private backend context
*/ */
static int sogo_create_context(TALLOC_CTX *mem_ctx, const char *uri, void **private_data) static int sogo_create_context(TALLOC_CTX *mem_ctx, const char *uri, void **private_data)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
DEBUG(0, ("[%s:%d]\n", __FUNCTION__, __LINE__)); DEBUG(0, ("[%s:%d]\n", __FUNCTION__, __LINE__));
context = [MAPIStoreContext contextFromURI: uri]; context = [MAPIStoreContext contextFromURI: uri];
[context setMemCtx: mem_ctx]; [context setMemCtx: mem_ctx];
[context retain]; [context retain];
cContext = talloc_zero(mem_ctx, sogo_context); cContext = talloc_zero(mem_ctx, sogo_context);
cContext->objcContext = context; cContext->objcContext = context;
*private_data = cContext; *private_data = cContext;
[pool release]; [pool release];
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
@ -83,24 +85,24 @@ static int sogo_create_context(TALLOC_CTX *mem_ctx, const char *uri, void **priv
\param private_data pointer to the current sogo context \param private_data pointer to the current sogo context
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/ */
static int sogo_delete_context(void *private_data) static int sogo_delete_context(void *private_data)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
DEBUG(5, ("[%s:%d]\n", __FUNCTION__, __LINE__)); DEBUG(5, ("[%s:%d]\n", __FUNCTION__, __LINE__));
cContext = private_data; cContext = private_data;
[cContext->objcContext release]; [cContext->objcContext release];
[pool release]; [pool release];
talloc_free (cContext); talloc_free (cContext);
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
/** /**
@ -109,25 +111,25 @@ static int sogo_delete_context(void *private_data)
\param private_data pointer to the current sogo context \param private_data pointer to the current sogo context
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/ */
static int sogo_release_record(void *private_data, uint64_t fmid, uint8_t type) static int sogo_release_record(void *private_data, uint64_t fmid, uint8_t type)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
DEBUG(5, ("[%s:%d]\n", __FUNCTION__, __LINE__)); DEBUG(5, ("[%s:%d]\n", __FUNCTION__, __LINE__));
switch (type) { switch (type) {
case MAPISTORE_FOLDER: case MAPISTORE_FOLDER:
break; break;
case MAPISTORE_MESSAGE: case MAPISTORE_MESSAGE:
break; break;
} }
[pool release]; [pool release];
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
@ -141,47 +143,47 @@ static int sogo_release_record(void *private_data, uint64_t fmid, uint8_t type)
\param path pointer on pointer to the path to return \param path pointer on pointer to the path to return
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
*/ */
static int sogo_get_path(void *private_data, uint64_t fmid, static int sogo_get_path(void *private_data, uint64_t fmid,
uint8_t type, char **path) uint8_t type, char **path)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
DEBUG(5, ("[%s:%d]\n", __FUNCTION__, __LINE__)); DEBUG(5, ("[%s:%d]\n", __FUNCTION__, __LINE__));
switch (type) { switch (type) {
case MAPISTORE_FOLDER: case MAPISTORE_FOLDER:
break; break;
case MAPISTORE_MESSAGE: case MAPISTORE_MESSAGE:
break; break;
} }
[pool release]; [pool release];
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
static int sogo_op_get_fid_by_name(void *private_data, uint64_t parent_fid, const char* foldername, uint64_t *fid) static int sogo_op_get_fid_by_name(void *private_data, uint64_t parent_fid, const char* foldername, uint64_t *fid)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context getFID: fid byName: foldername inParentFID: parent_fid]; rc = [context getFID: fid byName: foldername inParentFID: parent_fid];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
@ -191,27 +193,27 @@ static int sogo_op_get_fid_by_name(void *private_data, uint64_t parent_fid, cons
\param private_data pointer to the current sogo context \param private_data pointer to the current sogo context
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/ */
static int sogo_op_mkdir(void *private_data, uint64_t parent_fid, uint64_t fid, static int sogo_op_mkdir(void *private_data, uint64_t parent_fid, uint64_t fid,
struct SRow *aRow) struct SRow *aRow)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context mkDir: aRow withFID: fid inParentFID: parent_fid]; rc = [context mkDir: aRow withFID: fid inParentFID: parent_fid];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
@ -223,26 +225,26 @@ static int sogo_op_mkdir(void *private_data, uint64_t parent_fid, uint64_t fid,
\param fid the FID for the folder to delete \param fid the FID for the folder to delete
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/ */
static int sogo_op_rmdir(void *private_data, uint64_t parent_fid, uint64_t fid) static int sogo_op_rmdir(void *private_data, uint64_t parent_fid, uint64_t fid)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context rmDirWithFID: fid inParentFID: parent_fid]; rc = [context rmDirWithFID: fid inParentFID: parent_fid];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
@ -254,26 +256,26 @@ static int sogo_op_rmdir(void *private_data, uint64_t parent_fid, uint64_t fid)
\param fid the identifier of the colder to open \param fid the identifier of the colder to open
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/ */
static int sogo_op_opendir(void *private_data, uint64_t parent_fid, uint64_t fid) static int sogo_op_opendir(void *private_data, uint64_t parent_fid, uint64_t fid)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context openDir: fid inParentFID: parent_fid]; rc = [context openDir: fid inParentFID: parent_fid];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
@ -283,26 +285,26 @@ static int sogo_op_opendir(void *private_data, uint64_t parent_fid, uint64_t fid
\param private_data pointer to the current sogo context \param private_data pointer to the current sogo context
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/ */
static int sogo_op_closedir(void *private_data) static int sogo_op_closedir(void *private_data)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context closeDir]; rc = [context closeDir];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
@ -312,57 +314,57 @@ static int sogo_op_closedir(void *private_data)
\param private_data pointer to the current sogo context \param private_data pointer to the current sogo context
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/ */
static int sogo_op_readdir_count(void *private_data, static int sogo_op_readdir_count(void *private_data,
uint64_t fid, uint64_t fid,
uint8_t table_type, uint8_t table_type,
uint32_t *RowCount) uint32_t *RowCount)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context readCount: RowCount ofTableType: table_type inFID: fid]; rc = [context readCount: RowCount ofTableType: table_type inFID: fid];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
static int sogo_op_get_table_property(void *private_data, static int sogo_op_get_table_property(void *private_data,
uint64_t fid, uint64_t fid,
uint8_t table_type, uint8_t table_type,
uint32_t pos, uint32_t pos,
uint32_t proptag, uint32_t proptag,
void **data) void **data)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context getTableProperty: data withTag: proptag atPosition: pos rc = [context getTableProperty: data withTag: proptag atPosition: pos
withTableType: table_type inFID: fid]; withTableType: table_type inFID: fid];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
@ -371,23 +373,23 @@ static int sogo_op_openmessage(void *private_data,
uint64_t mid, uint64_t mid,
struct mapistore_message *msg) struct mapistore_message *msg)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context openMessage: msg withMID: mid inFID: fid]; rc = [context openMessage: msg withMID: mid inFID: fid];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
@ -395,69 +397,69 @@ static int sogo_op_createmessage(void *private_data,
uint64_t fid, uint64_t fid,
uint64_t mid) uint64_t mid)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context createMessageWithMID: mid inFID: fid]; rc = [context createMessageWithMID: mid inFID: fid];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
static int sogo_op_savechangesmessage(void *private_data, static int sogo_op_savechangesmessage(void *private_data,
uint64_t mid, uint64_t mid,
uint8_t flags) uint8_t flags)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context saveChangesInMessageWithMID: mid andFlags: flags]; rc = [context saveChangesInMessageWithMID: mid andFlags: flags];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
static int sogo_op_submitmessage(void *private_data, static int sogo_op_submitmessage(void *private_data,
uint64_t mid, uint64_t mid,
uint8_t flags) uint8_t flags)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context submitMessageWithMID: mid andFlags: flags]; rc = [context submitMessageWithMID: mid andFlags: flags];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
static int sogo_op_getprops(void *private_data, static int sogo_op_getprops(void *private_data,
@ -466,115 +468,125 @@ static int sogo_op_getprops(void *private_data,
struct SPropTagArray *SPropTagArray, struct SPropTagArray *SPropTagArray,
struct SRow *aRow) struct SRow *aRow)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context getProperties: SPropTagArray inRow: aRow withMID: fmid type: type]; rc = [context getProperties: SPropTagArray inRow: aRow withMID: fmid type: type];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
static int sogo_op_setprops(void *private_data, static int sogo_op_setprops(void *private_data,
uint64_t fmid, uint64_t fmid,
uint8_t type, uint8_t type,
struct SRow *aRow) struct SRow *aRow)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context setPropertiesWithMID: fmid type: type inRow: aRow]; rc = [context setPropertiesWithMID: fmid type: type inRow: aRow];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
static int sogo_op_deletemessage(void *private_data, static int sogo_op_deletemessage(void *private_data,
uint64_t mid, uint64_t mid,
uint8_t flags) uint8_t flags)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
sogo_context *cContext; sogo_context *cContext;
MAPIStoreContext *context; MAPIStoreContext *context;
int rc; int rc;
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
cContext = private_data; cContext = private_data;
context = cContext->objcContext; context = cContext->objcContext;
[context setupRequest]; [context setupRequest];
rc = [context deleteMessageWithMID: mid withFlags: flags]; rc = [context deleteMessageWithMID: mid withFlags: flags];
[context tearDownRequest]; [context tearDownRequest];
[pool release]; [pool release];
return rc; return rc;
} }
/** /**
\details Entry point for mapistore SOGO backend \details Entry point for mapistore SOGO backend
\return MAPI_E_SUCCESS on success, otherwise MAPISTORE error \return MAPI_E_SUCCESS on success, otherwise MAPISTORE error
*/ */
int mapistore_init_backend(void) int mapistore_init_backend(void)
{ {
struct mapistore_backend backend; struct mapistore_backend backend;
int ret; int ret;
static BOOL registered = NO;
/* Fill in our name */ if (registered)
backend.name = "sogo"; {
backend.description = "mapistore sogo backend"; ret = MAPISTORE_ERROR;
backend.namespace = "sogo://"; }
else
{
registered = YES;
/* Fill in our name */
backend.name = "SOGo";
backend.description = "mapistore SOGo backend";
backend.namespace = "sogo://";
/* Fill in all the operations */ /* Fill in all the operations */
backend.init = sogo_init; backend.init = sogo_init;
backend.create_context = sogo_create_context; backend.create_context = sogo_create_context;
backend.delete_context = sogo_delete_context; backend.delete_context = sogo_delete_context;
backend.release_record = sogo_release_record; backend.release_record = sogo_release_record;
backend.get_path = sogo_get_path; backend.get_path = sogo_get_path;
backend.op_mkdir = sogo_op_mkdir; backend.op_mkdir = sogo_op_mkdir;
backend.op_rmdir = sogo_op_rmdir; backend.op_rmdir = sogo_op_rmdir;
backend.op_opendir = sogo_op_opendir; backend.op_opendir = sogo_op_opendir;
backend.op_closedir = sogo_op_closedir; backend.op_closedir = sogo_op_closedir;
backend.op_readdir_count = sogo_op_readdir_count; backend.op_readdir_count = sogo_op_readdir_count;
backend.op_get_table_property = sogo_op_get_table_property; backend.op_get_table_property = sogo_op_get_table_property;
backend.op_openmessage = sogo_op_openmessage; backend.op_openmessage = sogo_op_openmessage;
backend.op_createmessage = sogo_op_createmessage; backend.op_createmessage = sogo_op_createmessage;
backend.op_savechangesmessage = sogo_op_savechangesmessage; backend.op_savechangesmessage = sogo_op_savechangesmessage;
backend.op_submitmessage = sogo_op_submitmessage; backend.op_submitmessage = sogo_op_submitmessage;
backend.op_getprops = sogo_op_getprops; backend.op_getprops = sogo_op_getprops;
backend.op_get_fid_by_name = sogo_op_get_fid_by_name; backend.op_get_fid_by_name = sogo_op_get_fid_by_name;
backend.op_setprops = sogo_op_setprops; backend.op_setprops = sogo_op_setprops;
backend.op_deletemessage = sogo_op_deletemessage; backend.op_deletemessage = sogo_op_deletemessage;
/* Register ourselves with the MAPISTORE subsystem */ /* Register ourselves with the MAPISTORE subsystem */
ret = mapistore_backend_register(&backend); ret = mapistore_backend_register(&backend);
if (ret != MAPISTORE_SUCCESS) { if (ret != MAPISTORE_SUCCESS) {
DEBUG(0, ("Failed to register the '%s' mapistore backend!\n", backend.name)); DEBUG(0, ("Failed to register the '%s' mapistore backend!\n", backend.name));
} }
}
return ret; return ret;
} }

View file

@ -38,13 +38,14 @@
NSTimeZone *utc; NSTimeZone *utc;
uint64_t interval; uint64_t interval;
if (!refDate) { if (!refDate)
utc = [NSTimeZone timeZoneWithName: @"UTC"]; {
refDate = [NSCalendarDate dateWithYear: 1601 month: 1 day: 1 utc = [NSTimeZone timeZoneWithName: @"UTC"];
hour: 0 minute: 0 second: 0 refDate = [NSCalendarDate dateWithYear: 1601 month: 1 day: 1
timeZone: utc]; hour: 0 minute: 0 second: 0
[refDate retain]; timeZone: utc];
} [refDate retain];
}
interval = (((uint64_t) [self timeIntervalSinceDate: refDate]) * 10000000); interval = (((uint64_t) [self timeIntervalSinceDate: refDate]) * 10000000);
timeValue = talloc_zero(memCtx, struct FILETIME); timeValue = talloc_zero(memCtx, struct FILETIME);
timeValue->dwLowDateTime = (uint32_t) (interval & 0xffffffff); timeValue->dwLowDateTime = (uint32_t) (interval & 0xffffffff);

View file

@ -28,11 +28,11 @@
- (char *) asUnicodeInMemCtx: (void *) memCtx - (char *) asUnicodeInMemCtx: (void *) memCtx
{ {
char *unicode; char *unicode;
unicode = talloc_strdup(memCtx, [self UTF8String]); unicode = talloc_strdup (memCtx, [self UTF8String]);
return unicode; return unicode;
} }
@end @end