diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 47856aefc..5465b209f 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -82,22 +82,30 @@ int __aeabi_idiv(int a, int b) { } } +- (void)applicationDidEnterBackground:(UIApplication *)application{ + [LinphoneLogger logc:LinphoneLoggerLog format:"applicationDidEnterBackground"]; + if(![LinphoneManager isLcReady]) return; + [[LinphoneManager instance] enterBackgroundMode]; +} + - (void)applicationWillResignActive:(UIApplication *)application { + [LinphoneLogger logc:LinphoneLoggerLog format:"applicationWillResignActive"]; if(![LinphoneManager isLcReady]) return; LinphoneCore* lc = [LinphoneManager getLc]; LinphoneCall* call = linphone_core_get_current_call(lc); - if (call == NULL) - return; + + + if (call){ + /* save call context */ + LinphoneManager* instance = [LinphoneManager instance]; + instance->currentCallContextBeforeGoingBackground.call = call; + instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call); - /* save call context */ - LinphoneManager* instance = [LinphoneManager instance]; - instance->currentCallContextBeforeGoingBackground.call = call; - instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call); - - const LinphoneCallParams* params = linphone_call_get_current_params(call); - if (linphone_call_params_video_enabled(params)) { - linphone_call_enable_camera(call, false); - } + const LinphoneCallParams* params = linphone_call_get_current_params(call); + if (linphone_call_params_video_enabled(params)) { + linphone_call_enable_camera(call, false); + } + } if (![[LinphoneManager instance] resignActive]) { // destroying eventHandler if app cannot go in background. @@ -111,7 +119,8 @@ int __aeabi_idiv(int a, int b) { } -- (void)applicationDidBecomeActive:(UIApplication *)application { +- (void)applicationDidBecomeActive:(UIApplication *)application { + [LinphoneLogger logc:LinphoneLoggerLog format:"applicationDidBecomeActive"]; [self startApplication]; [[LinphoneManager instance] becomeActive]; @@ -121,19 +130,19 @@ int __aeabi_idiv(int a, int b) { LinphoneCore* lc = [LinphoneManager getLc]; LinphoneCall* call = linphone_core_get_current_call(lc); - if (call == NULL) - return; - LinphoneManager* instance = [LinphoneManager instance]; - if (call == instance->currentCallContextBeforeGoingBackground.call) { - const LinphoneCallParams* params = linphone_call_get_current_params(call); - if (linphone_call_params_video_enabled(params)) { - linphone_call_enable_camera( + if (call){ + LinphoneManager* instance = [LinphoneManager instance]; + if (call == instance->currentCallContextBeforeGoingBackground.call) { + const LinphoneCallParams* params = linphone_call_get_current_params(call); + if (linphone_call_params_video_enabled(params)) { + linphone_call_enable_camera( call, instance->currentCallContextBeforeGoingBackground.cameraIsEnabled); - } - instance->currentCallContextBeforeGoingBackground.call = 0; - } + } + instance->currentCallContextBeforeGoingBackground.call = 0; + } + } } - (void)setupGSMInteraction { diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index acc6e1f55..86bd9814a 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -377,9 +377,9 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } - (BOOL)synchronize { + if (![LinphoneManager isLcReady]) return YES; LinphoneCore *lc=[LinphoneManager getLc]; - if (lc==NULL) return YES; BOOL account_changed; account_changed=[self valueChangedForKey:@"username_preference"] diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index d1e847b60..34bcabc3c 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -107,6 +107,7 @@ typedef struct _LinphoneManagerSounds { - (void)destroyLibLinphone; - (BOOL)resignActive; - (void)becomeActive; +- (BOOL)enterBackgroundMode; + (void)kickOffNetworkConnection; - (void)setupNetworkReachabilityCallback; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index eb7884f15..e1fc78eb5 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -668,7 +668,8 @@ static LinphoneCoreVTable linphonec_vtable = { else ms_set_cpu_count(1); - settingsStore = [[LinphoneCoreSettingsStore alloc] init]; + if (!settingsStore) + settingsStore = [[LinphoneCoreSettingsStore alloc] init]; [LinphoneLogger logc:LinphoneLoggerWarning format:"Linphone [%s] started on [%s]" ,linphone_core_get_version() @@ -686,10 +687,12 @@ static LinphoneCoreVTable linphonec_vtable = { [mIterateTimer invalidate]; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setDelegate:nil]; +#if 0 if (settingsStore != nil) { [settingsStore release]; settingsStore = nil; } +#endif if (theLinphoneCore != nil) { //just in case application terminate before linphone core initialization [LinphoneLogger logc:LinphoneLoggerLog format:"Destroy linphonecore"]; linphone_core_destroy(theLinphoneCore); @@ -705,19 +708,19 @@ static LinphoneCoreVTable linphonec_vtable = { - (BOOL)resignActive { if ([[LinphoneManager instance] settingsStore] != Nil) [[[LinphoneManager instance] settingsStore] synchronize]; - return [self enterBackgroundMode]; + linphone_core_stop_dtmf_stream(theLinphoneCore); + return YES; } - (BOOL)enterBackgroundMode { LinphoneProxyConfig* proxyCfg; linphone_core_get_default_proxy(theLinphoneCore, &proxyCfg); - linphone_core_stop_dtmf_stream(theLinphoneCore); - if (proxyCfg && [settingsStore boolForKey:@"backgroundmode_preference"]) { + + if (proxyCfg && [[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundmode_preference"]) { //For registration register linphone_core_refresh_registers(theLinphoneCore); - //wait for registration answer int i=0; while (!linphone_proxy_config_is_registered(proxyCfg) && i++<40 ) { diff --git a/Settings/InAppSettings.bundle/Call.plist b/Settings/InAppSettings.bundle/Call.plist index 8e0cb92ca..b5e1a7f6d 100644 --- a/Settings/InAppSettings.bundle/Call.plist +++ b/Settings/InAppSettings.bundle/Call.plist @@ -36,7 +36,7 @@ Type PSToggleSwitchSpecifier Title - Enable RFC DTMF + Send inband DTMFs Key rfc_dtmf_preference DefaultValue @@ -46,7 +46,7 @@ Type PSToggleSwitchSpecifier Title - Enable SIPINFO DTMF + Send SIP INFO DTMFs Key sipinfo_dtmf_preference DefaultValue