Monotone-Parent: 3f8608c82d9c379cc9e0fea6ffe853cc1949a24b

Monotone-Revision: 905276f295d6f28a6946297f6a7af9ad60f71842

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-06-29T17:59:38
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2012-06-29 17:59:38 +00:00
parent 591306481b
commit 95a443d89a
67 changed files with 2606 additions and 1873 deletions

View File

@@ -58,13 +58,11 @@ static Class NSExceptionK, MAPIStoreFolderK;
MAPIStoreFolderK = [MAPIStoreFolder class];
}
+ (id) mapiStoreObjectWithSOGoObject: (id) newSOGoObject
inContainer: (MAPIStoreObject *) newContainer
+ (id) mapiStoreObjectInContainer: (MAPIStoreObject *) newContainer
{
id newObject;
newObject = [[self alloc] initWithSOGoObject: newSOGoObject
inContainer: newContainer];
newObject = [[self alloc] initInContainer: newContainer];
[newObject autorelease];
return newObject;
@@ -106,22 +104,18 @@ static Class NSExceptionK, MAPIStoreFolderK;
classGetters = (IMP *) MAPIStorePropertyGettersForClass (isa);
parentContainersBag = [NSMutableArray new];
container = nil;
sogoObject = nil;
properties = [NSMutableDictionary new];
isNew = NO;
}
[self logWithFormat: @"-init"];
// [self logWithFormat: @"-init"];
return self;
}
- (id) initWithSOGoObject: (id) newSOGoObject
inContainer: (MAPIStoreObject *) newContainer
- (id) initInContainer: (MAPIStoreObject *) newContainer
{
if ((self = [self init]))
{
ASSIGN (sogoObject, newSOGoObject);
ASSIGN (container, newContainer);
}
@@ -130,42 +124,21 @@ static Class NSExceptionK, MAPIStoreFolderK;
- (void) dealloc
{
[self logWithFormat: @"-dealloc"];
[sogoObject release];
// [self logWithFormat: @"-dealloc"];
[properties release];
[parentContainersBag release];
[container release];
[super dealloc];
}
- (void) setIsNew: (BOOL) newIsNew
{
isNew = newIsNew;
}
- (BOOL) isNew
{
return isNew;
}
- (id) sogoObject
{
return sogoObject;
}
- (MAPIStoreObject *) container
{
return container;
}
- (NSString *) nameInContainer
{
return [sogoObject nameInContainer];
}
- (MAPIStoreContext *) context
{
return [container context];
return (MAPIStoreContext *) [container context];
}
- (MAPIStoreUserContext *) userContext
@@ -178,47 +151,14 @@ static Class NSExceptionK, MAPIStoreFolderK;
return [[self userContext] mapping];
}
- (void) cleanupCaches
{
}
/* helpers */
- (uint64_t) objectId
{
uint64_t objectId;
if ([container isKindOfClass: MAPIStoreFolderK])
objectId = [(MAPIStoreFolder *) container
idForObjectWithKey: [sogoObject nameInContainer]];
else
{
[self errorWithFormat: @"%s: container is not a folder", __PRETTY_FUNCTION__];
objectId = (uint64_t) -1;
}
return objectId;
}
- (NSString *) url
{
NSString *containerURL, *format;
containerURL = [container url];
if ([containerURL hasSuffix: @"/"])
format = @"%@%@";
else
format = @"%@/%@";
return [NSString stringWithFormat: format,
containerURL, [self nameInContainer]];
}
- (void) addProperties: (NSDictionary *) newNewProperties
{
[properties addEntriesFromDictionary: newNewProperties];
}
- (NSDictionary *) properties
- (NSMutableDictionary *) properties
{
return properties;
}
@@ -248,124 +188,8 @@ static Class NSExceptionK, MAPIStoreFolderK;
return rc;
}
/* helper getters */
- (NSData *) getReplicaKeyFromGlobCnt: (uint64_t) objectCnt
{
struct mapistore_connection_info *connInfo;
NSMutableData *replicaKey;
char buffer[6];
NSUInteger count;
connInfo = [[self context] connectionInfo];
for (count = 0; count < 6; count++)
{
buffer[count] = objectCnt & 0xff;
objectCnt >>= 8;
}
replicaKey = [NSMutableData dataWithCapacity: 22];
[replicaKey appendBytes: &connInfo->replica_guid
length: sizeof (struct GUID)];
[replicaKey appendBytes: buffer length: 6];
return replicaKey;
}
- (int) getReplicaKey: (void **) data
fromGlobCnt: (uint64_t) objectCnt
inMemCtx: (TALLOC_CTX *) memCtx
{
*data = [[self getReplicaKeyFromGlobCnt: objectCnt] asBinaryInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
}
/* getters */
- (int) getPidTagDisplayName: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
*data = [[sogoObject displayName] asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
}
- (int) getPidTagSearchKey: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
NSString *stringValue;
stringValue = [sogoObject nameInContainer];
*data = [[stringValue dataUsingEncoding: NSASCIIStringEncoding]
asBinaryInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
}
- (int) getPidTagGenerateExchangeViews: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
return [self getNo: data inMemCtx: memCtx];
}
- (int) getPidTagParentSourceKey: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
return [self getReplicaKey: data fromGlobCnt: [container objectId] >> 16
inMemCtx: memCtx];
}
- (int) getPidTagSourceKey: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
return [self getReplicaKey: data fromGlobCnt: [self objectId] >> 16
inMemCtx: memCtx];
}
- (uint64_t) objectVersion
{
[self subclassResponsibility: _cmd];
return ULLONG_MAX;
}
- (int) getPidTagChangeKey: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
int rc;
uint64_t obVersion;
obVersion = [self objectVersion];
if (obVersion == ULLONG_MAX)
rc = MAPISTORE_ERR_NOT_FOUND;
else
rc = [self getReplicaKey: data fromGlobCnt: obVersion
inMemCtx: memCtx];
return rc;
}
- (int) getPidTagChangeNumber: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
int rc;
uint64_t obVersion;
obVersion = [self objectVersion];
if (obVersion == ULLONG_MAX)
rc = MAPISTORE_ERR_NOT_FOUND;
else
{
*data = MAPILongLongValue (memCtx, ((obVersion << 16)
| 0x0001));
rc = MAPISTORE_SUCCESS;
}
return rc;
}
- (int) getPidTagCreationTime: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
inMemCtx: (TALLOC_CTX *) memCtx
{
*data = [[self creationTime] asFileTimeInMemCtx: memCtx];
@@ -474,6 +298,38 @@ static Class NSExceptionK, MAPIStoreFolderK;
return MAPISTORE_SUCCESS;
}
- (NSData *) getReplicaKeyFromGlobCnt: (uint64_t) objectCnt
{
struct mapistore_connection_info *connInfo;
NSMutableData *replicaKey;
char buffer[6];
NSUInteger count;
connInfo = [[self context] connectionInfo];
for (count = 0; count < 6; count++)
{
buffer[count] = objectCnt & 0xff;
objectCnt >>= 8;
}
replicaKey = [NSMutableData dataWithCapacity: 22];
[replicaKey appendBytes: &connInfo->replica_guid
length: sizeof (struct GUID)];
[replicaKey appendBytes: buffer length: 6];
return replicaKey;
}
- (int) getReplicaKey: (void **) data
fromGlobCnt: (uint64_t) objectCnt
inMemCtx: (TALLOC_CTX *) memCtx
{
*data = [[self getReplicaKeyFromGlobCnt: objectCnt] asBinaryInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
}
/* subclasses */
- (NSDate *) creationTime
{