From cd38fb01a46fc5ead7acb9a79a5f1a15501385ea Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 28 Jul 2015 14:52:02 +0200 Subject: [PATCH] factorize contaccts in fast address book (and probably broke everything) --- Classes/ChatRoomViewController.m | 34 ++--------- Classes/ContactDetailsTableViewController.m | 1 - Classes/ContactsTableViewController.m | 2 +- Classes/DialerViewController.m | 6 +- Classes/HistoryDetailsViewController.m | 6 +- Classes/IncomingCallViewController.m | 44 +------------- Classes/LinphoneManager.m | 55 ++---------------- Classes/LinphoneUI/UICallButton.m | 6 +- Classes/LinphoneUI/UICallCell.m | 41 ++++--------- Classes/LinphoneUI/UIChatCell.m | 7 ++- Classes/LinphoneUI/UIHistoryCell.m | 7 ++- Classes/Utils/FastAddressBook.h | 31 +++++----- Classes/Utils/FastAddressBook.m | 64 ++++++++------------- 13 files changed, 78 insertions(+), 226 deletions(-) diff --git a/Classes/ChatRoomViewController.m b/Classes/ChatRoomViewController.m index a3503589d..a07528708 100644 --- a/Classes/ChatRoomViewController.m +++ b/Classes/ChatRoomViewController.m @@ -188,8 +188,6 @@ static UICompositeViewDescription *compositeDescription = nil; return; } - NSString *displayName = nil; - UIImage *image = nil; const LinphoneAddress *linphoneAddress = linphone_chat_room_get_peer_address(chatRoom); if (linphoneAddress == NULL) { [[PhoneMainView instance] popCurrentView]; @@ -204,33 +202,10 @@ static UICompositeViewDescription *compositeDescription = nil; [error show]; return; } - char *tmp = linphone_address_as_string_uri_only(linphoneAddress); - NSString *normalizedSipAddress = [NSString stringWithUTF8String:tmp]; - ms_free(tmp); - - ABRecordRef acontact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; - if (acontact != nil) { - displayName = [FastAddressBook getContactDisplayName:acontact]; - image = [FastAddressBook getContactImage:acontact thumbnail:true]; - } - - // Display name - if (displayName == nil) { - const char *username = linphone_address_get_username(linphoneAddress); - char *address = linphone_address_as_string(linphoneAddress); - displayName = [NSString stringWithUTF8String:username ?: address]; - ms_free(address); - } - if (displayName == nil) - LOGF(@"No display name"); - addressLabel.text = displayName; - addressLabel.accessibilityValue = displayName; - - // Avatar - if (image == nil) { - image = [UIImage imageNamed:@"avatar_unknown_small.png"]; - } - [avatarImage setImage:image]; + [FastAddressBook setDisplayNameLabel:addressLabel forAddress:linphoneAddress]; + addressLabel.accessibilityValue = addressLabel.text; + avatarImage.image = + [FastAddressBook getContactImage:[FastAddressBook getContactWithLinphoneAddress:linphoneAddress] thumbnail:YES]; } static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state, void *ud) { @@ -296,7 +271,6 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st - (void)chooseImageQuality:(UIImage *)image url:(NSURL *)url { DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Choose the image size", nil)]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - // UIImage *image = [original_image normalizedImage]; for (NSString *key in [imageQualities allKeys]) { NSNumber *number = [imageQualities objectForKey:key]; NSData *data = UIImageJPEGRepresentation(image, [number floatValue]); diff --git a/Classes/ContactDetailsTableViewController.m b/Classes/ContactDetailsTableViewController.m index 9d158a033..a4d4c28c9 100644 --- a/Classes/ContactDetailsTableViewController.m +++ b/Classes/ContactDetailsTableViewController.m @@ -821,7 +821,6 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSe } return TRUE; } - - (BOOL)isValid { return true; } diff --git a/Classes/ContactsTableViewController.m b/Classes/ContactsTableViewController.m index 2e0ff9383..2766dce68 100644 --- a/Classes/ContactsTableViewController.m +++ b/Classes/ContactsTableViewController.m @@ -223,7 +223,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { - return [addressBookMap keyAtIndex:section]; + return nil; // [addressBookMap keyAtIndex:section]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { diff --git a/Classes/DialerViewController.m b/Classes/DialerViewController.m index c5e58c6d0..ff702a7ad 100644 --- a/Classes/DialerViewController.m +++ b/Classes/DialerViewController.m @@ -362,11 +362,7 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)call:(NSString *)address { - NSString *displayName = nil; - ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:address]; - if (contact) { - displayName = [FastAddressBook getContactDisplayName:contact]; - } + NSString *displayName = [FastAddressBook getContactDisplayName:[FastAddressBook getContact:address]]; [self call:address displayName:displayName]; } diff --git a/Classes/HistoryDetailsViewController.m b/Classes/HistoryDetailsViewController.m index 4c22e4211..6a1f227b2 100644 --- a/Classes/HistoryDetailsViewController.m +++ b/Classes/HistoryDetailsViewController.m @@ -166,13 +166,13 @@ static UICompositeViewDescription *compositeDescription = nil; assert(addr != NULL); [FastAddressBook setDisplayNameLabel:_contactLabel forAddress:addr]; - _avatarImage.image = [FastAddressBook avatarForAddress:addr]; + _avatarImage.image = + [FastAddressBook getContactImage:[FastAddressBook getContactWithLinphoneAddress:addr] thumbnail:NO]; char *addrURI = linphone_address_as_string_uri_only(addr); _addressLabel.text = [NSString stringWithUTF8String:addrURI]; ms_free(addrURI); - BOOL use_system = [[LinphoneManager instance] lpConfigBoolForKey:@"use_system_contacts"]; - _addContactButton.hidden = contact || use_system; + _addContactButton.hidden = contact || [[LinphoneManager instance] lpConfigBoolForKey:@"use_system_contacts"]; } #pragma mark - Action Functions diff --git a/Classes/IncomingCallViewController.m b/Classes/IncomingCallViewController.m index db980f670..3e534540f 100644 --- a/Classes/IncomingCallViewController.m +++ b/Classes/IncomingCallViewController.m @@ -101,48 +101,10 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)update { [self view]; // Force view load - [avatarImage setImage:[UIImage imageNamed:@"avatar_unknown.png"]]; - - NSString *address = nil; const LinphoneAddress *addr = linphone_call_get_remote_address(call); - if (addr != NULL) { - BOOL useLinphoneAddress = true; - // contact name - char *lAddress = linphone_address_as_string_uri_only(addr); - if (lAddress) { - NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]]; - ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; - if (contact) { - UIImage *tmpImage = [FastAddressBook getContactImage:contact thumbnail:false]; - if (tmpImage != nil) { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), - ^(void) { - UIImage *tmpImage2 = [UIImage decodedImageWithImage:tmpImage]; - dispatch_async(dispatch_get_main_queue(), ^{ - avatarImage.image = tmpImage2; - }); - }); - } - address = [FastAddressBook getContactDisplayName:contact]; - useLinphoneAddress = false; - } - ms_free(lAddress); - } - if (useLinphoneAddress) { - const char *lDisplayName = linphone_address_get_display_name(addr); - const char *lUserName = linphone_address_get_username(addr); - if (lDisplayName) - address = [NSString stringWithUTF8String:lDisplayName]; - else if (lUserName) - address = [NSString stringWithUTF8String:lUserName]; - } - } - - // Set Address - if (address == nil) { - address = @"Unknown"; - } - [addressLabel setText:address]; + [FastAddressBook setDisplayNameLabel:addressLabel forAddress:addr]; + avatarImage.image = + [FastAddressBook getContactImage:[FastAddressBook getContactWithLinphoneAddress:addr] thumbnail:NO]; } #pragma mark - Property Functions diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 830c33962..4b71ad810 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -628,32 +628,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char } const LinphoneAddress *addr = linphone_call_get_remote_address(call); - NSString *address = nil; - if (addr != NULL) { - BOOL useLinphoneAddress = true; - // contact name - char *lAddress = linphone_address_as_string_uri_only(addr); - if (lAddress) { - NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]]; - ABRecordRef contact = [fastAddressBook getContact:normalizedSipAddress]; - if (contact) { - address = [FastAddressBook getContactDisplayName:contact]; - useLinphoneAddress = false; - } - ms_free(lAddress); - } - if (useLinphoneAddress) { - const char *lDisplayName = linphone_address_get_display_name(addr); - const char *lUserName = linphone_address_get_username(addr); - if (lDisplayName) - address = [NSString stringWithUTF8String:lDisplayName]; - else if (lUserName) - address = [NSString stringWithUTF8String:lUserName]; - } - } - if (address == nil) { - address = NSLocalizedString(@"Unknown", nil); - } + NSString *address = [FastAddressBook displayNameForAddress:addr]; if (state == LinphoneCallIncomingReceived) { @@ -886,41 +861,21 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo #pragma mark - Text Received Functions - (void)onMessageReceived:(LinphoneCore *)lc room:(LinphoneChatRoom *)room message:(LinphoneChatMessage *)msg { - if (silentPushCompletion) { - // we were woken up by a silent push. Call the completion handler with NEWDATA // so that the push is notified to the user LOGI(@"onMessageReceived - handler %p", silentPushCompletion); silentPushCompletion(UIBackgroundFetchResultNewData); silentPushCompletion = nil; } + NSString *callID = [NSString stringWithUTF8String:linphone_chat_message_get_custom_header(msg, "Call-ID")]; const LinphoneAddress *remoteAddress = linphone_chat_message_get_from_address(msg); + NSString *from = [FastAddressBook displayNameForAddress:remoteAddress]; char *c_address = linphone_address_as_string_uri_only(remoteAddress); - NSString *address = [NSString stringWithUTF8String:c_address]; NSString *remote_uri = [NSString stringWithUTF8String:c_address]; - const char *call_id = linphone_chat_message_get_custom_header(msg, "Call-ID"); - NSString *callID = [NSString stringWithUTF8String:call_id]; - ms_free(c_address); if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { - - ABRecordRef contact = [fastAddressBook getContact:address]; - if (contact) { - address = [FastAddressBook getContactDisplayName:contact]; - } else { - if ([[LinphoneManager instance] lpConfigBoolForKey:@"show_contacts_emails_preference"] == true) { - LinphoneAddress *linphoneAddress = - linphone_address_new([address cStringUsingEncoding:[NSString defaultCStringEncoding]]); - address = [NSString stringWithUTF8String:linphone_address_get_username(linphoneAddress)]; - linphone_address_destroy(linphoneAddress); - } - } - if (address == nil) { - address = NSLocalizedString(@"Unknown", nil); - } - // Create a new notification UILocalNotification *notif = [[UILocalNotification alloc] init]; if (notif) { @@ -928,10 +883,10 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) { notif.category = @"incoming_msg"; } - notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG", nil), address]; + notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG", nil), from]; notif.alertAction = NSLocalizedString(@"Show", nil); notif.soundName = @"msg.caf"; - notif.userInfo = @{ @"from" : address, @"from_addr" : remote_uri, @"call-id" : callID }; + notif.userInfo = @{ @"from" : from, @"from_addr" : remote_uri, @"call-id" : callID }; [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } diff --git a/Classes/LinphoneUI/UICallButton.m b/Classes/LinphoneUI/UICallButton.m index 5ab299f96..f6a7fd4d7 100644 --- a/Classes/LinphoneUI/UICallButton.m +++ b/Classes/LinphoneUI/UICallButton.m @@ -60,7 +60,6 @@ - (void)touchUp:(id)sender { NSString *address = [addressField text]; - NSString *displayName = nil; if ([address length] == 0) { const MSList *logs = linphone_core_get_call_logs([LinphoneManager getLc]); @@ -96,10 +95,7 @@ } if ([address length] > 0) { - ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:address]; - if (contact) { - displayName = [FastAddressBook getContactDisplayName:contact]; - } + NSString *displayName = [FastAddressBook getContactDisplayName:[FastAddressBook getContact:address]]; [[LinphoneManager instance] call:address displayName:displayName transfer:FALSE]; } } diff --git a/Classes/LinphoneUI/UICallCell.m b/Classes/LinphoneUI/UICallCell.m index 8ab72369f..b02023199 100644 --- a/Classes/LinphoneUI/UICallCell.m +++ b/Classes/LinphoneUI/UICallCell.m @@ -48,38 +48,17 @@ return; } const LinphoneAddress *addr = linphone_call_get_remote_address(call); + address = [FastAddressBook displayNameForAddress:addr]; - if (addr != NULL) { - BOOL useLinphoneAddress = true; - // contact name - char *lAddress = linphone_address_as_string_uri_only(addr); - if (lAddress) { - NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]]; - ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; - if (contact) { - useLinphoneAddress = false; - self.address = [FastAddressBook getContactDisplayName:contact]; - UIImage *tmpImage = [FastAddressBook getContactImage:contact thumbnail:false]; - if (tmpImage != nil) { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), - ^(void) { - UIImage *tmpImage2 = [UIImage decodedImageWithImage:tmpImage]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self setImage:tmpImage2]; - }); - }); - } - } - ms_free(lAddress); - } - if (useLinphoneAddress) { - const char *lDisplayName = linphone_address_get_display_name(addr); - const char *lUserName = linphone_address_get_username(addr); - if (lDisplayName) - self.address = [NSString stringWithUTF8String:lDisplayName]; - else if (lUserName) - self.address = [NSString stringWithUTF8String:lUserName]; - } + ABRecordRef contact = [FastAddressBook getContactWithLinphoneAddress:addr]; + UIImage *tmpImage = [FastAddressBook getContactImage:contact thumbnail:false]; + if (tmpImage != nil) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), ^(void) { + UIImage *tmpImage2 = [UIImage decodedImageWithImage:tmpImage]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self setImage:tmpImage2]; + }); + }); } } diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index af7fed6e1..7c614bd01 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -68,9 +68,10 @@ LOGW(@"Cannot update chat cell: null chat"); return; } - const LinphoneAddress *linphoneAddress = linphone_chat_room_get_peer_address(chatRoom); - [FastAddressBook setDisplayNameLabel:addressLabel forAddress:linphoneAddress]; - avatarImage.image = [FastAddressBook avatarForAddress:linphoneAddress]; + const LinphoneAddress *addr = linphone_chat_room_get_peer_address(chatRoom); + [FastAddressBook setDisplayNameLabel:addressLabel forAddress:addr]; + avatarImage.image = + [FastAddressBook getContactImage:[FastAddressBook getContactWithLinphoneAddress:addr] thumbnail:NO]; LinphoneChatMessage *last_message = linphone_chat_room_get_user_data(chatRoom); if (last_message) { diff --git a/Classes/LinphoneUI/UIHistoryCell.m b/Classes/LinphoneUI/UIHistoryCell.m index 5a7991bac..181acc2d6 100644 --- a/Classes/LinphoneUI/UIHistoryCell.m +++ b/Classes/LinphoneUI/UIHistoryCell.m @@ -116,10 +116,11 @@ image = [UIImage imageNamed:@"call_status_outgoing.png"]; addr = linphone_call_log_get_to_address(callLog); } - - [FastAddressBook setDisplayNameLabel:displayNameLabel forAddress:addr]; - [_avatarImage setImage:[FastAddressBook avatarForAddress:addr]]; [historyStateButton setImage:image forState:UIControlStateNormal]; + + ABRecordRef contact = [FastAddressBook getContactWithLinphoneAddress:addr]; + [FastAddressBook setDisplayNameLabel:displayNameLabel forContact:contact]; + _avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:TRUE]; } - (void)setEditing:(BOOL)editing { diff --git a/Classes/Utils/FastAddressBook.h b/Classes/Utils/FastAddressBook.h index fcfb52ae6..5f34ca9e5 100644 --- a/Classes/Utils/FastAddressBook.h +++ b/Classes/Utils/FastAddressBook.h @@ -23,30 +23,33 @@ #include "linphone/linphonecore.h" @interface FastAddressBook : NSObject { - NSMutableDictionary* addressBookMap; - - ABAddressBookRef addressBook; + NSMutableDictionary *addressBookMap; + ABAddressBookRef addressBook; } -+ (BOOL)isSipURI:(NSString*)address; -+ (NSString*)getContactDisplayName:(ABRecordRef)contact; -+ (UIImage*)getContactImage:(ABRecordRef)contact thumbnail:(BOOL)thumbnail; -- (ABRecordRef)getContact:(NSString*)address; - (void)reload; - (void)saveAddressBook; + + (BOOL)isAuthorized; -+ (NSString*)appendCountryCodeIfPossible:(NSString*)number; -+ (NSString*)normalizePhoneNumber:(NSString*)number; -+ (NSString*)normalizeSipURI:(NSString*)address; // TOOLS -+(NSString*)localizedLabel:(NSString*)label; -+ (UIImage *)avatarForAddress:(const LinphoneAddress *)addr; ++ (ABRecordRef)getContact:(NSString *)address; ++ (ABRecordRef)getContactWithLinphoneAddress:(const LinphoneAddress *)address; + ++ (NSString *)getContactDisplayName:(ABRecordRef)contact; ++ (UIImage *)getContactImage:(ABRecordRef)contact thumbnail:(BOOL)thumbnail; + (BOOL)contactHasValidSipDomain:(ABRecordRef)person; -+ (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr; + (void)setDisplayNameLabel:(UILabel *)label forContact:(ABRecordRef)contact; + + (NSString *)displayNameForAddress:(const LinphoneAddress *)addr; -+ (NSString *)displayNameForContact:(ABRecordRef)contact; ++ (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr; + ++ (BOOL)isSipURI:(NSString *)address; // should be removed ++ (NSString *)appendCountryCodeIfPossible:(NSString *)number; // should be removed ++ (NSString *)normalizePhoneNumber:(NSString *)number; // should be removed ++ (NSString *)normalizeSipURI:(NSString *)address; // should be removed + ++ (NSString *)localizedLabel:(NSString *)label; @end diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 849d16b4b..5f1f467b0 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -64,22 +64,34 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info contact, thumbnail ? kABPersonImageFormatThumbnail : kABPersonImageFormatOriginalSize)); retImage = [UIImage imageWithData:imgData]; - - if (retImage != nil && retImage.size.width != retImage.size.height) { - LOGI(@"Image is not square : cropping it."); - return [self squareImageCrop:retImage]; - } } - + if (retImage == nil) { + retImage = [UIImage imageNamed:@"avatar"]; + } + if (retImage.size.width != retImage.size.height) { + LOGW(@"Image is not square (%@): cropping it.", retImage.size); + retImage = [self squareImageCrop:retImage]; + } return retImage; } -- (ABRecordRef)getContact:(NSString *)address { - @synchronized(addressBookMap) { - return (__bridge ABRecordRef)[addressBookMap objectForKey:address]; ++ (ABRecordRef)getContact:(NSString *)address { + @synchronized(LinphoneManager.instance.fastAddressBook->addressBookMap) { + return (__bridge ABRecordRef)[LinphoneManager.instance.fastAddressBook->addressBookMap objectForKey:address]; } } ++ (ABRecordRef)getContactWithLinphoneAddress:(const LinphoneAddress *)address { + ABRecordRef contact = nil; + if (address) { + char *uri = linphone_address_as_string_uri_only(address); + NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:uri]]; + contact = [FastAddressBook getContact:normalizedSipAddress]; + ms_free(uri); + } + return contact; +} + + (BOOL)isSipURI:(NSString *)address { return [address hasPrefix:@"sip:"] || [address hasPrefix:@"sips:"]; } @@ -341,16 +353,10 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void + (NSString *)displayNameForAddress:(const LinphoneAddress *)addr { NSString *ret = NSLocalizedString(@"Unknown", nil); - if (addr != NULL) { - char *lAddress = linphone_address_as_string_uri_only(addr); - if (lAddress) { - NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]]; - ms_free(lAddress); - ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; - if (contact) { - return [FastAddressBook displayNameForContact:contact]; - } - } + ABRecordRef contact = [FastAddressBook getContactWithLinphoneAddress:addr]; + if (contact) { + ret = [FastAddressBook displayNameForContact:contact]; + } else { const char *lDisplayName = linphone_address_get_display_name(addr); const char *lUserName = linphone_address_get_username(addr); if (lDisplayName) { @@ -366,24 +372,4 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void label.text = [FastAddressBook displayNameForAddress:addr]; } -+ (UIImage *)avatarForAddress:(const LinphoneAddress *)addr { - UIImage *avatar = nil; - if (addr != NULL) { - // contact name - char *lAddress = linphone_address_as_string_uri_only(addr); - if (lAddress) { - NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]]; - ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress]; - if (contact) { - avatar = [FastAddressBook getContactImage:contact thumbnail:TRUE]; - } - ms_free(lAddress); - } - } - if (avatar == nil) { - avatar = [UIImage imageNamed:@"avatar"]; - } - return avatar; -} - @end