diff --git a/Classes/AboutView.m b/Classes/AboutView.m index bdd061eaa..884a34013 100644 --- a/Classes/AboutView.m +++ b/Classes/AboutView.m @@ -128,6 +128,6 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onDialerBackClick:(id)sender { - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; + [PhoneMainView.instance popToView:DialerView.compositeViewDescription]; } @end diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 292abd547..89317afc5 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -125,7 +125,7 @@ static UICompositeViewDescription *compositeDescription = nil; linphone_account_creator_unref(account_creator); account_creator = NULL; } - [[LinphoneManager instance] resetLinphoneCore]; + [LinphoneManager.instance resetLinphoneCore]; account_creator = linphone_account_creator_new( LC, [LinphoneManager.instance lpConfigStringForKey:@"xmlrpc_url" inSection:@"assistant" withDefault:@""] .UTF8String); @@ -140,14 +140,14 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)loadAssistantConfig:(NSString *)rcFilename { NSString *fullPath = [@"file://" stringByAppendingString:[LinphoneManager bundleFile:rcFilename]]; linphone_core_set_provisioning_uri(LC, fullPath.UTF8String); - [[LinphoneManager instance] lpConfigSetInt:1 forKey:@"transient_provisioning" inSection:@"misc"]; + [LinphoneManager.instance lpConfigSetInt:1 forKey:@"transient_provisioning" inSection:@"misc"]; [self resetLiblinphone]; } - (void)reset { - [[LinphoneManager instance] removeAllAccounts]; - [[LinphoneManager instance] lpConfigSetBool:FALSE forKey:@"pushnotification_preference"]; + [LinphoneManager.instance removeAllAccounts]; + [LinphoneManager.instance lpConfigSetBool:FALSE forKey:@"pushnotification_preference"]; LinphoneCore *lc = LC; LCSipTransports transportValue = {5060, 5060, -1, -1}; @@ -156,8 +156,8 @@ static UICompositeViewDescription *compositeDescription = nil; LOGE(@"cannot set transport"); } - [[LinphoneManager instance] lpConfigSetBool:FALSE forKey:@"ice_preference"]; - [[LinphoneManager instance] lpConfigSetString:@"" forKey:@"stun_preference"]; + [LinphoneManager.instance lpConfigSetBool:FALSE forKey:@"ice_preference"]; + [LinphoneManager.instance lpConfigSetString:@"" forKey:@"stun_preference"]; linphone_core_set_stun_server(lc, NULL); linphone_core_set_firewall_policy(lc, LinphonePolicyNoFirewall); [self resetTextFields]; @@ -170,7 +170,7 @@ static UICompositeViewDescription *compositeDescription = nil; } + (NSString *)errorForStatus:(LinphoneAccountCreatorStatus)status { - BOOL usePhoneNumber = [[LinphoneManager instance] lpConfigBoolForKey:@"use_phone_number" inSection:@"assistant"]; + BOOL usePhoneNumber = [LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number" inSection:@"assistant"]; switch (status) { case LinphoneAccountCreatorEmailInvalid: return NSLocalizedString(@"Invalid email.", nil); @@ -214,7 +214,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)configureProxyConfig { LinphoneCore *lc = LC; - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; // remove previous proxy config, if any if (new_config != NULL) { @@ -232,7 +232,7 @@ static UICompositeViewDescription *compositeDescription = nil; linphone_core_set_default_proxy_config(lc, new_config); // reload address book to prepend proxy config domain to contacts' phone number // todo: STOP doing that! - [[[LinphoneManager instance] fastAddressBook] reload]; + [[LinphoneManager.instance fastAddressBook] reload]; } } @@ -247,10 +247,9 @@ static UICompositeViewDescription *compositeDescription = nil; [self displayUsernameAsPhoneOrUsername]; if (view == _welcomeView) { - BOOL show_logo = - [[LinphoneManager instance] lpConfigBoolForKey:@"show_assistant_logo_in_choice_view_preference"]; - BOOL show_extern = ![[LinphoneManager instance] lpConfigBoolForKey:@"hide_assistant_custom_account"]; - BOOL show_new = ![[LinphoneManager instance] lpConfigBoolForKey:@"hide_assistant_create_account"]; + BOOL show_logo = [LinphoneManager.instance lpConfigBoolForKey:@"show_assistant_logo_in_choice_view_preference"]; + BOOL show_extern = ![LinphoneManager.instance lpConfigBoolForKey:@"hide_assistant_custom_account"]; + BOOL show_new = ![LinphoneManager.instance lpConfigBoolForKey:@"hide_assistant_create_account"]; if (!placement_done) { // visibility @@ -321,7 +320,7 @@ static UICompositeViewDescription *compositeDescription = nil; LinphoneProxyConfig *default_conf = linphone_core_create_proxy_config(LC); const char *identity = linphone_proxy_config_get_identity(default_conf); if (identity) { - LinphoneAddress *default_addr = linphone_address_new(identity); + LinphoneAddress *default_addr = linphone_core_interpret_url(LC, identity); if (default_addr) { const char *domain = linphone_address_get_domain(default_addr); const char *username = linphone_address_get_username(default_addr); @@ -507,7 +506,7 @@ static UICompositeViewDescription *compositeDescription = nil; switch (state) { case LinphoneRegistrationOk: { _waitView.hidden = true; - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; + [PhoneMainView.instance popToView:DialerView.compositeViewDescription]; break; } case LinphoneRegistrationNone: @@ -527,7 +526,7 @@ static UICompositeViewDescription *compositeDescription = nil; otherButtonTitles:nil]; [alert addButtonWithTitle:@"Continue" block:^(void) { - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; + [PhoneMainView.instance popToView:DialerView.compositeViewDescription]; }]; [alert show]; break; @@ -623,7 +622,7 @@ void assistant_validation_tested(LinphoneAccountCreator *creator, LinphoneAccoun [alert addButtonWithTitle:NSLocalizedString(@"Skip verification", nil) block:^{ [thiz configureProxyConfig]; - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; + [PhoneMainView.instance popToView:DialerView.compositeViewDescription]; }]; [alert show]; } @@ -695,7 +694,7 @@ void assistant_validation_tested(LinphoneAccountCreator *creator, LinphoneAccoun nextView = _remoteProvisioningView; [self loadAssistantConfig:@"assistant_remote.rc"]; [self findTextField:ViewElement_URL].text = - [[LinphoneManager instance] lpConfigStringForKey:@"config-uri" inSection:@"misc"]; + [LinphoneManager.instance lpConfigStringForKey:@"config-uri" inSection:@"misc"]; } - (IBAction)onCreateAccountClick:(id)sender { @@ -720,7 +719,7 @@ void assistant_validation_tested(LinphoneAccountCreator *creator, LinphoneAccoun - (IBAction)onRemoteProvisioningLoginClick:(id)sender { _waitView.hidden = NO; - [[LinphoneManager instance] lpConfigSetInt:1 forKey:@"transient_provisioning" inSection:@"misc"]; + [LinphoneManager.instance lpConfigSetInt:1 forKey:@"transient_provisioning" inSection:@"misc"]; [self configureProxyConfig]; } @@ -744,7 +743,7 @@ void assistant_validation_tested(LinphoneAccountCreator *creator, LinphoneAccoun } - (IBAction)onDialerClick:(id)sender { - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; + [PhoneMainView.instance popToView:DialerView.compositeViewDescription]; } @end diff --git a/Classes/CallOutgoingView.m b/Classes/CallOutgoingView.m index a14992e8b..141b363a7 100644 --- a/Classes/CallOutgoingView.m +++ b/Classes/CallOutgoingView.m @@ -55,9 +55,7 @@ static UICompositeViewDescription *compositeDescription = nil; LinphoneCall *call = linphone_core_get_current_call(LC); if (!call) { - if (![PhoneMainView.instance popCurrentView]) { - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; - } + [PhoneMainView.instance popCurrentView]; } else { const LinphoneAddress *addr = linphone_call_get_remote_address(call); [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; @@ -77,18 +75,18 @@ static UICompositeViewDescription *compositeDescription = nil; - (IBAction)onRoutesBluetoothClick:(id)sender { [self hideRoutes:TRUE animated:TRUE]; - [[LinphoneManager instance] setBluetoothEnabled:TRUE]; + [LinphoneManager.instance setBluetoothEnabled:TRUE]; } - (IBAction)onRoutesEarpieceClick:(id)sender { [self hideRoutes:TRUE animated:TRUE]; - [[LinphoneManager instance] setSpeakerEnabled:FALSE]; - [[LinphoneManager instance] setBluetoothEnabled:FALSE]; + [LinphoneManager.instance setSpeakerEnabled:FALSE]; + [LinphoneManager.instance setBluetoothEnabled:FALSE]; } - (IBAction)onRoutesSpeakerClick:(id)sender { [self hideRoutes:TRUE animated:TRUE]; - [[LinphoneManager instance] setSpeakerEnabled:TRUE]; + [LinphoneManager.instance setSpeakerEnabled:TRUE]; } - (IBAction)onRoutesClick:(id)sender { @@ -104,9 +102,7 @@ static UICompositeViewDescription *compositeDescription = nil; if (call) { linphone_core_terminate_call(LC, call); } - if (![PhoneMainView.instance popCurrentView]) { - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; - } + [PhoneMainView.instance popCurrentView]; } - (void)hideRoutes:(BOOL)hidden animated:(BOOL)animated { diff --git a/Classes/CallView.m b/Classes/CallView.m index 4e393e350..64394e1ab 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -682,24 +682,23 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { } - (IBAction)onChatClick:(id)sender { - ChatsListView *view = VIEW(ChatsListView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; + [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; } - (IBAction)onRoutesBluetoothClick:(id)sender { [self hideRoutes:TRUE animated:TRUE]; - [[LinphoneManager instance] setBluetoothEnabled:TRUE]; + [LinphoneManager.instance setBluetoothEnabled:TRUE]; } - (IBAction)onRoutesEarpieceClick:(id)sender { [self hideRoutes:TRUE animated:TRUE]; - [[LinphoneManager instance] setSpeakerEnabled:FALSE]; - [[LinphoneManager instance] setBluetoothEnabled:FALSE]; + [LinphoneManager.instance setSpeakerEnabled:FALSE]; + [LinphoneManager.instance setBluetoothEnabled:FALSE]; } - (IBAction)onRoutesSpeakerClick:(id)sender { [self hideRoutes:TRUE animated:TRUE]; - [[LinphoneManager instance] setSpeakerEnabled:TRUE]; + [LinphoneManager.instance setSpeakerEnabled:TRUE]; } - (IBAction)onRoutesClick:(id)sender { @@ -712,22 +711,18 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { - (IBAction)onOptionsTransferClick:(id)sender { [self hideOptions:TRUE animated:TRUE]; - // Go to dialer view DialerView *view = VIEW(DialerView); + [view setAddress:@""]; + [view setTransferMode:TRUE]; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; - if (view != nil) { - [view setAddress:@""]; - [view setTransferMode:TRUE]; - } } - (IBAction)onOptionsAddClick:(id)sender { [self hideOptions:TRUE animated:TRUE]; - // Go to dialer view DialerView *view = VIEW(DialerView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; [view setAddress:@""]; [view setTransferMode:FALSE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } - (IBAction)onOptionsClick:(id)sender { diff --git a/Classes/ChatConversationCreateTableView.m b/Classes/ChatConversationCreateTableView.m index 0647b128b..0e069f238 100644 --- a/Classes/ChatConversationCreateTableView.m +++ b/Classes/ChatConversationCreateTableView.m @@ -94,7 +94,7 @@ ChatConversationView *view = VIEW(ChatConversationView); [view setChatRoom:room]; [PhoneMainView.instance popCurrentView]; - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } } diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index b494b8379..286df380d 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -54,7 +54,7 @@ messageList = linphone_chat_room_get_history(chatRoom, 0); // also append transient upload messages because they are not in history yet! - for (FileTransferDelegate *ftd in [[LinphoneManager instance] fileTransferDelegates]) { + for (FileTransferDelegate *ftd in [LinphoneManager.instance fileTransferDelegates]) { const LinphoneAddress *ftd_peer = linphone_chat_room_get_peer_address(linphone_chat_message_get_chat_room(ftd.message)); const LinphoneAddress *peer = linphone_chat_room_get_peer_address(chatRoom); diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 28d1a1450..e5066e9e6 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -236,8 +236,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)saveAndSend:(UIImage *)image url:(NSURL *)url { // photo from Camera, must be saved first if (url == nil) { - [[LinphoneManager instance] - .photoLibrary + [LinphoneManager.instance.photoLibrary writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error) { @@ -516,13 +515,7 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onCallClick:(id)sender { - NSString *displayName = [FastAddressBook displayNameForAddress:linphone_chat_room_get_peer_address(chatRoom)]; - // Go to dialer view - DialerView *view = VIEW(DialerView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; - char *uri = linphone_address_as_string(linphone_chat_room_get_peer_address(chatRoom)); - [view call:[NSString stringWithUTF8String:uri] displayName:displayName]; - ms_free(uri); + [LinphoneManager.instance call:linphone_chat_room_get_peer_address(chatRoom) transfer:NO]; } - (IBAction)onListSwipe:(id)sender { diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index 045ad8ce0..29756c6fe 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -58,8 +58,8 @@ [super viewDidAppear:animated]; // we cannot do that in viewWillAppear because we will change view while previous transition // was not finished, leading to "[CALayer retain]: message sent to deallocated instance" error msg - if (IPAD && [self totalNumberOfItems] == 0) { - [PhoneMainView.instance changeCurrentView:ChatConversationCreateView.compositeViewDescription]; + if (IPAD && [self totalNumberOfItems] > 0) { + [PhoneMainView.instance changeCurrentView:ChatConversationView.compositeViewDescription]; } } @@ -163,7 +163,7 @@ static void chatTable_free_chatrooms(void *data) { UIChatCell *cell = (UIChatCell *)[tableView cellForRowAtIndexPath:indexPath]; [cell updateUnreadBadge]; } - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } } @@ -181,7 +181,7 @@ static void chatTable_free_chatrooms(void *data) { } FileTransferDelegate *ftdToDelete = nil; - for (FileTransferDelegate *ftd in [[LinphoneManager instance] fileTransferDelegates]) { + for (FileTransferDelegate *ftd in [LinphoneManager.instance fileTransferDelegates]) { if (linphone_chat_message_get_chat_room(ftd.message) == chatRoom) { ftdToDelete = ftd; break; @@ -211,7 +211,7 @@ static void chatTable_free_chatrooms(void *data) { } FileTransferDelegate *ftdToDelete = nil; - for (FileTransferDelegate *ftd in [[LinphoneManager instance] fileTransferDelegates]) { + for (FileTransferDelegate *ftd in [LinphoneManager.instance fileTransferDelegates]) { if (linphone_chat_message_get_chat_room(ftd.message) == chatRoom) { ftdToDelete = ftd; break; diff --git a/Classes/ChatsListView.m b/Classes/ChatsListView.m index 6f7798769..c78ad994b 100644 --- a/Classes/ChatsListView.m +++ b/Classes/ChatsListView.m @@ -59,7 +59,7 @@ static UICompositeViewDescription *compositeDescription = nil; sideMenu:SideMenuView.class fullscreen:false isLeftFragment:YES - fragmentWith:ChatConversationView.class]; + fragmentWith:ChatConversationCreateView.class]; } return compositeDescription; } @@ -71,8 +71,7 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Action Functions - (IBAction)onAddClick:(id)event { - ChatConversationCreateView *view = VIEW(ChatConversationCreateView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:YES]; + [PhoneMainView.instance changeCurrentView:ChatConversationCreateView.compositeViewDescription]; } - (IBAction)onEditionChangeClick:(id)sender { diff --git a/Classes/Contact.m b/Classes/Contact.m index 1979b5a95..059fce1b8 100644 --- a/Classes/Contact.m +++ b/Classes/Contact.m @@ -64,7 +64,7 @@ for (int i = 0; i < ABMultiValueGetCount(map); ++i) { CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(map, i); if (CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) { - if (CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, + if (CFStringCompare((CFStringRef)LinphoneManager.instance.contactSipField, CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey), kCFCompareCaseInsensitive) == 0) { NSString *value = (NSString *)(CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey)); @@ -211,7 +211,7 @@ - (BOOL)addSipAddress:(NSString *)sip { NSDictionary *lDict = @{ (NSString *) kABPersonInstantMessageUsernameKey : sip, (NSString *) - kABPersonInstantMessageServiceKey : [LinphoneManager instance].contactSipField + kABPersonInstantMessageServiceKey : LinphoneManager.instance.contactSipField }; BOOL ret = [self addInProperty:kABPersonInstantMessageProperty value:(__bridge CFTypeRef)(lDict)]; diff --git a/Classes/ContactDetailsTableView.m b/Classes/ContactDetailsTableView.m index a6489c035..b087b98b3 100644 --- a/Classes/ContactDetailsTableView.m +++ b/Classes/ContactDetailsTableView.m @@ -34,7 +34,7 @@ } else if (section == ContactSections_Sip) { return _contact.sipAddresses; } else if (section == ContactSections_Email) { - if ([[LinphoneManager instance] lpConfigBoolForKey:@"show_contacts_emails_preference"] == true) { + if ([LinphoneManager.instance lpConfigBoolForKey:@"show_contacts_emails_preference"] == true) { return _contact.emails; } } @@ -166,8 +166,8 @@ } else if ([indexPath section] == ContactSections_Sip) { value = _contact.sipAddresses[indexPath.row]; LinphoneAddress *addr = NULL; - if ([[LinphoneManager instance] lpConfigBoolForKey:@"contact_display_username_only"] && - (addr = linphone_address_new([value UTF8String]))) { + if ([LinphoneManager.instance lpConfigBoolForKey:@"contact_display_username_only"] && + (addr = linphone_core_interpret_url(LC, [value UTF8String]))) { value = [NSString stringWithCString:linphone_address_get_username(addr) encoding:[NSString defaultCStringEncoding]]; linphone_address_destroy(addr); @@ -201,7 +201,7 @@ #pragma mark - UITableViewDelegate Functions - (void)setEditing:(BOOL)editing animated:(BOOL)animated { - BOOL showEmails = [[LinphoneManager instance] lpConfigBoolForKey:@"show_contacts_emails_preference"]; + BOOL showEmails = [LinphoneManager.instance lpConfigBoolForKey:@"show_contacts_emails_preference"]; if (editing) { // add phone/SIP/email entries so that the user can add new data for (int section = 0; section < [self numberOfSectionsInTableView:[self tableView]]; ++section) { diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 1cb0ba878..700d1fb75 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -78,7 +78,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info - (void)removeContact { if (_contact != NULL) { inhibUpdate = TRUE; - [[[LinphoneManager instance] fastAddressBook] removeContact:_contact]; + [[LinphoneManager.instance fastAddressBook] removeContact:_contact]; inhibUpdate = FALSE; } [PhoneMainView.instance popCurrentView]; @@ -111,7 +111,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info } else { LOGI(@"Save AddressBook: Success!"); } - [[LinphoneManager instance].fastAddressBook reload]; + [LinphoneManager.instance.fastAddressBook reload]; } - (void)selectContact:(ABRecordRef)acontact andReload:(BOOL)reload { @@ -136,10 +136,10 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info linphoneAddress ? [NSString stringWithUTF8String:linphone_address_get_username(linphoneAddress)] : address; if (([username rangeOfString:@"@"].length > 0) && - ([[LinphoneManager instance] lpConfigBoolForKey:@"show_contacts_emails_preference"] == true)) { + ([LinphoneManager.instance lpConfigBoolForKey:@"show_contacts_emails_preference"] == true)) { [_tableController addEmailField:username]; } else if ((linphone_proxy_config_is_phone_number(NULL, [username UTF8String])) && - ([[LinphoneManager instance] lpConfigBoolForKey:@"save_new_contacts_as_phone_number"] == true)) { + ([LinphoneManager.instance lpConfigBoolForKey:@"save_new_contacts_as_phone_number"] == true)) { [_tableController addPhoneField:username]; } else { [_tableController addSipField:address]; @@ -312,7 +312,7 @@ static UICompositeViewDescription *compositeDescription = nil; [VIEW(ImagePickerView).popoverController dismissPopoverAnimated:TRUE]; } - FastAddressBook *fab = [LinphoneManager instance].fastAddressBook; + FastAddressBook *fab = LinphoneManager.instance.fastAddressBook; CFErrorRef error = NULL; if (!ABPersonRemoveImageData(_contact, (CFErrorRef *)&error)) { LOGI(@"Can't remove entry: %@", [(__bridge NSError *)error localizedDescription]); diff --git a/Classes/ContactsListTableView.m b/Classes/ContactsListTableView.m index 9396d6915..cb1c5ac64 100644 --- a/Classes/ContactsListTableView.m +++ b/Classes/ContactsListTableView.m @@ -229,7 +229,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info // Go to Contact details view ContactDetailsView *view = VIEW(ContactDetailsView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; if ([ContactSelection getSelectionMode] != ContactSelectionModeEdit) { [view setContact:lPerson]; } else { @@ -254,7 +254,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info [tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationFade]; } - [[[LinphoneManager instance] fastAddressBook] removeContact:contact]; + [[LinphoneManager.instance fastAddressBook] removeContact:contact]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; [tableView endUpdates]; @@ -273,7 +273,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info if ([self.tableView numberOfRowsInSection:indexPath.section] == 1) { [addressBookMap removeObjectForKey:firstChar]; } - [[[LinphoneManager instance] fastAddressBook] removeContact:contact]; + [[LinphoneManager.instance fastAddressBook] removeContact:contact]; }]; } diff --git a/Classes/ContactsListView.m b/Classes/ContactsListView.m index 058aadc35..32d745fd2 100644 --- a/Classes/ContactsListView.m +++ b/Classes/ContactsListView.m @@ -131,7 +131,7 @@ static UICompositeViewDescription *compositeDescription = nil; cancelButtonTitle:NSLocalizedString(@"Continue", nil) otherButtonTitles:nil]; [error show]; - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; + [PhoneMainView.instance popCurrentView]; } } @@ -178,9 +178,8 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onAddContactClick:(id)event { - // Go to Contact details view ContactDetailsView *view = VIEW(ContactDetailsView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; if ([ContactSelection getAddAddress] == nil) { [view newContact]; } else { diff --git a/Classes/DialerView.h b/Classes/DialerView.h index 41ac64876..7c745d1dd 100644 --- a/Classes/DialerView.h +++ b/Classes/DialerView.h @@ -31,8 +31,6 @@ } - (void)setAddress:(NSString *)address; -- (void)call:(NSString *)address displayName:(NSString *)displayName; -- (void)call:(NSString *)address; @property(nonatomic, assign) BOOL transferMode; diff --git a/Classes/DialerView.m b/Classes/DialerView.m index 8b21dc18c..0a1c47227 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -115,7 +115,7 @@ static UICompositeViewDescription *compositeDescription = nil; [callButton setEnabled:TRUE]; // Update on show - LinphoneManager *mgr = [LinphoneManager instance]; + LinphoneManager *mgr = LinphoneManager.instance; LinphoneCore *lc = LC; LinphoneCall *call = linphone_core_get_current_call(lc); LinphoneCallState state = (call != NULL) ? linphone_call_get_state(call) : 0; @@ -180,7 +180,7 @@ static UICompositeViewDescription *compositeDescription = nil; [oneButton addGestureRecognizer:oneLongGesture]; if (IPAD) { - if ([LinphoneManager instance].frontCamId != nil) { + if (LinphoneManager.instance.frontCamId != nil) { // only show camera switch button if we have more than 1 camera [videoCameraSwitch setHidden:FALSE]; } @@ -288,7 +288,7 @@ static UICompositeViewDescription *compositeDescription = nil; } - (BOOL)displayDebugPopup:(NSString *)address { - LinphoneManager *mgr = [LinphoneManager instance]; + LinphoneManager *mgr = LinphoneManager.instance; NSString *debugAddress = [mgr lpConfigStringForKey:@"debug_popup_magic" withDefault:@""]; if (![debugAddress isEqualToString:@""] && [address isEqualToString:debugAddress]) { @@ -307,7 +307,7 @@ static UICompositeViewDescription *compositeDescription = nil; [self presentMailViewWithTitle:appName forRecipients:@[ logsAddress ] attachLogs:true]; }]; - BOOL debugEnabled = [[LinphoneManager instance] lpConfigBoolForKey:@"debugenable_preference"]; + BOOL debugEnabled = [LinphoneManager.instance lpConfigBoolForKey:@"debugenable_preference"]; NSString *actionLog = (debugEnabled ? NSLocalizedString(@"Disable logs", nil) : NSLocalizedString(@"Enable logs", nil)); [alertView addButtonWithTitle:actionLog @@ -347,18 +347,6 @@ static UICompositeViewDescription *compositeDescription = nil; [self callUpdate:call state:state]; } -- (void)call:(NSString *)address { - LinphoneAddress *addr = linphone_address_new(address.UTF8String); - NSString *displayName = addr ? [FastAddressBook displayNameForAddress:addr] : nil; - if (addr) - linphone_address_destroy(addr); - [self call:address displayName:displayName]; -} - -- (void)call:(NSString *)address displayName:(NSString *)displayName { - [[LinphoneManager instance] call:address displayName:displayName transfer:transferMode]; -} - #pragma mark - UITextFieldDelegate Functions - (BOOL)textField:(UITextField *)textField @@ -394,12 +382,11 @@ static UICompositeViewDescription *compositeDescription = nil; [ContactSelection setSipFilter:nil]; [ContactSelection setNameOrEmailFilter:nil]; [ContactSelection enableEmailFilter:FALSE]; - ContactsListView *view = VIEW(ContactsListView); - [PhoneMainView.instance changeCurrentView:view.class.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:ContactsListView.compositeViewDescription]; } - (IBAction)onBackClick:(id)event { - [PhoneMainView.instance changeCurrentView:CallView.compositeViewDescription]; + [PhoneMainView.instance popToView:CallView.compositeViewDescription]; } - (IBAction)onAddressChange:(id)sender { @@ -428,12 +415,15 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)onOneLongClick:(id)sender { - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; NSString *voiceMail = [lm lpConfigStringForKey:@"voice_mail_uri"]; - if (voiceMail != nil) { - [lm call:voiceMail displayName:NSLocalizedString(@"Voice mail", nil) transfer:FALSE]; + LinphoneAddress *addr = linphone_core_interpret_url(LC, voiceMail ? voiceMail.UTF8String : NULL); + if (addr) { + linphone_address_set_display_name(addr, NSLocalizedString(@"Voice mail", nil).UTF8String); + [lm call:addr transfer:FALSE]; + linphone_address_destroy(addr); } else { - LOGE(@"Cannot call voice mail because URI not set!"); + LOGE(@"Cannot call voice mail because URI not set or invalid!"); } } @end diff --git a/Classes/FirstLoginView.m b/Classes/FirstLoginView.m index c4ab68a66..249163798 100644 --- a/Classes/FirstLoginView.m +++ b/Classes/FirstLoginView.m @@ -56,8 +56,8 @@ static UICompositeViewDescription *compositeDescription = nil; name:kLinphoneRegistrationUpdate object:nil]; - [_usernameField setText:[[LinphoneManager instance] lpConfigStringForKey:@"assistant_username"]]; - [_passwordField setText:[[LinphoneManager instance] lpConfigStringForKey:@"assistant_password"]]; + [_usernameField setText:[LinphoneManager.instance lpConfigStringForKey:@"assistant_username"]]; + [_passwordField setText:[LinphoneManager.instance lpConfigStringForKey:@"assistant_password"]]; // Update on show const MSList *list = linphone_core_get_proxy_config_list(LC); @@ -103,7 +103,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewDidLoad { [super viewDidLoad]; - NSString *siteUrl = [[LinphoneManager instance] lpConfigStringForKey:@"first_login_view_url"]; + NSString *siteUrl = [LinphoneManager.instance lpConfigStringForKey:@"first_login_view_url"]; if (siteUrl == nil) { siteUrl = @"http://www.linphone.org"; } @@ -128,7 +128,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)registrationUpdate:(LinphoneRegistrationState)state { switch (state) { case LinphoneRegistrationOk: { - [[LinphoneManager instance] lpConfigSetBool:FALSE forKey:@"enable_first_login_view_preference"]; + [LinphoneManager.instance lpConfigSetBool:FALSE forKey:@"enable_first_login_view_preference"]; [_waitView setHidden:true]; [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; break; @@ -142,8 +142,8 @@ static UICompositeViewDescription *compositeDescription = nil; [_waitView setHidden:true]; // erase uername passwd - [[LinphoneManager instance] lpConfigSetString:nil forKey:@"assistant_username"]; - [[LinphoneManager instance] lpConfigSetString:nil forKey:@"assistant_password"]; + [LinphoneManager.instance lpConfigSetString:nil forKey:@"assistant_username"]; + [LinphoneManager.instance lpConfigSetString:nil forKey:@"assistant_password"]; break; } case LinphoneRegistrationProgress: { @@ -171,7 +171,7 @@ static UICompositeViewDescription *compositeDescription = nil; OnSuccess:^(NSString *url) { if (url) { linphone_core_set_provisioning_uri(LC, url.UTF8String); - [[LinphoneManager instance] resetLinphoneCore]; + [LinphoneManager.instance resetLinphoneCore]; } else { _waitView.hidden = YES; } diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m index 291e5a135..37cbc7b33 100644 --- a/Classes/HistoryDetailsView.m +++ b/Classes/HistoryDetailsView.m @@ -143,7 +143,7 @@ static UICompositeViewDescription *compositeDescription = nil; ABRecordRef contact = [FastAddressBook getContactWithAddress:addr]; if (contact) { ContactDetailsView *view = VIEW(ContactDetailsView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; [ContactSelection setSelectionMode:ContactSelectionModeNone]; [view setContact:contact]; } @@ -159,33 +159,24 @@ static UICompositeViewDescription *compositeDescription = nil; [ContactSelection setSipFilter:nil]; [ContactSelection enableEmailFilter:FALSE]; [ContactSelection setNameOrEmailFilter:nil]; - [PhoneMainView.instance changeCurrentView:ContactsListView.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:ContactsListView.compositeViewDescription]; ms_free(lAddress); } } - (IBAction)onCallClick:(id)event { LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); - char *lAddress = linphone_address_as_string_uri_only(addr); - if (lAddress == NULL) - return; - NSString *displayName = [FastAddressBook displayNameForAddress:addr]; - - DialerView *view = VIEW(DialerView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; - [view call:[NSString stringWithUTF8String:lAddress] displayName:displayName]; - ms_free(lAddress); + [LinphoneManager.instance call:addr transfer:NO]; } - (IBAction)onChatClick:(id)event { const LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); if (addr == NULL) return; - [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; ChatConversationView *view = VIEW(ChatConversationView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; LinphoneChatRoom *room = linphone_core_get_chat_room(LC, addr); [view setChatRoom:room]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } @end diff --git a/Classes/HistoryListTableView.m b/Classes/HistoryListTableView.m index 565d1b1f8..5ef0ff972 100644 --- a/Classes/HistoryListTableView.m +++ b/Classes/HistoryListTableView.m @@ -228,12 +228,7 @@ [cell onDetails:self]; } else { LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); - char *uri = linphone_address_as_string(addr); - DialerView *view = VIEW(DialerView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; - [view call:[NSString stringWithUTF8String:uri] - displayName:[FastAddressBook displayNameForAddress:addr]]; - ms_free(uri); + [LinphoneManager.instance call:addr transfer:NO]; } } } diff --git a/Classes/ImagePickerView.m b/Classes/ImagePickerView.m index bf13f0773..f8a76a36f 100644 --- a/Classes/ImagePickerView.m +++ b/Classes/ImagePickerView.m @@ -173,7 +173,7 @@ static UICompositeViewDescription *compositeDescription = nil; void (^block)(UIImagePickerControllerSourceType) = ^(UIImagePickerControllerSourceType type) { ImagePickerView *view = VIEW(ImagePickerView); if (!(IPAD && ipadView && ipadPopoverView)) { - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } view.sourceType = type; diff --git a/Classes/InAppProductsManager.m b/Classes/InAppProductsManager.m index 3f3bc3360..729d14a56 100644 --- a/Classes/InAppProductsManager.m +++ b/Classes/InAppProductsManager.m @@ -44,7 +44,7 @@ - (instancetype)init { if ((self = [super init]) != nil) { _enabled = (([SKPaymentQueue canMakePayments]) && - ([[LinphoneManager instance] lpConfigBoolForKey:@"enabled" inSection:@"in_app_purchase"])); + ([LinphoneManager.instance lpConfigBoolForKey:@"enabled" inSection:@"in_app_purchase"])); _initialized = false; _available = false; _accountActivationInProgress = false; @@ -107,8 +107,8 @@ monthly:(BOOL)monthly { if (phoneNumber) { NSString *productID = - [[LinphoneManager instance] lpConfigStringForKey:(monthly ? @"paid_account_id_monthly" : @"paid_account_id") - inSection:@"in_app_purchase"]; + [LinphoneManager.instance lpConfigStringForKey:(monthly ? @"paid_account_id_monthly" : @"paid_account_id") + inSection:@"in_app_purchase"]; self.accountCreationData = @{ @"phoneNumber" : phoneNumber, @"password" : password, @"email" : email }; if (![self purchaseWitID:productID]) { @@ -123,8 +123,8 @@ if (phoneNumber) { NSString *receiptBase64 = [self getReceipt]; if (receiptBase64) { - NSURL *URL = [NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"receipt_validation_url" - inSection:@"in_app_purchase"]]; + NSURL *URL = [NSURL URLWithString:[LinphoneManager.instance lpConfigStringForKey:@"receipt_validation_url" + inSection:@"in_app_purchase"]]; XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL]; // buying for the first time: need to create the account // if ([transaction.transactionIdentifier @@ -175,7 +175,7 @@ #pragma mark ProductListLoading - (void)loadProducts { - NSArray *list = [[[[LinphoneManager instance] lpConfigStringForKey:@"products_list" inSection:@"in_app_purchase"] + NSArray *list = [[[LinphoneManager.instance lpConfigStringForKey:@"products_list" inSection:@"in_app_purchase"] stringByReplacingOccurrencesOfString:@" " withString:@""] componentsSeparatedByString:@","]; @@ -262,8 +262,8 @@ if (latestReceiptMD5 == nil || ![latestReceiptMD5 isEqualToString:[receiptBase64 md5]]) { // transaction is null when restoring user purchases at application start or if user clicks the "restore" button // We must validate the receipt on our server - NSURL *URL = [NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"receipt_validation_url" - inSection:@"in_app_purchase"]]; + NSURL *URL = [NSURL URLWithString:[LinphoneManager.instance lpConfigStringForKey:@"receipt_validation_url" + inSection:@"in_app_purchase"]]; XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL]; // buying for the first time: need to create the account // if ([transaction.transactionIdentifier @@ -303,7 +303,7 @@ if (config) { const char *identity = linphone_proxy_config_get_identity(config); if (identity) { - LinphoneAddress *addr = linphone_address_new(identity); + LinphoneAddress *addr = linphone_core_interpret_url(LC, identity); if (addr) { phoneNumber = [NSString stringWithUTF8String:linphone_address_get_username(addr)]; linphone_address_destroy(addr); @@ -389,7 +389,7 @@ LOGI(@"XMLRPC response %@: %@", [request method], [response body]); NSString *productID = - [[LinphoneManager instance] lpConfigStringForKey:@"paid_account_id" inSection:@"in_app_purchase"]; + [LinphoneManager.instance lpConfigStringForKey:@"paid_account_id" inSection:@"in_app_purchase"]; // validation succeeded if (![response isFault] && [response object] != nil) { @@ -526,11 +526,11 @@ #pragma mark - XMLRPCConnectionDelegate Functions - (void)request:(XMLRPCRequest *)request didReceiveResponse:(XMLRPCResponse *)response { - [[[LinphoneManager instance] iapManager] XMLRPCRequest:request didReceiveResponse:response]; + [[LinphoneManager.instance iapManager] XMLRPCRequest:request didReceiveResponse:response]; } - (void)request:(XMLRPCRequest *)request didFailWithError:(NSError *)error { - [[[LinphoneManager instance] iapManager] XMLRPCRequest:request didFailWithError:error]; + [[LinphoneManager.instance iapManager] XMLRPCRequest:request didFailWithError:error]; } - (BOOL)request:(XMLRPCRequest *)request canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 7e4f664ee..32e7e37b4 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -48,7 +48,7 @@ - (void)applicationDidEnterBackground:(UIApplication *)application { LOGI(@"%@", NSStringFromSelector(_cmd)); - [[LinphoneManager instance] enterBackgroundMode]; + [LinphoneManager.instance enterBackgroundMode]; } - (void)applicationWillResignActive:(UIApplication *)application { @@ -58,7 +58,7 @@ if (call) { /* save call context */ - LinphoneManager *instance = [LinphoneManager instance]; + LinphoneManager *instance = LinphoneManager.instance; instance->currentCallContextBeforeGoingBackground.call = call; instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call); @@ -68,7 +68,7 @@ } } - if (![[LinphoneManager instance] resignActive]) { + if (![LinphoneManager.instance resignActive]) { } } @@ -80,7 +80,7 @@ [PhoneMainView.instance startUp]; [PhoneMainView.instance updateStatusBar:nil]; } - LinphoneManager *instance = [LinphoneManager instance]; + LinphoneManager *instance = LinphoneManager.instance; [instance becomeActive]; @@ -159,7 +159,7 @@ UIApplication *app = [UIApplication sharedApplication]; UIApplicationState state = app.applicationState; - LinphoneManager *instance = [LinphoneManager instance]; + LinphoneManager *instance = LinphoneManager.instance; BOOL background_mode = [instance lpConfigBoolForKey:@"backgroundmode_preference"]; BOOL start_at_boot = [instance lpConfigBoolForKey:@"start_at_boot_preference"]; @@ -199,7 +199,7 @@ [[UIApplication sharedApplication] endBackgroundTask:bgStartId]; }]; - [[LinphoneManager instance] startLinphoneCore]; + [LinphoneManager.instance startLinphoneCore]; // initialize UI [self.window makeKeyAndVisible]; [RootViewManager setupWithPortrait:(PhoneMainView *)self.window.rootViewController]; @@ -224,11 +224,11 @@ // destroyLinphoneCore automatically unregister proxies but if we are using // remote push notifications, we want to continue receiving them - if ([LinphoneManager instance].pushNotificationToken != nil) { + if (LinphoneManager.instance.pushNotificationToken != nil) { // trick me! setting network reachable to false will avoid sending unregister linphone_core_set_network_reachable(LC, FALSE); } - [[LinphoneManager instance] destroyLinphoneCore]; + [LinphoneManager.instance destroyLinphoneCore]; } - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { @@ -279,23 +279,20 @@ LinphoneCore *lc = LC; if (linphone_core_get_calls(lc) == NULL) { // if there are calls, obviously our TCP socket shall be working linphone_core_set_network_reachable(lc, FALSE); - [LinphoneManager instance].connectivity = none; /*force connectivity to be discovered again*/ - [[LinphoneManager instance] refreshRegisters]; + LinphoneManager.instance.connectivity = none; /*force connectivity to be discovered again*/ + [LinphoneManager.instance refreshRegisters]; if (loc_key != nil) { NSString *callId = [userInfo objectForKey:@"call-id"]; if (callId != nil) { - [[LinphoneManager instance] addPushCallId:callId]; + [LinphoneManager.instance addPushCallId:callId]; } else { LOGE(@"PushNotification: does not have call-id yet, fix it !"); } if ([loc_key isEqualToString:@"IM_MSG"] || [loc_key isEqualToString:@"IM_FULLMSG"]) { - [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; - } else if ([loc_key isEqualToString:@"IC_MSG"]) { - [self fixRing]; } } @@ -333,24 +330,23 @@ BOOL auto_answer = TRUE; // some local notifications have an internal timer to relaunch themselves at specified intervals if ([[notification.userInfo objectForKey:@"timer"] intValue] == 1) { - [[LinphoneManager instance] cancelLocalNotifTimerForCallId:[notification.userInfo objectForKey:@"callId"]]; - auto_answer = [[LinphoneManager instance] lpConfigBoolForKey:@"autoanswer_notif_preference"]; + [LinphoneManager.instance cancelLocalNotifTimerForCallId:[notification.userInfo objectForKey:@"callId"]]; + auto_answer = [LinphoneManager.instance lpConfigBoolForKey:@"autoanswer_notif_preference"]; } if (auto_answer) { - [[LinphoneManager instance] acceptCallForCallId:[notification.userInfo objectForKey:@"callId"]]; + [LinphoneManager.instance acceptCallForCallId:[notification.userInfo objectForKey:@"callId"]]; } } else if ([notification.userInfo objectForKey:@"from_addr"] != nil) { NSString *remoteContact = (NSString *)[notification.userInfo objectForKey:@"from_addr"]; - [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; LinphoneChatRoom *room = [self findChatRoomForContact:remoteContact]; ChatConversationView *view = VIEW(ChatConversationView); [view setChatRoom:room]; - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } else if ([notification.userInfo objectForKey:@"callLog"] != nil) { NSString *callLog = (NSString *)[notification.userInfo objectForKey:@"callLog"]; HistoryDetailsView *view = VIEW(HistoryDetailsView); [view setCallLogId:callLog]; - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } } @@ -360,7 +356,7 @@ didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { LOGI(@"%@ : %@", NSStringFromSelector(_cmd), userInfo); - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; // save the completion handler for later execution. // 2 outcomes: @@ -389,12 +385,12 @@ - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { LOGI(@"%@ : %@", NSStringFromSelector(_cmd), deviceToken); - [[LinphoneManager instance] setPushNotificationToken:deviceToken]; + [LinphoneManager.instance setPushNotificationToken:deviceToken]; } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { LOGI(@"%@ : %@", NSStringFromSelector(_cmd), [error localizedDescription]); - [[LinphoneManager instance] setPushNotificationToken:nil]; + [LinphoneManager.instance setPushNotificationToken:nil]; } #pragma mark - User notifications @@ -512,8 +508,8 @@ name:kLinphoneConfiguringStateUpdate object:nil]; linphone_core_set_provisioning_uri(LC, [configURL UTF8String]); - [[LinphoneManager instance] destroyLinphoneCore]; - [[LinphoneManager instance] startLinphoneCore]; + [LinphoneManager.instance destroyLinphoneCore]; + [LinphoneManager.instance startLinphoneCore]; } @end diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 528fcb247..1b37579ce 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -151,7 +151,7 @@ const LinphoneAddress *identity_addr = linphone_proxy_config_get_identity_address(proxy); if (identity_addr) { const char *server_addr = linphone_proxy_config_get_server_addr(proxy); - LinphoneAddress *proxy_addr = linphone_address_new(server_addr); + LinphoneAddress *proxy_addr = linphone_core_interpret_url(LC, server_addr); int port = linphone_address_get_port(proxy_addr); [self setCString:linphone_address_get_username(identity_addr) @@ -218,7 +218,7 @@ } - (void)transformLinphoneCoreToKeys { - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; LinphoneCore *lc = LC; // root section @@ -399,7 +399,7 @@ - (void)synchronizeAccounts { LOGI(@"Account changed, synchronizing."); - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; LinphoneCore *lc = LC; LinphoneProxyConfig *proxyCfg = NULL; NSString *error = nil; @@ -453,7 +453,7 @@ const char *route = NULL; - if (isWifiOnly && [LinphoneManager instance].connectivity == wwan) + if (isWifiOnly && LinphoneManager.instance.connectivity == wwan) expire = 0; if ((!proxyAddress || [proxyAddress length] < 1) && domain) { @@ -465,7 +465,7 @@ } char *proxy = ms_strdup(proxyAddress.UTF8String); - LinphoneAddress *proxy_addr = linphone_address_new(proxy); + LinphoneAddress *proxy_addr = linphone_core_interpret_url(LC, proxy); if (proxy_addr) { LinphoneTransportType type = LinphoneTransportUdp; @@ -480,7 +480,7 @@ } char normalizedUserName[256]; - LinphoneAddress *linphoneAddress = linphone_address_new("sip:user@domain.com"); + LinphoneAddress *linphoneAddress = linphone_core_interpret_url(LC, "sip:user@domain.com"); proxyCfg = ms_list_nth_data(linphone_core_get_proxy_config_list(lc), [self integerForKey:@"current_proxy_config_preference"]); @@ -523,7 +523,7 @@ } [lm lpConfigSetInt:pushnotification forKey:@"pushnotification_preference"]; - [[LinphoneManager instance] configurePushTokenForProxyConfig:proxyCfg]; + [LinphoneManager.instance configurePushTokenForProxyConfig:proxyCfg]; linphone_proxy_config_enable_register(proxyCfg, is_enabled); linphone_proxy_config_enable_avpf(proxyCfg, use_avpf); @@ -544,7 +544,7 @@ if (proxyAi) { linphone_core_remove_auth_info(lc, proxyAi); } - LinphoneAddress *from = linphone_address_new(identity); + LinphoneAddress *from = linphone_core_interpret_url(LC, identity); if (from) { const char *userid_str = (userID != nil) ? [userID UTF8String] : NULL; LinphoneAuthInfo *info = linphone_auth_info_new( @@ -573,7 +573,7 @@ } } // reload address book to prepend proxy config domain to contacts' phone number - [[[LinphoneManager instance] fastAddressBook] reload]; + [[LinphoneManager.instance fastAddressBook] reload]; } - (void)synchronizeCodecs:(const MSList *)codecs { @@ -589,7 +589,7 @@ } - (BOOL)synchronize { - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; LinphoneCore *lc = LC; // root section { @@ -636,7 +636,7 @@ BOOL equalizer = [self boolForKey:@"eq_active"]; [lm lpConfigSetBool:equalizer forKey:@"eq_active" inSection:@"sound"]; - [[LinphoneManager instance] configureVbrCodecs]; + [LinphoneManager.instance configureVbrCodecs]; NSString *au_device = @"AU: Audio Unit Receiver"; if (!voice_processing) { @@ -709,7 +709,7 @@ BOOL wifiOnly = [self boolForKey:@"wifi_only_preference"]; [lm lpConfigSetInt:wifiOnly forKey:@"wifi_only_preference"]; if ([self valueChangedForKey:@"wifi_only_preference"]) { - [[LinphoneManager instance] setupNetworkReachabilityCallback]; + [LinphoneManager.instance setupNetworkReachabilityCallback]; } NSString *stun_server = [self stringForKey:@"stun_preference"]; @@ -786,7 +786,7 @@ } [lm lpConfigSetString:lTunnelPrefMode forKey:@"tunnel_mode_preference"]; - [[LinphoneManager instance] setTunnelMode:mode]; + [LinphoneManager.instance setTunnelMode:mode]; } } @@ -794,7 +794,7 @@ { BOOL debugmode = [self boolForKey:@"debugenable_preference"]; [lm lpConfigSetInt:debugmode forKey:@"debugenable_preference"]; - [[LinphoneManager instance] setLogsEnabled:debugmode]; + [LinphoneManager.instance setLogsEnabled:debugmode]; BOOL animations = [self boolForKey:@"animations_preference"]; [lm lpConfigSetInt:animations forKey:@"animations_preference"]; diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index ba7a45232..f48d0d6e9 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -162,8 +162,7 @@ typedef struct _LinphoneManagerSounds { + (NSString*)cacheDirectory; - (void)acceptCall:(LinphoneCall *)call evenWithVideo:(BOOL)video; -- (void)call:(NSString *)address displayName:(NSString*)displayName transfer:(BOOL)transfer; - +- (BOOL)call:(const LinphoneAddress *)address transfer:(BOOL)transfer; +(id)getMessageAppDataForKey:(NSString*)key inMessage:(LinphoneChatMessage*)msg; +(void)setValueInMessageAppData:(id)value forKey:(NSString*)key inMessage:(LinphoneChatMessage*)msg; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 951e2fbf9..fa7ea0919 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -567,7 +567,7 @@ static void dump_section(const char *section, void *data) { + (void)dumpLcConfig { if (theLinphoneCore) { - LpConfig *conf = [LinphoneManager instance].configDb; + LpConfig *conf = LinphoneManager.instance.configDb; lp_config_for_each_section(conf, dump_section, conf); } } @@ -649,7 +649,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char LinphoneCallLog *callLog = linphone_call_get_call_log(call); NSString *callId = [NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog)]; - if (![[LinphoneManager instance] popPushCallID:callId]) { + if (![LinphoneManager.instance popPushCallID:callId]) { // case where a remote notification is not already received // Create a new local notification data->notification = [[UILocalNotification alloc] init]; @@ -909,8 +909,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char }]; [alertView addButtonWithTitle:NSLocalizedString(@"Go to settings", nil) block:^{ - SettingsView *view = VIEW(SettingsView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; + [PhoneMainView.instance changeCurrentView:SettingsView.compositeViewDescription]; }]; [alertView show]; } @@ -943,7 +942,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) { notif.category = @"incoming_msg"; } - if ([[LinphoneManager instance] lpConfigBoolForKey:@"show_msg_in_notif" withDefault:YES]) { + if ([LinphoneManager.instance lpConfigBoolForKey:@"show_msg_in_notif" withDefault:YES]) { notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_FULLMSG", nil), from, chat]; } else { notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG", nil), from]; @@ -1129,7 +1128,7 @@ static void showNetworkFlags(SCNetworkReachabilityFlags flags) { static void networkReachabilityNotification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { - LinphoneManager *mgr = [LinphoneManager instance]; + LinphoneManager *mgr = LinphoneManager.instance; SCNetworkReachabilityFlags flags; // for an unknown reason, we are receiving multiple time the notification, so @@ -1147,7 +1146,7 @@ static void networkReachabilityNotification(CFNotificationCenterRef center, void void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *nilCtx) { showNetworkFlags(flags); - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; SCNetworkReachabilityFlags networkDownFlags = kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand; @@ -1385,7 +1384,7 @@ static LinphoneCoreVTable linphonec_vtable = { NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSValue valueWithPointer:theLinphoneCore] forKey:@"core"]; [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCoreUpdate - object:[LinphoneManager instance] + object:LinphoneManager.instance userInfo:dict]; } @@ -1534,7 +1533,7 @@ static BOOL libStarted = FALSE; NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSValue valueWithPointer:theLinphoneCore] forKey:@"core"]; [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCoreUpdate - object:[LinphoneManager instance] + object:LinphoneManager.instance userInfo:dict]; SCNetworkReachabilityUnscheduleFromRunLoop(proxyReachability, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); @@ -1619,7 +1618,7 @@ static int comp_call_id(const LinphoneCall *call, const char *callid) { if (!success) { LOGE(@"Could not play the message sound"); } - AudioServicesPlaySystemSound([LinphoneManager instance].sounds.vibrate); + AudioServicesPlaySystemSound(LinphoneManager.instance.sounds.vibrate); } static int comp_call_state_paused(const LinphoneCall *call, const void *param) { @@ -1640,14 +1639,14 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { // handle proxy config if any if (proxyCfg) { - if ([[LinphoneManager instance] lpConfigBoolForKey:@"backgroundmode_preference"] || - [[LinphoneManager instance] lpConfigBoolForKey:@"pushnotification_preference"]) { + if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] || + [LinphoneManager.instance lpConfigBoolForKey:@"pushnotification_preference"]) { // For registration register [self refreshRegisters]; } - if ([[LinphoneManager instance] lpConfigBoolForKey:@"backgroundmode_preference"]) { + if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"]) { // register keepalive if ([[UIApplication sharedApplication] @@ -1693,7 +1692,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { LOGI(@"Entering [%s] bg mode", shouldEnterBgMode ? "normal" : "lite"); if (!shouldEnterBgMode) { - if ([[LinphoneManager instance] lpConfigBoolForKey:@"pushnotification_preference"]) { + if ([LinphoneManager.instance lpConfigBoolForKey:@"pushnotification_preference"]) { LOGI(@"Keeping lc core to handle push"); /*destroy voip socket if any and reset connectivity mode*/ connectivity = none; @@ -1909,7 +1908,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { linphone_core_accept_call_with_params(theLinphoneCore, call, lcallParams); } -- (void)call:(NSString *)address displayName:(NSString *)displayName transfer:(BOOL)transfer { +- (BOOL)call:(const LinphoneAddress *)iaddr transfer:(BOOL)transfer { // First verify that network is available, abort otherwise. if (!linphone_core_is_network_reachable(theLinphoneCore)) { UIAlertView *error = [[UIAlertView alloc] @@ -1922,7 +1921,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:nil]; [error show]; - return; + return FALSE; } // Then check that no GSM calls are in progress, abort otherwise. @@ -1936,14 +1935,11 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:nil]; [error show]; - return; + return FALSE; } - LinphoneAddress *addr = NULL; - // Continue by checking that the provided address is a valid SIP address, abort otherwise. - if ([address length] == 0) { - // no address provided... nothing to do - } else if ((addr = linphone_core_interpret_url(LC, address.UTF8String)) == NULL) { + // Then check that the supplied address is valid + if (!iaddr) { UIAlertView *error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Invalid SIP address", nil) message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to place a " @@ -1953,44 +1949,48 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:nil]; [error show]; + return FALSE; + } + LinphoneAddress *addr = linphone_address_clone(iaddr); + NSString *displayName = [FastAddressBook displayNameForAddress:addr]; + + // Finally we can make the call + LinphoneCallParams *lcallParams = linphone_core_create_call_params(theLinphoneCore, NULL); + if ([self lpConfigBoolForKey:@"edge_opt_preference"] && (self.network == network_2g)) { + LOGI(@"Enabling low bandwidth mode"); + linphone_call_params_enable_low_bandwidth(lcallParams, YES); + } + + if (displayName != nil) { + linphone_address_set_display_name(addr, displayName.UTF8String); + } + if ([LinphoneManager.instance lpConfigBoolForKey:@"override_domain_with_default_one"]) { + linphone_address_set_domain( + addr, [[LinphoneManager.instance lpConfigStringForKey:@"domain" inSection:@"assistant"] UTF8String]); + } + if (transfer) { + char *caddr = linphone_address_as_string(addr); + linphone_core_transfer_call(theLinphoneCore, linphone_core_get_current_call(theLinphoneCore), caddr); + ms_free(caddr); } else { - // Finally we can make the call - LinphoneCallParams *lcallParams = linphone_core_create_call_params(theLinphoneCore, NULL); - if ([self lpConfigBoolForKey:@"edge_opt_preference"] && (self.network == network_2g)) { - LOGI(@"Enabling low bandwidth mode"); - linphone_call_params_enable_low_bandwidth(lcallParams, YES); - } - - if (displayName != nil) { - linphone_address_set_display_name(addr, displayName.UTF8String); - } - if ([[LinphoneManager instance] lpConfigBoolForKey:@"override_domain_with_default_one"]) { - linphone_address_set_domain( - addr, [[[LinphoneManager instance] lpConfigStringForKey:@"domain" inSection:@"assistant"] UTF8String]); - } - - if (transfer) { - char *caddr = linphone_address_as_string(addr); - linphone_core_transfer_call(theLinphoneCore, linphone_core_get_current_call(theLinphoneCore), caddr); - ms_free(caddr); - } else { - LinphoneCall *call = linphone_core_invite_address_with_params(theLinphoneCore, addr, lcallParams); - if (call) { - // The LinphoneCallAppData object should be set on call creation with callback - // - (void)onCall:StateChanged:withMessage:. If not, we are in big trouble and expect it to crash - // We are NOT responsible for creating the AppData. - LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call); - if (data == nil) { - LOGE(@"New call instanciated but app data was not set. Expect it to crash."); - /* will be used later to notify user if video was not activated because of the linphone core*/ - } else { - data->videoRequested = linphone_call_params_video_enabled(lcallParams); - } + LinphoneCall *call = linphone_core_invite_address_with_params(theLinphoneCore, addr, lcallParams); + if (call) { + // The LinphoneCallAppData object should be set on call creation with callback + // - (void)onCall:StateChanged:withMessage:. If not, we are in big trouble and expect it to crash + // We are NOT responsible for creating the AppData. + LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call); + if (data == nil) { + LOGE(@"New call instanciated but app data was not set. Expect it to crash."); + /* will be used later to notify user if video was not activated because of the linphone core*/ + } else { + data->videoRequested = linphone_call_params_video_enabled(lcallParams); } } - linphone_address_destroy(addr); - linphone_call_params_destroy(lcallParams); } + linphone_address_destroy(addr); + linphone_call_params_destroy(lcallParams); + + return TRUE; } #pragma mark - Property Functions diff --git a/Classes/LinphoneUI/UIBackToCallButton.m b/Classes/LinphoneUI/UIBackToCallButton.m index a85002303..5cc7f05a2 100644 --- a/Classes/LinphoneUI/UIBackToCallButton.m +++ b/Classes/LinphoneUI/UIBackToCallButton.m @@ -35,8 +35,7 @@ } - (IBAction)onBackToCallClick:(id)sender { - CallView *view = VIEW(CallView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; + [PhoneMainView.instance popToView:CallView.compositeViewDescription]; } @end diff --git a/Classes/LinphoneUI/UICallButton.m b/Classes/LinphoneUI/UICallButton.m index 5269de7bf..36ec0f4a4 100644 --- a/Classes/LinphoneUI/UICallButton.m +++ b/Classes/LinphoneUI/UICallButton.m @@ -87,11 +87,10 @@ } if ([address length] > 0) { - LinphoneAddress *addr = linphone_address_new(address.UTF8String); - NSString *displayName = addr ? [FastAddressBook displayNameForAddress:addr] : nil; + LinphoneAddress *addr = linphone_core_interpret_url(LC, address.UTF8String); + [LinphoneManager.instance call:addr transfer:FALSE]; if (addr) linphone_address_destroy(addr); - [LinphoneManager.instance call:address displayName:displayName transfer:FALSE]; } } diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index 01675d019..9170fe311 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -62,7 +62,7 @@ const LinphoneContent *c = linphone_chat_message_get_file_transfer_information(amessage); if (c) { const char *name = linphone_content_get_name(c); - for (FileTransferDelegate *aftd in [[LinphoneManager instance] fileTransferDelegates]) { + for (FileTransferDelegate *aftd in [LinphoneManager.instance fileTransferDelegates]) { if (linphone_chat_message_get_file_transfer_information(aftd.message) && (linphone_chat_message_is_outgoing(aftd.message) == linphone_chat_message_is_outgoing(amessage)) && strcmp(name, linphone_content_get_name( @@ -191,7 +191,7 @@ } else { if (![_messageImageView isLoading]) { ImageView *view = VIEW(ImageView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; CGImageRef fullScreenRef = [[_messageImageView.fullImageUrl defaultRepresentation] fullScreenImage]; UIImage *fullScreen = [UIImage imageWithCGImage:fullScreenRef]; [view setImage:fullScreen]; diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index e65ddad83..a670d77e6 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -192,8 +192,7 @@ [self onDeleteClick:nil]; - [[LinphoneManager instance] - .photoLibrary assetForURL:imageUrl + [LinphoneManager.instance.photoLibrary assetForURL:imageUrl resultBlock:^(ALAsset *asset) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), ^(void) { diff --git a/Classes/LinphoneUI/UIContactDetailsCell.m b/Classes/LinphoneUI/UIContactDetailsCell.m index e4c023f51..2c1d5eaa5 100644 --- a/Classes/LinphoneUI/UIContactDetailsCell.m +++ b/Classes/LinphoneUI/UIContactDetailsCell.m @@ -76,27 +76,19 @@ - (IBAction)onCallClick:(id)event { LinphoneAddress *addr = linphone_core_interpret_url(LC, _addressLabel.text.UTF8String); - if (addr == NULL) - return; - char *lAddress = linphone_address_as_string_uri_only(addr); - NSString *displayName = [FastAddressBook displayNameForAddress:addr]; - - DialerView *view = VIEW(DialerView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; - [view call:[NSString stringWithUTF8String:lAddress] displayName:displayName]; - ms_free(lAddress); - linphone_address_destroy(addr); + [LinphoneManager.instance call:addr transfer:NO]; + if (addr) + linphone_address_destroy(addr); } - (IBAction)onChatClick:(id)event { LinphoneAddress *addr = linphone_core_interpret_url(LC, _addressLabel.text.UTF8String); if (addr == NULL) return; - [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; ChatConversationView *view = VIEW(ChatConversationView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; LinphoneChatRoom *room = linphone_core_get_chat_room(LC, addr); [view setChatRoom:room]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; linphone_address_destroy(addr); } diff --git a/Classes/LinphoneUI/UIHistoryCell.m b/Classes/LinphoneUI/UIHistoryCell.m index f34708b5b..15458d2fd 100644 --- a/Classes/LinphoneUI/UIHistoryCell.m +++ b/Classes/LinphoneUI/UIHistoryCell.m @@ -60,7 +60,9 @@ // Go to History details view HistoryDetailsView *view = VIEW(HistoryDetailsView); [view setCallLogId:[NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog)]]; - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; + } else { + LOGE(@"Cannot open selected call log, it is NULL or corrupted"); } } diff --git a/Classes/LinphoneUI/UISpeakerButton.m b/Classes/LinphoneUI/UISpeakerButton.m index 8b0279666..5580f12be 100644 --- a/Classes/LinphoneUI/UISpeakerButton.m +++ b/Classes/LinphoneUI/UISpeakerButton.m @@ -60,16 +60,16 @@ INIT_WITH_COMMON_CF { #pragma mark - UIToggleButtonDelegate Functions - (void)onOn { - [[LinphoneManager instance] setSpeakerEnabled:TRUE]; + [LinphoneManager.instance setSpeakerEnabled:TRUE]; } - (void)onOff { - [[LinphoneManager instance] setSpeakerEnabled:FALSE]; + [LinphoneManager.instance setSpeakerEnabled:FALSE]; } - (bool)onUpdate { - [self setEnabled:[[LinphoneManager instance] allowSpeaker]]; - return [[LinphoneManager instance] speakerEnabled]; + [self setEnabled:[LinphoneManager.instance allowSpeaker]]; + return [LinphoneManager.instance speakerEnabled]; } @end diff --git a/Classes/LinphoneUI/UITransferButton.m b/Classes/LinphoneUI/UITransferButton.m index 809336ee8..8ad3a577e 100644 --- a/Classes/LinphoneUI/UITransferButton.m +++ b/Classes/LinphoneUI/UITransferButton.m @@ -58,7 +58,10 @@ #pragma mark - - (void)touchUp:(id)sender { - [[LinphoneManager instance] call:[addressField text] displayName:nil transfer:TRUE]; + LinphoneAddress *addr = linphone_core_interpret_url(LC, addressField.text.UTF8String); + [LinphoneManager.instance call:addr transfer:TRUE]; + if (addr) + linphone_address_destroy(addr); } @end diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h index 855b41570..b3122151d 100644 --- a/Classes/PhoneMainView.h +++ b/Classes/PhoneMainView.h @@ -81,9 +81,7 @@ @property(weak, readonly) UICompositeViewDescription *currentView; @property(readonly, strong) MPVolumeView *volumeView; -- (void)changeCurrentView:(UICompositeViewDescription *)currentView; -- (void)changeCurrentView:(UICompositeViewDescription *)currentView push:(BOOL)push; -- (void)changeCurrentView:(UICompositeViewDescription *)view push:(BOOL)push animated:(BOOL)animated; +- (void)changeCurrentView:(UICompositeViewDescription *)view; - (UIViewController*)popCurrentView; - (UIViewController *)popToView:(UICompositeViewDescription *)currentView; - (UICompositeViewDescription *)firstView; diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 19ce95a01..fb5e26926 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -287,9 +287,9 @@ static RootViewManager *rootViewManagerInstance = nil; - (void)onGlobalStateChanged:(NSNotification *)notif { LinphoneGlobalState state = (LinphoneGlobalState)[[[notif userInfo] valueForKey:@"state"] integerValue]; static BOOL already_shown = FALSE; - if (state == LinphoneGlobalOn && !already_shown && [LinphoneManager instance].wasRemoteProvisioned) { + if (state == LinphoneGlobalOn && !already_shown && LinphoneManager.instance.wasRemoteProvisioned) { LinphoneProxyConfig *conf = linphone_core_get_default_proxy_config(LC); - if ([[LinphoneManager instance] lpConfigBoolForKey:@"show_login_view" inSection:@"app"] && conf == NULL) { + if ([LinphoneManager.instance lpConfigBoolForKey:@"show_login_view" inSection:@"app"] && conf == NULL) { already_shown = TRUE; AssistantView *view = VIEW(AssistantView); [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; @@ -322,7 +322,7 @@ static RootViewManager *rootViewManagerInstance = nil; case LinphoneCallPausedByRemote: case LinphoneCallConnected: case LinphoneCallStreamsRunning: { - [self changeCurrentView:CallView.compositeViewDescription push:NO]; + [self changeCurrentView:CallView.compositeViewDescription]; break; } case LinphoneCallUpdatedByRemote: { @@ -340,15 +340,11 @@ static RootViewManager *rootViewManagerInstance = nil; case LinphoneCallEnd: { const MSList *calls = linphone_core_get_calls(LC); if (calls == NULL) { - // if ((currentView == CallView.compositeViewDescription) || - // (currentView == CallIncomingView.compositeViewDescription) || - // (currentView == CallOutgoingView.compositeViewDescription)) { - DialerView *view = VIEW(DialerView); - [view setAddress:@""]; - [view setTransferMode:FALSE]; - [self changeCurrentView:view.compositeViewDescription push:NO]; - // [self popCurrentView]; - // } + if ((currentView == CallView.compositeViewDescription) || + (currentView == CallIncomingView.compositeViewDescription) || + (currentView == CallOutgoingView.compositeViewDescription)) { + [self popCurrentView]; + } } else { linphone_core_resume_call(LC, (LinphoneCall *)calls->data); [self changeCurrentView:CallView.compositeViewDescription]; @@ -406,10 +402,10 @@ static RootViewManager *rootViewManagerInstance = nil; LinphoneCore *core = nil; @try { core = LC; - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; if (linphone_core_get_global_state(core) != LinphoneGlobalOn) { [self changeCurrentView:DialerView.compositeViewDescription]; - } else if ([[LinphoneManager instance] lpConfigBoolForKey:@"enable_first_login_view_preference"] == true) { + } else if ([LinphoneManager.instance lpConfigBoolForKey:@"enable_first_login_view_preference"] == true) { [PhoneMainView.instance changeCurrentView:FirstLoginView.compositeViewDescription]; } else { // always start to dialer when testing @@ -539,32 +535,23 @@ static RootViewManager *rootViewManagerInstance = nil; - (UIViewController *)popCurrentView { NSMutableArray *viewStack = [RootViewManager instance].viewDescriptionStack; - if ([viewStack count] > 1) { - LOGI(@"PhoneMainView: Popping view %@, going to %@", currentView, viewStack.lastObject); + if (viewStack.count <= 1) { + [viewStack removeAllObjects]; + LOGW(@"PhoneMainView: Trying to pop view but none stacked, going to %@!", DialerView.compositeViewDescription); + } else { [viewStack removeLastObject]; - [self _changeCurrentView:[viewStack lastObject] - transition:[PhoneMainView getBackwardTransition] - animated:ANIMATED]; - return [mainViewController getCurrentViewController]; + LOGI(@"PhoneMainView: Popping view %@, going to %@", currentView, viewStack.lastObject); } - LOGW(@"PhoneMainView: Trying to pop view but none stacked!"); - return nil; + [self _changeCurrentView:viewStack.lastObject ?: DialerView.compositeViewDescription + transition:[PhoneMainView getBackwardTransition] + animated:ANIMATED]; + return [mainViewController getCurrentViewController]; } - (void)changeCurrentView:(UICompositeViewDescription *)view { - [self changeCurrentView:view push:TRUE]; -} - -- (void)changeCurrentView:(UICompositeViewDescription *)view push:(BOOL)push { - [self changeCurrentView:view push:push animated:ANIMATED]; -} - -- (void)changeCurrentView:(UICompositeViewDescription *)view push:(BOOL)push animated:(BOOL)animated { NSMutableArray *viewStack = [RootViewManager instance].viewDescriptionStack; - if (push && view) { - [viewStack addObject:view]; - } - [self _changeCurrentView:view transition:nil animated:animated]; + [viewStack addObject:view]; + [self _changeCurrentView:view transition:nil animated:ANIMATED]; } - (UIViewController *)_changeCurrentView:(UICompositeViewDescription *)view @@ -665,7 +652,7 @@ static RootViewManager *rootViewManagerInstance = nil; - (void)playMessageSoundForCallID:(NSString *)callID { if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; // if the message was already received through a push notif, we don't need to ring if (![lm popPushCallID:callID]) { [lm playMessageSound]; @@ -678,7 +665,7 @@ static RootViewManager *rootViewManagerInstance = nil; NSString *callId = [NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog)]; if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; BOOL callIDFromPush = [lm popPushCallID:callId]; BOOL autoAnswer = [lm lpConfigBoolForKey:@"autoanswer_notif_preference"]; @@ -688,7 +675,7 @@ static RootViewManager *rootViewManagerInstance = nil; } else { AudioServicesPlaySystemSound(lm.sounds.vibrate); CallIncomingView *view = VIEW(CallIncomingView); - [self changeCurrentView:view.compositeViewDescription push:TRUE]; + [self changeCurrentView:view.compositeViewDescription]; [view setCall:call]; [view setDelegate:self]; } @@ -736,7 +723,7 @@ static RootViewManager *rootViewManagerInstance = nil; } - (void)incomingCallAccepted:(LinphoneCall *)call evenWithVideo:(BOOL)video { - [[LinphoneManager instance] acceptCall:call evenWithVideo:video]; + [LinphoneManager.instance acceptCall:call evenWithVideo:video]; } - (void)incomingCallDeclined:(LinphoneCall *)call { diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index bf3538bb2..2e7e27db1 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -414,7 +414,7 @@ static UICompositeViewDescription *compositeDescription = nil; removeFromHiddenKeys = debugEnabled; [keys addObject:@"send_logs_button"]; [keys addObject:@"reset_logs_button"]; - [[LinphoneManager instance] setLogsEnabled:debugEnabled]; + [LinphoneManager.instance setLogsEnabled:debugEnabled]; } else if ([@"account_mandatory_advanced_preference" compare:notif.object] == NSOrderedSame) { removeFromHiddenKeys = [[notif.userInfo objectForKey:@"account_mandatory_advanced_preference"] boolValue]; for (NSString *key in settingsStore->dict) { @@ -499,7 +499,7 @@ static UICompositeViewDescription *compositeDescription = nil; } - (NSSet *)findHiddenKeys { - LinphoneManager *lm = [LinphoneManager instance]; + LinphoneManager *lm = LinphoneManager.instance; NSMutableSet *hiddenKeys = [NSMutableSet set]; const MSList *accounts = linphone_core_get_proxy_config_list(LC); @@ -520,7 +520,7 @@ static UICompositeViewDescription *compositeDescription = nil; [hiddenKeys addObject:@"flush_images_button"]; #endif - if (![[LinphoneManager instance] lpConfigBoolForKey:@"debugenable_preference"]) { + if (![LinphoneManager.instance lpConfigBoolForKey:@"debugenable_preference"]) { [hiddenKeys addObject:@"send_logs_button"]; [hiddenKeys addObject:@"reset_logs_button"]; } @@ -611,7 +611,7 @@ static UICompositeViewDescription *compositeDescription = nil; } } - if (![[[LinphoneManager instance] iapManager] enabled]) { + if (![[LinphoneManager.instance iapManager] enabled]) { [hiddenKeys addObject:@"in_app_products_button"]; } @@ -660,7 +660,7 @@ static UICompositeViewDescription *compositeDescription = nil; if ([key isEqual:@"release_button"]) { [UIApplication sharedApplication].keyWindow.rootViewController = nil; [[UIApplication sharedApplication].keyWindow setRootViewController:nil]; - [[LinphoneManager instance] destroyLinphoneCore]; + [LinphoneManager.instance destroyLinphoneCore]; [LinphoneManager instanceRelease]; } else if ([key isEqual:@"clear_cache_button"]) { [PhoneMainView.instance.mainViewController @@ -701,7 +701,7 @@ static UICompositeViewDescription *compositeDescription = nil; }]; [alert show]; } else if ([key isEqual:@"about_button"]) { - [PhoneMainView.instance changeCurrentView:AboutView.compositeViewDescription push:TRUE]; + [PhoneMainView.instance changeCurrentView:AboutView.compositeViewDescription]; } else if ([key isEqual:@"reset_logs_button"]) { linphone_core_reset_log_collection(); } else if ([key isEqual:@"send_logs_button"]) { @@ -826,9 +826,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (IBAction)onDialerBackClick:(id)sender { [_settingsController.navigationController popViewControllerAnimated:NO]; - - DialerView *view = VIEW(DialerView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; + [PhoneMainView.instance popToView:DialerView.compositeViewDescription]; } - (IBAction)onBackClick:(id)sender { diff --git a/Classes/SideMenuTableView.m b/Classes/SideMenuTableView.m index d5bca31d5..6495f93ac 100644 --- a/Classes/SideMenuTableView.m +++ b/Classes/SideMenuTableView.m @@ -39,24 +39,18 @@ addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Assistant", nil) tapBlock:^() { [PhoneMainView.instance - changeCurrentView:AssistantView.compositeViewDescription - push:NO - animated:NO]; + changeCurrentView:AssistantView.compositeViewDescription]; }]]; [_sideMenuEntries addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Settings", nil) tapBlock:^() { [PhoneMainView.instance - changeCurrentView:SettingsView.compositeViewDescription - push:NO - animated:NO]; + changeCurrentView:SettingsView.compositeViewDescription]; }]]; [_sideMenuEntries addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"About", nil) tapBlock:^() { [PhoneMainView.instance - changeCurrentView:AboutView.compositeViewDescription - push:NO - animated:NO]; + changeCurrentView:AboutView.compositeViewDescription]; }]]; } diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index eb8d81520..b86eb6e9e 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -76,7 +76,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info + (NSString *)appendCountryCodeIfPossible:(NSString *)number { if (![number hasPrefix:@"+"] && ![number hasPrefix:@"00"]) { - NSString *lCountryCode = [[LinphoneManager instance] lpConfigStringForKey:@"countrycode_preference"]; + NSString *lCountryCode = [LinphoneManager.instance lpConfigStringForKey:@"countrycode_preference"]; if (lCountryCode && [lCountryCode length] > 0) { // append country code return [lCountryCode stringByAppendingString:number]; @@ -211,7 +211,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(lMap, i); BOOL add = false; if (CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) { - if (CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, + if (CFStringCompare((CFStringRef)LinphoneManager.instance.contactSipField, CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey), kCFCompareCaseInsensitive) == 0) { add = true; @@ -273,14 +273,14 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void if (CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) { CFStringRef serviceKey = CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey); - if (CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, serviceKey, + 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]); + LinphoneAddress *address = linphone_core_interpret_url( + LC, [(NSString *)CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey) UTF8String]); if (address) { const char *dom = linphone_address_get_domain(address); diff --git a/Classes/Utils/FileTransferDelegate.m b/Classes/Utils/FileTransferDelegate.m index 81c37856e..65931496b 100644 --- a/Classes/Utils/FileTransferDelegate.m +++ b/Classes/Utils/FileTransferDelegate.m @@ -22,7 +22,7 @@ } + (FileTransferDelegate *)messageDelegate:(LinphoneChatMessage *)message { - for (FileTransferDelegate *ftd in [[LinphoneManager instance] fileTransferDelegates]) { + for (FileTransferDelegate *ftd in [LinphoneManager.instance fileTransferDelegates]) { if (ftd.message == message) { return ftd; } @@ -47,14 +47,13 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con UIImage *image = [UIImage imageWithData:thiz.data]; CFBridgingRetain(thiz); - [[[LinphoneManager instance] fileTransferDelegates] removeObject:thiz]; + [[LinphoneManager.instance fileTransferDelegates] removeObject:thiz]; // until image is properly saved, keep a reminder on it so that the // chat bubble is aware of the fact that image is being saved to device [LinphoneManager setValueInMessageAppData:@"saving..." forKey:@"localimage" inMessage:message]; - [[LinphoneManager instance] - .photoLibrary + [LinphoneManager.instance.photoLibrary writeImageToSavedPhotosAlbum:image.CGImage orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error) { @@ -172,7 +171,7 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m } - (BOOL)download:(LinphoneChatMessage *)message { - [[[LinphoneManager instance] fileTransferDelegates] addObject:self]; + [[LinphoneManager.instance fileTransferDelegates] addObject:self]; _message = message; @@ -191,7 +190,7 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m } - (void)stopAndDestroy { - [[[LinphoneManager instance] fileTransferDelegates] removeObject:self]; + [[LinphoneManager.instance fileTransferDelegates] removeObject:self]; if (_message != NULL) { LinphoneChatMessage *msg = _message; _message = NULL; diff --git a/TestsUI/LinphoneTestCase.m b/TestsUI/LinphoneTestCase.m index d3d672543..cb2deb163 100644 --- a/TestsUI/LinphoneTestCase.m +++ b/TestsUI/LinphoneTestCase.m @@ -104,8 +104,8 @@ linphone_core_clear_proxy_config(lc); linphone_core_clear_all_auth_info(lc); - LinphoneAddress *testAddr = linphone_address_new( - [[NSString stringWithFormat:@"sip:%@@%@", [self me], [self accountDomain]] UTF8String]); + LinphoneAddress *testAddr = linphone_core_interpret_url( + LC, [[NSString stringWithFormat:@"sip:%@@%@", [self me], [self accountDomain]] UTF8String]); linphone_address_set_header(testAddr, "X-Create-Account", "yes"); linphone_address_set_transport(testAddr, LinphoneTransportTcp); linphone_address_set_port(testAddr, 0);