From cfe04bb0c691c441145fd4e8da8481d308744461 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 13 Oct 2010 15:30:01 +0000 Subject: [PATCH] Monotone-Parent: 59d160b60daebebf7589645c180056eb1cc90294 Monotone-Revision: 141ad1bae936fb5a1442f7b24d77771ed518e940 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-10-13T15:30:01 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 10 +++ OpenChange/MAPIStoreContext.m | 1 - OpenChange/MAPIStoreMapping.h | 2 +- OpenChange/MAPIStoreMapping.m | 112 +++++++++++++++++++--------------- 4 files changed, 73 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18b4cd8e2..e1312c0b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-10-13 Wolfgang Sourdeau + + * 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 * UI/Scheduler/NSArray+Scheduler.h: added index constants for diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 3edd82eb7..9f61e0b33 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -160,7 +160,6 @@ static MAPIStoreMapping *mapping = nil; if (contextClass) { - [mapping registerURL: completeURLString]; context = [NSClassFromString (contextClass) new]; [context autorelease]; diff --git a/OpenChange/MAPIStoreMapping.h b/OpenChange/MAPIStoreMapping.h index a17d980e3..d416a99d2 100644 --- a/OpenChange/MAPIStoreMapping.h +++ b/OpenChange/MAPIStoreMapping.h @@ -39,7 +39,7 @@ - (uint64_t) idFromURL: (NSString *) url; - (BOOL) registerURL: (NSString *) urlString withID: (uint64_t) idNbr; -- (void) registerURL: (NSString *) urlString; +// - (void) registerURL: (NSString *) urlString; @end diff --git a/OpenChange/MAPIStoreMapping.m b/OpenChange/MAPIStoreMapping.m index 873691715..90e43dfd3 100644 --- a/OpenChange/MAPIStoreMapping.m +++ b/OpenChange/MAPIStoreMapping.m @@ -21,6 +21,7 @@ */ #import +#import #import #import @@ -28,17 +29,26 @@ #import "MAPIStoreMapping.h" -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 const uint64_t idIncrement = 0x010000; /* we choose a high enough id to avoid any clash with system folders */ +// static uint64_t idCounter = 0x200001; @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 { if ((self = [super init])) { mapping = [NSMutableDictionary new]; reverseMapping = [NSMutableDictionary new]; + [self _setupFixedMapping]; } return self; @@ -70,7 +80,7 @@ static uint64_t idCounter = 0x200001; idNbr = [idKey unsignedLongLongValue]; else idNbr = NSNotFound; - + return idNbr; } @@ -100,53 +110,55 @@ static uint64_t idCounter = 0x200001; return rc; } -- (void) registerURL: (NSString *) urlString -{ - uint64_t idNbr; +// - (void) registerURL: (NSString *) urlString +// { +// uint64_t idNbr; - // newID = openchangedb_get_new_folderID(); - 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: %@", - urlString]; - } - // 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 if ([urlString isEqualToString: @"sogo://openchange:openchange@tasks/personal"]) - { - idNbr = 0x1d0001; - 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]; - } -} +// // newID = openchangedb_get_new_folderID(); +// 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: %@", +// urlString]; +// } +// // 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 if ([urlString isEqualToString: @"sogo://openchange:openchange@tasks/personal"]) +// { +// idNbr = 0x1d0001; +// if (![self registerURL: urlString withID: idNbr]) +// [self errorWithFormat: @"Unable to register root folder: %@", +// urlString]; +// } +// else +// { +// [NSException raise: @"MAPIStoreSOGoException" +// format: @"use registerURL:withID: instead"]; +// // idCounter += idIncrement; +// // while (![self registerURL: urlString withID: idCounter]) +// // idCounter += idIncrement; +// } +// // [self _registerURL: urlString withID: newID]; +// } +// } @end