diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index b0056830b..3852941bd 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2014 Inverse inc. + Copyright (C) 2009-2017 Inverse inc. Copyright (C) 2004-2005 SKYRIX Software AG This file is part of SOGo. @@ -295,15 +295,15 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) return filenames; } -- (NSException *) renameTo: (NSString *) newName +- (NSException *) renameTo: (NSString *) theNewName { NSException *error; SOGoMailFolder *inbox; NSURL *destURL; - NSString *path; + NSString *path, *newName; NGImap4Client *client; - if ([newName length] > 0) + if ([theNewName length] > 0) { [self imap4URL]; @@ -318,17 +318,19 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) if (![path hasSuffix: @"/"]) path = [path stringByAppendingString: @"/"]; + newName = [theNewName stringByEncodingImap4FolderName]; + // If new name contains the path - dont't need to add if ([newName rangeOfString: @"/"].location == NSNotFound) destURL = [[NSURL alloc] initWithScheme: [imap4URL scheme] host: [imap4URL host] path: [NSString stringWithFormat: @"%@%@", - path, [newName stringByEncodingImap4FolderName]]]; + path, newName]]; else destURL = [[NSURL alloc] initWithScheme: [imap4URL scheme] host: [imap4URL host] path: [NSString stringWithFormat: @"%@", - [newName stringByEncodingImap4FolderName]]]; + newName]]; [destURL autorelease]; error = [imap4 moveMailboxAtURL: imap4URL toURL: destURL]; diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index 63b9c4d37..82fbdf2bf 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -1,6 +1,6 @@ /* UIxMailFolderActions.m - this file is part of SOGo * - * Copyright (C) 2007-2016 Inverse inc. + * Copyright (C) 2007-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ #import #import #import +#import #import #import @@ -106,6 +107,7 @@ * @apiParam {String} name Name of the mailbox * * @apiSuccess (Success 200) {String} path New mailbox path relative to account + * @apiSuccess (Success 200) {String} sievePath New mailbox path relative to account for Sieve script usage * @apiError (Error 500) {Object} error The error message */ - (WOResponse *) renameFolderAction @@ -115,7 +117,8 @@ WORequest *request; WOResponse *response; NSException *error; - NSString *newFolderName, *newFolderPath, *currentMailbox, *currentAccount, *keyForMsgUIDs, *newKeyForMsgUIDs; + NSString *newFolderName, *newFolderPath, *sievePath, *currentMailbox, *currentAccount, + *keyForMsgUIDs, *newKeyForMsgUIDs; NSMutableDictionary *params, *moduleSettings, *threadsCollapsed, *message; NSArray *values; @@ -164,8 +167,15 @@ } } newFolderPath = [[[co imap4URL] path] substringFromIndex: 1]; // remove slash at beginning of path - message = [NSDictionary dictionaryWithObject: newFolderPath - forKey: @"path"]; + + NSString *sieveFolderEncoding = [[SOGoSystemDefaults sharedSystemDefaults] sieveFolderEncoding]; + if ([sieveFolderEncoding isEqualToString: @"UTF-8"]) + sievePath = [newFolderPath stringByDecodingImap4FolderName]; + else + sievePath = newFolderPath; + + message = [NSDictionary dictionaryWithObjectsAndKeys: + newFolderPath, @"path", sievePath, @"sievePath", nil]; response = [self responseWithStatus: 200 andJSONRepresentation: message]; } }