From 93f9a7273e96970106259e4902cf378a425d1322 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 13 Mar 2013 15:04:11 -0400 Subject: [PATCH] Now handle mem context when saving messages and removed useless debugging. --- OpenChange/EOQualifier+MAPI.m | 10 +++++----- OpenChange/MAPIStoreCalendarEmbeddedMessage.m | 5 +++-- OpenChange/MAPIStoreCalendarFolder.m | 2 +- OpenChange/MAPIStoreCalendarMessage.m | 13 ++++++------ OpenChange/MAPIStoreContext.m | 6 +++--- OpenChange/MAPIStoreDBFolder.m | 4 ++-- OpenChange/MAPIStoreDBMessage.m | 2 +- OpenChange/MAPIStoreDBMessageTable.m | 2 +- OpenChange/MAPIStoreEmbeddedMessage.m | 2 +- OpenChange/MAPIStoreFAIMessage.m | 4 ++-- OpenChange/MAPIStoreFolder.m | 20 +++++++++---------- OpenChange/MAPIStoreGCSMessageTable.m | 4 ++-- OpenChange/MAPIStoreMailFolder.m | 6 +++--- OpenChange/MAPIStoreMailMessage.m | 2 +- OpenChange/MAPIStoreMailMessageTable.m | 8 ++++---- OpenChange/MAPIStoreMailVolatileMessage.m | 2 +- OpenChange/MAPIStoreMessage.h | 4 ++-- OpenChange/MAPIStoreMessage.m | 20 +++++++++---------- OpenChange/MAPIStoreSOGo.m | 6 +++--- OpenChange/MAPIStoreTable.m | 14 ++++++------- OpenChange/MAPIStoreTypes.m | 7 ++++--- OpenChange/NSObject+MAPIStore.m | 6 ++---- OpenChange/SOGoMAPIDBObject.m | 8 ++++---- OpenChange/iCalEvent+MAPIStore.h | 6 ++++-- OpenChange/iCalEvent+MAPIStore.m | 11 +++++----- 25 files changed, 89 insertions(+), 85 deletions(-) diff --git a/OpenChange/EOQualifier+MAPI.m b/OpenChange/EOQualifier+MAPI.m index 65e28c6fd..81e77d833 100644 --- a/OpenChange/EOQualifier+MAPI.m +++ b/OpenChange/EOQualifier+MAPI.m @@ -46,12 +46,12 @@ NSDictionary *properties; BOOL rc; - [self logWithFormat: @"evaluating object '%@'", object]; + //[self logWithFormat: @"evaluating object '%@'", object]; properties = [object properties]; rc = [self _evaluateSOGoMAPIDBObject: properties]; - [self logWithFormat: @" evaluation result: %d", rc]; + //[self logWithFormat: @" evaluation result: %d", rc]; return rc; } @@ -150,9 +150,9 @@ typedef BOOL (*EOComparator) (id, SEL, id); rc = ((isZero && (intValue & mask) == 0) || (!isZero && (intValue & mask) != 0)); - [self logWithFormat: @"evaluation of bitmask qualifier:" - @" (%.8x & %.8x) %s 0: %d", - intValue, mask, (isZero ? "==" : "!="), rc]; + //[self logWithFormat: @"evaluation of bitmask qualifier:" + // @" (%.8x & %.8x) %s 0: %d", + // intValue, mask, (isZero ? "==" : "!="), rc]; return rc; } diff --git a/OpenChange/MAPIStoreCalendarEmbeddedMessage.m b/OpenChange/MAPIStoreCalendarEmbeddedMessage.m index 35246c113..ca3ba12d6 100644 --- a/OpenChange/MAPIStoreCalendarEmbeddedMessage.m +++ b/OpenChange/MAPIStoreCalendarEmbeddedMessage.m @@ -161,7 +161,7 @@ return [self getNo: data inMemCtx: memCtx]; } -- (void) save +- (void) save: (TALLOC_CTX *) memCtx { // (gdb) po embeddedMessage->properties // 2442592320 = "2012-07-11 22:30:00 +0000"; @@ -208,7 +208,8 @@ [[container event] updateFromMAPIProperties: properties inUserContext: [self userContext] - withActiveUser: activeUser]; + withActiveUser: activeUser + inMemCtx: memCtx]; } @end diff --git a/OpenChange/MAPIStoreCalendarFolder.m b/OpenChange/MAPIStoreCalendarFolder.m index 5cab28712..8c0830683 100644 --- a/OpenChange/MAPIStoreCalendarFolder.m +++ b/OpenChange/MAPIStoreCalendarFolder.m @@ -63,7 +63,7 @@ SOGoAppointmentObject *newEntry; NSString *name; - [self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; + //[self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; name = [NSString stringWithFormat: @"%@.ics", [SOGoObject globallyUniqueObjectId]]; diff --git a/OpenChange/MAPIStoreCalendarMessage.m b/OpenChange/MAPIStoreCalendarMessage.m index bd6403f4c..de89eb487 100644 --- a/OpenChange/MAPIStoreCalendarMessage.m +++ b/OpenChange/MAPIStoreCalendarMessage.m @@ -200,6 +200,7 @@ static Class NSArrayK; - (void) dealloc { + //NSLog(@"MAPIStoreCalendarMessage: -dealloc (%p)", self); [calendar release]; [super dealloc]; } @@ -417,7 +418,7 @@ static Class NSArrayK; return [self getYes: data inMemCtx: memCtx]; } -- (NSString *) _uidFromGlobalObjectId +- (NSString *) _uidFromGlobalObjectId: (TALLOC_CTX *) memCtx { NSData *objectId; NSString *uid = nil; @@ -431,7 +432,7 @@ static Class NSArrayK; if (objectId) { length = [objectId length]; - bytesDup = talloc_array (NULL, char, length + 1); + bytesDup = talloc_array (memCtx, char, length + 1); memcpy (bytesDup, [objectId bytes], length); bytesDup[length] = 0; uidStart = bytesDup + length - 1; @@ -596,7 +597,7 @@ static Class NSArrayK; } } -- (void) save +- (void) save: (TALLOC_CTX *) memCtx { // iCalCalendar *vCalendar; // NSCalendarDate *now; @@ -608,7 +609,7 @@ static Class NSArrayK; if (isNew) { - uid = [self _uidFromGlobalObjectId]; + uid = [self _uidFromGlobalObjectId: memCtx]; if (uid) { /* Hack required because of what's explained in oxocal 3.1.4.7.1: @@ -650,12 +651,12 @@ static Class NSArrayK; activeUser = [[self context] activeUser]; [masterEvent updateFromMAPIProperties: properties inUserContext: [self userContext] - withActiveUser: activeUser]; + withActiveUser: activeUser + inMemCtx: memCtx]; [self _updateAttachedEvents]; [[self userContext] activateWithUser: activeUser]; [sogoObject updateContentWithCalendar: calendar fromRequest: nil]; - [self updateVersions]; } diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 658bea97d..4f1e67819 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -224,7 +224,7 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri) NSURL *baseURL; int rc = MAPISTORE_ERR_NOT_FOUND; - NSLog (@"METHOD '%s' (%d) -- uri: '%s'", __FUNCTION__, __LINE__, newUri); + //NSLog (@"METHOD '%s' (%d) -- uri: '%s'", __FUNCTION__, __LINE__, newUri); context = nil; @@ -532,8 +532,8 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri) mappingId = [mapping idFromURL: childURL]; if (mappingId == NSNotFound) { - [self warnWithFormat: @"no id exist yet for '%@', requesting one...", - childURL]; + //[self warnWithFormat: @"no id exist yet for '%@', requesting one...", + // childURL]; openchangedb_get_new_folderID (connInfo->oc_ctx, &mappingId); [mapping registerURL: childURL withID: mappingId]; contextId = 0; diff --git a/OpenChange/MAPIStoreDBFolder.m b/OpenChange/MAPIStoreDBFolder.m index d96b81faf..74bf12e2f 100644 --- a/OpenChange/MAPIStoreDBFolder.m +++ b/OpenChange/MAPIStoreDBFolder.m @@ -236,7 +236,7 @@ static NSString *MAPIStoreRightFolderContact = @"RightsFolderContact"; messageKeys = [self messageKeys]; date = [NSCalendarDate date]; - [self logWithFormat: @"current date: %@", date]; + //[self logWithFormat: @"current date: %@", date]; max = [messageKeys count]; for (count = 0; count < max; count++) @@ -245,7 +245,7 @@ static NSString *MAPIStoreRightFolderContact = @"RightsFolderContact"; fileDate = [msg lastModificationTime]; if ([date laterDate: fileDate] == fileDate) { - [self logWithFormat: @"current date: %@", date]; + //[self logWithFormat: @"current date: %@", date]; date = fileDate; } diff --git a/OpenChange/MAPIStoreDBMessage.m b/OpenChange/MAPIStoreDBMessage.m index f794a381b..997f46570 100644 --- a/OpenChange/MAPIStoreDBMessage.m +++ b/OpenChange/MAPIStoreDBMessage.m @@ -135,7 +135,7 @@ [super addProperties: newNewProperties]; } -- (void) save +- (void) save: (TALLOC_CTX *) memCtx { uint64_t newVersion; diff --git a/OpenChange/MAPIStoreDBMessageTable.m b/OpenChange/MAPIStoreDBMessageTable.m index e457b5ac8..de22e238e 100644 --- a/OpenChange/MAPIStoreDBMessageTable.m +++ b/OpenChange/MAPIStoreDBMessageTable.m @@ -65,7 +65,7 @@ static Class MAPIStoreDBMessageK = Nil; cVersion = exchange_globcnt (([value unsignedLongLongValue] >> 16) & 0x0000ffffffffffffLL); version = [NSNumber numberWithUnsignedLongLong: cVersion]; - [self logWithFormat: @"change number from oxcfxics: %.16lx", [value unsignedLongLongValue]]; + //[self logWithFormat: @"change number from oxcfxics: %.16lx", [value unsignedLongLongValue]]; [self logWithFormat: @" version: %.16lx", cVersion]; *qualifier = [[EOKeyValueQualifier alloc] initWithKey: @"version" operatorSelector: EOQualifierOperatorGreaterThanOrEqualTo diff --git a/OpenChange/MAPIStoreEmbeddedMessage.m b/OpenChange/MAPIStoreEmbeddedMessage.m index 562d581de..f609726db 100644 --- a/OpenChange/MAPIStoreEmbeddedMessage.m +++ b/OpenChange/MAPIStoreEmbeddedMessage.m @@ -146,7 +146,7 @@ static Class MAPIStoreAttachmentK; return ULLONG_MAX; } -- (void) save +- (void) save: (TALLOC_CTX *) memCtx { [self subclassResponsibility: _cmd]; } diff --git a/OpenChange/MAPIStoreFAIMessage.m b/OpenChange/MAPIStoreFAIMessage.m index 99ab23c85..bfa093ff7 100644 --- a/OpenChange/MAPIStoreFAIMessage.m +++ b/OpenChange/MAPIStoreFAIMessage.m @@ -51,7 +51,7 @@ return [self getYes: data inMemCtx: memCtx]; } -- (enum mapistore_error) saveMessage +- (enum mapistore_error) saveMessage: (TALLOC_CTX *) memCtx; { enum mapistore_error rc; MAPIStoreContext *context; @@ -60,7 +60,7 @@ context = [self context]; ownerUser = [[self userContext] sogoUser]; if ([[context activeUser] isEqual: ownerUser]) - rc = [super saveMessage]; + rc = [super saveMessage: memCtx]; else rc = MAPISTORE_ERR_DENIED; diff --git a/OpenChange/MAPIStoreFolder.m b/OpenChange/MAPIStoreFolder.m index ebb011013..2e54838b3 100644 --- a/OpenChange/MAPIStoreFolder.m +++ b/OpenChange/MAPIStoreFolder.m @@ -180,7 +180,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe - (void) dealloc { - [self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; + //[self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; // [messageKeys release]; // [faiMessageKeys release]; @@ -366,7 +366,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe MAPIStoreMapping *mapping; NSString *childURL; - [self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; + //[self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; mapping = [self mapping]; childURL = [mapping urlFromID: fid]; @@ -393,7 +393,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe MAPIStoreFolder *childFolder; SOGoUser *ownerUser; - [self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; + //[self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; ownerUser = [[self userContext] sogoUser]; if ([[context activeUser] isEqual: ownerUser] @@ -450,8 +450,8 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe NSArray *keys; int rc = MAPISTORE_SUCCESS; - [self logWithFormat: @"METHOD '%s' (%d) -- tableType: %d", - __FUNCTION__, __LINE__, tableType]; + //[self logWithFormat: @"METHOD '%s' (%d) -- tableType: %d", + //__FUNCTION__, __LINE__, tableType]; if (tableType == MAPISTORE_MESSAGE_TABLE) keys = [self messageKeys]; @@ -513,8 +513,8 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe MAPIStoreMapping *mapping; SOGoUser *ownerUser; - [self logWithFormat: @"METHOD '%s' -- mid: 0x%.16llx associated: %d", - __FUNCTION__, mid, isAssociated]; + //[self logWithFormat: @"METHOD '%s' -- mid: 0x%.16llx associated: %d", + // __FUNCTION__, mid, isAssociated]; context = [self context]; ownerUser = [[self userContext] sogoUser]; @@ -699,7 +699,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe if (rc != MAPISTORE_SUCCESS) goto end; } - [destMsg save]; + [destMsg save: memCtx]; if (!wantCopy) rc = [sourceFolder deleteMessageWithMID: srcMid andFlags: 0]; @@ -844,7 +844,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe [mapping registerURL: [targetMessage url] withID: fmid]; } - [targetMessage save]; + [targetMessage save: memCtx]; } [pool release]; @@ -865,7 +865,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe [mapping registerURL: [targetMessage url] withID: fmid]; } - [targetMessage save]; + [targetMessage save: memCtx]; } [pool release]; diff --git a/OpenChange/MAPIStoreGCSMessageTable.m b/OpenChange/MAPIStoreGCSMessageTable.m index 74d9d3151..e6da41039 100644 --- a/OpenChange/MAPIStoreGCSMessageTable.m +++ b/OpenChange/MAPIStoreGCSMessageTable.m @@ -92,8 +92,8 @@ value = NSObjectFromMAPISPropValue (&res->lpProp); lastModified = [(MAPIStoreGCSFolder *) container lastModifiedFromMessageChangeNumber: value]; - [self logWithFormat: @"change number from oxcfxics: %.16lx", [value unsignedLongLongValue]]; - [self logWithFormat: @" c_lastmodified: %@", lastModified]; + //[self logWithFormat: @"change number from oxcfxics: %.16lx", [value unsignedLongLongValue]]; + //[self logWithFormat: @" c_lastmodified: %@", lastModified]; if (lastModified) { *qualifier = [[EOKeyValueQualifier alloc] initWithKey: @"c_lastmodified" diff --git a/OpenChange/MAPIStoreMailFolder.m b/OpenChange/MAPIStoreMailFolder.m index e0be222b9..f06508962 100644 --- a/OpenChange/MAPIStoreMailFolder.m +++ b/OpenChange/MAPIStoreMailFolder.m @@ -390,7 +390,7 @@ static Class SOGoMailFolderK, MAPIStoreMailFolderK, MAPIStoreOutboxFolderK; else value = [NSDate date]; - [self logWithFormat: @"lastMessageModificationTime: %@", value]; + //[self logWithFormat: @"lastMessageModificationTime: %@", value]; return value; } @@ -613,8 +613,8 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) [messageEntry setObject: modseq forKey: @"modseq"]; [messageEntry setObject: changeNumber forKey: @"version"]; - [self logWithFormat: @"added message entry for uid %@, modseq %@," - @" version %@", uid, modseq, changeNumber]; + //[self logWithFormat: @"added message entry for uid %@, modseq %@," + // @" version %@", uid, modseq, changeNumber]; changeKey = [self getReplicaKeyFromGlobCnt: newChangeNum >> 16]; [self _setChangeKey: changeKey forMessageEntry: messageEntry]; diff --git a/OpenChange/MAPIStoreMailMessage.m b/OpenChange/MAPIStoreMailMessage.m index d49cc0572..476ddbac6 100644 --- a/OpenChange/MAPIStoreMailMessage.m +++ b/OpenChange/MAPIStoreMailMessage.m @@ -1576,7 +1576,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data) bodySetup = YES; } -- (void) save +- (void) save: (TALLOC_CTX *) memCtx { NSNumber *value; diff --git a/OpenChange/MAPIStoreMailMessageTable.m b/OpenChange/MAPIStoreMailMessageTable.m index eb40f6739..c13605829 100644 --- a/OpenChange/MAPIStoreMailMessageTable.m +++ b/OpenChange/MAPIStoreMailMessageTable.m @@ -120,7 +120,7 @@ static Class MAPIStoreMailMessageK, NSDataK, NSStringK; case PidLidAppointmentStartWhole: case PidLidAppointmentEndWhole: case PidLidRecurring: - [self logWithFormat: @"apt restriction on mail folder?"]; + //[self logWithFormat: @"apt restriction on mail folder?"]; rc = MAPIRestrictionStateAlwaysFalse; break; @@ -158,8 +158,8 @@ static Class MAPIStoreMailMessageK, NSDataK, NSStringK; value = [NSString stringWithFormat: @"0x%.16llx", [value unsignedLongLongValue]]; modseq = [(MAPIStoreMailFolder *) container modseqFromMessageChangeNumber: value]; - [self logWithFormat: @"change number from oxcfxics: %.16lx", [value unsignedLongLongValue]]; - [self logWithFormat: @" modseq: %.16lx", [modseq unsignedLongLongValue]]; + //[self logWithFormat: @"change number from oxcfxics: %.16lx", [value unsignedLongLongValue]]; + //[self logWithFormat: @" modseq: %.16lx", [modseq unsignedLongLongValue]]; if (modseq) modseq = [NSNumber numberWithUnsignedLongLong: [modseq unsignedLongLongValue] + 1]; @@ -317,7 +317,7 @@ static Class MAPIStoreMailMessageK, NSDataK, NSStringK; ASSIGN (sortOrderings, newSortOrderings); else ASSIGN (sortOrderings, [NSArray arrayWithObject: @"ARRIVAL"]); - [self logWithFormat: @"new sort orderings: '%@'", sortOrderings]; + //[self logWithFormat: @"new sort orderings: '%@'", sortOrderings]; } else ASSIGN (sortOrderings, [NSArray arrayWithObject: @"ARRIVAL"]); diff --git a/OpenChange/MAPIStoreMailVolatileMessage.m b/OpenChange/MAPIStoreMailVolatileMessage.m index 9193794dd..c8044d65f 100644 --- a/OpenChange/MAPIStoreMailVolatileMessage.m +++ b/OpenChange/MAPIStoreMailVolatileMessage.m @@ -904,7 +904,7 @@ MakeMessageBody (NSDictionary *mailProperties, NSDictionary *attachmentParts, NS return MAPISTORE_SUCCESS; } -- (void) save +- (void) save: (TALLOC_CTX *) memCtx { NSString *folderName, *flag, *newIdString, *messageKey; NSData *changeKey, *messageData; diff --git a/OpenChange/MAPIStoreMessage.h b/OpenChange/MAPIStoreMessage.h index 06ca45436..6fa42218c 100644 --- a/OpenChange/MAPIStoreMessage.h +++ b/OpenChange/MAPIStoreMessage.h @@ -64,7 +64,7 @@ - (int) getAttachmentTable: (MAPIStoreAttachmentTable **) tablePtr andRowCount: (uint32_t *) countPtr; - (int) setReadFlag: (uint8_t) flag; -- (enum mapistore_error) saveMessage; +- (enum mapistore_error) saveMessage: (TALLOC_CTX *) memCtx; - (NSArray *) activeContainerMessageTables; @@ -74,7 +74,7 @@ - (void) copyToMessage: (MAPIStoreMessage *) newMessage inMemCtx: (TALLOC_CTX *) memCtx; /* subclasses */ -- (void) save; +- (void) save: (TALLOC_CTX *) memCtx; /* attachments (subclasses) */ - (MAPIStoreAttachment *) createAttachment; diff --git a/OpenChange/MAPIStoreMessage.m b/OpenChange/MAPIStoreMessage.m index 0751c993d..0706432ab 100644 --- a/OpenChange/MAPIStoreMessage.m +++ b/OpenChange/MAPIStoreMessage.m @@ -139,7 +139,7 @@ rtf2html (NSData *compressedRTF) - (id) init { - [self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self]; + //[self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self]; if ((self = [super init])) { @@ -153,7 +153,7 @@ rtf2html (NSData *compressedRTF) - (void) dealloc { - [self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self]; + //[self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self]; [activeUserRoles release]; [attachmentKeys release]; [attachmentParts release]; @@ -260,7 +260,7 @@ rtf2html (NSData *compressedRTF) struct mapistore_message_recipient *recipient; NSUInteger count; - [self logWithFormat: @"METHOD '%s'", __FUNCTION__]; + //[self logWithFormat: @"METHOD '%s'", __FUNCTION__]; recipients = [NSMutableDictionary new]; recipientProperties = [NSDictionary dictionaryWithObject: recipients @@ -450,7 +450,7 @@ rtf2html (NSData *compressedRTF) NSString *key; MAPIStoreAttachment *attachment, *newAttachment; - [self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self]; + //[self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self]; //memCtx = talloc_zero (NULL, TALLOC_CTX); @@ -477,7 +477,7 @@ rtf2html (NSData *compressedRTF) //talloc_free (memCtx); } -- (enum mapistore_error) saveMessage +- (enum mapistore_error) saveMessage: (TALLOC_CTX *) memCtx { enum mapistore_error rc; NSArray *containerTables; @@ -490,7 +490,7 @@ rtf2html (NSData *compressedRTF) BOOL userIsOwner; MAPIStoreMessage *mainMessage; - [self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; + //[self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__]; context = [self context]; ownerUser = [[self userContext] sogoUser]; @@ -518,7 +518,7 @@ rtf2html (NSData *compressedRTF) /* folder modified */ notif_parameters - = talloc_zero(NULL, struct mapistore_object_notification_parameters); + = talloc_zero(memCtx, struct mapistore_object_notification_parameters); notif_parameters->object_id = folderId; if (isNew) { @@ -542,7 +542,7 @@ rtf2html (NSData *compressedRTF) if (isNew) { notif_parameters - = talloc_zero(NULL, + = talloc_zero(memCtx, struct mapistore_object_notification_parameters); notif_parameters->object_id = [self objectId]; notif_parameters->folder_id = folderId; @@ -562,7 +562,7 @@ rtf2html (NSData *compressedRTF) [[containerTables objectAtIndex: count] restrictedChildKeys]; } - [self save]; + [self save: memCtx]; /* We make sure that any change-related properties are removes from the properties dictionary, to make sure that related methods will be invoked the next time they are requested. */ @@ -937,7 +937,7 @@ rtf2html (NSData *compressedRTF) return MAPISTORE_ERROR; } -- (void) save +- (void) save: (TALLOC_CTX *) memCtx { [self subclassResponsibility: _cmd]; } diff --git a/OpenChange/MAPIStoreSOGo.m b/OpenChange/MAPIStoreSOGo.m index 399a215c7..720635975 100644 --- a/OpenChange/MAPIStoreSOGo.m +++ b/OpenChange/MAPIStoreSOGo.m @@ -68,7 +68,7 @@ sogo_backend_atexit (void) GSRegisterCurrentThread (); pool = [NSAutoreleasePool new]; - NSLog (@"allocated classes:\n%s", GSDebugAllocationList (YES)); + //NSLog (@"allocated classes:\n%s", GSDebugAllocationList (YES)); [pool release]; GSUnregisterCurrentThread (); } @@ -1024,7 +1024,7 @@ sogo_message_set_read_flag (void *message_object, uint8_t flag) } static enum mapistore_error -sogo_message_save (void *message_object) +sogo_message_save (void *message_object, TALLOC_CTX *mem_ctx) { struct MAPIStoreTallocWrapper *wrapper; NSAutoreleasePool *pool; @@ -1039,7 +1039,7 @@ sogo_message_save (void *message_object) message = wrapper->instance; GSRegisterCurrentThread (); pool = [NSAutoreleasePool new]; - rc = [message saveMessage]; + rc = [message saveMessage: mem_ctx]; // [context tearDownRequest]; [pool release]; GSUnregisterCurrentThread (); diff --git a/OpenChange/MAPIStoreTable.m b/OpenChange/MAPIStoreTable.m index cf34f1fe9..842fa3afc 100644 --- a/OpenChange/MAPIStoreTable.m +++ b/OpenChange/MAPIStoreTable.m @@ -375,12 +375,12 @@ static Class NSDataK, NSStringK; - (void) setRestrictions: (const struct mapi_SRestriction *) res { - EOQualifier *oldRestriction; + //EOQualifier *oldRestriction; // [self logWithFormat: @"set restriction to (table type: %d): %@", // type, MAPIStringForRestriction (res)]; - oldRestriction = restriction; + //oldRestriction = restriction; [restriction autorelease]; if (res) restrictionState = [self evaluateRestriction: res @@ -396,11 +396,11 @@ static Class NSDataK, NSStringK; // FIXME: we should not flush the caches if the restrictions matches [self cleanupCaches]; - if (restriction) - [self logWithFormat: @"restriction set to EOQualifier: %@", - restriction]; - else if (oldRestriction) - [self logWithFormat: @"restriction unset (was %@)", oldRestriction]; + //if (restriction) + // [self logWithFormat: @"restriction set to EOQualifier: %@", +// restriction]; + // else if (oldRestriction) + // [self logWithFormat: @"restriction unset (was %@)", oldRestriction]; } - (MAPIRestrictionState) evaluateNotRestriction: (struct mapi_SNotRestriction *) res diff --git a/OpenChange/MAPIStoreTypes.m b/OpenChange/MAPIStoreTypes.m index 8903eba73..f8e32c824 100644 --- a/OpenChange/MAPIStoreTypes.m +++ b/OpenChange/MAPIStoreTypes.m @@ -342,7 +342,8 @@ MAPIStoreDumpMessageProperties (NSDictionary *properties) { NSNumber *key; NSArray *allKeys; - NSUInteger keyAsInt, count, max; + NSUInteger count, max; + NSUInteger keyAsInt; id value; allKeys = [properties allKeys]; @@ -351,7 +352,7 @@ MAPIStoreDumpMessageProperties (NSDictionary *properties) NSLog (@"message properties (%d):", max); value = [properties objectForKey: @"recipients"]; - if (value) + if (value) NSLog (@" recipients: %@", value); for (count = 0; count < max; count++) @@ -363,7 +364,7 @@ MAPIStoreDumpMessageProperties (NSDictionary *properties) value = [properties objectForKey: key]; NSLog (@" 0x%.4x: %@ (%@)", keyAsInt, value, - NSStringFromClass ([value class])); + NSStringFromClass ([value class])); } } } diff --git a/OpenChange/NSObject+MAPIStore.m b/OpenChange/NSObject+MAPIStore.m index 958fb9208..e02f29f07 100644 --- a/OpenChange/NSObject+MAPIStore.m +++ b/OpenChange/NSObject+MAPIStore.m @@ -50,8 +50,7 @@ MAPIStoreTallocWrapperDestroy (void *data) GSRegisterCurrentThread (); pool = [NSAutoreleasePool new]; wrapper = data; - //NSLog (@"destroying wrapped object (wrapper: %p; object: %p)...\n", wrapper, wrapper->MAPIStoreSOGoObject); - NSLog (@"destroying wrapped object (wrapper: %p)", wrapper); + //NSLog (@"destroying wrapped object (wrapper: %p; object: %p (%@))...\n", wrapper, wrapper->instance, NSStringFromClass([wrapper->instance class])); [wrapper->instance release]; [pool release]; GSUnregisterCurrentThread (); @@ -67,8 +66,7 @@ MAPIStoreTallocWrapperDestroy (void *data) talloc_set_destructor ((void *) wrapper, MAPIStoreTallocWrapperDestroy); wrapper->instance = self; [self retain]; - NSLog (@"returning wrapper: %p; object: %p", wrapper, self); - + //NSLog (@"returning wrapper: %p; object: %p (%@)", wrapper, self, NSStringFromClass([self class])); return wrapper; } diff --git a/OpenChange/SOGoMAPIDBObject.m b/OpenChange/SOGoMAPIDBObject.m index 94b6f975e..6407fbda3 100644 --- a/OpenChange/SOGoMAPIDBObject.m +++ b/OpenChange/SOGoMAPIDBObject.m @@ -251,13 +251,13 @@ static EOAttribute *textColumn = nil; className = @"MAPIStoreNotesMessage"; else className = @"MAPIStoreDBMessage"; - [self logWithFormat: @"PidTagMessageClass = '%@', returning '%@'", - mapiMsgClass, className]; + //[self logWithFormat: @"PidTagMessageClass = '%@', returning '%@'", + // mapiMsgClass, className]; } else { - [self warnWithFormat: @"PidTagMessageClass is not set, falling back" - @" to 'MAPIStoreDBMessage'"]; + //[self warnWithFormat: @"PidTagMessageClass is not set, falling back" + // @" to 'MAPIStoreDBMessage'"]; className = @"MAPIStoreDBMessage"; } break; diff --git a/OpenChange/iCalEvent+MAPIStore.h b/OpenChange/iCalEvent+MAPIStore.h index 171813e2b..198526687 100644 --- a/OpenChange/iCalEvent+MAPIStore.h +++ b/OpenChange/iCalEvent+MAPIStore.h @@ -23,6 +23,8 @@ #ifndef ICALEVENT_MAPISTORE_H #define ICALEVENT_MAPISTORE_H +#include + #import @class MAPIStoreUserContext; @@ -34,8 +36,8 @@ - (void) updateFromMAPIProperties: (NSDictionary *) properties inUserContext: (MAPIStoreUserContext *) userContext - withActiveUser: (SOGoUser *) activeUser; - + withActiveUser: (SOGoUser *) activeUser + inMemCtx: (TALLOC_CTX *) memCtx; @end #endif /* ICALEVENT_MAPISTORE_H */ diff --git a/OpenChange/iCalEvent+MAPIStore.m b/OpenChange/iCalEvent+MAPIStore.m index 84ddddd7d..4d64a7ac7 100644 --- a/OpenChange/iCalEvent+MAPIStore.m +++ b/OpenChange/iCalEvent+MAPIStore.m @@ -20,7 +20,6 @@ * Boston, MA 02111-1307, USA. */ -#include #include #import @@ -75,16 +74,17 @@ @implementation iCalEvent (MAPIStoreProperties) - (void) _setupEventRecurrence: (NSData *) mapiRecurrenceData + inMemCtx: (TALLOC_CTX *) memCtx { struct Binary_r *blob; struct AppointmentRecurrencePattern *pattern; - blob = [mapiRecurrenceData asBinaryInMemCtx: NULL]; - pattern = get_AppointmentRecurrencePattern (blob, blob); + blob = [mapiRecurrenceData asBinaryInMemCtx: memCtx]; + pattern = get_AppointmentRecurrencePattern (memCtx, blob); [(iCalCalendar *) parent setupRecurrenceWithMasterEntity: self fromRecurrencePattern: &pattern->RecurrencePattern]; - talloc_free (blob); + //talloc_free (blob); } - (void) _setupEventAlarmFromProperties: (NSDictionary *) properties @@ -134,6 +134,7 @@ - (void) updateFromMAPIProperties: (NSDictionary *) properties inUserContext: (MAPIStoreUserContext *) userContext withActiveUser: (SOGoUser *) activeUser + inMemCtx: (TALLOC_CTX *) memCtx { BOOL isAllDay; iCalDateTime *start, *end; @@ -328,7 +329,7 @@ value = [properties objectForKey: MAPIPropertyKey (PidLidAppointmentRecur)]; if (value) - [self _setupEventRecurrence: value]; + [self _setupEventRecurrence: value inMemCtx: memCtx]; /* alarm */ [self _setupEventAlarmFromProperties: properties];