Monotone-Parent: 59d160b60daebebf7589645c180056eb1cc90294

Monotone-Revision: 141ad1bae936fb5a1442f7b24d77771ed518e940

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-10-13T15:30:01
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2010-10-13 15:30:01 +00:00
parent 9660aeb84e
commit cfe04bb0c6
4 changed files with 73 additions and 52 deletions

View file

@ -1,3 +1,13 @@
2010-10-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreMapping.m (-registerURL:): commented method out.
(-_setupFixedMapping): new method that registers well-known ids
with well-known urls.
* OpenChange/MAPIStoreContext.m (+contextFromURI:): no longer
register the URI mapping since the basic ones are always
registered.
2010-10-13 Francis Lachapelle <flachapelle@inverse.ca> 2010-10-13 Francis Lachapelle <flachapelle@inverse.ca>
* UI/Scheduler/NSArray+Scheduler.h: added index constants for * UI/Scheduler/NSArray+Scheduler.h: added index constants for

View file

@ -160,7 +160,6 @@ static MAPIStoreMapping *mapping = nil;
if (contextClass) if (contextClass)
{ {
[mapping registerURL: completeURLString];
context = [NSClassFromString (contextClass) new]; context = [NSClassFromString (contextClass) new];
[context autorelease]; [context autorelease];

View file

@ -39,7 +39,7 @@
- (uint64_t) idFromURL: (NSString *) url; - (uint64_t) idFromURL: (NSString *) url;
- (BOOL) registerURL: (NSString *) urlString - (BOOL) registerURL: (NSString *) urlString
withID: (uint64_t) idNbr; withID: (uint64_t) idNbr;
- (void) registerURL: (NSString *) urlString; // - (void) registerURL: (NSString *) urlString;
@end @end

View file

@ -21,6 +21,7 @@
*/ */
#import <Foundation/NSDictionary.h> #import <Foundation/NSDictionary.h>
#import <Foundation/NSException.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <Foundation/NSValue.h> #import <Foundation/NSValue.h>
@ -28,17 +29,26 @@
#import "MAPIStoreMapping.h" #import "MAPIStoreMapping.h"
static const uint64_t idIncrement = 0x010000; /* we choose a high enough id to avoid any clash with system folders */ // static const uint64_t idIncrement = 0x010000; /* we choose a high enough id to avoid any clash with system folders */
static uint64_t idCounter = 0x200001; // static uint64_t idCounter = 0x200001;
@implementation MAPIStoreMapping @implementation MAPIStoreMapping
- (void) _setupFixedMapping
{
[self registerURL: @"sogo://openchange:openchange@mail/folderINBOX" withID: 0x160001];
[self registerURL: @"sogo://openchange:openchange@contacts/personal" withID: 0x1a0001];
[self registerURL: @"sogo://openchange:openchange@calendar/personal" withID: 0x190001];
[self registerURL: @"sogo://openchange:openchange@tasks/personal" withID: 0x1d0001];
}
- (id) init - (id) init
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
mapping = [NSMutableDictionary new]; mapping = [NSMutableDictionary new];
reverseMapping = [NSMutableDictionary new]; reverseMapping = [NSMutableDictionary new];
[self _setupFixedMapping];
} }
return self; return self;
@ -70,7 +80,7 @@ static uint64_t idCounter = 0x200001;
idNbr = [idKey unsignedLongLongValue]; idNbr = [idKey unsignedLongLongValue];
else else
idNbr = NSNotFound; idNbr = NSNotFound;
return idNbr; return idNbr;
} }
@ -100,53 +110,55 @@ static uint64_t idCounter = 0x200001;
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"]) // 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: %@",
urlString]; // urlString];
} // }
// else if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderSent"]) { // // else if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderSent"]) {
// 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 if ([urlString isEqualToString: @"sogo://openchange:openchange@tasks/personal"]) // else if ([urlString isEqualToString: @"sogo://openchange:openchange@tasks/personal"])
{ // {
idNbr = 0x1d0001; // idNbr = 0x1d0001;
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; // [NSException raise: @"MAPIStoreSOGoException"
while (![self registerURL: urlString withID: idCounter]) // format: @"use registerURL:withID: instead"];
idCounter += idIncrement; // // idCounter += idIncrement;
} // // while (![self registerURL: urlString withID: idCounter])
// [self _registerURL: urlString withID: newID]; // // idCounter += idIncrement;
} // }
} // // [self _registerURL: urlString withID: newID];
// }
// }
@end @end