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