diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 2fab6935fa..bdee5feada 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -301,8 +301,7 @@ - (NSException *) renameTo: (NSString *) theNewName { NSException *error; SOGoMailFolder *inbox; - NSURL *destURL; - NSString *path, *newName; + NSString *path, *newName, *destName; NGImap4Client *client; if ([theNewName length] > 0) @@ -324,22 +323,16 @@ - (NSException *) renameTo: (NSString *) theNewName // 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]]; + destName = [NSString stringWithFormat: @"%@%@", + path, newName]; else - destURL = [[NSURL alloc] initWithScheme: [imap4URL scheme] - host: [imap4URL host] - path: [NSString stringWithFormat: @"%@", - newName]]; - [destURL autorelease]; - error = [imap4 moveMailboxAtURL: imap4URL - toURL: destURL]; + destName = newName; + error = [imap4 moveMailbox: [imap4URL path] + to: destName]; if (!error) { // We unsubscribe to the old one, and subscribe back to the new one - [client subscribe: [destURL path]]; + [client subscribe: destName]; [client unsubscribe: [imap4URL path]]; ASSIGN (imap4URL, nil); diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index 5e9e0b8772..9313feb17f 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -287,12 +287,11 @@ - (WOResponse *) moveFolderAction return response; } -- (NSURL *) _trashedURLOfFolder: (NSURL *) srcURL - withObject: (SOGoMailFolder *) co +- (NSString *) _trashedNameOfFolder: (NSURL *) srcURL + withObject: (SOGoMailFolder *) co { NSString *trashFolderName, *folderName, *path, *testPath; NGImap4Connection *connection; - NSURL *destURL; id test; int i; @@ -318,14 +317,11 @@ - (NSURL *) _trashedURLOfFolder: (NSURL *) srcURL break; } } - destURL = [[NSURL alloc] initWithScheme: [srcURL scheme] - host: [srcURL host] path: path]; - [destURL autorelease]; - return destURL; + return path; } -- (void) _removeFolderAtURL: (NSURL *) srcURL +- (void) _removeFolder: (NSString *) srcName { NGImap4Connection *connection; NSMutableDictionary *moduleSettings, *threadsCollapsed;; @@ -337,7 +333,7 @@ - (void) _removeFolderAtURL: (NSURL *) srcURL connection = [co imap4Connection]; // Unsubscribe from mailbox - [[connection client] unsubscribe: [srcURL path]]; + [[connection client] unsubscribe: srcName]; // Verify if the current folder have any collapsed threads save under it name and erase it us = [[context activeUser] userSettings]; @@ -359,21 +355,22 @@ - (void) _removeFolderAtURL: (NSURL *) srcURL - (WOResponse *) deleteAction { NSDictionary *jsonRequest, *jsonResponse; - NSEnumerator *subURLs; + NSEnumerator *subNames; NGImap4Connection *connection; SOGoMailFolder *co, *inbox; - NSURL *srcURL, *destURL, *currentURL; + NSURL *srcURL; WORequest *request; WOResponse *response; NSException *error; NSInteger count; + NSString *destName, *currentName; BOOL moved, withTrash; request = [context request]; co = [self clientObject]; connection = [co imap4Connection]; srcURL = [co imap4URL]; - subURLs = [[co allFolderURLs] objectEnumerator]; + subNames = [[co allFolderPaths] objectEnumerator]; jsonRequest = [[request contentAsString] objectFromJSONString]; withTrash = ![[jsonRequest objectForKey: @"withoutTrash"] boolValue]; error = nil; @@ -383,7 +380,7 @@ - (WOResponse *) deleteAction { if ([co ensureTrashFolder]) { - destURL = [self _trashedURLOfFolder: srcURL withObject: co]; + destName = [self _trashedNameOfFolder: srcURL withObject: co]; inbox = [[co mailAccountFolder] inboxFolderInContext: context]; [[connection client] select: [inbox absoluteImap4Name]]; @@ -391,14 +388,14 @@ - (WOResponse *) deleteAction // the folder within the 'Trash' folder, as it's getting renamed // over and over with an integer suffix (in trashedURLOfFolder:...) // If that is the case, we simple delete the folder, instead of renaming it - if ([[destURL path] hasPrefix: [srcURL path]]) + if ([destName hasPrefix: [srcURL path]]) { error = [connection deleteMailboxAtURL: srcURL]; moved = NO; } else { - error = [connection moveMailboxAtURL: srcURL toURL: destURL]; + error = [connection moveMailbox: [srcURL path] to: destName]; } if (error) { @@ -409,25 +406,25 @@ - (WOResponse *) deleteAction else { // We unsubscribe to the old one, and subscribe back to the new one - [self _removeFolderAtURL: srcURL]; + [self _removeFolder: [srcURL path]]; if (moved) - [[connection client] subscribe: [destURL path]]; + [[connection client] subscribe: destName]; // We do the same for all subfolders count = [[srcURL pathComponents] count]; - while (!error && (currentURL = [subURLs nextObject])) + while (!error && (currentName = [subNames nextObject])) { - [self _removeFolderAtURL: currentURL]; + [self _removeFolder: currentName]; if (moved) { NSArray *currentComponents; NSMutableArray *destComponents; NSInteger currentCount; - destComponents = [NSMutableArray arrayWithArray: [destURL pathComponents]]; + destComponents = [NSMutableArray arrayWithArray: [destName componentsSeparatedByString: @"/"]]; [destComponents removeObjectAtIndex: 0]; // remove leading forward slash - currentCount = [[currentURL pathComponents] count]; - currentComponents = [[currentURL pathComponents] subarrayWithRange: NSMakeRange(count, currentCount - count)]; + currentCount = [[currentName componentsSeparatedByString: @"/"] count]; + currentComponents = [[currentName componentsSeparatedByString: @"/"] subarrayWithRange: NSMakeRange(count, currentCount - count)]; [destComponents addObjectsFromArray: currentComponents]; [[connection client] subscribe: [NSString stringWithFormat: @"/%@", [destComponents componentsJoinedByString: @"/"]]]; @@ -457,10 +454,10 @@ - (WOResponse *) deleteAction else { // Cleanup all references to mailbox and submailboxes - [self _removeFolderAtURL: srcURL]; - while (!error && (currentURL = [subURLs nextObject])) + [self _removeFolder: [srcURL path]]; + while (!error && (currentName = [subNames nextObject])) { - [self _removeFolderAtURL: currentURL]; + [self _removeFolder: currentName]; } response = [self responseWith204]; } @@ -884,7 +881,7 @@ - (WOResponse *) emptyTrashAction NSEnumerator *subfolders; WOResponse *response; NGImap4Connection *connection; - NSURL *currentURL; + NSString *currentName; NSDictionary *data; id quota; @@ -900,11 +897,11 @@ - (WOResponse *) emptyTrashAction // Delete folders within the trash connection = [co imap4Connection]; - subfolders = [[co allFolderURLs] objectEnumerator]; - while ((currentURL = [subfolders nextObject])) + subfolders = [[co allFolderPaths] objectEnumerator]; + while ((currentName = [subfolders nextObject])) { - [[connection client] unsubscribe: [currentURL path]]; - [connection deleteMailboxAtURL: currentURL]; + [[connection client] unsubscribe: currentName]; + [connection deleteMailbox: currentName]; } } if (error) diff --git a/UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js b/UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js index b3df9154e0..7c04256568 100644 --- a/UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js +++ b/UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js @@ -273,11 +273,13 @@ }; this.share = function() { + var encodeURL = angular.bind(this.folder.constructor.$$resource, + this.folder.constructor.$$resource.encodeURL); // Fetch list of ACL users this.folder.$acl.$users().then(function() { // Show ACL editor $mdDialog.show({ - templateUrl: $menuCtrl.folder.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox + templateUrl: encodeURL($menuCtrl.folder.id).join('/') + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox controller: 'AclController', // from the ng module SOGo.Common controllerAs: 'acl', clickOutsideToClose: true,