From e2c691ed35516adbe14853c102fcd42fa4c7c7ce Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 13 Dec 2010 14:08:12 +0100 Subject: [PATCH 1/2] Add unregistration. --- .../core/tutorials/TutorialRegistration.java | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java index bab85c682..3f03081e9 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java @@ -65,9 +65,6 @@ public class TutorialRegistration implements LinphoneCoreListener { */ public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg,RegistrationState cstate, String smessage) { write(cfg.getIdentity() + " : "+smessage+"\n"); - - if (RegistrationState.RegistrationOk.equals(cstate)) - running = false; } public void show(LinphoneCore lc) {} @@ -132,7 +129,6 @@ public class TutorialRegistration implements LinphoneCoreListener { - // main loop for receiving notifications and doing background linphonecore work running = true; while (running) { @@ -145,10 +141,37 @@ public class TutorialRegistration implements LinphoneCoreListener { } } + // Unregister then register again + lc.getDefaultProxyConfig().edit(); + lc.getDefaultProxyConfig().enableRegister(false); + lc.getDefaultProxyConfig().done(); + + for (int i = 0; i < 20; i++) { + lc.iterate(); + try{ + Thread.sleep(50); + } catch(InterruptedException ie) { + write("Interrupted!\nAborting"); + return; + } + } + lc.getDefaultProxyConfig().edit(); + lc.getDefaultProxyConfig().enableRegister(true); + lc.getDefaultProxyConfig().done(); + + for (int i = 0; i < 20; i++) { + lc.iterate(); + try{ + Thread.sleep(50); + } catch(InterruptedException ie) { + write("Interrupted!\nAborting"); + return; + } + } + + // Automatic unregistration on exit - - } finally { write("Shutting down linphone..."); // You need to destroy the LinphoneCore object when no longer used From 4a836da794a81b3d9c3841781c376e5ad081e0b0 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 13 Dec 2010 14:08:55 +0100 Subject: [PATCH 2/2] Change iterate on sal in iterate on linphonecore. This causes hang on destroy. --- coreapi/linphonecore.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 7c5ee9071..940202428 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3669,16 +3669,13 @@ void sip_config_uninit(LinphoneCore *lc) linphone_proxy_config_edit(cfg); /* to unregister */ } - if (lc->sal){ - int i; - for (i=0;i<20;i++){ - sal_iterate(lc->sal); + for (i=0;i<20;i++){ + linphone_core_iterate(lc); #ifndef WIN32 - usleep(100000); + usleep(100000); #else - Sleep(100); + Sleep(100); #endif - } } ms_list_for_each(config->proxies,(void (*)(void*)) linphone_proxy_config_destroy);