mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-28 20:56:24 +00:00
Monotone-Parent: de4fcfa81509a5dd3cc5acd2a1c6ba7c97653649
Monotone-Revision: 85e37dbc7e87a173193494e6234f460788904318 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-08-15T13:13:15 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2012-08-15 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreMailFolder.m
|
||||
(-moveCopyToFolder:withNewName:isMove:isRecursive:): implemented
|
||||
IMAP-based copy operation, for speed.
|
||||
|
||||
2012-08-14 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreFolder.m (-moveToFolder:withNewName:):
|
||||
|
||||
@@ -157,6 +157,8 @@ static NSString *MAPIStoreRightFolderContact = @"RightsFolderContact";
|
||||
[mapping updateID: [self objectId]
|
||||
withURL: newURL];
|
||||
|
||||
[targetFolder cleanupCaches];
|
||||
|
||||
rc = MAPISTORE_SUCCESS;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -127,9 +127,6 @@
|
||||
withNewName: (NSString *) newFolderName
|
||||
isMove: (BOOL) isMove
|
||||
isRecursive: (BOOL) isRecursive;
|
||||
- (enum mapistore_error) copyToFolder: (MAPIStoreFolder *) targetFolder
|
||||
recursive: (BOOL) resursive
|
||||
withNewName: (NSString *) newFolderName;
|
||||
|
||||
- (int) getDeletedFMIDs: (struct I8Array_r **) fmidsPtr
|
||||
andCN: (uint64_t *) cnPtr
|
||||
|
||||
@@ -806,6 +806,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
||||
childKey = [children objectAtIndex: count];
|
||||
message = [self lookupMessage: childKey];
|
||||
targetMessage = [newFolder createMessage: NO];
|
||||
[targetMessage setIsNew: YES];
|
||||
[message copyToMessage: targetMessage];
|
||||
if (isMove)
|
||||
{
|
||||
@@ -826,6 +827,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
||||
childKey = [children objectAtIndex: count];
|
||||
message = [self lookupFAIMessage: childKey];
|
||||
targetMessage = [newFolder createMessage: YES];
|
||||
[targetMessage setIsNew: YES];
|
||||
[message copyToMessage: targetMessage];
|
||||
if (isMove)
|
||||
{
|
||||
@@ -872,13 +874,6 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
||||
return rc;
|
||||
}
|
||||
|
||||
- (enum mapistore_error) copyToFolder: (MAPIStoreFolder *) targetFolder
|
||||
recursive: (BOOL) resursive
|
||||
withNewName: (NSString *) newFolderName
|
||||
{
|
||||
return MAPISTORE_ERR_DENIED;
|
||||
}
|
||||
|
||||
- (SOGoFolder *) aclFolder
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
@@ -1019,12 +1019,21 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP)
|
||||
{
|
||||
enum mapistore_error rc;
|
||||
NSURL *folderURL, *newFolderURL;
|
||||
struct SRow folderRow;
|
||||
struct SPropValue nameProperty;
|
||||
MAPIStoreMailFolder *newFolder;
|
||||
SOGoMailFolder *targetSOGoFolder;
|
||||
NSString *newURL, *parentDBFolderPath;
|
||||
NSMutableArray *uids;
|
||||
NSArray *childKeys;
|
||||
NSUInteger count, max;
|
||||
NGImap4Connection *connection;
|
||||
NGImap4Client *client;
|
||||
NSString *newURL, *parentDBFolderPath, *childKey, *folderIMAPName, *newFolderIMAPName;
|
||||
NSException *error;
|
||||
MAPIStoreMapping *mapping;
|
||||
NSDictionary *result;
|
||||
|
||||
if (isMove && [targetFolder isKindOfClass: MAPIStoreMailFolderK])
|
||||
if ([targetFolder isKindOfClass: MAPIStoreMailFolderK])
|
||||
{
|
||||
folderURL = [sogoObject imap4URL];
|
||||
if (!newFolderName)
|
||||
@@ -1033,29 +1042,84 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP)
|
||||
targetSOGoFolder = [targetFolder sogoObject];
|
||||
newFolderURL = [NSURL URLWithString: newFolderName
|
||||
relativeToURL: [targetSOGoFolder imap4URL]];
|
||||
error = [[sogoObject imap4Connection]
|
||||
moveMailboxAtURL: folderURL
|
||||
toURL: newFolderURL];
|
||||
if (error)
|
||||
rc = MAPISTORE_ERR_DENIED;
|
||||
if (isMove)
|
||||
{
|
||||
error = [[sogoObject imap4Connection]
|
||||
moveMailboxAtURL: folderURL
|
||||
toURL: newFolderURL];
|
||||
if (error)
|
||||
rc = MAPISTORE_ERR_DENIED;
|
||||
else
|
||||
{
|
||||
rc = MAPISTORE_SUCCESS;
|
||||
mapping = [self mapping];
|
||||
newURL = [NSString stringWithFormat: @"%@folder%@/",
|
||||
[targetFolder url], newFolderName];
|
||||
[mapping updateID: [self objectId]
|
||||
withURL: newURL];
|
||||
parentDBFolderPath = [[targetFolder dbFolder] path];
|
||||
if (!parentDBFolderPath)
|
||||
parentDBFolderPath = @"";
|
||||
[dbFolder changePathTo: [NSString stringWithFormat:
|
||||
@"%@/folder%@",
|
||||
parentDBFolderPath,
|
||||
newFolderName]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = MAPISTORE_SUCCESS;
|
||||
mapping = [self mapping];
|
||||
newURL = [NSString stringWithFormat: @"%@folder%@/",
|
||||
[targetFolder url], newFolderName];
|
||||
[mapping updateID: [self objectId]
|
||||
withURL: newURL];
|
||||
parentDBFolderPath = [[targetFolder dbFolder] path];
|
||||
if (!parentDBFolderPath)
|
||||
parentDBFolderPath = @"";
|
||||
[dbFolder changePathTo: [NSString stringWithFormat:
|
||||
@"%@/folder%@",
|
||||
parentDBFolderPath,
|
||||
newFolderName]];
|
||||
nameProperty.ulPropTag = PidTagDisplayName;
|
||||
nameProperty.value.lpszW = [newFolderName UTF8String];
|
||||
folderRow.lpProps = &nameProperty;
|
||||
folderRow.cValues = 1;
|
||||
rc = [targetFolder createFolder: &folderRow
|
||||
withFID: -1
|
||||
andKey: &childKey];
|
||||
if (rc == MAPISTORE_SUCCESS)
|
||||
{
|
||||
newFolder = [targetFolder lookupFolder: childKey];
|
||||
|
||||
connection = [sogoObject imap4Connection];
|
||||
folderIMAPName = [connection
|
||||
imap4FolderNameForURL: [sogoObject imap4URL]];
|
||||
newFolderIMAPName = [connection
|
||||
imap4FolderNameForURL: [[newFolder sogoObject] imap4URL]];
|
||||
client = [connection client];
|
||||
[client select: folderIMAPName];
|
||||
|
||||
childKeys = [self messageKeys];
|
||||
max = [childKeys count];
|
||||
uids = [NSMutableArray arrayWithCapacity: max];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
childKey = [childKeys objectAtIndex: count];
|
||||
[uids addObject: [self messageUIDFromMessageKey: childKey]];
|
||||
}
|
||||
|
||||
result = [client copyUids: uids
|
||||
toFolder: newFolderIMAPName];
|
||||
if ([[result objectForKey: @"result"] boolValue])
|
||||
{
|
||||
if (isRecursive)
|
||||
{
|
||||
childKeys = [self folderKeys];
|
||||
max = [childKeys count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
childKey = [childKeys objectAtIndex: count];
|
||||
[[self lookupFolder: childKey]
|
||||
moveCopyToFolder: newFolder
|
||||
withNewName: nil
|
||||
isMove: NO
|
||||
isRecursive: YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
rc = MAPISTORE_ERROR;
|
||||
}
|
||||
}
|
||||
[targetFolder cleanupCaches];
|
||||
[self cleanupCaches];
|
||||
}
|
||||
else
|
||||
rc = [super moveCopyToFolder: targetFolder withNewName: newFolderName
|
||||
|
||||
@@ -679,9 +679,10 @@ sogo_folder_copy_folder(void *folder_object, void *target_folder_object,
|
||||
|
||||
newFolderName = [NSString stringWithUTF8String: new_folder_name];
|
||||
|
||||
rc = [copyFolder copyToFolder: targetFolder
|
||||
recursive: recursive
|
||||
withNewName: newFolderName];
|
||||
rc = [copyFolder moveCopyToFolder: targetFolder
|
||||
withNewName: newFolderName
|
||||
isMove: NO
|
||||
isRecursive: recursive];
|
||||
[pool release];
|
||||
GSUnregisterCurrentThread ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user