From 52928e7e1e94140dfd668493424f01c54ed370e9 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Wed, 20 Aug 2014 11:09:18 +0200 Subject: [PATCH] Don't wait for unregister when editing the account, and re-register after unsuccessful edit. --- Classes/LinphoneCoreSettingsStore.m | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 5ab8d7423..c84efbe01 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -295,27 +295,13 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); LpConfig* conf = linphone_core_get_config(lc); LinphoneManager* lLinphoneMgr = [LinphoneManager instance]; LinphoneProxyConfig* proxyCfg = NULL; + LinphoneProxyConfig* defaultProxy = NULL; NSString* error = nil; - /* unregister before modifying any settings */ - { - linphone_core_get_default_proxy(lc, &proxyCfg); - - if (proxyCfg) { - // this will force unregister WITHOUT destorying the proxyCfg object - linphone_proxy_config_edit(proxyCfg); - - int i=0; - while (linphone_proxy_config_get_state(proxyCfg)!=LinphoneRegistrationNone && - linphone_proxy_config_get_state(proxyCfg)!=LinphoneRegistrationCleared && - linphone_proxy_config_get_state(proxyCfg)!=LinphoneRegistrationFailed && - i++<40 ) { - linphone_core_iterate(lc); - usleep(10000); - } - } - } - + /* unregister before modifying any settings: editing will force unregistration */ + linphone_core_get_default_proxy(lc, &defaultProxy); + if (defaultProxy) linphone_proxy_config_edit(defaultProxy); + int port_preference = [self integerForKey:@"port_preference"]; BOOL random_port_preference = [self boolForKey:@"random_port_preference"]; @@ -454,7 +440,11 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); ms_free(proxy); if( info ) linphone_auth_info_destroy(info); + + // in case of error, show an alert to the user if( error != nil ){ + // restart the registration on the old proxy + if( defaultProxy ) linphone_proxy_config_done(defaultProxy); [self alertAccountError:error]; } }