From bff811b7b86beeefb685c585f19efbdd9411ea7f Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 13 Aug 2012 19:40:22 +0000 Subject: [PATCH] Monotone-Parent: 43d241658c366d49394b3972e7951947d8271398 Monotone-Revision: 2042b5fba4b0e3a86f1181c84e675df4953329e4 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-08-13T19:40:22 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 +++ OpenChange/MAPIStoreDBFolder.m | 42 +++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0a51e0a0c..a05380841 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2012-08-13 Wolfgang Sourdeau + * OpenChange/MAPIStoreDBFolder.m (-moveToFolder:withNewName:): + implemented method. + * OpenChange/MAPIStoreMailFolder.m (-moveToFolder:withNewName:): invoke changePathTo: on the dbFolder. diff --git a/OpenChange/MAPIStoreDBFolder.m b/OpenChange/MAPIStoreDBFolder.m index 21c542f81..3cb90b949 100644 --- a/OpenChange/MAPIStoreDBFolder.m +++ b/OpenChange/MAPIStoreDBFolder.m @@ -25,6 +25,7 @@ #import #import #import +#import #import #import #import @@ -36,6 +37,7 @@ #import "MAPIStoreDBFolderTable.h" #import "MAPIStoreDBMessage.h" #import "MAPIStoreDBMessageTable.h" +#import "MAPIStoreMapping.h" #import "MAPIStoreTypes.h" #import "MAPIStoreUserContext.h" #import "SOGoMAPIDBFolder.h" @@ -47,7 +49,7 @@ #include #include -static Class EOKeyValueQualifierK, SOGoMAPIDBFolderK; +static Class EOKeyValueQualifierK, SOGoMAPIDBFolderK, MAPIStoreDBFolderK; static NSString *MAPIStoreRightReadItems = @"RightsReadItems"; static NSString *MAPIStoreRightCreateItems = @"RightsCreateItems"; @@ -65,6 +67,7 @@ static NSString *MAPIStoreRightFolderContact = @"RightsFolderContact"; { EOKeyValueQualifierK = [EOKeyValueQualifier class]; SOGoMAPIDBFolderK = [SOGoMAPIDBFolder class]; + MAPIStoreDBFolderK = [MAPIStoreDBFolder class]; } - (void) setupAuxiliaryObjects @@ -123,6 +126,43 @@ static NSString *MAPIStoreRightFolderContact = @"RightsFolderContact"; return rc; } +- (enum mapistore_error) moveToFolder: (MAPIStoreFolder *) targetFolder + withNewName: (NSString *) newFolderName +{ + enum mapistore_error rc; + NSString *path, *pathComponent, *targetPath, *newPath; + NSString *newURL; + MAPIStoreMapping *mapping; + NSRange slashRange; + + if ([targetFolder isKindOfClass: MAPIStoreDBFolderK]) + { + path = [sogoObject path]; + slashRange = [path rangeOfString: @"/" options: NSBackwardsSearch]; + if (slashRange.location == NSNotFound) + [NSException raise: @"MAPIStoreIOException" + format: @"db folder path must start with a '/'"]; + else + pathComponent = [path substringFromIndex: slashRange.location + 1]; + targetPath = [[targetFolder sogoObject] path]; + newPath = [NSString stringWithFormat: @"%@/%@", + targetPath, pathComponent]; + [dbFolder changePathTo: newPath]; + + mapping = [self mapping]; + newURL = [NSString stringWithFormat: @"%@%@/", + [targetFolder url], pathComponent]; + [mapping updateID: [self objectId] + withURL: newURL]; + + rc = MAPISTORE_SUCCESS; + } + else + rc = MAPISTORE_ERR_DENIED; + + return rc; +} + - (MAPIStoreMessage *) createMessage { MAPIStoreMessage *newMessage;