Improved handling of non-existant vs. subscribed folders over EAS
parent
204a62aa6a
commit
a0c1ce8f3b
|
@ -793,10 +793,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
{
|
||||
cKey = [allKeys objectAtIndex: i];
|
||||
|
||||
// ignore invalid folder in cache caused by fs code bugs
|
||||
if ([cKey isEqualToString:@"(null)"])
|
||||
continue;
|
||||
|
||||
// if a cache entry is not found in imapGUIDs its either an imap which has been deleted or its an other folder type which can be checked via lookupName.
|
||||
if (![imapGUIDs allKeysForObject: cKey])
|
||||
{
|
||||
|
@ -807,7 +803,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
[o setTableUrl: [self folderTableURL]];
|
||||
[o reloadIfNeeded];
|
||||
|
||||
if ([cKey hasPrefix: @"folder"])
|
||||
if ([cKey hasPrefix: @"folder"] || [cKey isEqualToString:@"(null)"])
|
||||
{
|
||||
[commands appendFormat: @"<Delete><ServerId>%@</ServerId></Delete>", [[NSString stringWithFormat: @"mail/%@", [cKey substringFromIndex: 6]] stringByEscapingURL]] ;
|
||||
command_count++;
|
||||
|
@ -849,6 +845,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
folderMetadata = [allFoldersMetadata objectAtIndex: i];
|
||||
|
||||
nameInCache = [NSString stringWithFormat: @"folder%@", [[folderMetadata objectForKey: @"path"] substringFromIndex: 1]];
|
||||
|
||||
// we have no guid - ignore the folder
|
||||
if (![imapGUIDs objectForKey: nameInCache])
|
||||
continue;
|
||||
|
||||
serverId = [NSString stringWithFormat: @"mail/%@", [[imapGUIDs objectForKey: nameInCache] substringFromIndex: 6]];
|
||||
name = [folderMetadata objectForKey: @"displayName"];
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#import <NGImap4/NGImap4Connection.h>
|
||||
#import <NGImap4/NGImap4Client.h>
|
||||
#import <NGImap4/NGImap4Context.h>
|
||||
#import <NGImap4/NSString+Imap4.h>
|
||||
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
|
@ -667,19 +668,14 @@ static NSString *inboxFolderName = @"INBOX";
|
|||
NSDictionary *result, *nresult, *namespaceDict;
|
||||
NSMutableDictionary *folders;
|
||||
NGImap4Client *client;
|
||||
SOGoUserDefaults *ud;
|
||||
NSArray *folderList;
|
||||
NSEnumerator *e;
|
||||
NSString *guid;
|
||||
id object;
|
||||
|
||||
BOOL subscribedOnly, hasAnnotatemore;
|
||||
BOOL hasAnnotatemore;
|
||||
|
||||
ud = [[context activeUser] userDefaults];
|
||||
subscribedOnly = [ud mailShowSubscribedFoldersOnly];
|
||||
|
||||
folderList = [[self imap4Connection] allFoldersForURL: [self imap4URL]
|
||||
onlySubscribedFolders: subscribedOnly];
|
||||
folderList = [self allFolderPaths];
|
||||
|
||||
folders = [NSMutableDictionary dictionary];
|
||||
|
||||
|
@ -688,18 +684,18 @@ static NSString *inboxFolderName = @"INBOX";
|
|||
hasAnnotatemore = [self hasCapability: @"annotatemore"];
|
||||
|
||||
if (hasAnnotatemore)
|
||||
result = [client annotation: @"*" entryName: @"/comment" attributeName: @"value.priv"];
|
||||
result = [client annotation: @"*" entryName: @"/comment" attributeName: @"value.priv"];
|
||||
else
|
||||
result = [client lstatus: @"*" flags: [NSArray arrayWithObjects: @"x-guid", nil]];
|
||||
result = [client lstatus: @"*" flags: [NSArray arrayWithObjects: @"x-guid", nil]];
|
||||
|
||||
e = [folderList objectEnumerator];
|
||||
|
||||
while ((object = [e nextObject]))
|
||||
{
|
||||
if (hasAnnotatemore)
|
||||
guid = [[[[result objectForKey: @"FolderList"] objectForKey: [object substringFromIndex: 1]] objectForKey: @"/comment"] objectForKey: @"value.priv"];
|
||||
guid = [[[[result objectForKey: @"FolderList"] objectForKey: [object substringFromIndex: 1]] objectForKey: @"/comment"] objectForKey: @"value.priv"];
|
||||
else
|
||||
guid = [[[result objectForKey: @"status"] objectForKey: [object substringFromIndex: 1]] objectForKey: @"x-guid"];
|
||||
guid = [[[result objectForKey: @"status"] objectForKey: [object substringFromIndex: 1]] objectForKey: @"x-guid"];
|
||||
|
||||
if (!guid)
|
||||
{
|
||||
|
@ -711,11 +707,21 @@ static NSString *inboxFolderName = @"INBOX";
|
|||
continue;
|
||||
}
|
||||
|
||||
guid = [[NSProcessInfo processInfo] globallyUniqueString];
|
||||
nresult = [client annotation: [object substringFromIndex: 1] entryName: @"/comment" attributeName: @"value.priv" attributeValue: guid];
|
||||
// if folder doesn't exists - ignore it
|
||||
nresult = [client status: [object substringFromIndex: 1]
|
||||
flags: [NSArray arrayWithObject: @"UIDVALIDITY"]];
|
||||
if (![[nresult valueForKey: @"result"] boolValue])
|
||||
continue;
|
||||
|
||||
if (![[nresult objectForKey: @"result"] boolValue])
|
||||
guid = [NSString stringWithFormat: @"%@", [object substringFromIndex: 1]];
|
||||
if (hasAnnotatemore)
|
||||
{
|
||||
guid = [[NSProcessInfo processInfo] globallyUniqueString];
|
||||
nresult = [client annotation: [object substringFromIndex: 1] entryName: @"/comment" attributeName: @"value.priv" attributeValue: guid];
|
||||
}
|
||||
|
||||
// setannotation failed or annotatemore is not available
|
||||
if (![[nresult objectForKey: @"result"] boolValue] || !hasAnnotatemore)
|
||||
guid = [NSString stringWithFormat: @"%@", [object substringFromIndex: 1]];
|
||||
}
|
||||
|
||||
[folders setObject: [NSString stringWithFormat: @"folder%@", guid] forKey: [NSString stringWithFormat: @"folder%@", [object substringFromIndex: 1]]];
|
||||
|
|
|
@ -1069,7 +1069,11 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
|
|||
NSException *error;
|
||||
|
||||
if ([self imap4Connection])
|
||||
error = [imap4 deleteMailboxAtURL: [self imap4URL]];
|
||||
{
|
||||
error = [imap4 deleteMailboxAtURL: [self imap4URL]];
|
||||
if (!error)
|
||||
[[imap4 client] unsubscribe: [[self imap4URL] path]];
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithName: @"SOGoMailException"
|
||||
reason: @"IMAP connection is invalid"
|
||||
|
|
Loading…
Reference in New Issue