From 29fcfda1183dbd6c6de6e30d43c9d83004b46380 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 15 Jan 2014 09:36:25 -0500 Subject: [PATCH] Implemented FolderDelete for mail folders --- ActiveSync/SOGoActiveSyncDispatcher.m | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index 8f06b4e67..553e52b8b 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -241,6 +241,66 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [theResponse setContent: d]; } +// +// +// +- (void) processFolderDelete: (id ) theDocumentElement + inResponse: (WOResponse *) theResponse +{ + SOGoMailAccounts *accountsFolder; + SOGoMailFolder *folderToDelete; + SOGoUserFolder *userFolder; + id currentFolder; + NSException *error; + NSString *serverId; + + SOGoMicrosoftActiveSyncFolderType folderType; + + + serverId = [[[(id)[theDocumentElement getElementsByTagName: @"ServerId"] lastObject] textValue] realCollectionIdWithFolderType: &folderType]; + + userFolder = [[context activeUser] homeFolderInContext: context]; + accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO]; + currentFolder = [accountsFolder lookupName: @"0" inContext: context acquire: NO]; + + folderToDelete = [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", serverId] + inContext: context + acquire: NO]; + + error = [folderToDelete delete]; + + if (!error) + { + NSMutableString *s; + NSString *syncKey; + NSData *d; + + // + // We update the FolderSync's synckey + // + syncKey = [[NSProcessInfo processInfo] globallyUniqueString]; + + [self _setFolderSyncKey: syncKey]; + + s = [NSMutableString string]; + [s appendString: @""]; + [s appendString: @""]; + [s appendString: @""]; + [s appendFormat: @"%d", 1]; + [s appendFormat: @"%@", syncKey]; + [s appendString: @""]; + + d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml]; + + [theResponse setContent: d]; + } + else + { + [theResponse setStatus: 500]; + [theResponse appendContentString: @"Unable to delete folder."]; + } +} + // // //