diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 64d42d13c..09b49b20a 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -63,6 +63,9 @@ - (void)applicationDidEnterBackground:(UIApplication *)application { LOGI(@"%@", NSStringFromSelector(_cmd)); + if([LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"]){ + linphone_core_set_consolidated_presence([LinphoneManager getLc], LinphoneConsolidatedPresenceBusy); + } if (linphone_core_get_global_state(LC) != LinphoneGlobalOff) { [LinphoneManager.instance enterBackgroundMode]; [LinphoneManager.instance.fastAddressBook clearFriends]; @@ -75,12 +78,6 @@ // To avoid crash [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; } - - [LinphoneManager.instance lpConfigSetBool:FALSE forKey:@"account_push_presence_preference"]; - - if([LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"]){ - linphone_core_set_consolidated_presence(LC, LinphoneConsolidatedPresenceBusy); - } [CallManager.instance stopLinphoneCore]; } @@ -92,9 +89,9 @@ [LinphoneManager.instance startLinphoneCore]; [LinphoneManager.instance.fastAddressBook reloadFriends]; - + [AvatarBridge clearFriends]; if([LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"]){ - linphone_core_set_consolidated_presence(LC, LinphoneConsolidatedPresenceOnline); + linphone_core_set_consolidated_presence([LinphoneManager getLc], LinphoneConsolidatedPresenceOnline); } [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil]; diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 690115aa7..604fb1fd0 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -186,7 +186,7 @@ BOOL pushEnabled = linphone_account_params_get_push_notification_allowed(accountParams); [self setBool:pushEnabled forKey:@"account_pushnotification_preference"]; - BOOL pushPresenceEnabled = [LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"]; + BOOL pushPresenceEnabled = linphone_account_params_get_publish_enabled(accountParams); [self setBool:pushPresenceEnabled forKey:@"account_push_presence_preference"]; const LinphoneAddress *identity_addr = linphone_account_params_get_identity_address(accountParams); @@ -618,6 +618,7 @@ if (username && [username length] > 0 && domain && [domain length] > 0) { int expire = [self integerForKey:@"account_expire_preference"]; BOOL pushnotification = [self boolForKey:@"account_pushnotification_preference"]; + BOOL publishPrensence = [self boolForKey:@"account_push_presence_preference"]; NSString *prefix = [self stringForKey:@"account_prefix_preference"]; BOOL use_prefix = [self boolForKey:@"apply_international_prefix_for_calls_and_chats"]; NSString *proxyAddress = [self stringForKey:@"account_proxy_preference"]; @@ -698,7 +699,10 @@ // use empty string "" instead of NULL to avoid being overwritten by default proxy config values linphone_account_params_set_push_notification_allowed(newAccountParams, pushnotification); linphone_account_params_set_remote_push_notification_allowed(newAccountParams, pushnotification); - + + linphone_account_params_set_publish_enabled(newAccountParams, publishPrensence); + [LinphoneManager.instance lpConfigSetBool:publishPrensence forKey:@"account_push_presence_preference"]; + linphone_account_params_set_register_enabled(newAccountParams, is_enabled); linphone_account_params_set_avpf_mode(newAccountParams, use_avpf); linphone_account_params_set_expires(newAccountParams, expire); diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index ea047e045..fd5f9d5bc 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -381,6 +381,10 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char * } - (void)migrationLinphoneSettings { + NSString *appDomain = [LinphoneManager.instance lpConfigStringForKey:@"domain_name" + inSection:@"app" + withDefault:@"sip.linphone.org"]; + /* AVPF migration */ if ([self lpConfigBoolForKey:@"avpf_migration_done"] == FALSE) { const MSList *accounts = linphone_core_get_account_list(theLinphoneCore); @@ -473,6 +477,26 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char * } [self lpConfigSetBool:TRUE forKey:@"push_notification_migration_done"]; } + if ([self lpConfigBoolForKey:@"publish_enabled_migration_done"] == FALSE) { + const MSList *accounts = linphone_core_get_account_list(theLinphoneCore); + linphone_core_set_log_collection_upload_server_url(LC, "https://www.linphone.org:444/lft.php"); + [self lpConfigSetBool:TRUE forKey:@"update_presence_model_timestamp_before_publish_expires_refresh"]; + + while (accounts) + { + LinphoneAccount *account = (LinphoneAccount *)accounts->data; + LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account)); + + if (strcmp(appDomain.UTF8String, linphone_account_params_get_domain(newAccountParams)) == 0) { + linphone_account_params_set_publish_enabled(newAccountParams, true); + linphone_account_params_set_publish_expires(newAccountParams, 120); + linphone_account_set_params(account, newAccountParams); + } + linphone_account_params_unref(newAccountParams); + accounts = accounts->next; + } + [self lpConfigSetBool:TRUE forKey:@"publish_enabled_migration_done"]; + } } - (void)migrationPerAccount { diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index f92f93988..5b28009aa 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -1118,6 +1118,14 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat // retrieve linphone logs if available char *filepath = linphone_core_compress_log_collection(); + + + LinphoneCoreCbs *coreCbs = linphone_factory_create_core_cbs(linphone_factory_get()); + linphone_core_cbs_set_log_collection_upload_state_changed(coreCbs, core_log_collection_upload_state_changed); + linphone_core_add_callbacks(LC, coreCbs); + + linphone_core_upload_log_collection(LC); + if (filepath != NULL) { NSString *filename = [[NSString stringWithUTF8String:filepath] componentsSeparatedByString:@"/"].lastObject; NSString *mimeType = nil; @@ -1165,6 +1173,17 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat [self emailAttachments:attachments]; } +void core_log_collection_upload_state_changed(LinphoneCore *core, LinphoneCoreLogCollectionUploadState state , const char* info) { + + LOGD(@"LinphoneCoreLogCollectionUploadStateDelivered core_log_collection_upload_state_changed %s", info); + if (state == LinphoneCoreLogCollectionUploadStateDelivered) { + LOGD(@"LinphoneCoreLogCollectionUploadStateDelivered %s", info); + UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; + + pasteboard.string = [NSString stringWithUTF8String: info]; + } +} + - (void)sendEmailWithPrivacyAttachments { NSMutableArray *attachments = [[NSMutableArray alloc] initWithCapacity:4]; diff --git a/Classes/Swift/Voip/Widgets/Avatar.swift b/Classes/Swift/Voip/Widgets/Avatar.swift index 07be0823e..efae522ff 100644 --- a/Classes/Swift/Voip/Widgets/Avatar.swift +++ b/Classes/Swift/Voip/Widgets/Avatar.swift @@ -101,8 +101,9 @@ class Avatar : UIView { friend.append(Friend.getSwiftObject(cObject: (contactAddress.friend)!)) let newFriendDelegate = FriendDelegateStub( onPresenceReceived: { (linphoneFriend: Friend) -> Void in + let presenceModel = linphoneFriend.getPresenceModelForUriOrTel(uriOrTel: (linphoneFriend.address?.asStringUriOnly())!) - NotificationCenter.default.post(name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil, userInfo: ["friend": linphoneFriend.address?.asStringUriOnly() ?? "", "isOnline": presenceModel!.isOnline]) + NotificationCenter.default.post(name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil, userInfo: ["friend": linphoneFriend.address?.asStringUriOnly() ?? "", "isOnline": presenceModel!.consolidatedPresence.rawValue == LinphoneConsolidatedPresenceOnline.rawValue]) } ) friendDelegate.append(newFriendDelegate) @@ -138,13 +139,15 @@ class Avatar : UIView { let contactAddress = Address.getSwiftObject(cObject: address).contact() var iconPresenceView = UIImageView() if (contactAddress != nil) { - iconPresenceView = updatePresenceImage(contact: contactAddress!) + + + shared?.addDelegate(contactAddress: contactAddress!) + + iconPresenceView = updatePresenceImage(contact: contactAddress!) avatarWithPresence.addSubview(avatarImageWihtoutPresence) avatarWithPresence.addSubview(iconPresenceView) iconPresenceView.frame = CGRect(x: 35, y: 35, width: 16, height: 16) - - shared?.addDelegate(contactAddress: contactAddress!) }else{ avatarWithPresence.addSubview(avatarImageWihtoutPresence) } @@ -183,13 +186,22 @@ class Avatar : UIView { presenceModel = friend.getPresenceModelForUriOrTel(uriOrTel: (friend.address?.asStringUriOnly())!) hasPresence = presenceModel != nil && presenceModel!.basicStatus == PresenceBasicStatus.Open } - + if (hasPresence! && presenceModel?.consolidatedPresence == ConsolidatedPresence.Online) { imageName = "led_connected"; - } else { + } else if (hasPresence! && presenceModel?.consolidatedPresence == ConsolidatedPresence.Busy){ imageName = "led_inprogress"; - } + } else { + imageName = ""; + } return UIImageView(image: UIImage(named:imageName)) } + + @objc static func clearFriends(){ + if shared != nil { + shared!.friend = [] + shared!.friendDelegate = [] + } + } } diff --git a/Resources/assistant_external_sip.rc b/Resources/assistant_external_sip.rc index 46d2f70a3..355634107 100644 --- a/Resources/assistant_external_sip.rc +++ b/Resources/assistant_external_sip.rc @@ -4,6 +4,7 @@
0 0 + -1 3600 diff --git a/Resources/assistant_linphone_create.rc b/Resources/assistant_linphone_create.rc index 16cce1f73..91eff3d56 100644 --- a/Resources/assistant_linphone_create.rc +++ b/Resources/assistant_linphone_create.rc @@ -4,7 +4,8 @@
1 0 - 0 + 1 + 120 sip:voip-metrics@sip.linphone.org;transport=tls 1 180 diff --git a/Resources/assistant_linphone_existing.rc b/Resources/assistant_linphone_existing.rc index 2437ed1d3..32285d284 100644 --- a/Resources/assistant_linphone_existing.rc +++ b/Resources/assistant_linphone_existing.rc @@ -3,7 +3,8 @@
1 0 - 0 + 1 + 120 sip:voip-metrics@sip.linphone.org;transport=tls 1 180 diff --git a/Resources/linphonerc b/Resources/linphonerc index 89d9ad73f..8df2b1501 100644 --- a/Resources/linphonerc +++ b/Resources/linphonerc @@ -50,6 +50,7 @@ reg_expires=1314000 [misc] file_transfer_server_url=https://www.linphone.org:444/lft.php +log_collection_upload_server_url=https://www.linphone.org:444/lft.php real_early_media=1 prefer_basic_chat_room=-1 conference_layout=1 @@ -69,6 +70,7 @@ video_jitt_comp=60 video_rtp_port=9200-9299 [sip] +update_presence_model_timestamp_before_publish_expires_refresh=1 contact="Linphone iPhone" guess_hostname=1 inc_timeout=45 diff --git a/Settings/InAppSettings.bundle/en.lproj/Account.strings b/Settings/InAppSettings.bundle/en.lproj/Account.strings index 0bfbac138..a904fc5fe 100644 Binary files a/Settings/InAppSettings.bundle/en.lproj/Account.strings and b/Settings/InAppSettings.bundle/en.lproj/Account.strings differ