diff --git a/UI/Contacts/UIxContactView.h b/UI/Contacts/UIxContactView.h index 749caa57e..e617b43ad 100644 --- a/UI/Contacts/UIxContactView.h +++ b/UI/Contacts/UIxContactView.h @@ -34,6 +34,8 @@ CardElement *workAdr; } +- (NSString *) fullName; + @end #endif /* UIXCONTACTVIEW_H */ diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index 75d4bd0db..5efce1000 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -67,7 +67,7 @@ { return [NSString stringWithFormat: [self labelForKey: @"Card for %@"], - [card fn]]; + [self fullName]]; } - (NSString *) displayName @@ -82,6 +82,32 @@ value: [card nickname]]; } +- (NSString *) fullName +{ + NSArray *n; + NSString *fn; + unsigned int max; + + fn = [card fn]; + if ([fn length] == 0) + { + n = [card n]; + if (n) + { + max = [n count]; + if (max > 0) + { + if (max > 1) + fn = [NSString stringWithFormat: @"%@ %@", [n objectAtIndex: 1], [n objectAtIndex: 0]]; + else + fn = [n objectAtIndex: 0]; + } + } + } + + return fn; +} + - (NSString *) primaryEmail { NSString *email, *mailTo; diff --git a/UI/MailerUI/UIxMailMainFrame.m b/UI/MailerUI/UIxMailMainFrame.m index 95d247f9a..669c078ea 100644 --- a/UI/MailerUI/UIxMailMainFrame.m +++ b/UI/MailerUI/UIxMailMainFrame.m @@ -151,7 +151,7 @@ { id contact; NSArray *accounts, *contactsId; - NSString *firstAccount, *newLocation, *parameters, *folderId, *uid, *email; + NSString *firstAccount, *newLocation, *parameters, *folderId, *uid, *email, *n; NSMutableString *fn; NSEnumerator *uids; NSMutableArray *addresses; @@ -160,6 +160,7 @@ SOGoContactFolders *folders; SOGoParentFolder *folder; WORequest *request; + unsigned int max; parameters = nil; co = [self clientObject]; @@ -202,7 +203,24 @@ if (email) { email = [NSString stringWithFormat: @"<%@>", email]; + + // We append the contact's name fn = [NSMutableString stringWithString: [card fn]]; + if ([fn length] == 0) + { + n = [card n]; + if (n) + { + max = [n count]; + if (max > 0) + { + if (max > 1) + fn = [NSMutableString stringWithFormat: @"%@ %@", [n objectAtIndex: 1], [n objectAtIndex: 0]]; + else + fn = [NSMutableString stringWithString: [n objectAtIndex: 0]]; + } + } + } if (fn) { [fn appendFormat: @" %@", email];