diff --git a/Classes/Base.lproj/ChatRoomViewController.xib b/Classes/Base.lproj/ChatRoomViewController.xib index b35749862..74afbc6db 100644 --- a/Classes/Base.lproj/ChatRoomViewController.xib +++ b/Classes/Base.lproj/ChatRoomViewController.xib @@ -14,8 +14,7 @@ - - + @@ -28,6 +27,43 @@ + + + + + + + + + @@ -36,11 +72,7 @@ - - - - - + @@ -49,7 +81,7 @@ + - + @@ -72,7 +111,7 @@ - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + - + - - - - - - - - - - - - - @@ -207,23 +181,18 @@ + - - - - - - - - - - - - - - + + + + + + + + diff --git a/Classes/ChatRoomViewController.h b/Classes/ChatRoomViewController.h index 763018847..36b760ccd 100644 --- a/Classes/ChatRoomViewController.h +++ b/Classes/ChatRoomViewController.h @@ -22,30 +22,28 @@ #import "UIToggleButton.h" #import "UICompositeViewController.h" #import "ChatRoomTableViewController.h" -#import "HPGrowingTextView.h" #import "ImagePickerViewController.h" #import "OrderedDictionary.h" #include "linphone/linphonecore.h" -@interface ChatRoomViewController : UIViewController { - LinphoneChatRoom *chatRoom; - OrderedDictionary *imageQualities; - BOOL scrollOnGrowingEnabled; - BOOL composingVisible; +@interface ChatRoomViewController + : UIViewController { + LinphoneChatRoom *chatRoom; + OrderedDictionary *imageQualities; + BOOL scrollOnGrowingEnabled; + BOOL composingVisible; } @property (nonatomic, strong) IBOutlet ChatRoomTableViewController* tableController; @property (nonatomic, strong) IBOutlet UIToggleButton *editButton; -@property (nonatomic, strong) IBOutlet HPGrowingTextView* messageField; +@property(weak, nonatomic) IBOutlet UITextView *messageField; @property (nonatomic, strong) IBOutlet UIButton* sendButton; @property (nonatomic, strong) IBOutlet UILabel *addressLabel; @property (nonatomic, strong) IBOutlet UIImageView *avatarImage; @property (nonatomic, strong) IBOutlet UIView *headerView; @property (nonatomic, strong) IBOutlet UIView *chatView; @property (nonatomic, strong) IBOutlet UIView *messageView; -@property (nonatomic, strong) IBOutlet UIImageView *messageBackgroundImage; -@property (nonatomic, strong) IBOutlet UIImageView *transferBackgroundImage; @property (nonatomic, strong) IBOutlet UITapGestureRecognizer *listTapGestureRecognizer; @property (nonatomic, strong) IBOutlet UISwipeGestureRecognizer *listSwipeGestureRecognizer; @property (strong, nonatomic) IBOutlet UILabel *composeLabel; diff --git a/Classes/ChatRoomViewController.m b/Classes/ChatRoomViewController.m index 7d937f20e..43c8a1db7 100644 --- a/Classes/ChatRoomViewController.m +++ b/Classes/ChatRoomViewController.m @@ -30,9 +30,9 @@ @implementation ChatRoomViewController +@synthesize messageField; @synthesize tableController; @synthesize sendButton; -@synthesize messageField; @synthesize editButton; @synthesize addressLabel; @synthesize composeLabel; @@ -41,8 +41,6 @@ @synthesize headerView; @synthesize chatView; @synthesize messageView; -@synthesize messageBackgroundImage; -@synthesize transferBackgroundImage; @synthesize listTapGestureRecognizer; @synthesize listSwipeGestureRecognizer; @synthesize pictureButton; @@ -94,21 +92,6 @@ static UICompositeViewDescription *compositeDescription = nil; [super viewDidLoad]; [tableController setChatRoomDelegate:self]; - // Set selected+over background: IB lack ! - [editButton setBackgroundImage:[UIImage imageNamed:@"chat_ok_over.png"] - forState:(UIControlStateHighlighted | UIControlStateSelected)]; - - [LinphoneUtils buttonFixStates:editButton]; - - messageField.minNumberOfLines = 1; - messageField.maxNumberOfLines = ([LinphoneManager runningOnIpad]) ? 10 : 3; - messageField.delegate = self; - messageField.font = [UIFont systemFontOfSize:18.0f]; - messageField.contentInset = UIEdgeInsetsMake(0, -5, -2, -5); - messageField.internalTextView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 10); - messageField.backgroundColor = [UIColor clearColor]; - [sendButton setEnabled:FALSE]; - [tableController.tableView addGestureRecognizer:listTapGestureRecognizer]; [listTapGestureRecognizer setEnabled:FALSE]; @@ -152,9 +135,6 @@ static UICompositeViewDescription *compositeDescription = nil; [editButton setOff]; [[tableController tableView] reloadData]; - [messageBackgroundImage setImage:[TUNinePatchCache imageOfSize:[messageBackgroundImage bounds].size - forNinePatchNamed:@"chat_message_background"]]; - BOOL fileSharingEnabled = [[LinphoneManager instance] lpConfigStringForKey:@"sharing_server_preference"] != NULL && [[[LinphoneManager instance] lpConfigStringForKey:@"sharing_server_preference"] length] > 0; @@ -173,8 +153,6 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; - [messageBackgroundImage setImage:[TUNinePatchCache imageOfSize:[messageBackgroundImage bounds].size - forNinePatchNamed:@"chat_message_background"]]; [tableController scrollToBottom:true]; } @@ -411,7 +389,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st #pragma mark - UITextFieldDelegate Functions -- (BOOL)growingTextViewShouldBeginEditing:(HPGrowingTextView *)growingTextView { +- (BOOL)textViewShouldBeginEditing:(UITextView *)textView { if (editButton.selected) { [tableController setEditing:FALSE animated:TRUE]; [editButton setOff]; @@ -420,17 +398,34 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st return TRUE; } -- (BOOL)growingTextViewShouldEndEditing:(HPGrowingTextView *)growingTextView { +- (BOOL)textViewShouldEndEditing:(UITextView *)textView { [listTapGestureRecognizer setEnabled:FALSE]; return TRUE; } -- (void)growingTextChanged:(HPGrowingTextView *)growingTextView text:(NSString *)text { - if ([text length] > 0 && chatRoom) - linphone_chat_room_compose(chatRoom); +- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { + if ([text isEqualToString:@"\n"]) { + [listTapGestureRecognizer setEnabled:FALSE]; + [self onSendClick:nil]; + textView.text = @""; + return NO; + } + return YES; } -- (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height { +- (void)textViewDidChange:(UITextView *)textView { + if ([textView.text length] > 0) { + linphone_chat_room_compose(chatRoom); + } +} + +- (void)textViewDidEndEditing:(UITextView *)textView { + [listTapGestureRecognizer setEnabled:FALSE]; + [textView resignFirstResponder]; +} + +/* + - (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height { int diff = height - growingTextView.bounds.size.height; if (diff != 0) { @@ -453,8 +448,6 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st tableRect.size.height -= diff; [tableController.view setFrame:tableRect]; - [messageBackgroundImage setImage:[TUNinePatchCache imageOfSize:[messageBackgroundImage bounds].size - forNinePatchNamed:@"chat_message_background"]]; // if we're showing the compose message, update it position if (![composeLabel isHidden]) { CGRect frame = [composeLabel frame]; @@ -462,7 +455,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st [composeLabel setFrame:frame]; } } -} +}*/ #pragma mark - Action Functions diff --git a/Classes/ContactsTableViewController.m b/Classes/ContactsTableViewController.m index ae8cd8882..2e0ff9383 100644 --- a/Classes/ContactsTableViewController.m +++ b/Classes/ContactsTableViewController.m @@ -63,45 +63,6 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info #pragma mark - -- (BOOL)contactHasValidSipDomain:(ABRecordRef)person { - // Check if one of the contact' sip URI matches the expected SIP filter - ABMultiValueRef personSipAddresses = ABRecordCopyValue(person, kABPersonInstantMessageProperty); - BOOL match = false; - NSString *filter = [ContactSelection getSipFilter]; - - for (int i = 0; i < ABMultiValueGetCount(personSipAddresses) && !match; ++i) { - CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(personSipAddresses, i); - if (CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) { - CFStringRef serviceKey = CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey); - - if (CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, serviceKey, - kCFCompareCaseInsensitive) == 0) { - match = true; - } - } else { - // check domain - LinphoneAddress *address = linphone_address_new( - [(NSString *)CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey) UTF8String]); - - if (address) { - const char *dom = linphone_address_get_domain(address); - if (dom != NULL) { - NSString *domain = [NSString stringWithCString:dom encoding:[NSString defaultCStringEncoding]]; - - if (([filter compare:@"*" options:NSCaseInsensitiveSearch] == NSOrderedSame) || - ([filter compare:domain options:NSCaseInsensitiveSearch] == NSOrderedSame)) { - match = true; - } - } - linphone_address_destroy(address); - } - } - CFRelease(lDict); - } - CFRelease(personSipAddresses); - return match; -} - static int ms_strcmpfuz(const char *fuzzy_word, const char *sentence) { if (!fuzzy_word || !sentence) { return fuzzy_word == sentence; @@ -138,7 +99,7 @@ static int ms_strcmpfuz(const char *fuzzy_word, const char *sentence) { if ([ContactSelection getSipFilter] || [ContactSelection emailFilterEnabled]) { add = false; } - if ([ContactSelection getSipFilter] && [self contactHasValidSipDomain:person]) { + if ([FastAddressBook contactHasValidSipDomain:person]) { add = true; } if (!add && [ContactSelection emailFilterEnabled]) { @@ -175,8 +136,7 @@ static int ms_strcmpfuz(const char *fuzzy_word, const char *sentence) { [[name lowercaseString] UTF8String]) == 0)) { // Sort contacts by first letter. We need to translate the name to ASCII first, because of UTF-8 - // issues. For instance - // we expect order: Alberta(A tilde) before ASylvano. + // issues. For instance expected order would be: Alberta(A tilde) before ASylvano. NSData *name2ASCIIdata = [name dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *name2ASCII = diff --git a/Classes/ContactsViewController.m b/Classes/ContactsViewController.m index 6d86482cf..229857b12 100644 --- a/Classes/ContactsViewController.m +++ b/Classes/ContactsViewController.m @@ -175,34 +175,9 @@ static UICompositeViewDescription *compositeDescription = nil; } } -- (void)viewDidDisappear:(BOOL)animated { - [super viewDidDisappear:animated]; -} - - (void)viewDidLoad { [super viewDidLoad]; - [self changeView:History_All]; - - [linphoneButton.titleLabel setAdjustsFontSizeToFitWidth:TRUE]; - - // Set selected+over background: IB lack ! - [linphoneButton setBackgroundImage:[UIImage imageNamed:@"contacts_linphone_selected.png"] - forState:(UIControlStateHighlighted | UIControlStateSelected)]; - - [linphoneButton setTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] - forState:UIControlStateNormal]; - - [LinphoneUtils buttonFixStates:linphoneButton]; - - // Set selected+over background: IB lack ! - [allButton setBackgroundImage:[UIImage imageNamed:@"contacts_all_selected.png"] - forState:(UIControlStateHighlighted | UIControlStateSelected)]; - - [LinphoneUtils buttonFixStates:allButton]; - - // [tableController.tableView setBackgroundColor:[UIColor clearColor]]; // Can't do it in Xib: issue with ios4 - // [tableController.tableView setBackgroundView:nil]; // Can't do it in Xib: issue with ios4 } #pragma mark - diff --git a/Classes/LinphoneUI/Base.lproj/UIContactCell.xib b/Classes/LinphoneUI/Base.lproj/UIContactCell.xib index 15083b17e..6c4f16eab 100644 --- a/Classes/LinphoneUI/Base.lproj/UIContactCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIContactCell.xib @@ -33,7 +33,7 @@ IBCocoaTouchFramework - + 274 @@ -41,17 +41,23 @@ 300 {{6, 6}, {32, 32}} + _NS:9 NO IBCocoaTouchFramework + + NSImage + avatar.png + 274 - {{46, 0}, {95, 44}} + {{46, 0}, {261, 44}} - + + _NS:328 3 @@ -66,52 +72,63 @@ Firstname IBCocoaTouchFramework - John + YES + + John Doe + + + + 3 + MAA + + + HelveticaNeue + 25 + 16 + + + 4 + + + + + + + HelveticaNeue-Bold + 25 + 16 + + + + + + BQADAQ + + 1 10 - - 1 - 0 - 25 - - - HelveticaNeue - 25 - 16 - YES - + - 274 - {{111, 0}, {240, 44}} + 300 + {{315, 12}, {37, 20}} - _NS:328 - - NO - YES - 7 - 2 + + + _NS:9 NO - - Lastname - IBCocoaTouchFramework - Doe - - 1 - 10 - - 2 - 30 - 25 + + NSImage + incoming_call_icon.png - - YES {360, 44} + + _NS:9 @@ -124,22 +141,6 @@ - - - firstNameLabel - - - - 17 - - - - lastNameLabel - - - - 18 - avatarImage @@ -148,6 +149,22 @@ 24 + + + nameLabel + + + + 26 + + + + linphoneImage + + + + 27 + @@ -174,7 +191,7 @@ - + @@ -182,13 +199,7 @@ 6 - firstName - - - 10 - - - lastName + nameLabel 23 @@ -196,6 +207,12 @@ avatarImage + + 25 + + + linphoneImage + @@ -203,18 +220,116 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIResponder com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIRoundedImageView com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 24 + 27 + + + + + UIContactCell + UITransparentTVCell + + UIImageView + UIImageView + UILabel + + + + avatarImage + UIImageView + + + linphoneImage + UIImageView + + + nameLabel + UILabel + + + + IBProjectSource + ../Classes/LinphoneUI/UIContactCell.h + + + + UIRoundedImageView + UIImageView + + IBProjectSource + ../Classes/LinphoneUI/UIRoundedImageView.h + + + + UITransparentTVCell + UITableViewCell + + IBProjectSource + ../Classes/LinphoneUI/UITransparentTVCell.h + + + + + + UIGestureRecognizer + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIGestureRecognizer.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UIResponder + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UITableViewCell + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITableViewCell.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + - 0 IBCocoaTouchFramework NO @@ -224,5 +339,9 @@ YES 3 + + {751, 751} + {111, 62} + diff --git a/Classes/LinphoneUI/UIContactCell.h b/Classes/LinphoneUI/UIContactCell.h index 06c26b305..f27ec85f4 100644 --- a/Classes/LinphoneUI/UIContactCell.h +++ b/Classes/LinphoneUI/UIContactCell.h @@ -24,9 +24,9 @@ @interface UIContactCell : UITransparentTVCell { } -@property (nonatomic, strong) IBOutlet UILabel* firstNameLabel; -@property (nonatomic, strong) IBOutlet UILabel* lastNameLabel; +@property(nonatomic, strong) IBOutlet UILabel *nameLabel; @property (nonatomic, strong) IBOutlet UIImageView *avatarImage; +@property(weak, nonatomic) IBOutlet UIImageView *linphoneImage; @property (nonatomic, assign) ABRecordRef contact; - (id)initWithIdentifier:(NSString*)identifier; diff --git a/Classes/LinphoneUI/UIContactCell.m b/Classes/LinphoneUI/UIContactCell.m index a15fb5917..ef23b1a34 100644 --- a/Classes/LinphoneUI/UIContactCell.m +++ b/Classes/LinphoneUI/UIContactCell.m @@ -20,11 +20,11 @@ #import "UIContactCell.h" #import "Utils.h" #import "FastAddressBook.h" +#import "UILabel+Boldify.h" @implementation UIContactCell -@synthesize firstNameLabel; -@synthesize lastNameLabel; +@synthesize nameLabel; @synthesize avatarImage; @synthesize contact; @@ -45,7 +45,25 @@ - (void)setContact:(ABRecordRef)acontact { contact = acontact; - [self update]; + if (contact != nil) { + NSString *lFirstName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonFirstNameProperty)); + NSString *lLocalizedFirstName = [FastAddressBook localizedLabel:lFirstName]; + + NSString *lLastName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonLastNameProperty)); + NSString *lLocalizedLastName = [FastAddressBook localizedLabel:lLastName]; + + NSString *lOrganization = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonOrganizationProperty)); + NSString *lLocalizedOrganization = [FastAddressBook localizedLabel:lOrganization]; + + if (lLocalizedFirstName == nil && lLocalizedLastName == nil) { + [nameLabel setText:(NSString *)(lLocalizedOrganization)]; + } else { + nameLabel.text = [NSString stringWithFormat:@"%@ %@", lLocalizedFirstName, lLocalizedLastName]; + [nameLabel boldSubstring:lLocalizedLastName]; + } + + _linphoneImage.hidden = !([FastAddressBook contactHasValidSipDomain:contact]); + } } #pragma mark - @@ -59,60 +77,7 @@ } - (NSString *)accessibilityLabel { - return [NSString stringWithFormat:@"%@ %@", firstNameLabel.text, lastNameLabel.text]; -} - -- (void)update { - if (contact == NULL) { - LOGW(@"Cannot update contact cell: null contact"); - return; - } - - NSString *lFirstName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonFirstNameProperty)); - NSString *lLocalizedFirstName = [FastAddressBook localizedLabel:lFirstName]; - - NSString *lLastName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonLastNameProperty)); - NSString *lLocalizedLastName = [FastAddressBook localizedLabel:lLastName]; - - NSString *lOrganization = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonOrganizationProperty)); - NSString *lLocalizedOrganization = [FastAddressBook localizedLabel:lOrganization]; - - [firstNameLabel setText:(NSString *)(lLocalizedFirstName)]; - [lastNameLabel setText:(NSString *)(lLocalizedLastName)]; - - if (lLocalizedFirstName == nil && lLocalizedLastName == nil) { - [firstNameLabel setText:(NSString *)(lLocalizedOrganization)]; - } -} - -- (void)layoutSubviews { - [super layoutSubviews]; - // - // Adapt size - // - CGRect firstNameFrame = [firstNameLabel frame]; - CGRect lastNameFrame = [lastNameLabel frame]; - - // Compute firstName size - CGSize firstNameSize = [[firstNameLabel text] sizeWithFont:[firstNameLabel font]]; - CGSize lastNameSize = [[lastNameLabel text] sizeWithFont:[lastNameLabel font]]; - float sum = firstNameSize.width + 5 + lastNameSize.width; - float limit = self.bounds.size.width - 5 - firstNameFrame.origin.x; - if (sum > limit) { - firstNameSize.width *= limit / sum; - lastNameSize.width *= limit / sum; - } - - firstNameFrame.size.width = firstNameSize.width; - lastNameFrame.size.width = lastNameSize.width; - - // Compute lastName size & position - lastNameFrame.origin.x = firstNameFrame.origin.x + firstNameFrame.size.width; - if (firstNameFrame.size.width) - lastNameFrame.origin.x += 5; - - [firstNameLabel setFrame:firstNameFrame]; - [lastNameLabel setFrame:lastNameFrame]; + return nameLabel.text; } - (void)setHighlighted:(BOOL)highlighted { @@ -122,11 +87,9 @@ - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { [super setHighlighted:highlighted animated:animated]; if (highlighted) { - [lastNameLabel setTextColor:[UIColor whiteColor]]; - [firstNameLabel setTextColor:[UIColor whiteColor]]; + [nameLabel setTextColor:[UIColor whiteColor]]; } else { - [lastNameLabel setTextColor:[UIColor blackColor]]; - [firstNameLabel setTextColor:[UIColor blackColor]]; + [nameLabel setTextColor:[UIColor blackColor]]; } } diff --git a/Classes/LinphoneUI/UILabel+Boldify.h b/Classes/LinphoneUI/UILabel+Boldify.h new file mode 100644 index 000000000..bac9c5995 --- /dev/null +++ b/Classes/LinphoneUI/UILabel+Boldify.h @@ -0,0 +1,16 @@ +// +// UILabel+Boldify.h +// linphone +// +// Created by guillaume on 20/05/2015. +// Copyright (c) 2015 Urmet. All rights reserved. +// + +#import + +@interface UILabel (Boldify) + +- (void)boldSubstring:(NSString *)substring; +- (void)boldRange:(NSRange)range; + +@end diff --git a/Classes/LinphoneUI/UILabel+Boldify.m b/Classes/LinphoneUI/UILabel+Boldify.m new file mode 100644 index 000000000..6b95716eb --- /dev/null +++ b/Classes/LinphoneUI/UILabel+Boldify.m @@ -0,0 +1,30 @@ +// +// UILabel+Boldify.m +// linphone +// +// Created by guillaume on 20/05/2015. +// +// + +#import "UILabel+Boldify.h" + +@implementation UILabel (Boldify) + +- (void)boldRange:(NSRange)range { + if (![self respondsToSelector:@selector(setAttributedText:)]) { + return; + } + NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:self.text]; + [attributedText setAttributes:@{ + NSFontAttributeName : [UIFont boldSystemFontOfSize:self.font.pointSize] + } range:range]; + + self.attributedText = attributedText; +} + +- (void)boldSubstring:(NSString *)substring { + NSRange range = [self.text rangeOfString:substring]; + [self boldRange:range]; +} + +@end diff --git a/Classes/Utils/FastAddressBook.h b/Classes/Utils/FastAddressBook.h index a33b25545..909a0dbf1 100644 --- a/Classes/Utils/FastAddressBook.h +++ b/Classes/Utils/FastAddressBook.h @@ -36,7 +36,7 @@ + (NSString*)appendCountryCodeIfPossible:(NSString*)number; + (NSString*)normalizePhoneNumber:(NSString*)number; + (NSString*)normalizeSipURI:(NSString*)address; - ++ (BOOL)contactHasValidSipDomain:(ABRecordRef)person; // TOOLS diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index aa076ea62..ea2dbace6 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -19,6 +19,7 @@ #import "FastAddressBook.h" #import "LinphoneManager.h" +#import "ContactsViewController.h" @implementation FastAddressBook @@ -268,4 +269,42 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void return @""; } ++ (BOOL)contactHasValidSipDomain:(ABRecordRef)person { + // Check if one of the contact' sip URI matches the expected SIP filter + ABMultiValueRef personSipAddresses = ABRecordCopyValue(person, kABPersonInstantMessageProperty); + BOOL match = false; + NSString *domain = [ContactSelection getSipFilter]; + + for (int i = 0; i < ABMultiValueGetCount(personSipAddresses) && !match; ++i) { + CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(personSipAddresses, i); + if (CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) { + CFStringRef serviceKey = CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey); + + if (CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, serviceKey, + kCFCompareCaseInsensitive) == 0) { + match = true; + } + } else if (domain != nil) { + // check domain + LinphoneAddress *address = linphone_address_new( + [(NSString *)CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey) UTF8String]); + + if (address) { + const char *dom = linphone_address_get_domain(address); + if (dom != NULL) { + NSString *contactDomain = + [NSString stringWithCString:dom encoding:[NSString defaultCStringEncoding]]; + + match = (([domain compare:@"*" options:NSCaseInsensitiveSearch] == NSOrderedSame) || + ([domain compare:contactDomain options:NSCaseInsensitiveSearch] == NSOrderedSame)); + } + linphone_address_destroy(address); + } + } + CFRelease(lDict); + } + CFRelease(personSipAddresses); + return match; +} + @end diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 47f8e28fe..33b8a83b4 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -110,6 +110,7 @@ 631C4FB719D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m in Sources */ = {isa = PBXBuildFile; fileRef = 631C4FB619D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m */; }; 632DA24D1B43EE9400EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; }; 632DA24E1B43EEEF00EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; }; + 634610061B61330300548952 /* UILabel+Boldify.m in Sources */ = {isa = PBXBuildFile; fileRef = 634610051B61330300548952 /* UILabel+Boldify.m */; }; 636316D11A1DEBCB0009B839 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D31A1DEBCB0009B839 /* AboutViewController.xib */; }; 636316D41A1DEC650009B839 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D61A1DEC650009B839 /* SettingsViewController.xib */; }; 636316D91A1DECC90009B839 /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D71A1DECC90009B839 /* PhoneMainView.xib */; }; @@ -683,6 +684,8 @@ 631C4FB519D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDigitButtonLongVoiceMail.h; sourceTree = ""; }; 631C4FB619D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIDigitButtonLongVoiceMail.m; sourceTree = ""; }; 633E388219FFB0F400936D1C /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + 634610041B61330300548952 /* UILabel+Boldify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UILabel+Boldify.h"; sourceTree = ""; }; + 634610051B61330300548952 /* UILabel+Boldify.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UILabel+Boldify.m"; sourceTree = ""; }; 636316D21A1DEBCB0009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/AboutViewController.xib; sourceTree = ""; }; 636316D51A1DEC650009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SettingsViewController.xib; sourceTree = ""; }; 636316D81A1DECC90009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/PhoneMainView.xib; sourceTree = ""; }; @@ -1480,6 +1483,8 @@ D32460E5159D9AAD00BA7F3A /* UITransparentView.m */, 340751E5150F38FC00B89C47 /* UIVideoButton.h */, 340751E6150F38FD00B89C47 /* UIVideoButton.m */, + 634610041B61330300548952 /* UILabel+Boldify.h */, + 634610051B61330300548952 /* UILabel+Boldify.m */, ); path = LinphoneUI; sourceTree = ""; @@ -2535,6 +2540,7 @@ 22F2508E107141E100AC9B3F /* DialerViewController.m in Sources */, 22E0A822111C44E100B04932 /* AboutViewController.m in Sources */, 631C4FB119D2A8F2004BFE77 /* UIDigitButtonLongPlus.m in Sources */, + 634610061B61330300548952 /* UILabel+Boldify.m in Sources */, 2248E90E12F7E4CF00220D9C /* UIDigitButton.m in Sources */, 2214EB7A12F846B1002A5394 /* UICallButton.m in Sources */, 2214EB8912F84EBB002A5394 /* UIHangUpButton.m in Sources */,