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,7 +35,7 @@ MAPIApplication *MAPIApp = nil;
@interface UnixSignalHandler : NSObject @interface UnixSignalHandler : NSObject
+ sharedHandler; + (id) sharedHandler;
- (void) removeObserver: (id) observer; - (void) removeObserver: (id) observer;
@ -49,7 +49,8 @@ MAPIApplication *MAPIApp = nil;
NSUserDefaults *ud; NSUserDefaults *ud;
SOGoSystemDefaults *sd; SOGoSystemDefaults *sd;
if (!MAPIApp) { if (!MAPIApp)
{
/* Here we work around a bug in GNUstep which decodes XML user /* Here we work around a bug in GNUstep which decodes XML user
defaults using the system encoding rather than honouring defaults using the system encoding rather than honouring
the encoding specified in the file. */ the encoding specified in the file. */

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,7 +41,7 @@ static Class SOGoUserFolderK;
+ (void) initialize + (void) initialize
{ {
SOGoUserFolderK = [SOGoUserFolderK class]; SOGoUserFolderK = [SOGoUserFolder class];
} }
- (void) setupModuleFolder - (void) setupModuleFolder
@ -72,7 +72,8 @@ static Class SOGoUserFolderK;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
{
case PR_ICON_INDEX: // TODO case PR_ICON_INDEX: // TODO
longValue = talloc_zero(memCtx, uint32_t); longValue = talloc_zero(memCtx, uint32_t);
*longValue = 0x00000400; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */ *longValue = 0x00000400; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */

View file

@ -45,7 +45,7 @@ static Class SOGoUserFolderK;
+ (void) initialize + (void) initialize
{ {
SOGoUserFolderK = [SOGoUserFolderK class]; SOGoUserFolderK = [SOGoUserFolder class];
} }
- (void) setupModuleFolder - (void) setupModuleFolder
@ -137,7 +137,8 @@ static Class SOGoUserFolderK;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
{
case PR_ICON_INDEX: // TODO case PR_ICON_INDEX: // TODO
longValue = talloc_zero(memCtx, uint32_t); longValue = talloc_zero(memCtx, uint32_t);
*longValue = 0x00000200; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */ *longValue = 0x00000200; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
@ -271,26 +272,27 @@ static Class SOGoUserFolderK;
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

@ -49,6 +49,8 @@
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;

View file

@ -1,6 +1,6 @@
/* MAPIStoreContext.m - this file is part of $PROJECT_NAME_HERE$ /* MAPIStoreContext.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>
* *
@ -84,8 +84,8 @@ static MAPIStoreMapping *mapping = nil;
+ (void) initialize + (void) initialize
{ {
SOGoObjectK = [SOGoObject class]; SOGoObjectK = [SOGoObject class];
SOGoMailAccountK = [SOGoMailAccount class]; SOGoMailAccountK = NSClassFromString (@"SOGoMailAccount");
SOGoMailFolderK = [SOGoMailFolder class]; SOGoMailFolderK = NSClassFromString (@"SOGoMailFolder");
mapping = [MAPIStoreMapping new]; mapping = [MAPIStoreMapping new];
} }
@ -101,24 +101,29 @@ static MAPIStoreMapping *mapping = nil;
context = nil; context = nil;
urlString = [NSString stringWithUTF8String: newUri]; urlString = [NSString stringWithUTF8String: newUri];
if (urlString) { if (urlString)
{
completeURLString = [@"sogo://" stringByAppendingString: urlString]; completeURLString = [@"sogo://" stringByAppendingString: urlString];
baseURL = [NSURL URLWithString: completeURLString]; baseURL = [NSURL URLWithString: completeURLString];
if (baseURL) { if (baseURL)
{
module = [baseURL host]; module = [baseURL host];
if (module) { if (module)
{
if ([module isEqualToString: @"mail"]) if ([module isEqualToString: @"mail"])
contextClass = @"MAPIStoreMailContext"; contextClass = @"MAPIStoreMailContext";
else if ([module isEqualToString: @"contacts"]) else if ([module isEqualToString: @"contacts"])
contextClass = @"MAPIStoreContactsContext"; contextClass = @"MAPIStoreContactsContext";
else if ([module isEqualToString: @"calendar"]) else if ([module isEqualToString: @"calendar"])
contextClass = @"MAPIStoreCalendarContext"; contextClass = @"MAPIStoreCalendarContext";
else { else
{
NSLog (@"ERROR: unrecognized module name '%@'", module); NSLog (@"ERROR: unrecognized module name '%@'", module);
contextClass = nil; contextClass = nil;
} }
if (contextClass) { if (contextClass)
{
[mapping registerURL: completeURLString]; [mapping registerURL: completeURLString];
context = [NSClassFromString (contextClass) new]; context = [NSClassFromString (contextClass) new];
[context autorelease]; [context autorelease];
@ -146,8 +151,8 @@ static MAPIStoreMapping *mapping = nil;
- (id) init - (id) init
{ {
if ((self = [super init])) { if ((self = [super init]))
// objectCache = [NSMutableDictionary new]; {
messageCache = [NSMutableDictionary new]; messageCache = [NSMutableDictionary new];
subfolderCache = [NSMutableDictionary new]; subfolderCache = [NSMutableDictionary new];
woContext = [WOContext contextWithRequest: nil]; woContext = [WOContext contextWithRequest: nil];
@ -164,13 +169,13 @@ static MAPIStoreMapping *mapping = nil;
{ {
[self logWithFormat: @"-dealloc"]; [self logWithFormat: @"-dealloc"];
// [objectCache release];
[messageCache release]; [messageCache release];
[subfolderCache release]; [subfolderCache release];
[moduleFolder release]; [moduleFolder release];
[woContext release]; [woContext release];
[authenticator release]; [authenticator release];
[super dealloc]; [super dealloc];
} }
@ -212,6 +217,31 @@ static MAPIStoreMapping *mapping = nil;
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
// - (void) _setNewLastObject: (id) newLastObject
// {
// id currentObject, container;
// if (newLastObject != lastObject)
// {
// currentObject = lastObject;
// while (currentObject)
// {
// container = [currentObject container];
// [currentObject release];
// currentObject = container;
// }
// currentObject = newLastObject;
// while (currentObject)
// {
// [currentObject retain];
// currentObject = [currentObject container];
// }
// lastObject = newLastObject;
// }
// }
- (id) lookupObject: (NSString *) objectURLString - (id) lookupObject: (NSString *) objectURLString
{ {
id object; id object;
@ -220,8 +250,6 @@ static MAPIStoreMapping *mapping = nil;
int count, max; int count, max;
NSString *pathString, *nameInContainer; NSString *pathString, *nameInContainer;
// object = [objectCache objectForKey: objectURLString];
// if (!object) {
objectURL = [NSURL URLWithString: objectURLString]; objectURL = [NSURL URLWithString: objectURLString];
if (!objectURL) if (!objectURL)
[self errorWithFormat: @"url string gave nil NSURL: '%@'", objectURLString]; [self errorWithFormat: @"url string gave nil NSURL: '%@'", objectURLString];
@ -230,13 +258,16 @@ static MAPIStoreMapping *mapping = nil;
pathString = [objectURL path]; pathString = [objectURL path];
if ([pathString hasPrefix: @"/"]) if ([pathString hasPrefix: @"/"])
pathString = [pathString substringFromIndex: 1]; pathString = [pathString substringFromIndex: 1];
if ([pathString length] > 0) { if ([pathString length] > 0)
{
path = [pathString componentsSeparatedByString: @"/"]; path = [pathString componentsSeparatedByString: @"/"];
max = [path count]; max = [path count];
if (max > 0) { if (max > 0)
{
for (count = 0; for (count = 0;
object && count < max; object && count < max;
count++) { count++)
{
nameInContainer = [[path objectAtIndex: count] nameInContainer = [[path objectAtIndex: count]
stringByUnescapingURL]; stringByUnescapingURL];
object = [object lookupName: nameInContainer object = [object lookupName: nameInContainer
@ -248,17 +279,14 @@ static MAPIStoreMapping *mapping = nil;
object = nil; object = nil;
} }
} }
} else }
else
object = nil; object = nil;
// [self _setNewLastObject: object];
// ASSIGN (lastObjectURL, objectURLString);
[woContext setClientObject: object]; [woContext setClientObject: object];
// if (object && [object isKindOfClass: SOGoObjectK])
// [objectCache setObject: object
// forKey: objectURLString];
// else {
// object = nil;
// [woContext setClientObject: nil];
// }
return object; return object;
} }
@ -274,20 +302,22 @@ static MAPIStoreMapping *mapping = nil;
newFolderURL = nil; newFolderURL = nil;
folderName = nil; folderName = nil;
for (i = 0; !folderName && i < aRow->cValues; i++) { for (i = 0; !folderName && i < aRow->cValues; i++)
if (aRow->lpProps[i].ulPropTag == PR_DISPLAY_NAME_UNICODE) { {
if (aRow->lpProps[i].ulPropTag == PR_DISPLAY_NAME_UNICODE)
folderName = [NSString stringWithUTF8String: aRow->lpProps[i].value.lpszW]; folderName = [NSString stringWithUTF8String: aRow->lpProps[i].value.lpszW];
} else if (aRow->lpProps[i].ulPropTag == PR_DISPLAY_NAME)
else if (aRow->lpProps[i].ulPropTag == PR_DISPLAY_NAME) {
folderName = [NSString stringWithUTF8String: aRow->lpProps[i].value.lpszA]; folderName = [NSString stringWithUTF8String: aRow->lpProps[i].value.lpszA];
} }
}
if (folderName) { if (folderName)
{
parentFolder = [self lookupObject: parentFolderURL]; parentFolder = [self lookupObject: parentFolderURL];
if (parentFolder) { if (parentFolder)
{
if ([parentFolder isKindOfClass: SOGoMailAccountK] if ([parentFolder isKindOfClass: SOGoMailAccountK]
|| [parentFolder isKindOfClass: SOGoMailFolderK]) { || [parentFolder isKindOfClass: SOGoMailFolderK])
{
nameInContainer = [NSString stringWithFormat: @"folder%@", nameInContainer = [NSString stringWithFormat: @"folder%@",
[folderName asCSSIdentifier]]; [folderName asCSSIdentifier]];
newFolder = [SOGoMailFolderK objectWithName: nameInContainer newFolder = [SOGoMailFolderK objectWithName: nameInContainer
@ -323,7 +353,8 @@ static MAPIStoreMapping *mapping = nil;
folderURL = [mapping urlFromID: fid]; folderURL = [mapping urlFromID: fid];
if (folderURL) if (folderURL)
rc = MAPISTORE_ERR_EXIST; rc = MAPISTORE_ERR_EXIST;
else { else
{
parentFolderURL = [mapping urlFromID: parentFID]; parentFolderURL = [mapping urlFromID: parentFID];
if (!parentFolderURL) if (!parentFolderURL)
[self errorWithFormat: @"No url found for FID: %lld", parentFID]; [self errorWithFormat: @"No url found for FID: %lld", parentFID];
@ -402,7 +433,8 @@ static MAPIStoreMapping *mapping = nil;
SOGoFolder *folder; SOGoFolder *folder;
keys = [messageCache objectForKey: folderURL]; keys = [messageCache objectForKey: folderURL];
if (!keys) { if (!keys)
{
folder = [self lookupObject: folderURL]; folder = [self lookupObject: folderURL];
if (folder) if (folder)
keys = [folder toOneRelationshipKeys]; keys = [folder toOneRelationshipKeys];
@ -420,9 +452,11 @@ static MAPIStoreMapping *mapping = nil;
SOGoFolder *folder; SOGoFolder *folder;
keys = [subfolderCache objectForKey: folderURL]; keys = [subfolderCache objectForKey: folderURL];
if (!keys) { if (!keys)
{
folder = [self lookupObject: folderURL]; folder = [self lookupObject: folderURL];
if (folder) { if (folder)
{
keys = [folder toManyRelationshipKeys]; keys = [folder toManyRelationshipKeys];
if (!keys) if (!keys)
keys = (NSArray *) [NSNull null]; keys = (NSArray *) [NSNull null];
@ -456,7 +490,8 @@ static MAPIStoreMapping *mapping = nil;
if (!url) if (!url)
[self errorWithFormat: @"No url found for FID: %lld", fid]; [self errorWithFormat: @"No url found for FID: %lld", fid];
switch (tableType) { switch (tableType)
{
case MAPISTORE_FOLDER_TABLE: case MAPISTORE_FOLDER_TABLE:
ids = [self _subfolderKeysForFolderURL: url]; ids = [self _subfolderKeysForFolderURL: url];
break; break;
@ -468,7 +503,8 @@ static MAPIStoreMapping *mapping = nil;
ids = nil; ids = nil;
} }
if ([ids isKindOfClass: [NSArray class]]) { if ([ids isKindOfClass: [NSArray class]])
{
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
*rowCount = [ids count]; *rowCount = [ids count];
} }
@ -491,20 +527,23 @@ static MAPIStoreMapping *mapping = nil;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
{
case PR_DISPLAY_NAME_UNICODE: case PR_DISPLAY_NAME_UNICODE:
child = [self lookupObject: childURL]; child = [self lookupObject: childURL];
*data = [[child displayName] asUnicodeInMemCtx: memCtx]; *data = [[child displayName] asUnicodeInMemCtx: memCtx];
break; break;
default: default:
if ((proptag & 0x001F) == 0x001F) { if ((proptag & 0x001F) == 0x001F)
{
stringValue = [NSString stringWithFormat: @"Unhandled unicode value: 0x%x", proptag]; stringValue = [NSString stringWithFormat: @"Unhandled unicode value: 0x%x", proptag];
*data = [stringValue asUnicodeInMemCtx: memCtx]; *data = [stringValue asUnicodeInMemCtx: memCtx];
[self errorWithFormat: @"Unknown proptag (returned): %.8x for child '%@'", [self errorWithFormat: @"Unknown proptag (returned): %.8x for child '%@'",
proptag, childURL]; proptag, childURL];
break; break;
} }
else { else
{
[self errorWithFormat: @"Unknown proptag: %.8x for child '%@'", [self errorWithFormat: @"Unknown proptag: %.8x for child '%@'",
proptag, childURL]; proptag, childURL];
*data = NULL; *data = NULL;
@ -526,7 +565,8 @@ static MAPIStoreMapping *mapping = nil;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
{
case PR_INST_ID: // TODO: DOUBT case PR_INST_ID: // TODO: DOUBT
llongValue = talloc_zero(memCtx, uint64_t); llongValue = talloc_zero(memCtx, uint64_t);
// *llongValue = 1; // *llongValue = 1;
@ -590,7 +630,8 @@ static MAPIStoreMapping *mapping = nil;
NSMutableArray *newParts; NSMutableArray *newParts;
parts = [urlString componentsSeparatedByString: @"/"]; parts = [urlString componentsSeparatedByString: @"/"];
if ([parts count] > 3) { if ([parts count] > 3)
{
newParts = [parts mutableCopy]; newParts = [parts mutableCopy];
[newParts autorelease]; [newParts autorelease];
[newParts removeLastObject]; [newParts removeLastObject];
@ -617,11 +658,13 @@ static MAPIStoreMapping *mapping = nil;
NSString *parentURL; NSString *parentURL;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
{
case PR_FID: case PR_FID:
llongValue = talloc_zero(memCtx, uint64_t); llongValue = talloc_zero(memCtx, uint64_t);
*llongValue = [mapping idFromURL: childURL]; *llongValue = [mapping idFromURL: childURL];
if (*llongValue == NSNotFound) { if (*llongValue == NSNotFound)
{
[mapping registerURL: childURL]; [mapping registerURL: childURL];
*llongValue = [mapping idFromURL: childURL]; *llongValue = [mapping idFromURL: childURL];
} }
@ -630,15 +673,18 @@ static MAPIStoreMapping *mapping = nil;
case PR_PARENT_FID: case PR_PARENT_FID:
llongValue = talloc_zero(memCtx, uint64_t); llongValue = talloc_zero(memCtx, uint64_t);
parentURL = [self _parentURLFromURL: childURL]; parentURL = [self _parentURLFromURL: childURL];
if (parentURL) { if (parentURL)
{
*llongValue = [mapping idFromURL: childURL]; *llongValue = [mapping idFromURL: childURL];
if (*llongValue == NSNotFound) { if (*llongValue == NSNotFound)
{
[mapping registerURL: childURL]; [mapping registerURL: childURL];
*llongValue = [mapping idFromURL: childURL]; *llongValue = [mapping idFromURL: childURL];
} }
*data = llongValue; *data = llongValue;
} }
else { else
{
*data = NULL; *data = NULL;
rc = MAPISTORE_ERR_NOT_FOUND; rc = MAPISTORE_ERR_NOT_FOUND;
} }
@ -693,9 +739,11 @@ static MAPIStoreMapping *mapping = nil;
__FUNCTION__, __LINE__, proptag, pos, tableType, fid]; __FUNCTION__, __LINE__, proptag, pos, tableType, fid];
folderURL = [mapping urlFromID: fid]; folderURL = [mapping urlFromID: fid];
if (folderURL) { if (folderURL)
{
folder = [self lookupObject: folderURL]; folder = [self lookupObject: folderURL];
switch (tableType) { switch (tableType)
{
case MAPISTORE_FOLDER_TABLE: case MAPISTORE_FOLDER_TABLE:
children = [self _subfolderKeysForFolderURL: folderURL]; children = [self _subfolderKeysForFolderURL: folderURL];
break; break;
@ -707,12 +755,14 @@ static MAPIStoreMapping *mapping = nil;
break; break;
} }
if ([children count] > pos) { if ([children count] > pos)
{
childName = [children objectAtIndex: pos]; childName = [children objectAtIndex: pos];
childURL = [folderURL stringByAppendingFormat: @"/%@", childURL = [folderURL stringByAppendingFormat: @"/%@",
[childName stringByEscapingURL]]; [childName stringByEscapingURL]];
if (tableType == MAPISTORE_FOLDER_TABLE) { if (tableType == MAPISTORE_FOLDER_TABLE)
{
[self logWithFormat: @" querying child folder at URL: %@", childURL]; [self logWithFormat: @" querying child folder at URL: %@", childURL];
rc = [self getFolderTableChildproperty: data rc = [self getFolderTableChildproperty: data
atURL: childURL atURL: childURL
@ -720,7 +770,8 @@ static MAPIStoreMapping *mapping = nil;
inFolder: folder inFolder: folder
withFID: fid]; withFID: fid];
} }
else { else
{
[self logWithFormat: @" querying child message at URL: %@", childURL]; [self logWithFormat: @" querying child message at URL: %@", childURL];
rc = [self getMessageTableChildproperty: data rc = [self getMessageTableChildproperty: data
atURL: childURL atURL: childURL
@ -748,7 +799,8 @@ static MAPIStoreMapping *mapping = nil;
else else
rc = MAPISTORE_ERROR; rc = MAPISTORE_ERROR;
} }
else { else
{
[self errorWithFormat: @"No url found for FID: %lld", fid]; [self errorWithFormat: @"No url found for FID: %lld", fid];
rc = MAPISTORE_ERR_NOT_FOUND; rc = MAPISTORE_ERR_NOT_FOUND;
} }
@ -798,7 +850,8 @@ static MAPIStoreMapping *mapping = nil;
[self logWithFormat: @"METHOD '%s' (%d) -- tableType: %d, mid: %lld", [self logWithFormat: @"METHOD '%s' (%d) -- tableType: %d, mid: %lld",
__FUNCTION__, __LINE__, tableType, fmid]; __FUNCTION__, __LINE__, tableType, fmid];
switch (tableType) { switch (tableType)
{
case MAPISTORE_FOLDER: case MAPISTORE_FOLDER:
break; break;
case MAPISTORE_MESSAGE: case MAPISTORE_MESSAGE:
@ -824,7 +877,8 @@ static MAPIStoreMapping *mapping = nil;
{ {
[self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; [self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__];
switch (type) { switch (type)
{
case MAPISTORE_FOLDER: case MAPISTORE_FOLDER:
break; break;
case MAPISTORE_MESSAGE: case MAPISTORE_MESSAGE:

View file

@ -39,11 +39,20 @@
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
@ -101,7 +110,8 @@ static Class SOGoUserFolderK;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
{
case PR_ICON_INDEX: // TODO case PR_ICON_INDEX: // TODO
longValue = talloc_zero(memCtx, uint32_t); longValue = talloc_zero(memCtx, uint32_t);
*longValue = 0x00000100; /* read mail, see http://msdn.microsoft.com/en-us/library/cc815472.aspx */ *longValue = 0x00000100; /* read mail, see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
@ -188,7 +198,8 @@ static Class SOGoUserFolderK;
int rc; int rc;
rc = MAPI_E_SUCCESS; rc = MAPI_E_SUCCESS;
switch (proptag) { switch (proptag)
{
case PR_CONTENT_UNREAD: case PR_CONTENT_UNREAD:
longValue = talloc_zero(memCtx, uint32_t); longValue = talloc_zero(memCtx, uint32_t);
*longValue = 0; *longValue = 0;

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,7 +35,8 @@ static uint64_t idCounter = 0x200001;
- (id) init - (id) init
{ {
if ((self = [super init])) { if ((self = [super init]))
{
mapping = [NSMutableDictionary new]; mapping = [NSMutableDictionary new];
reverseMapping = [NSMutableDictionary new]; reverseMapping = [NSMutableDictionary new];
} }
@ -80,12 +81,15 @@ static uint64_t idCounter = 0x200001;
BOOL rc; BOOL rc;
idKey = [NSNumber numberWithUnsignedLongLong: idNbr]; idKey = [NSNumber numberWithUnsignedLongLong: idNbr];
if ([mapping objectForKey: idKey] || [reverseMapping objectForKey: urlString]) { if ([mapping objectForKey: idKey]
|| [reverseMapping objectForKey: urlString])
{
[self errorWithFormat: @"attempt to double register an entry ('%@', %lld)", [self errorWithFormat: @"attempt to double register an entry ('%@', %lld)",
urlString, idNbr]; urlString, idNbr];
rc = NO; rc = NO;
} }
else { else
{
[mapping setObject: urlString forKey: idKey]; [mapping setObject: urlString forKey: idKey];
[reverseMapping setObject: idKey forKey: urlString]; [reverseMapping setObject: idKey forKey: urlString];
rc = YES; rc = YES;
@ -101,8 +105,10 @@ static uint64_t idCounter = 0x200001;
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"]) { {
if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderINBOX"])
{
idNbr = 0x160001; idNbr = 0x160001;
if (![self registerURL: urlString withID: idNbr]) if (![self registerURL: urlString withID: idNbr])
[self errorWithFormat: @"Unable to register root folder: %@", [self errorWithFormat: @"Unable to register root folder: %@",
@ -112,19 +118,22 @@ static uint64_t idCounter = 0x200001;
// idNbr = 0x140001; // idNbr = 0x140001;
// idCounter = idNbr; // idCounter = idNbr;
// } // }
else if ([urlString isEqualToString: @"sogo://openchange:openchange@contacts/personal"]) { else if ([urlString isEqualToString: @"sogo://openchange:openchange@contacts/personal"])
{
idNbr = 0x1a0001; idNbr = 0x1a0001;
if (![self registerURL: urlString withID: idNbr]) if (![self registerURL: urlString withID: idNbr])
[self errorWithFormat: @"Unable to register root folder: %@", [self errorWithFormat: @"Unable to register root folder: %@",
urlString]; urlString];
} }
else if ([urlString isEqualToString: @"sogo://openchange:openchange@calendar/personal"]) { else if ([urlString isEqualToString: @"sogo://openchange:openchange@calendar/personal"])
{
idNbr = 0x190001; idNbr = 0x190001;
if (![self registerURL: urlString withID: idNbr]) if (![self registerURL: urlString withID: idNbr])
[self errorWithFormat: @"Unable to register root folder: %@", [self errorWithFormat: @"Unable to register root folder: %@",
urlString]; urlString];
} }
else { else
{
idCounter += idIncrement; idCounter += idIncrement;
while (![self registerURL: urlString withID: idCounter]) while (![self registerURL: urlString withID: idCounter])
idCounter += idIncrement; idCounter += idIncrement;

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"
@ -542,10 +544,19 @@ int mapistore_init_backend(void)
{ {
struct mapistore_backend backend; struct mapistore_backend backend;
int ret; int ret;
static BOOL registered = NO;
if (registered)
{
ret = MAPISTORE_ERROR;
}
else
{
registered = YES;
/* Fill in our name */ /* Fill in our name */
backend.name = "sogo"; backend.name = "SOGo";
backend.description = "mapistore sogo backend"; backend.description = "mapistore SOGo backend";
backend.namespace = "sogo://"; backend.namespace = "sogo://";
/* Fill in all the operations */ /* Fill in all the operations */
@ -575,6 +586,7 @@ int mapistore_init_backend(void)
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,7 +38,8 @@
NSTimeZone *utc; NSTimeZone *utc;
uint64_t interval; uint64_t interval;
if (!refDate) { if (!refDate)
{
utc = [NSTimeZone timeZoneWithName: @"UTC"]; utc = [NSTimeZone timeZoneWithName: @"UTC"];
refDate = [NSCalendarDate dateWithYear: 1601 month: 1 day: 1 refDate = [NSCalendarDate dateWithYear: 1601 month: 1 day: 1
hour: 0 minute: 0 second: 0 hour: 0 minute: 0 second: 0