Do not allow user to start/answer a SIP call when a GSM call is active

This commit is contained in:
Pierre-Eric Pelloux-Prayer 2011-12-01 12:45:00 +01:00
parent 04d7e5e0ca
commit 2ab0771646
7 changed files with 37 additions and 11 deletions

View file

@ -22,7 +22,7 @@
#import "linphonecore.h"
#include "LinphoneManager.h"
#include "private.h"
#import "ContactPickerDelegate.h"Òß
#import "ContactPickerDelegate.h"
@implementation IncallViewController

View file

@ -42,6 +42,10 @@
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[[LinphoneManager instance] becomeActive];
if (myPhoneViewController != nil) {
[myPhoneViewController updateCallAndBackButtons];
}
}
- (void) loadDefaultSettings {

View file

@ -48,6 +48,7 @@ typedef enum _Connectivity {
}
+(LinphoneManager*) instance;
+(LinphoneCore*) getLc;
+(BOOL) audioSessionInterrupted;
-(void) registerLogView:(id<LogView>) view;

View file

@ -30,6 +30,7 @@
static LinphoneCore* theLinphoneCore=nil;
static LinphoneManager* theLinphoneManager=nil;
static BOOL audioSessionInterrupted = NO;
extern void libmsilbc_init();
#ifdef HAVE_AMR
@ -835,6 +836,8 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
}
-(void) beginInterruption {
audioSessionInterrupted = YES;
LinphoneCall* c = linphone_core_get_current_call(theLinphoneCore);
ms_message("Sound interruption detected!");
if (c) {
@ -850,7 +853,12 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
ms_message("Auto resuming call");
linphone_core_resume_call(theLinphoneCore, (LinphoneCall*) c->data);
}
audioSessionInterrupted = NO;
}
+(BOOL) audioSessionInterrupted {
return audioSessionInterrupted;
}

View file

@ -64,6 +64,8 @@
IncallViewController* mIncallViewController;
}
-(void) updateCallAndBackButtons;
@property (nonatomic, retain) IBOutlet UIView* dialerView;
@property (nonatomic, retain) IBOutlet UITextField* address;

View file

@ -164,6 +164,12 @@
[exc.name cStringUsingEncoding:[NSString defaultCStringEncoding]],
[exc.reason cStringUsingEncoding:[NSString defaultCStringEncoding]]);
}
/* if audio session is unavailable -> disable call buttons */
if ([LinphoneManager audioSessionInterrupted]) {
[callShort setEnabled:NO];
[callLarge setEnabled:NO];
}
}
-(void)viewWillAppear:(BOOL)animated {
@ -212,7 +218,13 @@
-(void) displayIncomingCall:(LinphoneCall*) call NotificationFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
if ([LinphoneManager audioSessionInterrupted]) {
// TODO: should we notify the user and let him cancel the call (without letting him accept it) ?
ms_message("Call refused: audio session is not available");
linphone_core_terminate_call([LinphoneManager getLc], call);
return;
}
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
// Create a new notification
@ -233,17 +245,16 @@
cd.delegate = self;
cd.call = call;
mIncomingCallActionSheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@" %@ is calling you",nil),[displayName length]>0?displayName:username]
delegate:cd
cancelButtonTitle:NSLocalizedString(@"Decline",nil)
mIncomingCallActionSheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@" %@ is calling you",nil),[displayName length]>0?displayName:username]
delegate:cd
cancelButtonTitle:NSLocalizedString(@"Decline",nil)
destructiveButtonTitle:NSLocalizedString(@"Answer",nil)
otherButtonTitles:nil];
otherButtonTitles:nil];
mIncomingCallActionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[mIncomingCallActionSheet showInView:self.parentViewController.view];
[mIncomingCallActionSheet release];
}
}
-(void) backToCallViewPressed {
@ -292,7 +303,7 @@
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex withUserDatas:(void *)datas{
LinphoneCall* call = (LinphoneCall*)datas;
if (buttonIndex == 0 ) {
if (buttonIndex == actionSheet.destructiveButtonIndex ) {
linphone_core_accept_call([LinphoneManager getLc],call);
} else {
linphone_core_terminate_call ([LinphoneManager getLc], call);

@ -1 +1 @@
Subproject commit c3da0303519ad3120355cb85baee9cf6d0e4d1c2
Subproject commit f288044136b3e60baf6c0805e8cf87e5cdbc7890