mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-21 06:33:18 +00:00
propagate from branch 'ca.inverse.sogo.1_3_13' (head 9cacc7ba282ab08c75e02952d2f95a3f5bdf9010)
to branch 'ca.inverse.sogo' (head b3c1d7bab2024077b5c89d49297c6ceb5bc5aa0e) Monotone-Parent: 9cacc7ba282ab08c75e02952d2f95a3f5bdf9010 Monotone-Parent: b3c1d7bab2024077b5c89d49297c6ceb5bc5aa0e Monotone-Revision: 7fc3840c26038b9a53ac374b2e5b17f2ceeb99ab Monotone-Author: jraby@inverse.ca Monotone-Date: 2012-03-15T21:02:00 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -279,28 +279,38 @@ static NSString *defaultUserID = @"anyone";
|
||||
{
|
||||
[self imap4URL];
|
||||
|
||||
[self imap4Connection];
|
||||
client = [imap4 client];
|
||||
if ([self imap4Connection])
|
||||
{
|
||||
client = [imap4 client];
|
||||
|
||||
inbox = [[self mailAccountFolder] inboxFolderInContext: context];
|
||||
[client select: [inbox absoluteImap4Name]];
|
||||
inbox = [[self mailAccountFolder] inboxFolderInContext: context];
|
||||
[client select: [inbox absoluteImap4Name]];
|
||||
|
||||
path = [[imap4URL path] stringByDeletingLastPathComponent];
|
||||
if (![path hasSuffix: @"/"])
|
||||
path = [path stringByAppendingString: @"/"];
|
||||
destURL = [[NSURL alloc] initWithScheme: [imap4URL scheme]
|
||||
host: [imap4URL host]
|
||||
path: [NSString stringWithFormat: @"%@%@",
|
||||
path, newName]];
|
||||
[destURL autorelease];
|
||||
error = [imap4 moveMailboxAtURL: imap4URL
|
||||
toURL: destURL];
|
||||
if (!error)
|
||||
{
|
||||
// We unsubscribe to the old one, and subscribe back to the new one
|
||||
[client subscribe: [destURL path]];
|
||||
[client unsubscribe: [imap4URL path]];
|
||||
path = [[imap4URL path] stringByDeletingLastPathComponent];
|
||||
if (![path hasSuffix: @"/"])
|
||||
path = [path stringByAppendingString: @"/"];
|
||||
destURL = [[NSURL alloc] initWithScheme: [imap4URL scheme]
|
||||
host: [imap4URL host]
|
||||
path: [NSString stringWithFormat: @"%@%@",
|
||||
path, newName]];
|
||||
[destURL autorelease];
|
||||
error = [imap4 moveMailboxAtURL: imap4URL
|
||||
toURL: destURL];
|
||||
if (!error)
|
||||
{
|
||||
ASSIGN (imap4URL, nil);
|
||||
ASSIGN (nameInContainer,
|
||||
([NSString stringWithFormat: @"folder%@", [newName asCSSIdentifier]]));
|
||||
|
||||
// We unsubscribe to the old one, and subscribe back to the new one
|
||||
[client subscribe: [destURL path]];
|
||||
[client unsubscribe: [imap4URL path]];
|
||||
}
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
userInfo: nil];
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
@@ -386,33 +396,41 @@ static NSString *defaultUserID = @"anyone";
|
||||
error = (NSException *) trashFolder;
|
||||
else
|
||||
{
|
||||
client = [[self imap4Connection] client];
|
||||
[imap4 selectFolder: [self imap4URL]];
|
||||
folderName = [imap4 imap4FolderNameForURL: [trashFolder imap4URL]];
|
||||
b = YES;
|
||||
if ([self imap4Connection])
|
||||
{
|
||||
error = nil;
|
||||
client = [imap4 client];
|
||||
[imap4 selectFolder: [self imap4URL]];
|
||||
folderName = [imap4 imap4FolderNameForURL: [trashFolder imap4URL]];
|
||||
b = YES;
|
||||
|
||||
// If we are deleting messages within the Trash folder itself, we
|
||||
// do not, of course, try to move messages to the Trash folder.
|
||||
if ([folderName isEqualToString: [self relativeImap4Name]])
|
||||
{
|
||||
*withTrash = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If our Trash folder doesn't exist when we try to copy messages
|
||||
// to it, we create it.
|
||||
result = [[client status: folderName flags: [NSArray arrayWithObject: @"UIDVALIDITY"]]
|
||||
objectForKey: @"result"];
|
||||
// If we are deleting messages within the Trash folder itself, we
|
||||
// do not, of course, try to move messages to the Trash folder.
|
||||
if ([folderName isEqualToString: [self relativeImap4Name]])
|
||||
{
|
||||
*withTrash = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If our Trash folder doesn't exist when we try to copy messages
|
||||
// to it, we create it.
|
||||
result = [[client status: folderName flags: [NSArray arrayWithObject: @"UIDVALIDITY"]]
|
||||
objectForKey: @"result"];
|
||||
|
||||
if (![result boolValue])
|
||||
[[self imap4Connection] createMailbox: folderName
|
||||
atURL: [[self mailAccountFolder] imap4URL]];
|
||||
if (![result boolValue])
|
||||
[imap4 createMailbox: folderName
|
||||
atURL: [[self mailAccountFolder] imap4URL]];
|
||||
|
||||
result = [[client copyUids: uids toFolder: folderName]
|
||||
objectForKey: @"result"];
|
||||
result = [[client copyUids: uids toFolder: folderName]
|
||||
objectForKey: @"result"];
|
||||
|
||||
b = [result boolValue];
|
||||
b = [result boolValue];
|
||||
}
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
userInfo: nil];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -608,23 +626,32 @@ static NSString *defaultUserID = @"anyone";
|
||||
}
|
||||
|
||||
client = [[self imap4Connection] client];
|
||||
[imap4 selectFolder: [self imap4URL]];
|
||||
if (client)
|
||||
{
|
||||
[imap4 selectFolder: [self imap4URL]];
|
||||
|
||||
// We make sure the destination IMAP folder exist, if not, we create it.
|
||||
result = [[client status: imapDestinationFolder
|
||||
flags: [NSArray arrayWithObject: @"UIDVALIDITY"]]
|
||||
objectForKey: @"result"];
|
||||
if (![result boolValue])
|
||||
result = [[self imap4Connection] createMailbox: imapDestinationFolder
|
||||
atURL: [[self mailAccountFolder] imap4URL]];
|
||||
if (!result || [result boolValue])
|
||||
result = [client copyUids: uids toFolder: imapDestinationFolder];
|
||||
// We make sure the destination IMAP folder exist, if not, we create it.
|
||||
result = [[client status: imapDestinationFolder
|
||||
flags: [NSArray arrayWithObject: @"UIDVALIDITY"]]
|
||||
objectForKey: @"result"];
|
||||
if (![result boolValue])
|
||||
result = [[self imap4Connection] createMailbox: imapDestinationFolder
|
||||
atURL: [[self mailAccountFolder] imap4URL]];
|
||||
if (!result || [result boolValue])
|
||||
result = [client copyUids: uids toFolder: imapDestinationFolder];
|
||||
|
||||
if ([[result valueForKey: @"result"] boolValue])
|
||||
result = nil;
|
||||
if ([[result valueForKey: @"result"] boolValue])
|
||||
result = nil;
|
||||
else
|
||||
result = [NSException exceptionWithHTTPStatus: 500
|
||||
reason: [[[result objectForKey: @"RawResponse"]
|
||||
objectForKey: @"ResponseResult"]
|
||||
objectForKey: @"description"]];
|
||||
}
|
||||
else
|
||||
result = [NSException exceptionWithHTTPStatus: 500
|
||||
reason: [[[result objectForKey: @"RawResponse"] objectForKey: @"ResponseResult"] objectForKey: @"description"]];
|
||||
result = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
userInfo: nil];
|
||||
}
|
||||
else
|
||||
result = [NSException exceptionWithHTTPStatus: 500
|
||||
@@ -645,18 +672,24 @@ static NSString *defaultUserID = @"anyone";
|
||||
NGImap4Client *client;
|
||||
|
||||
client = [[self imap4Connection] client];
|
||||
|
||||
result = [self copyUIDs: uids toFolder: destinationFolder inContext: localContext];
|
||||
if (![result isNotNull])
|
||||
if (client)
|
||||
{
|
||||
result = [client storeFlags: [NSArray arrayWithObject: @"Deleted"]
|
||||
forUIDs: uids addOrRemove: YES];
|
||||
if ([[result valueForKey: @"result"] boolValue])
|
||||
{
|
||||
[self markForExpunge];
|
||||
result = nil;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -740,7 +773,15 @@ static NSString *defaultUserID = @"anyone";
|
||||
|
||||
- (NSException *) expunge
|
||||
{
|
||||
return [[self imap4Connection] expungeAtURL: [self imap4URL]];
|
||||
NSException *error;
|
||||
|
||||
if ([self imap4Connection])
|
||||
error = [imap4 expungeAtURL: [self imap4URL]];
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
userInfo: nil];
|
||||
return error;
|
||||
}
|
||||
|
||||
- (void) markForExpunge
|
||||
@@ -796,8 +837,17 @@ static NSString *defaultUserID = @"anyone";
|
||||
|
||||
- (NSException *) addFlagsToAllMessages: (id) _f
|
||||
{
|
||||
return [[self imap4Connection] addFlags:_f
|
||||
toAllMessagesInURL: [self imap4URL]];
|
||||
NSException *error;
|
||||
|
||||
if ([self imap4Connection])
|
||||
error = [imap4 addFlags:_f
|
||||
toAllMessagesInURL: [self imap4URL]];
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
userInfo: nil];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* name lookup */
|
||||
@@ -866,7 +916,16 @@ static NSString *defaultUserID = @"anyone";
|
||||
- (NSException *) davCreateCollection: (NSString *) _name
|
||||
inContext: (id) _ctx
|
||||
{
|
||||
return [[self imap4Connection] createMailbox:_name atURL:[self imap4URL]];
|
||||
NSException *error;
|
||||
|
||||
if ([self imap4Connection])
|
||||
error = [imap4 createMailbox:_name atURL:[self imap4URL]];
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
userInfo: nil];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
- (BOOL) exists
|
||||
@@ -879,29 +938,43 @@ static NSString *defaultUserID = @"anyone";
|
||||
NSException *error;
|
||||
BOOL rc;
|
||||
|
||||
[self imap4Connection];
|
||||
error = [imap4 createMailbox: [self relativeImap4Name]
|
||||
atURL: [container imap4URL]];
|
||||
if (error)
|
||||
rc = NO;
|
||||
else
|
||||
if ([self imap4Connection])
|
||||
{
|
||||
[[imap4 client] subscribe: [self absoluteImap4Name]];
|
||||
rc = YES;
|
||||
error = [imap4 createMailbox: [self relativeImap4Name]
|
||||
atURL: [container imap4URL]];
|
||||
if (error)
|
||||
rc = NO;
|
||||
else
|
||||
{
|
||||
[[imap4 client] subscribe: [self absoluteImap4Name]];
|
||||
rc = YES;
|
||||
}
|
||||
}
|
||||
else
|
||||
rc = NO;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
- (NSException *) delete
|
||||
{
|
||||
return [[self imap4Connection] deleteMailboxAtURL:[self imap4URL]];
|
||||
NSException *error;
|
||||
|
||||
if ([self imap4Connection])
|
||||
error = [imap4 deleteMailboxAtURL: [self imap4URL]];
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
userInfo: nil];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
- (NSException *) davMoveToTargetObject: (id) _target
|
||||
newName: (NSString *) _name
|
||||
inContext: (id)_ctx
|
||||
{
|
||||
NSException *error;
|
||||
NSURL *destImapURL;
|
||||
|
||||
if ([_name length] == 0) { /* target already exists! */
|
||||
@@ -926,9 +999,16 @@ static NSString *defaultUserID = @"anyone";
|
||||
[self logWithFormat:@"TODO: should move collection as '%@' to: %@",
|
||||
[[self imap4URL] absoluteString],
|
||||
[destImapURL absoluteString]];
|
||||
|
||||
return [[self imap4Connection] moveMailboxAtURL:[self imap4URL]
|
||||
toURL:destImapURL];
|
||||
|
||||
if ([self imap4Connection])
|
||||
error = [imap4 moveMailboxAtURL: [self imap4URL]
|
||||
toURL: destImapURL];
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
userInfo: nil];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
- (NSException *) davCopyToTargetObject: (id) _target
|
||||
|
||||
Reference in New Issue
Block a user