From f638113d53195df8b567b53b19a251f90072d8e2 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 6 Jul 2016 15:35:09 -0400 Subject: [PATCH] Improve handling of mail delegates --- SoObjects/Mailer/SOGoMailAccount.m | 4 ++-- SoObjects/SOGo/SOGoUserManager.m | 20 ++++++++++++-------- UI/MailerUI/UIxMailUserDelegationEditor.m | 5 +++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index bc5c73b66..55ea63767 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -1022,7 +1022,7 @@ static NSString *inboxFolderName = @"INBOX"; max = [newDelegates count]; for (count = 0; count < max; count++) { - currentDelegate = [newDelegates objectAtIndex: 0]; + currentDelegate = [newDelegates objectAtIndex: count]; delegateUser = [SOGoUser userWithLogin: currentDelegate]; if (delegateUser) { @@ -1049,7 +1049,7 @@ static NSString *inboxFolderName = @"INBOX"; max = [oldDelegates count]; for (count = 0; count < max; count++) { - currentDelegate = [oldDelegates objectAtIndex: 0]; + currentDelegate = [oldDelegates objectAtIndex: count]; delegateUser = [SOGoUser userWithLogin: currentDelegate]; if (delegateUser) { diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index b92c0fdac..e276d04fa 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -358,18 +358,22 @@ static Class NSNullK; NSDictionary *contactInfos; NSString *cn, *email, *fullEmail; + fullEmail = nil; contactInfos = [self contactInfosForUserWithUIDorEmail: uid]; - email = [contactInfos objectForKey: @"c_email"]; - cn = [contactInfos objectForKey: @"cn"]; - if ([cn length] > 0) + if (contactInfos) { - if ([email length] > 0) - fullEmail = [NSString stringWithFormat: @"%@ <%@>", cn, email]; + email = [contactInfos objectForKey: @"c_email"]; + cn = [contactInfos objectForKey: @"cn"]; + if ([cn length] > 0) + { + if ([email length] > 0) + fullEmail = [NSString stringWithFormat: @"%@ <%@>", cn, email]; + else + fullEmail = cn; + } else - fullEmail = cn; + fullEmail = email; } - else - fullEmail = email; return fullEmail; } diff --git a/UI/MailerUI/UIxMailUserDelegationEditor.m b/UI/MailerUI/UIxMailUserDelegationEditor.m index b0e8a8cb7..9495102a2 100644 --- a/UI/MailerUI/UIxMailUserDelegationEditor.m +++ b/UI/MailerUI/UIxMailUserDelegationEditor.m @@ -84,14 +84,15 @@ - (NSString *) currentDelegateDisplayName { SOGoUserManager *um; - NSString *s; + NSString *s, *fullEmail; um = [SOGoUserManager sharedUserManager]; s = ([currentDelegate hasPrefix: @"@"] ? [currentDelegate substringFromIndex: 1] : currentDelegate); + fullEmail = [um getFullEmailForUID: s]; - return [um getFullEmailForUID: s]; + return fullEmail? fullEmail : currentDelegate; } - (id) defaultAction