mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-18 17:58:12 +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 parent
19cbe54277
commit
47afdfcd40
6 files changed
+99
-34
No files matched your search
@@ -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>
|
2012-08-14 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
* OpenChange/MAPIStoreFolder.m (-moveToFolder:withNewName:):
|
* OpenChange/MAPIStoreFolder.m (-moveToFolder:withNewName:):
|
||||||
|
|||||||
@@ -157,6 +157,8 @@ static NSString *MAPIStoreRightFolderContact = @"RightsFolderContact";
|
|||||||
[mapping updateID: [self objectId]
|
[mapping updateID: [self objectId]
|
||||||
withURL: newURL];
|
withURL: newURL];
|
||||||
|
|
||||||
|
[targetFolder cleanupCaches];
|
||||||
|
|
||||||
rc = MAPISTORE_SUCCESS;
|
rc = MAPISTORE_SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -127,9 +127,6 @@
|
|||||||
withNewName: (NSString *) newFolderName
|
withNewName: (NSString *) newFolderName
|
||||||
isMove: (BOOL) isMove
|
isMove: (BOOL) isMove
|
||||||
isRecursive: (BOOL) isRecursive;
|
isRecursive: (BOOL) isRecursive;
|
||||||
- (enum mapistore_error) copyToFolder: (MAPIStoreFolder *) targetFolder
|
|
||||||
recursive: (BOOL) resursive
|
|
||||||
withNewName: (NSString *) newFolderName;
|
|
||||||
|
|
||||||
- (int) getDeletedFMIDs: (struct I8Array_r **) fmidsPtr
|
- (int) getDeletedFMIDs: (struct I8Array_r **) fmidsPtr
|
||||||
andCN: (uint64_t *) cnPtr
|
andCN: (uint64_t *) cnPtr
|
||||||
|
|||||||
@@ -806,6 +806,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
childKey = [children objectAtIndex: count];
|
childKey = [children objectAtIndex: count];
|
||||||
message = [self lookupMessage: childKey];
|
message = [self lookupMessage: childKey];
|
||||||
targetMessage = [newFolder createMessage: NO];
|
targetMessage = [newFolder createMessage: NO];
|
||||||
|
[targetMessage setIsNew: YES];
|
||||||
[message copyToMessage: targetMessage];
|
[message copyToMessage: targetMessage];
|
||||||
if (isMove)
|
if (isMove)
|
||||||
{
|
{
|
||||||
@@ -826,6 +827,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
childKey = [children objectAtIndex: count];
|
childKey = [children objectAtIndex: count];
|
||||||
message = [self lookupFAIMessage: childKey];
|
message = [self lookupFAIMessage: childKey];
|
||||||
targetMessage = [newFolder createMessage: YES];
|
targetMessage = [newFolder createMessage: YES];
|
||||||
|
[targetMessage setIsNew: YES];
|
||||||
[message copyToMessage: targetMessage];
|
[message copyToMessage: targetMessage];
|
||||||
if (isMove)
|
if (isMove)
|
||||||
{
|
{
|
||||||
@@ -872,13 +874,6 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (enum mapistore_error) copyToFolder: (MAPIStoreFolder *) targetFolder
|
|
||||||
recursive: (BOOL) resursive
|
|
||||||
withNewName: (NSString *) newFolderName
|
|
||||||
{
|
|
||||||
return MAPISTORE_ERR_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (SOGoFolder *) aclFolder
|
- (SOGoFolder *) aclFolder
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
|
|||||||
@@ -1019,12 +1019,21 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP)
|
|||||||
{
|
{
|
||||||
enum mapistore_error rc;
|
enum mapistore_error rc;
|
||||||
NSURL *folderURL, *newFolderURL;
|
NSURL *folderURL, *newFolderURL;
|
||||||
|
struct SRow folderRow;
|
||||||
|
struct SPropValue nameProperty;
|
||||||
|
MAPIStoreMailFolder *newFolder;
|
||||||
SOGoMailFolder *targetSOGoFolder;
|
SOGoMailFolder *targetSOGoFolder;
|
||||||
NSString *newURL, *parentDBFolderPath;
|
NSMutableArray *uids;
|
||||||
|
NSArray *childKeys;
|
||||||
|
NSUInteger count, max;
|
||||||
|
NGImap4Connection *connection;
|
||||||
|
NGImap4Client *client;
|
||||||
|
NSString *newURL, *parentDBFolderPath, *childKey, *folderIMAPName, *newFolderIMAPName;
|
||||||
NSException *error;
|
NSException *error;
|
||||||
MAPIStoreMapping *mapping;
|
MAPIStoreMapping *mapping;
|
||||||
|
NSDictionary *result;
|
||||||
|
|
||||||
if (isMove && [targetFolder isKindOfClass: MAPIStoreMailFolderK])
|
if ([targetFolder isKindOfClass: MAPIStoreMailFolderK])
|
||||||
{
|
{
|
||||||
folderURL = [sogoObject imap4URL];
|
folderURL = [sogoObject imap4URL];
|
||||||
if (!newFolderName)
|
if (!newFolderName)
|
||||||
@@ -1033,29 +1042,84 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP)
|
|||||||
targetSOGoFolder = [targetFolder sogoObject];
|
targetSOGoFolder = [targetFolder sogoObject];
|
||||||
newFolderURL = [NSURL URLWithString: newFolderName
|
newFolderURL = [NSURL URLWithString: newFolderName
|
||||||
relativeToURL: [targetSOGoFolder imap4URL]];
|
relativeToURL: [targetSOGoFolder imap4URL]];
|
||||||
error = [[sogoObject imap4Connection]
|
if (isMove)
|
||||||
moveMailboxAtURL: folderURL
|
{
|
||||||
toURL: newFolderURL];
|
error = [[sogoObject imap4Connection]
|
||||||
if (error)
|
moveMailboxAtURL: folderURL
|
||||||
rc = MAPISTORE_ERR_DENIED;
|
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
|
else
|
||||||
{
|
{
|
||||||
rc = MAPISTORE_SUCCESS;
|
nameProperty.ulPropTag = PidTagDisplayName;
|
||||||
mapping = [self mapping];
|
nameProperty.value.lpszW = [newFolderName UTF8String];
|
||||||
newURL = [NSString stringWithFormat: @"%@folder%@/",
|
folderRow.lpProps = &nameProperty;
|
||||||
[targetFolder url], newFolderName];
|
folderRow.cValues = 1;
|
||||||
[mapping updateID: [self objectId]
|
rc = [targetFolder createFolder: &folderRow
|
||||||
withURL: newURL];
|
withFID: -1
|
||||||
parentDBFolderPath = [[targetFolder dbFolder] path];
|
andKey: &childKey];
|
||||||
if (!parentDBFolderPath)
|
if (rc == MAPISTORE_SUCCESS)
|
||||||
parentDBFolderPath = @"";
|
{
|
||||||
[dbFolder changePathTo: [NSString stringWithFormat:
|
newFolder = [targetFolder lookupFolder: childKey];
|
||||||
@"%@/folder%@",
|
|
||||||
parentDBFolderPath,
|
connection = [sogoObject imap4Connection];
|
||||||
newFolderName]];
|
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];
|
[targetFolder cleanupCaches];
|
||||||
[self cleanupCaches];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rc = [super moveCopyToFolder: targetFolder withNewName: newFolderName
|
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];
|
newFolderName = [NSString stringWithUTF8String: new_folder_name];
|
||||||
|
|
||||||
rc = [copyFolder copyToFolder: targetFolder
|
rc = [copyFolder moveCopyToFolder: targetFolder
|
||||||
recursive: recursive
|
withNewName: newFolderName
|
||||||
withNewName: newFolderName];
|
isMove: NO
|
||||||
|
isRecursive: recursive];
|
||||||
[pool release];
|
[pool release];
|
||||||
GSUnregisterCurrentThread ();
|
GSUnregisterCurrentThread ();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user