From 3f2cfd97e4fda9ee70623f90f89049f0f1150107 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 15 Aug 2012 18:59:42 +0000 Subject: [PATCH] Monotone-Parent: 107e4e5ebd41e916769f1be7ce070d725d255f0d Monotone-Revision: 2180e9f83acd350f77772f161695cca6bff102ec Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-08-15T18:59:42 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ OpenChange/MAPIStoreMailContext.h | 3 +++ OpenChange/MAPIStoreMailContext.m | 28 +++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f8496b16d..ab99c99d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-08-15 Wolfgang Sourdeau + * OpenChange/MAPIStoreMailContext.m (-updateURLWithFolderName): + change the folder name used in the context url to use the new + folder name after a rename operation, so that further invocations + of -url will return the right url. + * OpenChange/MAPIStoreMailFolder.m (-moveCopyToFolder:withNewName:isMove:isRecursive:): implemented IMAP-based copy operation, for speed. diff --git a/OpenChange/MAPIStoreMailContext.h b/OpenChange/MAPIStoreMailContext.h index ab176cd1a..5c23fc98a 100644 --- a/OpenChange/MAPIStoreMailContext.h +++ b/OpenChange/MAPIStoreMailContext.h @@ -26,6 +26,9 @@ #import "MAPIStoreContext.h" @interface MAPIStoreMailContext : MAPIStoreContext + +- (void) updateURLWithFolderName: (NSString *) newFolderName; + @end @interface MAPIStoreOutboxContext : MAPIStoreMailContext diff --git a/OpenChange/MAPIStoreMailContext.m b/OpenChange/MAPIStoreMailContext.m index d91d76514..8046c994c 100644 --- a/OpenChange/MAPIStoreMailContext.m +++ b/OpenChange/MAPIStoreMailContext.m @@ -23,7 +23,8 @@ #import #import #import - +#import +#import #import #import @@ -203,6 +204,31 @@ MakeDisplayFolderName (NSString *folderName) return [[userContext rootFolders] objectForKey: @"mail"]; } +- (void) updateURLWithFolderName: (NSString *) newFolderName +{ + NSString *urlString; + NSMutableArray *pathComponents; + BOOL hasSlash; + NSUInteger max, folderNameIdx; + NSURL *newURL; + + urlString = [contextUrl absoluteString]; + hasSlash = [urlString hasSuffix: @"/"]; + pathComponents = [[urlString componentsSeparatedByString: @"/"] + mutableCopy]; + [pathComponents autorelease]; + max = [pathComponents count]; + if (hasSlash) + folderNameIdx = max - 2; + else + folderNameIdx = max - 1; + [pathComponents replaceObjectAtIndex: folderNameIdx + withObject: [newFolderName stringByEscapingURL]]; + urlString = [pathComponents componentsJoinedByString: @"/"]; + newURL = [NSURL URLWithString: urlString]; + ASSIGN (contextUrl, newURL); +} + @end @implementation MAPIStoreOutboxContext