From a5b387cfebe91d9df12343315535b9cbc380c4c9 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 3 Feb 2011 22:39:02 +0000 Subject: [PATCH] Monotone-Parent: 48706c943fa3ceb72288194c22bfec223fb4a890 Monotone-Revision: cf82a6c633ed0ff127f0f681583035b3bcc35b77 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-02-03T22:39:02 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 +++ OpenChange/MAPIStoreContext.h | 1 + OpenChange/MAPIStoreContext.m | 124 ++++++++++++++++++++++++---------- OpenChange/MAPIStoreSOGo.m | 3 +- 4 files changed, 101 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 303eb444d..bdc553a64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,8 +3,16 @@ * OpenChange/MAPIStoreMapping.m (-unregisterURLWithID:): new method for removing entries from the mapping dictionaries. + * OpenChange/MAPIStoreContext.m + (-deleteMessageWithMID:inFID:withFlags:): implemented backend method. + 2011-02-03 Wolfgang Sourdeau + * OpenChange/MAPIStoreContext.m + (_saveOrSubmitChangesInMessageWithMID:andFlags:save:): silently + ignore "IPM.Schedule.Meeting.Request" messages from Outlook + and return a success code. + * SoObjects/SOGo/WOResourceManager+SOGo.m: new category module defining methods useful to the vanilla and OpenChange frontends. (-localeForLanguageNamed:): method moved from SOGo.m. diff --git a/OpenChange/MAPIStoreContext.h b/OpenChange/MAPIStoreContext.h index b3b0f9517..13eb25f67 100644 --- a/OpenChange/MAPIStoreContext.h +++ b/OpenChange/MAPIStoreContext.h @@ -142,6 +142,7 @@ inRows: (struct ModifyRecipientRow *) rows withCount: (NSUInteger) max; - (int) deleteMessageWithMID: (uint64_t) mid + inFID: (uint64_t) fid withFlags: (uint8_t) flags; - (int) releaseRecordWithFMID: (uint64_t) fmid ofTableType: (uint8_t) tableType; diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 016a0dca5..0a6d42318 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -965,39 +965,50 @@ _prepareContextClass (struct mapistore_context *newMemCtx, [NSNumber numberWithUnsignedLongLong: mid]]; if (messageProperties) { - messageURL = [mapping urlFromID: mid]; - associated = [[messageProperties objectForKey: @"associated"] boolValue]; - if (messageURL) + if ([[messageProperties + objectForKey: MAPIPropertyKey (PR_MESSAGE_CLASS_UNICODE)] + isEqualToString: @"IPM.Schedule.Meeting.Request"]) { - if (associated) - message = [self lookupFAIObject: messageURL]; - else - message = [self lookupObject: messageURL]; - } - else - { - fid = [[messageProperties objectForKey: @"fid"] - unsignedLongLongValue]; - message = [self _createMessageOfClass: [messageProperties objectForKey: MAPIPropertyKey (PR_MESSAGE_CLASS_UNICODE)] - associated: associated - withMID: mid inFID: fid]; - } - if (message) - { - if (associated) - [faiTable cleanupCaches]; - else - [messageTable cleanupCaches]; - - [message setMAPIProperties: messageProperties]; - if (isSave) - [message MAPISave]; - else - [message MAPISubmit]; + /* We silently discard invitation emails since this is already + handled internally by SOGo. */ rc = MAPISTORE_SUCCESS; } else - rc = MAPISTORE_ERROR; + { + messageURL = [mapping urlFromID: mid]; + associated = [[messageProperties objectForKey: @"associated"] boolValue]; + if (messageURL) + { + if (associated) + message = [self lookupFAIObject: messageURL]; + else + message = [self lookupObject: messageURL]; + } + else + { + fid = [[messageProperties objectForKey: @"fid"] + unsignedLongLongValue]; + message = [self _createMessageOfClass: [messageProperties objectForKey: MAPIPropertyKey (PR_MESSAGE_CLASS_UNICODE)] + associated: associated + withMID: mid inFID: fid]; + } + if (message) + { + if (associated) + [faiTable cleanupCaches]; + else + [messageTable cleanupCaches]; + + [message setMAPIProperties: messageProperties]; + if (isSave) + [message MAPISave]; + else + [message MAPISubmit]; + rc = MAPISTORE_SUCCESS; + } + else + rc = MAPISTORE_ERROR; + } } else rc = MAPISTORE_ERR_NOT_FOUND; @@ -1394,8 +1405,9 @@ _prepareContextClass (struct mapistore_context *newMemCtx, for (count = 0; count < max; count++) { currentRow = rows + count; - if (currentRow->RecipClass >= 0 - && currentRow->RecipClass < 3) + + if (currentRow->RecipClass >= MAPI_ORIG + && currentRow->RecipClass < MAPI_BCC) { recType = recTypes[currentRow->RecipClass]; list = [recipients objectForKey: recType]; @@ -1418,12 +1430,56 @@ _prepareContextClass (struct mapistore_context *newMemCtx, } - (int) deleteMessageWithMID: (uint64_t) mid + inFID: (uint64_t) fid withFlags: (uint8_t) flags { - [self logWithFormat: @"UNIMPLEMENTED METHOD '%s' (%d)", __FUNCTION__, __LINE__]; - [self logWithFormat: @" mid: 0x%.16x flags: %d", mid, flags]; + NSString *childURL, *childKey; + MAPIStoreTable *table; + id message; + int rc; - return MAPISTORE_ERROR; + [self logWithFormat: @"-deleteMessageWithMID: mid: 0x%.16x flags: %d", mid, flags]; + + childURL = [mapping urlFromID: mid]; + if (childURL) + { + [self logWithFormat: @"-deleteMessageWithMID: url (%@) found for object", childURL]; + + childKey = [self extractChildNameFromURL: childURL + andFolderURLAt: NULL]; + table = [self _tableForFID: fid andTableType: MAPISTORE_FAI_TABLE]; + if ([[table cachedChildKeys] containsObject: childKey]) + message = [self lookupFAIObject: childURL]; + else + { + table = [self _tableForFID: fid andTableType: MAPISTORE_MESSAGE_TABLE]; + if ([[table cachedChildKeys] containsObject: childKey]) + message = [self lookupObject: childURL]; + else + message = nil; + } + + if (message) + { + if ([message delete]) + { + rc = MAPISTORE_ERROR; + [self logWithFormat: @"ERROR deleting object at URL: %@", childURL]; + } + else + { + [self logWithFormat: @"sucessfully deleted object at URL: %@", childURL]; + [mapping unregisterURLWithID: mid]; + rc = MAPISTORE_SUCCESS; + } + } + else + rc = MAPI_E_INVALID_OBJECT; + } + else + rc = MAPISTORE_ERR_NOT_FOUND; + + return rc; } - (int) releaseRecordWithFMID: (uint64_t) fmid diff --git a/OpenChange/MAPIStoreSOGo.m b/OpenChange/MAPIStoreSOGo.m index 479d9da2f..da5237f90 100644 --- a/OpenChange/MAPIStoreSOGo.m +++ b/OpenChange/MAPIStoreSOGo.m @@ -713,6 +713,7 @@ sogo_op_modifyrecipients(void *private_data, static int sogo_op_deletemessage(void *private_data, + uint64_t fid, uint64_t mid, uint8_t flags) { @@ -729,7 +730,7 @@ sogo_op_deletemessage(void *private_data, context = cContext->objcContext; [context setupRequest]; - rc = [context deleteMessageWithMID: mid withFlags: flags]; + rc = [context deleteMessageWithMID: mid inFID: fid withFlags: flags]; [context tearDownRequest]; [pool release];