From bfd35089499c134ca0541d8fbb27ca2363ee0131 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 | 75 ----------------------- 3 files changed, 14 insertions(+), 85 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 8a706d8bf..a73a9f072 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -1100,7 +1100,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) { @@ -1127,7 +1127,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 13d9da392..4c86b4793 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -346,18 +346,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 e781ee0af..2f184ef10 100644 --- a/UI/MailerUI/UIxMailUserDelegationEditor.m +++ b/UI/MailerUI/UIxMailUserDelegationEditor.m @@ -24,84 +24,9 @@ #import @interface UIxMailUserDelegationEditor : UIxComponent -// { -// NSArray *delegates; -// NSString *currentDelegate; -// } - -// - (NSArray *) delegates; -// - (void) setCurrentDelegate: (NSString *) newCurrentDelegate; -// - (NSString *) currentDelegate; @end @implementation UIxMailUserDelegationEditor -// - (id) init -// { -// if ((self = [super init])) -// { -// delegates = nil; -// currentDelegate = nil; -// } - -// return self; -// } - -// - (void) dealloc -// { -// [delegates release]; -// [currentDelegate release]; -// [super dealloc]; -// } - -// - (NSArray *) delegates -// { -// if (!delegates) -// { -// delegates = [[self clientObject] delegates]; -// [delegates retain]; -// } - -// return delegates; -// } - -// - (void) setCurrentDelegate: (NSString *) newCurrentDelegate -// { -// ASSIGN (currentDelegate, newCurrentDelegate); -// } - -// - (NSString *) currentDelegate -// { -// return currentDelegate; -// } - -// - (NSString *) currentDelegateDisplayName -// { -// SOGoUserManager *um; -// NSString *s; - -// um = [SOGoUserManager sharedUserManager]; -// s = ([currentDelegate hasPrefix: @"@"] -// ? [currentDelegate substringFromIndex: 1] -// : currentDelegate); - -// return [um getFullEmailForUID: s]; -// } - -// - (id) defaultAction -// { -// id response; -// SOGoMailAccount *co; - -// co = [self clientObject]; -// if ([[co nameInContainer] isEqualToString: @"0"]) -// response = self; -// else -// response = [self responseWithStatus: 403 -// andString: @"The list of account delegates cannot be modified on secondary accounts."]; - -// return response; -// } - @end