diff --git a/Classes/IncallViewController.m b/Classes/IncallViewController.m index a5b991804..fd1518bc5 100644 --- a/Classes/IncallViewController.m +++ b/Classes/IncallViewController.m @@ -22,7 +22,7 @@ #import "linphonecore.h" #include "LinphoneManager.h" #include "private.h" -#import "ContactPickerDelegate.h"Òß +#import "ContactPickerDelegate.h" @implementation IncallViewController diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index dcb97b6b7..46c8b1a9b 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -42,6 +42,10 @@ } - (void)applicationDidBecomeActive:(UIApplication *)application { [[LinphoneManager instance] becomeActive]; + + if (myPhoneViewController != nil) { + [myPhoneViewController updateCallAndBackButtons]; + } } - (void) loadDefaultSettings { diff --git a/Classes/LinphoneUI/LinphoneManager.h b/Classes/LinphoneUI/LinphoneManager.h index 5da93e076..32f403dee 100644 --- a/Classes/LinphoneUI/LinphoneManager.h +++ b/Classes/LinphoneUI/LinphoneManager.h @@ -48,6 +48,7 @@ typedef enum _Connectivity { } +(LinphoneManager*) instance; +(LinphoneCore*) getLc; ++(BOOL) audioSessionInterrupted; -(void) registerLogView:(id) view; diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index de012d74c..75c5dee6e 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -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; } diff --git a/Classes/PhoneViewController.h b/Classes/PhoneViewController.h index b9f5f09e2..03947ff5c 100644 --- a/Classes/PhoneViewController.h +++ b/Classes/PhoneViewController.h @@ -64,6 +64,8 @@ IncallViewController* mIncallViewController; } +-(void) updateCallAndBackButtons; + @property (nonatomic, retain) IBOutlet UIView* dialerView; @property (nonatomic, retain) IBOutlet UITextField* address; diff --git a/Classes/PhoneViewController.m b/Classes/PhoneViewController.m index 1e06fbf61..26c44d9ce 100644 --- a/Classes/PhoneViewController.m +++ b/Classes/PhoneViewController.m @@ -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); diff --git a/submodules/externals/exosip b/submodules/externals/exosip index c3da03035..f28804413 160000 --- a/submodules/externals/exosip +++ b/submodules/externals/exosip @@ -1 +1 @@ -Subproject commit c3da0303519ad3120355cb85baee9cf6d0e4d1c2 +Subproject commit f288044136b3e60baf6c0805e8cf87e5cdbc7890