From 8ce4c7d15c60b1fd31183078cfac3d8bbbcd47e2 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 30 Aug 2012 16:13:57 +0200 Subject: [PATCH] update exosip and use long running task for registering while in background. --- Classes/LinphoneManager.h | 3 ++- Classes/LinphoneManager.m | 25 +++++++++++++++++++++---- submodules/externals/exosip | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 7016fbd60..cea4de9d7 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -78,7 +78,7 @@ typedef struct _LinphoneManagerSounds { NSTimer* mIterateTimer; time_t lastRemoteNotificationTime; Connectivity connectivity; - + BOOL stopWaitingRegisters; NSMutableArray *inhibitedEvent; @public @@ -104,6 +104,7 @@ typedef struct _LinphoneManagerSounds { - (void)didReceiveRemoteNotification; - (void)addPushTokenToProxyConfig: (LinphoneProxyConfig*)cfg; - (BOOL)shouldAutoAcceptCall; +- (void)waitForRegisterToArrive; + (void)kickOffNetworkConnection; - (void)setupNetworkReachabilityCallback; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 410d9137c..ee5abc758 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -389,6 +389,8 @@ static void linphone_iphone_transfer_state_changed(LinphoneCore* lc, LinphoneCal -(void) onRegister:(LinphoneCore *)lc cfg:(LinphoneProxyConfig*) cfg state:(LinphoneRegistrationState) state message:(const char*) message { [LinphoneLogger logc:LinphoneLoggerLog format:"NEW REGISTRATION STATE: '%s' (message: '%s')", linphone_registration_state_to_string(state), message]; + if (state==LinphoneRegistrationOk) + [LinphoneManager instance]->stopWaitingRegisters=TRUE; // Post event NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys: @@ -507,10 +509,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach linphone_proxy_config_expires(proxy, lLinphoneMgr.defaultExpires); //might be better to save the previous value } - if (lLinphoneMgr.connectivity == none) { - linphone_core_set_network_reachable([LinphoneManager getLc],true); - - } else if (lLinphoneMgr.connectivity != newConnectivity) { + if (lLinphoneMgr.connectivity != newConnectivity) { // connectivity has changed linphone_core_set_network_reachable([LinphoneManager getLc],false); if (newConnectivity == wwan && proxy && isWifiOnly) { @@ -518,6 +517,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach } linphone_core_set_network_reachable([LinphoneManager getLc],true); [LinphoneLogger logc:LinphoneLoggerLog format:"Network connectivity changed to type [%s]",(newConnectivity==wifi?"wifi":"wwan")]; + [lLinphoneMgr waitForRegisterToArrive]; } lLinphoneMgr.connectivity=newConnectivity; } @@ -749,6 +749,23 @@ static LinphoneCoreVTable linphonec_vtable = { return YES; } +- (void)waitForRegisterToArrive{ + int i; + UIBackgroundTaskIdentifier bgid; + stopWaitingRegisters=FALSE; + [LinphoneLogger logc:LinphoneLoggerLog format:"Starting long running task for registering"]; + bgid=[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler: ^{ + [LinphoneManager instance]->stopWaitingRegisters=TRUE; + [LinphoneLogger logc:LinphoneLoggerLog format:"Expiration handler called"]; + }]; + for(i=0;i<100 && (!stopWaitingRegisters);i++){ + linphone_core_iterate(theLinphoneCore); + usleep(20000); + } + [LinphoneLogger logc:LinphoneLoggerLog format:"Ending long running task for registering"]; + [[UIApplication sharedApplication] endBackgroundTask:bgid]; +} + - (BOOL)enterBackgroundMode { LinphoneProxyConfig* proxyCfg; linphone_core_get_default_proxy(theLinphoneCore, &proxyCfg); diff --git a/submodules/externals/exosip b/submodules/externals/exosip index 6ba04c22c..b62c41677 160000 --- a/submodules/externals/exosip +++ b/submodules/externals/exosip @@ -1 +1 @@ -Subproject commit 6ba04c22ccc8b140a9de84124d0e4ee7a406705b +Subproject commit b62c4167702f5333686754f55a2da81705e170ba