mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
Forbid SIP calls if GSM call is active
This commit is contained in:
parent
cdc7c80a6a
commit
37dd2841dd
1 changed files with 40 additions and 2 deletions
|
|
@ -22,6 +22,9 @@
|
|||
#import "ContactPickerDelegate.h"
|
||||
#import "AddressBook/ABPerson.h"
|
||||
|
||||
#import "CoreTelephony/CTCallCenter.h"
|
||||
#import "CoreTelephony/CTCall.h"
|
||||
|
||||
#import "ConsoleViewController.h"
|
||||
#import "MoreViewController.h"
|
||||
#include "CallHistoryTableViewController.h"
|
||||
|
|
@ -175,9 +178,44 @@ int __aeabi_idiv(int a, int b) {
|
|||
|
||||
[[LinphoneManager instance] setCallDelegate:myPhoneViewController];
|
||||
[[LinphoneManager instance] startLibLinphone];
|
||||
|
||||
|
||||
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];
|
||||
|
||||
|
||||
UIDevice* device = [UIDevice currentDevice];
|
||||
BOOL backgroundSupported = false;
|
||||
if ([device respondsToSelector:@selector(isMultitaskingSupported)]){
|
||||
backgroundSupported = device.multitaskingSupported;
|
||||
}
|
||||
if(backgroundSupported){
|
||||
[[LinphoneManager instance] kickOffBackgroundTCPConnection];
|
||||
NSLog(@"We are using my method");
|
||||
}
|
||||
|
||||
CTCallCenter* ct = [[CTCallCenter alloc] init];
|
||||
ct.callEventHandler = ^(CTCall* call) {
|
||||
@synchronized([LinphoneManager instance]) {
|
||||
if (call.callState == CTCallStateDisconnected) {
|
||||
NSLog(@"GSM call disconnected");
|
||||
if ([ct.currentCalls count] > 0) {
|
||||
NSLog(@"There are still some ongoing GSM call: disable SIP calls");
|
||||
linphone_core_set_max_calls([LinphoneManager getLc], 0);
|
||||
} else {
|
||||
NSLog(@"Re-enabling SIP calls");
|
||||
linphone_core_set_max_calls([LinphoneManager getLc], 3);
|
||||
}
|
||||
} else {
|
||||
NSLog(@"GSM call existing");
|
||||
/* pause current call, if any */
|
||||
LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]);
|
||||
if (call) {
|
||||
NSLog(@"Pausing SIP call");
|
||||
linphone_core_pause_call([LinphoneManager getLc], call);
|
||||
}
|
||||
NSLog(@"Disabling SIP calls");
|
||||
linphone_core_set_max_calls([LinphoneManager getLc], 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue