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>
*
@ -35,7 +35,7 @@ MAPIApplication *MAPIApp = nil;
@interface UnixSignalHandler : NSObject
+ sharedHandler;
+ (id) sharedHandler;
- (void) removeObserver: (id) observer;
@ -49,7 +49,8 @@ MAPIApplication *MAPIApp = nil;
NSUserDefaults *ud;
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
the encoding specified in the file. */

View file

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

View file

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

View file

@ -45,7 +45,7 @@ static Class SOGoUserFolderK;
+ (void) initialize
{
SOGoUserFolderK = [SOGoUserFolderK class];
SOGoUserFolderK = [SOGoUserFolder class];
}
- (void) setupModuleFolder
@ -137,7 +137,8 @@ static Class SOGoUserFolderK;
int rc;
rc = MAPI_E_SUCCESS;
switch (proptag) {
switch (proptag)
{
case PR_ICON_INDEX: // TODO
longValue = talloc_zero(memCtx, uint32_t);
*longValue = 0x00000200; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
@ -271,26 +272,27 @@ static Class SOGoUserFolderK;
return rc;
}
- (int) getFolderTableChildproperty: (void **) data
atURL: (NSString *) childURL
withTag: (uint32_t) proptag
inFolder: (SOGoFolder *) folder
withFID: (uint64_t) fid
{
int rc;
// - (int) getFolderTableChildproperty: (void **) data
// atURL: (NSString *) childURL
// withTag: (uint32_t) proptag
// inFolder: (SOGoFolder *) folder
// withFID: (uint64_t) fid
// {
// int rc;
[self logWithFormat: @"XXXXX unexpected!!!!!!!!!"];
rc = MAPI_E_SUCCESS;
switch (proptag) {
default:
rc = [super getFolderTableChildproperty: data
atURL: childURL
withTag: proptag
inFolder: folder
withFID: fid];
}
// [self logWithFormat: @"XXXXX unexpected!!!!!!!!!"];
// rc = MAPI_E_SUCCESS;
// switch (proptag)
// {
// default:
// rc = [super getFolderTableChildproperty: data
// atURL: childURL
// withTag: proptag
// inFolder: folder
// withFID: fid];
// }
return rc;
}
// return rc;
// }
@end

View file

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

View file

@ -39,11 +39,20 @@
static Class SOGoUserFolderK;
@implementation SOGoObject (LeakD)
- (void) dealloc
{
[super dealloc];
}
@end
@implementation MAPIStoreMailContext
+ (void) initialize
{
SOGoUserFolderK = [SOGoUserFolderK class];
SOGoUserFolderK = [SOGoUserFolder class];
}
- (void) setupModuleFolder
@ -101,7 +110,8 @@ static Class SOGoUserFolderK;
int rc;
rc = MAPI_E_SUCCESS;
switch (proptag) {
switch (proptag)
{
case PR_ICON_INDEX: // TODO
longValue = talloc_zero(memCtx, uint32_t);
*longValue = 0x00000100; /* read mail, see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
@ -188,7 +198,8 @@ static Class SOGoUserFolderK;
int rc;
rc = MAPI_E_SUCCESS;
switch (proptag) {
switch (proptag)
{
case PR_CONTENT_UNREAD:
longValue = talloc_zero(memCtx, uint32_t);
*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.
*
@ -35,7 +35,8 @@ static uint64_t idCounter = 0x200001;
- (id) init
{
if ((self = [super init])) {
if ((self = [super init]))
{
mapping = [NSMutableDictionary new];
reverseMapping = [NSMutableDictionary new];
}
@ -80,12 +81,15 @@ static uint64_t idCounter = 0x200001;
BOOL rc;
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)",
urlString, idNbr];
rc = NO;
}
else {
else
{
[mapping setObject: urlString forKey: idKey];
[reverseMapping setObject: idKey forKey: urlString];
rc = YES;
@ -101,8 +105,10 @@ static uint64_t idCounter = 0x200001;
uint64_t idNbr;
// newID = openchangedb_get_new_folderID();
if (![reverseMapping objectForKey: urlString]) {
if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderINBOX"]) {
if (![reverseMapping objectForKey: urlString])
{
if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderINBOX"])
{
idNbr = 0x160001;
if (![self registerURL: urlString withID: idNbr])
[self errorWithFormat: @"Unable to register root folder: %@",
@ -112,19 +118,22 @@ static uint64_t idCounter = 0x200001;
// idNbr = 0x140001;
// idCounter = idNbr;
// }
else if ([urlString isEqualToString: @"sogo://openchange:openchange@contacts/personal"]) {
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"]) {
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 {
else
{
idCounter += idIncrement;
while (![self registerURL: urlString withID: idCounter])
idCounter += idIncrement;

View file

@ -1,25 +1,27 @@
/*
OpenChange Storage Abstraction Layer library
SOGo backend
OpenChange Project
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
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. If not, see <http://www.gnu.org/licenses/>.
/* MAPIStoreSOGo.m - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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
* the Free Software Foundation; either version 2, 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
* 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
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* OpenChange SOGo storage backend */
#import <Foundation/NSAutoreleasePool.h>
#import "MAPIApplication.h"
@ -542,10 +544,19 @@ int mapistore_init_backend(void)
{
struct mapistore_backend backend;
int ret;
static BOOL registered = NO;
if (registered)
{
ret = MAPISTORE_ERROR;
}
else
{
registered = YES;
/* Fill in our name */
backend.name = "sogo";
backend.description = "mapistore sogo backend";
backend.name = "SOGo";
backend.description = "mapistore SOGo backend";
backend.namespace = "sogo://";
/* Fill in all the operations */
@ -575,6 +586,7 @@ int mapistore_init_backend(void)
if (ret != MAPISTORE_SUCCESS) {
DEBUG(0, ("Failed to register the '%s' mapistore backend!\n", backend.name));
}
}
return ret;
}

View file

@ -38,7 +38,8 @@
NSTimeZone *utc;
uint64_t interval;
if (!refDate) {
if (!refDate)
{
utc = [NSTimeZone timeZoneWithName: @"UTC"];
refDate = [NSCalendarDate dateWithYear: 1601 month: 1 day: 1
hour: 0 minute: 0 second: 0