mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-26 11:46:23 +00:00
Monotone-Parent: 8fcaef79630a50f01c6aba0e5fdc0744c274cba6
Monotone-Revision: 87fd75f525e094b816fcad443e6fe4b2c8c8479c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-03-07T21:33:13 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
2011-03-07 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreContext.m (_prepareContextClass): now takes
|
||||
the context fid as argument.
|
||||
|
||||
* OpenChange/MAPIStore*Context.m (+registerFixedMappings): removed
|
||||
method, made obsolete by the fact that we now receive the context
|
||||
fid during initialization.
|
||||
|
||||
* OpenChange/MAPIStoreFAIMessageTable.[hm]: restored class module
|
||||
in order to reenable proper class testing during notifications.
|
||||
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
return @"calendar";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@calendar/"
|
||||
withID: 0x190001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreCalendarFolder baseFolderWithURL: newURL
|
||||
@@ -47,12 +41,4 @@
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
|
||||
- (int) readCount: (uint32_t *) rowCount
|
||||
ofTableType: (uint8_t) tableType
|
||||
inFID: (uint64_t) fid
|
||||
{
|
||||
return [super readCount: rowCount ofTableType: tableType inFID: fid];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -33,10 +33,4 @@
|
||||
return @"common-views";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@common-views/"
|
||||
withID: 0xc0001];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
return @"contacts";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@contacts/"
|
||||
withID: 0x1a0001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreContactsFolder baseFolderWithURL: newURL
|
||||
|
||||
@@ -49,7 +49,8 @@
|
||||
{
|
||||
struct mapistore_context *memCtx;
|
||||
|
||||
NSString *uri;
|
||||
NSURL *contextUrl;
|
||||
uint64_t contextFid;
|
||||
|
||||
MAPIStoreAuthenticator *authenticator;
|
||||
WOContext *woContext;
|
||||
@@ -61,10 +62,12 @@
|
||||
}
|
||||
|
||||
+ (id) contextFromURI: (const char *) newUri
|
||||
andFID: (uint64_t) fid
|
||||
inMemCtx: (struct mapistore_context *) newMemCtx;
|
||||
|
||||
- (void) setURI: (NSString *) newUri
|
||||
andMemCtx: (struct mapistore_context *) newMemCtx;
|
||||
- (id) initFromURL: (NSURL *) newUri
|
||||
andFID: (uint64_t) fid
|
||||
inMemCtx: (struct mapistore_context *) newMemCtx;
|
||||
|
||||
- (void) setAuthenticator: (MAPIStoreAuthenticator *) newAuthenticator;
|
||||
- (MAPIStoreAuthenticator *) authenticator;
|
||||
@@ -156,7 +159,6 @@
|
||||
|
||||
/* subclass methods */
|
||||
+ (NSString *) MAPIModuleName;
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) storeMapping;
|
||||
- (void) setupBaseFolder: (NSURL *) newURL;
|
||||
|
||||
/* proof of concept */
|
||||
|
||||
@@ -106,7 +106,8 @@ static void *ldbCtx = NULL;
|
||||
|
||||
static inline MAPIStoreContext *
|
||||
_prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
Class contextClass, NSURL *url)
|
||||
Class contextClass,
|
||||
NSURL *url, uint64_t fid)
|
||||
{
|
||||
static NSMutableDictionary *registration = nil;
|
||||
MAPIStoreContext *context;
|
||||
@@ -116,14 +117,11 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
registration = [NSMutableDictionary new];
|
||||
|
||||
if (![registration objectForKey: contextClass])
|
||||
{
|
||||
[contextClass registerFixedMappings: mapping];
|
||||
[registration setObject: [NSNull null]
|
||||
forKey: contextClass];
|
||||
}
|
||||
[registration setObject: [NSNull null]
|
||||
forKey: contextClass];
|
||||
|
||||
context = [contextClass new];
|
||||
[context setURI: [url absoluteString] andMemCtx: newMemCtx];
|
||||
context = [[contextClass alloc] initFromURL: url andFID: fid
|
||||
inMemCtx: newMemCtx];
|
||||
[context autorelease];
|
||||
|
||||
authenticator = [MAPIStoreAuthenticator new];
|
||||
@@ -140,6 +138,7 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
}
|
||||
|
||||
+ (id) contextFromURI: (const char *) newUri
|
||||
andFID: (uint64_t) fid
|
||||
inMemCtx: (struct mapistore_context *) newMemCtx
|
||||
{
|
||||
MAPIStoreContext *context;
|
||||
@@ -167,7 +166,8 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
if (contextClass)
|
||||
context = _prepareContextClass (newMemCtx,
|
||||
contextClass,
|
||||
baseURL);
|
||||
baseURL,
|
||||
fid);
|
||||
else
|
||||
NSLog (@"ERROR: unrecognized module name '%@'", module);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
woContext = [WOContext contextWithRequest: nil];
|
||||
[woContext retain];
|
||||
baseFolder = nil;
|
||||
uri = nil;
|
||||
contextUrl = nil;
|
||||
}
|
||||
|
||||
[self logWithFormat: @"-init"];
|
||||
@@ -197,6 +197,35 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initFromURL: (NSURL *) newUrl
|
||||
andFID: (uint64_t) newFid
|
||||
inMemCtx: (struct mapistore_context *) newMemCtx
|
||||
{
|
||||
struct loadparm_context *lpCtx;
|
||||
MAPIStoreMapping *mapping;
|
||||
|
||||
if ((self = [self init]))
|
||||
{
|
||||
if (!ldbCtx)
|
||||
{
|
||||
lpCtx = loadparm_init (newMemCtx);
|
||||
ldbCtx = mapiproxy_server_openchange_ldb_init (lpCtx);
|
||||
}
|
||||
|
||||
ASSIGN (contextUrl, newUrl);
|
||||
|
||||
mapping = [MAPIStoreMapping sharedMapping];
|
||||
if (![mapping urlFromID: newFid])
|
||||
[mapping registerURL: [newUrl absoluteString]
|
||||
withID: newFid];
|
||||
contextFid = newFid;
|
||||
|
||||
memCtx = newMemCtx;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[self logWithFormat: @"-dealloc"];
|
||||
@@ -207,26 +236,11 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
[woContext release];
|
||||
[authenticator release];
|
||||
|
||||
[uri release];
|
||||
[contextUrl release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setURI: (NSString *) newUri
|
||||
andMemCtx: (struct mapistore_context *) newMemCtx
|
||||
{
|
||||
struct loadparm_context *lpCtx;
|
||||
|
||||
if (!ldbCtx)
|
||||
{
|
||||
lpCtx = loadparm_init (newMemCtx);
|
||||
ldbCtx = mapiproxy_server_openchange_ldb_init (lpCtx);
|
||||
}
|
||||
|
||||
ASSIGN (uri, newUri);
|
||||
memCtx = newMemCtx;
|
||||
}
|
||||
|
||||
- (WOContext *) woContext
|
||||
{
|
||||
return woContext;
|
||||
@@ -835,13 +849,14 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
withTableType: (uint8_t) tableType
|
||||
{
|
||||
int rc;
|
||||
NSString *objectURL;
|
||||
NSString *objectURL, *url;
|
||||
// TDB_DATA key, dbuf;
|
||||
|
||||
url = [contextUrl absoluteString];
|
||||
objectURL = [mapping urlFromID: fmid];
|
||||
if (objectURL)
|
||||
{
|
||||
if ([objectURL hasPrefix: uri])
|
||||
if ([objectURL hasPrefix: url])
|
||||
{
|
||||
*path = [[objectURL substringFromIndex: 7]
|
||||
asUnicodeInMemCtx: memCtx];
|
||||
@@ -853,7 +868,7 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
{
|
||||
[self logWithFormat: @"context (%@, %@) does not contain"
|
||||
@" found fmid: 0x%.16x",
|
||||
objectURL, uri, fmid];
|
||||
objectURL, url, fmid];
|
||||
*path = NULL;
|
||||
rc = MAPI_E_NOT_FOUND;
|
||||
}
|
||||
@@ -1295,7 +1310,7 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
withFMID: (uint64_t) fmid
|
||||
{
|
||||
int rc;
|
||||
NSString *currentURL;
|
||||
NSString *currentURL, *url;
|
||||
NSMutableArray *nsFolderList;
|
||||
uint64_t fid;
|
||||
|
||||
@@ -1303,15 +1318,16 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
|
||||
rc = MAPI_E_SUCCESS;
|
||||
|
||||
url = [contextUrl absoluteString];
|
||||
currentURL = [mapping urlFromID: fmid];
|
||||
if (currentURL && ![currentURL isEqualToString: uri]
|
||||
&& [currentURL hasPrefix: uri])
|
||||
if (currentURL && ![currentURL isEqualToString: url]
|
||||
&& [currentURL hasPrefix: url])
|
||||
{
|
||||
nsFolderList = [NSMutableArray arrayWithCapacity: 32];
|
||||
[self extractChildNameFromURL: currentURL
|
||||
andFolderURLAt: ¤tURL];
|
||||
while (currentURL && rc == MAPI_E_SUCCESS
|
||||
&& ![currentURL isEqualToString: uri])
|
||||
&& ![currentURL isEqualToString: url])
|
||||
{
|
||||
fid = [mapping idFromURL: currentURL];
|
||||
if (fid == NSNotFound)
|
||||
@@ -1329,7 +1345,7 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
|
||||
if (rc != MAPI_E_NOT_FOUND)
|
||||
{
|
||||
fid = [mapping idFromURL: uri];
|
||||
fid = [mapping idFromURL: url];
|
||||
[nsFolderList addObject: [NSNumber numberWithUnsignedLongLong: fid]];
|
||||
[self logWithFormat: @"resulting folder list: %@", nsFolderList];
|
||||
*folders_list = [nsFolderList asFoldersListInCtx: memCtx];
|
||||
@@ -1513,10 +1529,6 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) storeMapping
|
||||
{
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
@@ -33,10 +33,4 @@
|
||||
return @"deferred-actions";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@deferred-actions/"
|
||||
withID: 0xb0001];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -37,25 +37,4 @@
|
||||
return @"freebusy";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@freebusy/"
|
||||
withID: 0x70001];
|
||||
}
|
||||
|
||||
// - (void) setupModuleFolder
|
||||
// {
|
||||
// SOGoUserFolder *userFolder;
|
||||
|
||||
// userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
// inContainer: MAPIApp];
|
||||
// [parentFoldersBag addObject: userFolder];
|
||||
// [woContext setClientObject: userFolder];
|
||||
|
||||
// moduleFolder = [userFolder lookupName: @"Calendar"
|
||||
// inContext: woContext
|
||||
// acquire: NO];
|
||||
// [moduleFolder retain];
|
||||
// }
|
||||
|
||||
@end
|
||||
|
||||
@@ -33,10 +33,4 @@
|
||||
return @"journal";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@journal/"
|
||||
withID: 0x1b0001];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -43,12 +43,6 @@
|
||||
return @"inbox";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@inbox/"
|
||||
withID: 0x160001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreInboxFolder baseFolderWithURL: newURL
|
||||
@@ -65,12 +59,6 @@
|
||||
return @"sent-items";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@sent-items/"
|
||||
withID: 0x140001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreSentItemsFolder baseFolderWithURL: newURL
|
||||
@@ -87,12 +75,6 @@
|
||||
return @"drafts";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@inbox/"
|
||||
withID: 0x1e0001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreDraftsFolder baseFolderWithURL: newURL
|
||||
@@ -109,12 +91,6 @@
|
||||
return @"deleted-items";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@deleted-items/"
|
||||
withID: 0x170001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreDeletedItemsFolder baseFolderWithURL: newURL
|
||||
@@ -131,12 +107,6 @@
|
||||
return @"outbox";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@outbox/"
|
||||
withID: 0x150001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreOutboxFolder baseFolderWithURL: newURL
|
||||
@@ -150,13 +120,7 @@
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
{
|
||||
return @"spooler";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@spooler/"
|
||||
withID: 0x120001];
|
||||
return @"spooler-queue";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -76,14 +76,14 @@ MAPIStoreMappingInitDictionary (NSMutableDictionary *mapping)
|
||||
struct tdb_wrap *wrap;
|
||||
TDB_CONTEXT *context;
|
||||
char *tdb_path;
|
||||
int rc;
|
||||
|
||||
tdb_path = "/usr/local/samba/private/mapistore/openchange/indexing.tdb";
|
||||
wrap = tdb_wrap_open(NULL, tdb_path, 0, TDB_NOLOCK, O_RDONLY, 0600);
|
||||
|
||||
context = wrap->tdb;
|
||||
rc = tdb_traverse_read(wrap->tdb, MAPIStoreMappingTDBTraverse, mapping);
|
||||
|
||||
if (wrap)
|
||||
{
|
||||
context = wrap->tdb;
|
||||
tdb_traverse_read(wrap->tdb, MAPIStoreMappingTDBTraverse, mapping);
|
||||
}
|
||||
}
|
||||
|
||||
@implementation MAPIStoreMapping
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
return @"notes";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@notes/"
|
||||
withID: 0x1c0001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreNotesFolder baseFolderWithURL: newURL
|
||||
|
||||
@@ -33,10 +33,4 @@
|
||||
return @"reminders";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@reminders/"
|
||||
withID: 0x180001];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -102,7 +102,8 @@ sogo_init (void)
|
||||
*/
|
||||
|
||||
static int
|
||||
sogo_create_context(TALLOC_CTX *mem_ctx, const char *uri, void **private_data)
|
||||
sogo_create_context(TALLOC_CTX *mem_ctx, const char *uri, uint64_t fid,
|
||||
void **private_data)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
sogo_context *cContext;
|
||||
@@ -117,8 +118,8 @@ sogo_create_context(TALLOC_CTX *mem_ctx, const char *uri, void **private_data)
|
||||
MAPIStoreContextK = NSClassFromString (@"MAPIStoreContext");
|
||||
if (MAPIStoreContextK)
|
||||
{
|
||||
context = [MAPIStoreContextK contextFromURI: uri
|
||||
inMemCtx: mem_ctx];
|
||||
context = [MAPIStoreContextK contextFromURI: uri andFID: fid
|
||||
inMemCtx: mem_ctx];
|
||||
[context retain];
|
||||
|
||||
cContext = talloc_zero(mem_ctx, sogo_context);
|
||||
|
||||
@@ -33,10 +33,4 @@
|
||||
return @"schedule";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@schedule/"
|
||||
withID: 0xe0001];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -33,10 +33,4 @@
|
||||
return @"search";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@search/"
|
||||
withID: 0xd0001];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -33,10 +33,4 @@
|
||||
return @"shortcuts";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@shortcuts/"
|
||||
withID: 0xf0001];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
return @"tasks";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@tasks/"
|
||||
withID: 0x1d0001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreTasksFolder baseFolderWithURL: newURL
|
||||
|
||||
@@ -33,10 +33,4 @@
|
||||
return @"views";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@views/"
|
||||
withID: 0x110001];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user