From a3a7bab33684ee36210b28ba1356ee150ee15afa Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 5 Oct 2012 11:33:19 +0200 Subject: [PATCH] send busy message while incoming sip call arrive during a GSM call. create a new CTCallCenter each time the application become active --- Classes/LinphoneManager.m | 51 ++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 49e4eebf3..56c920db7 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -378,13 +378,7 @@ 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 ([callCenter currentCalls]!=nil && 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; - } - - if(state == LinphoneCallReleased) { + if(state == LinphoneCallReleased) { LinphoneCallAppData* data = linphone_call_get_user_pointer(call); if(data != NULL) { [data release]; @@ -908,6 +902,16 @@ static int comp_call_state_paused (const LinphoneCall* call, const void* param) } /*IOS specific*/ linphone_core_start_dtmf_stream(theLinphoneCore); + + + //call center is unrelialable on the long run, so we change it each time the application is resumed. To avoid zombie GSM call + [self setupGSMInteraction]; + + //to make sure presence status is correct + if ([callCenter currentCalls]==nil) + linphone_core_set_presence_info(theLinphoneCore, 0, nil, LinphoneStatusAltService); + + } - (void)beginInterruption { @@ -1204,24 +1208,31 @@ static void audioRouteChangeListenerCallback ( #pragma GSM management - (void)setupGSMInteraction { - if (callCenter == nil) { - callCenter = [[CTCallCenter alloc] init]; - callCenter.callEventHandler = ^(CTCall* call) { - // post on main thread - [self performSelectorOnMainThread:@selector(handleGSMCallInteration:) - withObject:callCenter - waitUntilDone:YES]; - }; - } + + if (callCenter != nil) + [callCenter release]; + + callCenter = [[CTCallCenter alloc] init]; + callCenter.callEventHandler = ^(CTCall* call) { + // post on main thread + [self performSelectorOnMainThread:@selector(handleGSMCallInteration:) + withObject:callCenter + waitUntilDone:YES]; + }; + } - (void)handleGSMCallInteration: (id) cCenter { CTCallCenter* ct = (CTCallCenter*) cCenter; /* pause current call, if any */ LinphoneCall* call = linphone_core_get_current_call(theLinphoneCore); - if ([ct currentCalls]!=nil && call) { - [LinphoneLogger logc:LinphoneLoggerLog format:"Pausing SIP call"]; - linphone_core_pause_call(theLinphoneCore, call); - } + if ([ct currentCalls]!=nil) { + if (call) {[LinphoneLogger logc:LinphoneLoggerLog format:"Pausing SIP call"]; + linphone_core_pause_call(theLinphoneCore, call); + } + //set current status to busy + linphone_core_set_presence_info(theLinphoneCore, 0, nil, LinphoneStatusBusy); + } else + linphone_core_set_presence_info(theLinphoneCore, 0, nil, LinphoneStatusAltService); } @end