feat(mail): add support for UID MOVE operation
parent
534bea674b
commit
d1fc15b3a4
|
@ -78,6 +78,7 @@ typedef enum {
|
||||||
- (BOOL) hasCapability: (NSString *) capability;
|
- (BOOL) hasCapability: (NSString *) capability;
|
||||||
- (BOOL) supportsQuotas;
|
- (BOOL) supportsQuotas;
|
||||||
- (BOOL) supportsQResync;
|
- (BOOL) supportsQResync;
|
||||||
|
- (BOOL) supportsMove;
|
||||||
|
|
||||||
- (id) getInboxQuota;
|
- (id) getInboxQuota;
|
||||||
- (NSException *) updateFilters;
|
- (NSException *) updateFilters;
|
||||||
|
|
|
@ -267,6 +267,11 @@ static NSString *inboxFolderName = @"INBOX";
|
||||||
return [self hasCapability: @"qresync"];
|
return [self hasCapability: @"qresync"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) supportsMove
|
||||||
|
{
|
||||||
|
return [self hasCapability: @"move"];
|
||||||
|
}
|
||||||
|
|
||||||
- (id) getInboxQuota
|
- (id) getInboxQuota
|
||||||
{
|
{
|
||||||
SOGoMailFolder *inbox;
|
SOGoMailFolder *inbox;
|
||||||
|
|
|
@ -70,6 +70,10 @@
|
||||||
- (NSArray *) fetchUIDs: (NSArray *) _uids parts: (NSArray *) _parts;
|
- (NSArray *) fetchUIDs: (NSArray *) _uids parts: (NSArray *) _parts;
|
||||||
- (NSArray *) fetchUIDsOfVanishedItems: (uint64_t) modseq;
|
- (NSArray *) fetchUIDsOfVanishedItems: (uint64_t) modseq;
|
||||||
|
|
||||||
|
- (WOResponse *) moveUIDs: (NSArray *) uids
|
||||||
|
toFolder: (NSString *) destinationFolder
|
||||||
|
inContext: (id) localContext
|
||||||
|
keepCopy: (BOOL) copy;
|
||||||
- (WOResponse *) copyUIDs: (NSArray *) uids
|
- (WOResponse *) copyUIDs: (NSArray *) uids
|
||||||
toFolder: (NSString *) destinationFolder
|
toFolder: (NSString *) destinationFolder
|
||||||
inContext: (id) localContext;
|
inContext: (id) localContext;
|
||||||
|
|
|
@ -636,6 +636,27 @@ static NSComparisonResult _compareFetchResultsByUID (id entry1, id entry2, NSArr
|
||||||
- (WOResponse *) copyUIDs: (NSArray *) uids
|
- (WOResponse *) copyUIDs: (NSArray *) uids
|
||||||
toFolder: (NSString *) destinationFolder
|
toFolder: (NSString *) destinationFolder
|
||||||
inContext: (id) localContext
|
inContext: (id) localContext
|
||||||
|
{
|
||||||
|
return [self moveUIDs: uids
|
||||||
|
toFolder: destinationFolder
|
||||||
|
inContext: localContext
|
||||||
|
keepCopy: YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (WOResponse *) moveUIDs: (NSArray *) uids
|
||||||
|
toFolder: (NSString *) destinationFolder
|
||||||
|
inContext: (id) localContext
|
||||||
|
{
|
||||||
|
return [self moveUIDs: uids
|
||||||
|
toFolder: destinationFolder
|
||||||
|
inContext: localContext
|
||||||
|
keepCopy: NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (WOResponse *) moveUIDs: (NSArray *) uids
|
||||||
|
toFolder: (NSString *) destinationFolder
|
||||||
|
inContext: (id) localContext
|
||||||
|
keepCopy: (BOOL) copy
|
||||||
{
|
{
|
||||||
NSArray *folders;
|
NSArray *folders;
|
||||||
NSString *currentFolderName, *currentAccountName, *destinationAccountName;
|
NSString *currentFolderName, *currentAccountName, *destinationAccountName;
|
||||||
|
@ -673,15 +694,35 @@ static NSComparisonResult _compareFetchResultsByUID (id entry1, id entry2, NSArr
|
||||||
result = [[self imap4Connection] createMailbox: imapDestinationFolder
|
result = [[self imap4Connection] createMailbox: imapDestinationFolder
|
||||||
atURL: [[self mailAccountFolder] imap4URL]];
|
atURL: [[self mailAccountFolder] imap4URL]];
|
||||||
if (!result || [result boolValue])
|
if (!result || [result boolValue])
|
||||||
result = [client copyUids: uids toFolder: imapDestinationFolder];
|
{
|
||||||
|
if (copy || ![[self mailAccountFolder] supportsMove])
|
||||||
|
result = [client copyUids: uids toFolder: imapDestinationFolder];
|
||||||
|
else
|
||||||
|
result = [client moveUids: uids toFolder: imapDestinationFolder];
|
||||||
|
}
|
||||||
|
|
||||||
if ([[result valueForKey: @"result"] boolValue])
|
if ([[result valueForKey: @"result"] boolValue])
|
||||||
result = nil;
|
{
|
||||||
|
result = nil;
|
||||||
|
if (!copy && ![[self mailAccountFolder] supportsMove])
|
||||||
|
{
|
||||||
|
// Server doesn't support MOVE -- delete messages
|
||||||
|
result = [client storeFlags: [NSArray arrayWithObject: @"Deleted"]
|
||||||
|
forUIDs: uids addOrRemove: YES];
|
||||||
|
if ([[result valueForKey: @"result"] boolValue])
|
||||||
|
{
|
||||||
|
[self markForExpunge];
|
||||||
|
result = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
result = [NSException exceptionWithHTTPStatus: 500
|
{
|
||||||
reason: [[[result objectForKey: @"RawResponse"]
|
result = [NSException exceptionWithHTTPStatus: 500
|
||||||
objectForKey: @"ResponseResult"]
|
reason: [[[result objectForKey: @"RawResponse"]
|
||||||
objectForKey: @"description"]];
|
objectForKey: @"ResponseResult"]
|
||||||
|
objectForKey: @"description"]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -759,36 +800,6 @@ static NSComparisonResult _compareFetchResultsByUID (id entry1, id entry2, NSArr
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (WOResponse *) moveUIDs: (NSArray *) uids
|
|
||||||
toFolder: (NSString *) destinationFolder
|
|
||||||
inContext: (id) localContext
|
|
||||||
{
|
|
||||||
id result;
|
|
||||||
NGImap4Client *client;
|
|
||||||
|
|
||||||
client = [[self imap4Connection] client];
|
|
||||||
if (client)
|
|
||||||
{
|
|
||||||
result = [self copyUIDs: uids toFolder: destinationFolder inContext: localContext];
|
|
||||||
if (![result isNotNull])
|
|
||||||
{
|
|
||||||
result = [client storeFlags: [NSArray arrayWithObject: @"Deleted"]
|
|
||||||
forUIDs: uids addOrRemove: YES];
|
|
||||||
if ([[result valueForKey: @"result"] boolValue])
|
|
||||||
{
|
|
||||||
[self markForExpunge];
|
|
||||||
result = nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
result = [NSException exceptionWithName: @"SOGoMailException"
|
|
||||||
reason: @"IMAP connection is invalid"
|
|
||||||
userInfo: nil];
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (WOResponse *) markMessagesAsJunkOrNotJunk: (NSArray *) uids
|
- (WOResponse *) markMessagesAsJunkOrNotJunk: (NSArray *) uids
|
||||||
junk: (BOOL) isJunk
|
junk: (BOOL) isJunk
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue