merge of '47c78c5b5ba20e869ca5d21c7e0575d6f8a0ea6b'

and '70abddfe36eb868aa185ad5ad7f41e1c8fe7ee9c'

Monotone-Parent: 47c78c5b5ba20e869ca5d21c7e0575d6f8a0ea6b
Monotone-Parent: 70abddfe36eb868aa185ad5ad7f41e1c8fe7ee9c
Monotone-Revision: fb3ae1be0d4c0ad6fd7491bea70eefa829243ad4

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-06-04T00:03:42
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2011-06-04 00:03:42 +00:00
14 changed files with 105 additions and 101 deletions
+20
View File
@@ -1,3 +1,23 @@
2011-06-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreSOGo.m (sogo_op_opendir): op_opendir no
longer takes the parent fid as parameter.
* OpenChange/MAPIStoreCalendarMessageTable.m
(-sortIdentifierForProperty:): c_isallday and c_creationdate as
mappings for PidLidAppointmentSubType and PR_CREATION_TIME.
* OpenChange/MAPIStoreContext.m: MAPIStoreMapping instances are
now per-user instances rather than class singletons.
* OpenChange/MAPIStoreMapping.m: now makes use of the records
already present in indexing.tdb for building the initial mapping
dictionary.
* OpenChange/MAPIStoreSpoolerContext.[hm]: new context module,
which subclasses MAPIStoreSpoolerContext from
MAPIStoreFSBaseContext rather than MAPIStoreOutboxContext.
2011-06-03 Francis Lachapelle <flachapelle@inverse.ca>
* UI/WebServerResources/generic.js (initMenu): the wrong callbacks
+2
View File
@@ -92,12 +92,14 @@ $(SOGOBACKEND)_OBJC_FILES += \
\
MAPIStoreCommonViewsContext.m \
MAPIStoreDeferredActionsContext.m \
MAPIStoreFallbackContext.m \
MAPIStoreFreebusyContext.m \
MAPIStoreJournalContext.m \
MAPIStoreRemindersContext.m \
MAPIStoreScheduleContext.m \
MAPIStoreSearchContext.m \
MAPIStoreShortcutsContext.m \
MAPIStoreSpoolerContext.m \
MAPIStoreViewsContext.m \
\
NSArray+MAPIStore.m \
+4 -7
View File
@@ -23,6 +23,7 @@
#import <Foundation/NSData.h>
#import "MAPIStoreAttachment.h"
#import "MAPIStoreContext.h"
#import "MAPIStoreMapping.h"
#import "MAPIStoreMessage.h"
#import "MAPIStoreTypes.h"
@@ -33,15 +34,8 @@
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>
static MAPIStoreMapping *mapping;
@implementation MAPIStoreAttachment
+ (void) initialize
{
mapping = [MAPIStoreMapping sharedMapping];
}
- (void) setAID: (uint32_t) newAID
{
aid = newAID;
@@ -102,9 +96,12 @@ static MAPIStoreMapping *mapping;
andFlags: (enum OpenEmbeddedMessage_OpenModeFlags) flags
{
MAPIStoreAttachmentMessage *attMessage;
MAPIStoreMapping *mapping;
memset (mapistoreMsg, 0, sizeof (struct mapistore_message));
mapping = [[self context] mapping];
attMessage = [self openEmbeddedMessage];
if (attMessage)
*mid = [mapping idFromURL: [attMessage url]];
@@ -95,6 +95,10 @@
forKey: MAPIPropertyKey (PidLidAppointmentEndWhole)];
[knownProperties setObject: @"c_iscycle"
forKey: MAPIPropertyKey (PidLidRecurring)];
[knownProperties setObject: @"c_isallday"
forKey: MAPIPropertyKey (PidLidAppointmentSubType)];
[knownProperties setObject: @"c_creationdate"
forKey: MAPIPropertyKey (PR_CREATION_TIME)];
}
return [knownProperties objectForKey: MAPIPropertyKey (property)];
-2
View File
@@ -22,8 +22,6 @@
#import <Foundation/NSString.h>
#import "MAPIStoreMapping.h"
#import "MAPIStoreCommonViewsContext.h"
@implementation MAPIStoreCommonViewsContext
+4 -2
View File
@@ -53,6 +53,8 @@
NSURL *contextUrl;
uint64_t contextFid;
MAPIStoreMapping *mapping;
MAPIStoreAuthenticator *authenticator;
WOContext *woContext;
@@ -79,6 +81,7 @@
- (struct mapistore_connection_info *) connectionInfo;
- (WOContext *) woContext;
- (MAPIStoreMapping *) mapping;
- (void) setupRequest;
- (void) tearDownRequest;
@@ -114,8 +117,7 @@
inParentFID: (uint64_t) parentFID;
- (int) rmDirWithFID: (uint64_t) fid
inParentFID: (uint64_t) parentFid;
- (int) openDir: (uint64_t) fid
inParentFID: (uint64_t) parentFID;
- (int) openDir: (uint64_t) fid;
- (int) closeDir;
- (int) readCount: (uint32_t *) rowCount
ofTableType: (uint8_t) tableType
+21 -13
View File
@@ -70,8 +70,8 @@
static Class NSDataK, NSStringK, MAPIStoreFAIMessageK;
static MAPIStoreMapping *mapping;
static NSMutableDictionary *contextClassMapping;
static NSMutableDictionary *userMAPIStoreMapping;
static void *ldbCtx = NULL;
@@ -86,8 +86,6 @@ static void *ldbCtx = NULL;
NSStringK = [NSString class];
MAPIStoreFAIMessageK = [MAPIStoreFAIMessage class];
mapping = [MAPIStoreMapping sharedMapping];
contextClassMapping = [NSMutableDictionary new];
classes = GSObjCAllSubclassesOfClass (self);
max = [classes count];
@@ -103,6 +101,8 @@ static void *ldbCtx = NULL;
NSStringFromClass (currentClass), moduleName);
}
}
userMAPIStoreMapping = [NSMutableDictionary new];
}
static inline MAPIStoreContext *
@@ -209,7 +209,7 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
inMemCtx: (struct mapistore_context *) newMemCtx
{
struct loadparm_context *lpCtx;
MAPIStoreMapping *mapping;
NSString *username;
if ((self = [self init]))
{
@@ -221,7 +221,15 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
ASSIGN (contextUrl, newUrl);
mapping = [MAPIStoreMapping sharedMapping];
username = [NSString stringWithUTF8String: newConnInfo->username];
mapping = [userMAPIStoreMapping objectForKey: username];
if (!mapping)
{
[self logWithFormat: @"generating mapping of ids for user '%@'",
username];
mapping = [MAPIStoreMapping mappingWithIndexing: newConnInfo->indexing];
[userMAPIStoreMapping setObject: mapping forKey: username];
}
if (![mapping urlFromID: newFid])
[mapping registerURL: [newUrl absoluteString]
withID: newFid];
@@ -254,6 +262,11 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
return woContext;
}
- (MAPIStoreMapping *) mapping
{
return mapping;
}
- (void) setAuthenticator: (MAPIStoreAuthenticator *) newAuthenticator
{
ASSIGN (authenticator, newAuthenticator);
@@ -372,18 +385,15 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/
- (int) openDir: (uint64_t) fid
inParentFID: (uint64_t) parentFID
{
[self logWithFormat:
@"UNIMPLEMENTED METHOD '%s' (%d):\n fid=0x%.16x, parentFID=0x%.16x",
@"UNIMPLEMENTED METHOD '%s' (%d):\n fid=0x%.16x",
__FUNCTION__, __LINE__,
(unsigned long long) fid,
(unsigned long long) parentFID];
(unsigned long long) fid];
return MAPISTORE_ERROR;
return MAPISTORE_SUCCESS;
}
/**
\details Close a folder from the sogo backend
@@ -1332,8 +1342,6 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
uint64_t mappingId;
uint32_t contextId;
mapping = [MAPIStoreMapping sharedMapping];
if (key)
childURL = [NSString stringWithFormat: @"%@%@", folderURL, key];
else
-8
View File
@@ -23,7 +23,6 @@
#import <NGExtensions/NSObject+Logs.h>
#import "MAPIStoreFolder.h"
#import "MAPIStoreMapping.h"
#import "MAPIStoreTypes.h"
#import "MAPIStoreFolderTable.h"
@@ -35,13 +34,6 @@
@implementation MAPIStoreFolderTable
static MAPIStoreMapping *mapping;
+ (void) initialize
{
mapping = [MAPIStoreMapping sharedMapping];
}
- (id) init
{
if ((self = [super init]))
-3
View File
@@ -43,7 +43,4 @@
@interface MAPIStoreOutboxContext : MAPIStoreMailContext
@end
@interface MAPIStoreSpoolerContext : MAPIStoreOutboxContext
@end
#endif /* MAPISTOREMAILCONTEXT_H */
-9
View File
@@ -115,12 +115,3 @@
}
@end
@implementation MAPIStoreSpoolerContext
+ (NSString *) MAPIModuleName
{
return @"spooler-queue";
}
@end
+4 -1
View File
@@ -32,9 +32,12 @@
{
NSMutableDictionary *mapping; /* FID/MID -> url */
NSMutableDictionary *reverseMapping; /* url -> FID/MID */
struct tdb_wrap *indexing;
}
+ (id) sharedMapping;
+ (id) mappingWithIndexing: (struct tdb_wrap *) indexing;
- (id) initWithIndexing: (struct tdb_wrap *) indexing;
- (NSString *) urlFromID: (uint64_t) idKey;
+44 -46
View File
@@ -28,22 +28,15 @@
#import <NGExtensions/NSObject+Logs.h>
#import "MAPIStoreTypes.h"
#import "MAPIStoreMapping.h"
#include <fcntl.h>
#include <tdb.h>
#include <talloc.h>
#include <tdb.h>
#include <tdb_wrap.h>
struct tdb_wrap {
struct tdb_context *tdb;
const char *name;
struct tdb_wrap *next, *prev;
};
extern struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode);
@implementation MAPIStoreMapping
static int
MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
@@ -59,7 +52,7 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
idVal = strtoll (idStr, NULL, 16);
idNbr = [NSNumber numberWithUnsignedLongLong: idVal];
uriStr = strdup ((const char *) data2.dptr);
uriStr = strndup ((const char *) data2.dptr, data2.dsize);
*(uriStr+(data2.dsize)) = 0;
uri = [NSString stringWithUTF8String: uriStr];
free (uriStr);
@@ -70,47 +63,39 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
return 0;
}
static void
MAPIStoreMappingInitDictionary (NSMutableDictionary *mapping)
+ (id) mappingWithIndexing: (struct tdb_wrap *) indexing
{
struct tdb_wrap *wrap;
TDB_CONTEXT *context;
char *tdb_path;
id newMapping;
tdb_path = "/usr/local/samba/private/mapistore/openchange/indexing.tdb";
wrap = tdb_wrap_open(NULL, tdb_path, 0, TDB_NOLOCK, O_RDONLY, 0600);
if (wrap)
{
context = wrap->tdb;
tdb_traverse_read(wrap->tdb, MAPIStoreMappingTDBTraverse, mapping);
}
}
newMapping = [[self alloc] initWithIndexing: indexing];
[newMapping autorelease];
@implementation MAPIStoreMapping
+ (id) sharedMapping
{
static id sharedMapping = nil;
if (!sharedMapping)
sharedMapping = [self new];
return sharedMapping;
return newMapping;
}
- (id) init
{
if ((self = [super init]))
{
mapping = [NSMutableDictionary new];
reverseMapping = [NSMutableDictionary new];
indexing = NULL;
}
return self;
}
- (id) initWithIndexing: (struct tdb_wrap *) newIndexing
{
NSNumber *idNbr;
NSString *uri;
NSArray *keys;
NSUInteger count, max;
if ((self = [super init]))
if ((self = [self init]))
{
mapping = [NSMutableDictionary new];
MAPIStoreMappingInitDictionary (mapping);
reverseMapping = [NSMutableDictionary new];
indexing = newIndexing;
tdb_traverse_read (indexing->tdb, MAPIStoreMappingTDBTraverse, mapping);
keys = [mapping allKeys];
max = [keys count];
for (count = 0; count < max; count++)
@@ -144,7 +129,7 @@ MAPIStoreMappingInitDictionary (NSMutableDictionary *mapping)
{
NSNumber *idKey;
uint64_t idNbr;
idKey = [reverseMapping objectForKey: url];
if (idKey)
idNbr = [idKey unsignedLongLongValue];
@@ -159,13 +144,16 @@ MAPIStoreMappingInitDictionary (NSMutableDictionary *mapping)
{
NSNumber *idKey;
BOOL rc;
TDB_DATA key, dbuf;
idKey = [NSNumber numberWithUnsignedLongLong: idNbr];
if ([mapping objectForKey: idKey]
|| [reverseMapping objectForKey: urlString])
{
[self errorWithFormat: @"attempt to double register an entry ('%@', %lld)",
urlString, idNbr];
[self errorWithFormat:
@"attempt to double register an entry ('%@', %lld,"
@" 0x%.16"PRIx64")",
urlString, idNbr, idNbr];
rc = NO;
}
else
@@ -173,8 +161,18 @@ MAPIStoreMappingInitDictionary (NSMutableDictionary *mapping)
[mapping setObject: urlString forKey: idKey];
[reverseMapping setObject: idKey forKey: urlString];
rc = YES;
[self logWithFormat: @"registered url '%@' with id %lld (0x%.8x)",
urlString, idNbr, (uint32_t) idNbr];
[self logWithFormat: @"registered url '%@' with id %lld (0x%.16"PRIx64")",
urlString, idNbr, idNbr];
/* Add the record given its fid and mapistore_uri */
key.dptr = (unsigned char *) talloc_asprintf(NULL, "0x%.16"PRIx64, idNbr);
key.dsize = strlen((const char *) key.dptr);
dbuf.dptr = (unsigned char *) talloc_strdup(NULL, [urlString UTF8String]);
dbuf.dsize = strlen((const char *) dbuf.dptr);
tdb_store (indexing->tdb, key, dbuf, TDB_INSERT);
talloc_free (key.dptr);
talloc_free (dbuf.dptr);
}
return rc;
-8
View File
@@ -26,7 +26,6 @@
#import <SOGo/SOGoObject.h>
#import "MAPIStoreFolder.h"
#import "MAPIStoreMapping.h"
#import "MAPIStoreTypes.h"
#import "NSData+MAPIStore.h"
#import "NSString+MAPIStore.h"
@@ -35,13 +34,6 @@
@implementation MAPIStoreMessageTable
static MAPIStoreMapping *mapping;
+ (void) initialize
{
mapping = [MAPIStoreMapping sharedMapping];
}
- (void) setSortOrder: (const struct SSortOrderSet *) set
{
[self logWithFormat: @"unimplemented method: %@", NSStringFromSelector (_cmd)];
+2 -2
View File
@@ -336,7 +336,7 @@ sogo_op_rmdir(void *private_data, uint64_t parent_fid, uint64_t fid)
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
*/
static int
sogo_op_opendir(void *private_data, uint64_t parent_fid, uint64_t fid)
sogo_op_opendir(void *private_data, uint64_t fid)
{
NSAutoreleasePool *pool;
sogo_context *cContext;
@@ -351,7 +351,7 @@ sogo_op_opendir(void *private_data, uint64_t parent_fid, uint64_t fid)
context = cContext->objcContext;
[context setupRequest];
rc = [context openDir: fid inParentFID: parent_fid];
rc = [context openDir: fid];
[context tearDownRequest];
[pool release];