From 2b95dd2c0a04b28839a721cb3ba40c674f3981b5 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 8 Dec 2014 10:29:23 -0500 Subject: [PATCH] Avoid generating GUID for "Other user"/"Shared" folders --- SoObjects/Mailer/SOGoMailAccount.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index ab6021f07..a7c492f20 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -664,7 +664,7 @@ static NSString *inboxFolderName = @"INBOX"; - (NSDictionary *) imapFolderGUIDs { - NSDictionary *result, *nresult, *folderData; + NSDictionary *result, *nresult, *namespaceDict; NSMutableDictionary *folders; NGImap4Client *client; SOGoUserDefaults *ud; @@ -684,16 +684,26 @@ static NSString *inboxFolderName = @"INBOX"; folders = [NSMutableDictionary dictionary]; client = [[self imap4Connection] client]; + namespaceDict = [client namespace]; + result = [client annotation: @"*" entryName: @"/comment" attributeName: @"value.priv"]; e = [folderList objectEnumerator]; - while (object = [e nextObject]) + while ((object = [e nextObject])) { guid = [[[[result objectForKey: @"FolderList"] objectForKey: [object substringFromIndex: 1]] objectForKey: @"/comment"] objectForKey: @"value.priv"]; if (!guid) { + // Don't generate a GUID for "Other users" and "Shared" namespace folders - user foldername instead + if ([[object substringFromIndex: 1] isEqualToString: [[[[namespaceDict objectForKey: @"other users"] lastObject] objectForKey: @"prefix"] substringFromIndex: 1]] || + [[object substringFromIndex: 1] isEqualToString: [[[[namespaceDict objectForKey: @"shared"] lastObject] objectForKey: @"prefix"] substringFromIndex: 1]]) + { + [folders setObject: [NSString stringWithFormat: @"folder%@", [object substringFromIndex: 1]] forKey: [NSString stringWithFormat: @"folder%@", [object substringFromIndex: 1]]]; + continue; + } + guid = [[NSProcessInfo processInfo] globallyUniqueString]; nresult = [client annotation: [object substringFromIndex: 1] entryName: @"/comment" attributeName: @"value.priv" attributeValue: guid];