diff --git a/ChangeLog b/ChangeLog index c324a3569..c2cb1a151 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-05-28 Wolfgang Sourdeau + * UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions + -renameFolderAction]): implemented method. + * UI/MailerUI/UIxMailListView.m ([-createFolderAction]): removed method, replaced with a similar method in the new UIxMailFolderAction class module. diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index e5f9550e0..2045bcfdc 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -23,6 +23,7 @@ #import #import #import +#import #import #import @@ -68,6 +69,27 @@ return response; } +- (NSURL *) _urlOfFolder: (NSURL *) srcURL + renamedTo: (NSString *) folderName +{ + NSString *path; + NSMutableArray *pathArray; + NSURL *destURL; + + path = [srcURL path]; + pathArray = [NSMutableArray arrayWithArray: + [path componentsSeparatedByString: @"/"]]; + [pathArray replaceObjectAtIndex: [pathArray count] - 1 + withObject: folderName]; + + destURL = [[NSURL alloc] initWithScheme: [srcURL scheme] + host: [srcURL host] + path: [pathArray componentsJoinedByString: @"/"]]; + [destURL autorelease]; + + return destURL; +} + - (WOResponse *) renameFolderAction { SOGoMailFolder *co; @@ -75,6 +97,7 @@ NGImap4Connection *connection; NSException *error; NSString *folderName; + NSURL *srcURL, *destURL; co = [self clientObject]; response = [context response]; @@ -82,15 +105,18 @@ folderName = [[context request] formValueForKey: @"name"]; if ([folderName length] > 0) { -// connection = [co imap4Connection]; -// error = [connection createMailbox: folderName atURL: [co imap4URL]]; -// if (error) -// { + srcURL = [co imap4URL]; + destURL = [self _urlOfFolder: srcURL renamedTo: folderName]; + connection = [co imap4Connection]; + error = [connection moveMailboxAtURL: srcURL + toURL: destURL]; + if (error) + { [response setStatus: 403]; [response appendContentString: @"Unable to rename folder."]; -// } -// else -// [response setStatus: 204]; + } + else + [response setStatus: 204]; } else {