From 4c026f68c40f293faebdc689f7b3ddc3bfc99294 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Wed, 24 Mar 2021 17:04:42 +0100 Subject: [PATCH] Unsubscribe from friends list when removing and account, and add a small filter to avoid displaying irrelevant authentication requests from previously logged account on the app --- Classes/LinphoneCoreSettingsStore.m | 13 +++++++++++-- Classes/LinphoneManager.m | 17 ++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 2c3578c0d..e8b6f0599 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -947,13 +947,22 @@ - (void)removeAccount { LinphoneProxyConfig *config = bctbx_list_nth_data(linphone_core_get_proxy_config_list(LC), [self integerForKey:@"current_proxy_config_preference"]); - + + const MSList *lists = linphone_core_get_friends_lists(LC); + while (lists) { + linphone_friend_list_enable_subscriptions(lists->data, FALSE); + linphone_friend_list_update_subscriptions(lists->data); + lists = lists->next; + } BOOL isDefault = (linphone_core_get_default_proxy_config(LC) == config); const LinphoneAuthInfo *ai = linphone_proxy_config_find_auth_info(config); linphone_core_remove_proxy_config(LC, config); if (ai) { - linphone_core_remove_auth_info(LC, ai); + // Friend list unsubscription above is not instantanous, so give a bit of a time margin before finishing the removal of the auth info + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + linphone_core_remove_auth_info(LC, ai); + }); } [self setInteger:-1 forKey:@"current_proxy_config_preference"]; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 17585fed7..118eca70f 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -723,7 +723,22 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut const char * usernameC = linphone_auth_info_get_username(auth_info) ? : ""; const char * domainC = linphone_auth_info_get_domain(auth_info) ? : ""; static UIAlertController *alertView = nil; - + + // InstantMessageDeliveryNotifications from previous accounts can trigger some pop-up spam asking for indentification + // Try to filter the popup password request to avoid displaying those that do not matter and can be handled through a simple warning + const MSList *configList = linphone_core_get_proxy_config_list(LC); + bool foundMatchingConfig = false; + while (configList && !foundMatchingConfig) { + const char * configUsername = linphone_proxy_config_get_identity(configList->data); + const char * configDomain = linphone_proxy_config_get_domain(configList->data); + foundMatchingConfig = (strcmp(configUsername, usernameC) == 0) && (strcmp(configDomain, domainC) == 0); + configList = configList->next; + } + if (!foundMatchingConfig) { + LOGW(@"Received an authentication request from %s@%s, but ignored it did not match any current user", usernameC, domainC); + return; + } + // avoid having multiple popups [PhoneMainView.instance dismissViewControllerAnimated:YES completion:nil];