From c68dd94acbac973fa0face6c78460d2cad628bcf Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 21 Aug 2014 17:01:55 +0200 Subject: [PATCH] allow notification of registration_state_changed callback for removed proxy configs. --- coreapi/callbacks.c | 8 ++------ coreapi/linphonecore.c | 5 +++-- coreapi/private.h | 1 + coreapi/proxy.c | 22 +++++++++++++--------- gtk/main.c | 2 +- oRTP | 2 +- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index c64a5d7e3..7a09fa76e 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -843,8 +843,8 @@ static void register_success(SalOp *op, bool_t registered){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op); char *msg; - if (!cfg || cfg->deletion_date!=0){ - ms_message("Registration success for removed proxy config, ignored"); + if (!cfg){ + ms_message("Registration success for deleted proxy config, ignored"); return; } linphone_proxy_config_set_state(cfg, registered ? LinphoneRegistrationOk : LinphoneRegistrationCleared , @@ -868,10 +868,6 @@ static void register_failure(SalOp *op){ ms_warning("Registration failed for unknown proxy config."); return ; } - if (cfg->deletion_date!=0){ - ms_message("Registration failed for removed proxy config, ignored"); - return; - } if (details==NULL) details=_("no response timeout"); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 67582a2b0..eb137bdd9 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2200,9 +2200,10 @@ static void proxy_update(LinphoneCore *lc){ for(elem=lc->sip_conf.deleted_proxies;elem!=NULL;elem=next){ LinphoneProxyConfig* cfg = (LinphoneProxyConfig*)elem->data; next=elem->next; - if (ms_time(NULL) - cfg->deletion_date > 5) { + if (ms_time(NULL) - cfg->deletion_date > 32) { lc->sip_conf.deleted_proxies =ms_list_remove_link(lc->sip_conf.deleted_proxies,elem); - ms_message("clearing proxy config for [%s]",linphone_proxy_config_get_addr(cfg)); + ms_message("Proxy config for [%s] is definitely removed from core.",linphone_proxy_config_get_addr(cfg)); + _linphone_proxy_config_release_ops(cfg); linphone_proxy_config_destroy(cfg); } } diff --git a/coreapi/private.h b/coreapi/private.h index 14e86e48b..be8d8667f 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -407,6 +407,7 @@ void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun LINPHONE_PUBLIC bool_t linphone_proxy_config_address_equal(const LinphoneAddress *a, const LinphoneAddress *b); LINPHONE_PUBLIC bool_t linphone_proxy_config_is_server_config_changed(const LinphoneProxyConfig* obj); void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj); +void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj); /*chat*/ void linphone_chat_message_destroy(LinphoneChatMessage* msg); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 4c21d61c7..c96544e8b 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -149,6 +149,17 @@ LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc) { return obj; } +void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj){ + if (obj->op) { + sal_op_release(obj->op); + obj->op=NULL; + } + if (obj->publish_op){ + sal_op_release(obj->publish_op); + obj->publish_op=NULL; + } +} + void _linphone_proxy_config_destroy(LinphoneProxyConfig *obj){ if (obj->reg_proxy!=NULL) ms_free(obj->reg_proxy); if (obj->reg_identity!=NULL) ms_free(obj->reg_identity); @@ -159,12 +170,11 @@ void _linphone_proxy_config_destroy(LinphoneProxyConfig *obj){ if (obj->realm!=NULL) ms_free(obj->realm); if (obj->type!=NULL) ms_free(obj->type); if (obj->dial_prefix!=NULL) ms_free(obj->dial_prefix); - if (obj->op) sal_op_release(obj->op); - if (obj->publish_op) sal_op_release(obj->publish_op); if (obj->contact_params) ms_free(obj->contact_params); if (obj->contact_uri_params) ms_free(obj->contact_uri_params); if (obj->saved_proxy!=NULL) linphone_address_destroy(obj->saved_proxy); if (obj->saved_identity!=NULL) linphone_address_destroy(obj->saved_identity); + _linphone_proxy_config_release_ops(obj); } /** @@ -467,9 +477,6 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ linphone_proxy_config_set_state(obj,LinphoneRegistrationCleared,"Registration cleared"); } _linphone_proxy_config_unregister(obj); - - - } } @@ -1156,10 +1163,7 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf linphone_proxy_config_edit(cfg); linphone_proxy_config_enable_register(cfg,FALSE); linphone_proxy_config_done(cfg); - linphone_proxy_config_update(cfg); /*so that it has an effect*/ - - /*as cfg no longer in proxies, unregister will never be issued*/ - _linphone_proxy_config_unregister(cfg); + linphone_proxy_config_update(cfg); } if (lc->default_proxy==cfg){ lc->default_proxy=NULL; diff --git a/gtk/main.c b/gtk/main.c index a08681dde..2886f1d8d 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1540,7 +1540,7 @@ static void update_registration_status(LinphoneProxyConfig *cfg, LinphoneRegistr }while(gtk_tree_model_iter_next(model,&iter)); } if (!found) { - g_warning("Could not find proxy config in combo box of identities."); + /*ignored, this is a notification for a removed proxy config.*/ return; } switch (rs){ diff --git a/oRTP b/oRTP index 007016485..49fc68957 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 00701648593b0fce93b3d519e281dd6f547db670 +Subproject commit 49fc68957126d1126be1eb0fcaaa6153480e93e4