From 421a1a390fcf3ea61d5054114e560751e8d388f9 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 24 Sep 2012 18:54:52 +0200 Subject: [PATCH] fix GSM call handling --- Classes/LinphoneAppDelegate.m | 19 ++++++------------- Classes/LinphoneManager.m | 13 ++++++++++++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 2537e7949..e739de4a0 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -60,19 +60,12 @@ CTCallCenter* ct = (CTCallCenter*) cCenter; int callCount = [ct.currentCalls count]; - if (!callCount) { - [LinphoneLogger logc:LinphoneLoggerLog format:"No GSM call -> enabling SIP calls"]; - linphone_core_set_max_calls([LinphoneManager getLc], 3); - } else { - [LinphoneLogger logc:LinphoneLoggerLog format:"%d GSM call(s) -> disabling SIP calls", callCount]; - /* pause current call, if any */ - LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]); - if (call) { - [LinphoneLogger logc:LinphoneLoggerLog format:"Pausing SIP call"]; - linphone_core_pause_call([LinphoneManager getLc], call); - } - linphone_core_set_max_calls([LinphoneManager getLc], 0); - } + /* pause current call, if any */ + LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]); + if (callCount>0 && call) { + [LinphoneLogger logc:LinphoneLoggerLog format:"Pausing SIP call"]; + linphone_core_pause_call([LinphoneManager getLc], call); + } } - (void)applicationDidEnterBackground:(UIApplication *)application{ diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index f6ab7e647..e6be143bc 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -360,7 +360,18 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char - (void)onCall:(LinphoneCall*)call StateChanged:(LinphoneCallState)state withMessage:(const char *)message { // Handling wrapper - if(state == LinphoneCallReleased) { + + CTCallCenter* ct = [[CTCallCenter alloc] init]; + + int callCount = [ct.currentCalls count]; + if (callCount>0 && state==LinphoneCallIncomingReceived) { + [LinphoneLogger logc:LinphoneLoggerLog format:"Mobile call ongoing... rejecting call from [%s]",linphone_address_get_username(linphone_call_get_call_log(call)->from)]; + linphone_core_terminate_call([LinphoneManager getLc], call); + return; + } + [ct release]; + + if(state == LinphoneCallReleased) { if(linphone_call_get_user_pointer(call) != NULL) { free (linphone_call_get_user_pointer(call)); linphone_call_set_user_pointer(call, NULL);