Monotone-Parent: 3dcf94352c5cd46c85e96c73b1a937bc01cd0f16

Monotone-Revision: dfd1432deb15d83cbdbaf1744401c991a8101e4f

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-11-22T16:03:30
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2010-11-22 16:03:30 +00:00
parent a87916d88a
commit c528bcd29a
9 changed files with 122 additions and 44 deletions

View File

@@ -1,5 +1,14 @@
2010-11-22 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreContext.m (_contextClassFromModule)
(_prepareContextClass): new static functions for clearing up
+contextFromURI:inMemCtx:.
(+registerFixedMappings:): new subclassable method.
(_prepareContextClass): the static mappings are now initialized
from the context class themselves, via the use of an unique
invocation of registerFixedMappings: when the class is
instantiated first.
* OpenChange/SOGoTaskObject+MAPIStore.m (-setMAPIProperties:): the
start date must be taken from the 0x811e0040 property rather than
"PR_START_DATE" (contrary to the event properties), we now handle

View File

@@ -29,6 +29,7 @@
#import "MAPIApplication.h"
#import "MAPIStoreAuthenticator.h"
#import "MAPIStoreMapping.h"
#import "NSCalendarDate+MAPIStore.h"
#import "NSString+MAPIStore.h"
#import "SOGoGCSFolder+MAPIStore.h"
@@ -40,6 +41,12 @@
@implementation MAPIStoreCalendarContext
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
{
[mapping registerURL: @"sogo://openchange:openchange@calendar/personal"
withID: 0x190001];
}
- (void) setupModuleFolder
{
id userFolder;

View File

@@ -32,6 +32,7 @@
#import "MAPIApplication.h"
#import "MAPIStoreAuthenticator.h"
#import "MAPIStoreMapping.h"
#import "NSString+MAPIStore.h"
#import "SOGoGCSFolder+MAPIStore.h"
@@ -42,6 +43,12 @@
@implementation MAPIStoreContactsContext
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
{
[mapping registerURL: @"sogo://openchange:openchange@contacts/personal"
withID: 0x1a0001];
}
- (void) setupModuleFolder
{
id userFolder;

View File

@@ -130,6 +130,7 @@ extern uint64_t *MAPILongLongValue (void *, uint64_t);
withFlags: (uint8_t) flags;
/* subclass methods */
+ (void) registerFixedMappings: (MAPIStoreMapping *) storeMapping;
- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder;

View File

@@ -73,6 +73,7 @@
/* sogo://username:password@{contacts,calendar,tasks,journal,notes,mail}/dossier/id */
static Class SOGoObjectK, SOGoMailAccountK, SOGoMailFolderK;
static Class NSArrayK;
static MAPIStoreMapping *mapping = nil;
@@ -81,14 +82,80 @@ static MAPIStoreMapping *mapping = nil;
SOGoObjectK = [SOGoObject class];
SOGoMailAccountK = [SOGoMailAccount class];
SOGoMailFolderK = [SOGoMailFolder class];
NSArrayK = [NSArray class];
mapping = [MAPIStoreMapping sharedMapping];
}
+ (void) registerFixedMappings: (MAPIStoreMapping *) storeMapping
{
}
static inline NSString *
_contextClassFromModule (NSString *module)
{
NSString *contextClass;
if ([module isEqualToString: @"mail"])
contextClass = @"MAPIStoreMailContext";
else if ([module isEqualToString: @"contacts"])
contextClass = @"MAPIStoreContactsContext";
else if ([module isEqualToString: @"calendar"])
contextClass = @"MAPIStoreCalendarContext";
else if ([module isEqualToString: @"tasks"])
contextClass = @"MAPIStoreTasksContext";
else if ([module isEqualToString: @"freebusy"])
contextClass = @"MAPIStoreFreebusyContext";
else
{
NSLog (@"ERROR: unrecognized module name '%@'", module);
contextClass = nil;
}
return contextClass;
}
static inline MAPIStoreContext *
_prepareContextClass (struct mapistore_context *newMemCtx,
NSString *contextClass, NSString *completeURLString,
NSString *username, NSString *password)
{
MAPIStoreContext *context;
MAPIStoreAuthenticator *authenticator;
static NSMutableDictionary *registration = nil;
Class contextK;
if (!registration)
registration = [NSMutableDictionary new];
contextK = NSClassFromString (contextClass);
if (![registration objectForKey: contextClass])
{
[contextK registerFixedMappings: mapping];
[registration setObject: [NSNull null]
forKey: contextClass];
}
context = [contextK new];
[context setURI: completeURLString andMemCtx: newMemCtx];
[context autorelease];
authenticator = [MAPIStoreAuthenticator new];
[authenticator setUsername: username];
[authenticator setPassword: password];
[context setAuthenticator: authenticator];
[authenticator release];
[context setupRequest];
[context setupModuleFolder];
[context tearDownRequest];
return context;
}
+ (id) contextFromURI: (const char *) newUri
inMemCtx: (struct mapistore_context *) newMemCtx
{
MAPIStoreContext *context;
MAPIStoreAuthenticator *authenticator;
NSString *contextClass, *module, *completeURLString, *urlString;
NSURL *baseURL;
@@ -106,38 +173,13 @@ static MAPIStoreMapping *mapping = nil;
module = [baseURL host];
if (module)
{
if ([module isEqualToString: @"mail"])
contextClass = @"MAPIStoreMailContext";
else if ([module isEqualToString: @"contacts"])
contextClass = @"MAPIStoreContactsContext";
else if ([module isEqualToString: @"calendar"])
contextClass = @"MAPIStoreCalendarContext";
else if ([module isEqualToString: @"tasks"])
contextClass = @"MAPIStoreTasksContext";
else if ([module isEqualToString: @"freebusy"])
contextClass = @"MAPIStoreFreebusyContext";
else
{
NSLog (@"ERROR: unrecognized module name '%@'", module);
contextClass = nil;
}
contextClass = _contextClassFromModule (module);
if (contextClass)
{
context = [NSClassFromString (contextClass) new];
[context setURI: completeURLString andMemCtx: newMemCtx];
[context autorelease];
authenticator = [MAPIStoreAuthenticator new];
[authenticator setUsername: [baseURL user]];
[authenticator setPassword: [baseURL password]];
[context setAuthenticator: authenticator];
[authenticator release];
[context setupRequest];
[context setupModuleFolder];
[context tearDownRequest];
}
context = _prepareContextClass (newMemCtx,
contextClass,
completeURLString,
[baseURL user],
[baseURL password]);
}
}
else
@@ -531,7 +573,7 @@ static MAPIStoreMapping *mapping = nil;
ids = nil;
}
if ([ids isKindOfClass: [NSArray class]])
if ([ids isKindOfClass: NSArrayK])
{
rc = MAPI_E_SUCCESS;
*rowCount = [ids count];

View File

@@ -26,11 +26,18 @@
#import "MAPIApplication.h"
#import "MAPIStoreAuthenticator.h"
#import "MAPIStoreMapping.h"
#import "MAPIStoreFreebusyContext.h"
@implementation MAPIStoreFreebusyContext
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
{
[mapping registerURL: @"sogo://openchange:openchange@freebusy/"
withID: 0x70001];
}
- (void) setupModuleFolder
{
id userFolder;

View File

@@ -34,6 +34,7 @@
#import "MAPIApplication.h"
#import "MAPIStoreAuthenticator.h"
#import "MAPIStoreMapping.h"
#import "NSData+MAPIStore.h"
#import "NSCalendarDate+MAPIStore.h"
#import "NSString+MAPIStore.h"
@@ -48,6 +49,14 @@
@implementation MAPIStoreMailContext
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
{
[mapping registerURL: @"sogo://openchange:openchange@mail/folderINBOX"
withID: 0x160001];
[mapping registerURL: @"sogo://openchange:openchange@mail/folderxxxc0001"
withID: 0x0c0001];
}
- (void) setupModuleFolder
{
id userFolder, accountsFolder;

View File

@@ -44,23 +44,12 @@
return sharedMapping;
}
- (void) _setupFixedMapping
{
[self registerURL: @"sogo://openchange:openchange@mail/folderINBOX" withID: 0x160001];
[self registerURL: @"sogo://openchange:openchange@mail/folderxxxc0001" withID: 0x0c0001];
[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];
[self registerURL: @"sogo://openchange:openchange@freebusy/" withID: 0x70001];
}
- (id) init
{
if ((self = [super init]))
{
mapping = [NSMutableDictionary new];
reverseMapping = [NSMutableDictionary new];
[self _setupFixedMapping];
}
return self;

View File

@@ -27,6 +27,7 @@
#import "MAPIApplication.h"
#import "MAPIStoreAuthenticator.h"
#import "MAPIStoreMapping.h"
#import "NSCalendarDate+MAPIStore.h"
#import "NSString+MAPIStore.h"
#import "SOGoGCSFolder+MAPIStore.h"
@@ -38,6 +39,12 @@
@implementation MAPIStoreTasksContext
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
{
[mapping registerURL: @"sogo://openchange:openchange@tasks/personal"
withID: 0x1d0001];
}
- (void) setupModuleFolder
{
id userFolder;