diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index eb197f6ae..4965e7e3c 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -147,6 +147,8 @@ typedef struct _LinphoneManagerSounds { - (void)refreshRegisters; +- (bool)allowSpeaker; + + (BOOL)copyFile:(NSString*)src destination:(NSString*)dst override:(BOOL)override; + (NSString*)bundleFile:(NSString*)file; + (NSString*)documentFile:(NSString*)file; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index f41d5cd1c..dd910501f 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -453,7 +453,11 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char /*should we reject this call ?*/ if ([lCTCallCenter currentCalls]!=nil) { - [LinphoneLogger logc:LinphoneLoggerLog format:"Mobile call ongoing... rejecting call from [%s]",linphone_address_get_username(linphone_call_get_call_log(call)->from)]; + char *tmp=linphone_call_get_remote_address_as_string(call); + if (tmp) { + [LinphoneLogger logc:LinphoneLoggerLog format:"Mobile call ongoing... rejecting call from [%s]",tmp]; + ms_free(tmp); + } linphone_core_decline_call(theLinphoneCore, call,LinphoneReasonBusy); [lCTCallCenter release]; return; @@ -464,7 +468,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char && [UIApplication sharedApplication].applicationState != UIApplicationStateActive) { LinphoneCallLog* callLog=linphone_call_get_call_log(call); - NSString* callId=[NSString stringWithUTF8String:callLog->call_id]; + NSString* callId=[NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog)]; if (![[LinphoneManager instance] shouldAutoAcceptCallForCallId:callId]){ NSString *ringtone = [NSString stringWithFormat:@"%@_loop.wav", [[NSUserDefaults standardUserDefaults] stringForKey:@"ringtone_preference"], nil]; @@ -494,7 +498,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char // Disable speaker when no more call if ((state == LinphoneCallEnd || state == LinphoneCallError)) { LinphoneCallLog *log = linphone_call_get_call_log(call); - if(log != NULL && log->status == LinphoneCallMissed) { + if(log != NULL && linphone_call_log_get_status(log) == LinphoneCallMissed) { // We can't use the comparison method, we can be in background mode and the application // will no send/update the http request int missed = [[UIApplication sharedApplication] applicationIconBadgeNumber]; @@ -516,12 +520,12 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char [data->notification release]; data->notification = nil; - if(log == NULL || log->status == LinphoneCallMissed) { + if(log == NULL || linphone_call_log_get_status(log) == LinphoneCallMissed) { UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.repeatInterval = 0; notification.alertBody = [NSString stringWithFormat:@"%@", address]; notification.alertAction = NSLocalizedString(@"Show", nil); - notification.userInfo = [NSDictionary dictionaryWithObject:[NSString stringWithUTF8String:log->call_id] forKey:@"callLog"]; + notification.userInfo = [NSDictionary dictionaryWithObject:[NSString stringWithUTF8String:linphone_call_log_get_call_id(log)] forKey:@"callLog"]; [[UIApplication sharedApplication] presentLocalNotificationNow:notification]; [notification release]; } @@ -1001,7 +1005,7 @@ static LinphoneCoreVTable linphonec_vtable = { } static int comp_call_id(const LinphoneCall* call , const char *callid) { - return strcmp(linphone_call_get_call_log(call)->call_id, callid); + return strcmp(linphone_call_log_get_call_id(linphone_call_get_call_log(call)), callid); } - (void)acceptCallForCallId:(NSString*)callid { @@ -1180,6 +1184,23 @@ static int comp_call_state_paused (const LinphoneCall* call, const void* param) #pragma mark - Speaker Functions +- (bool)allowSpeaker { + bool notallow = false; + CFStringRef lNewRoute = CFSTR("Unknown"); + UInt32 lNewRouteSize = sizeof(lNewRoute); + OSStatus lStatus = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &lNewRouteSize, &lNewRoute); + if (!lStatus && lNewRouteSize > 0) { + NSString *route = (NSString *) lNewRoute; + notallow = [route isEqualToString: @"Headset"] || + [route isEqualToString: @"Headphone"] || + [route isEqualToString: @"HeadphonesAndMicrophone"] || + [route isEqualToString: @"HeadsetInOut"] || + [route isEqualToString: @"Lineout"]; + CFRelease(lNewRoute); + } + return !notallow; +} + static void audioRouteChangeListenerCallback ( void *inUserData, // 1 AudioSessionPropertyID inPropertyID, // 2 @@ -1207,7 +1228,7 @@ static void audioRouteChangeListenerCallback ( - (void)setSpeakerEnabled:(BOOL)enable { speakerEnabled = enable; - if(enable) { + if(enable && [self allowSpeaker]) { UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute , sizeof (audioRouteOverride) diff --git a/Classes/LinphoneUI/UISpeakerButton.m b/Classes/LinphoneUI/UISpeakerButton.m index 474bd6f8c..0cf70b561 100644 --- a/Classes/LinphoneUI/UISpeakerButton.m +++ b/Classes/LinphoneUI/UISpeakerButton.m @@ -92,6 +92,7 @@ static void audioRouteChangeListenerCallback ( } - (bool)onUpdate { + [self setEnabled:[[LinphoneManager instance] allowSpeaker]]; return [[LinphoneManager instance] speakerEnabled]; } diff --git a/Classes/Utils/DTFoundation/DTActionSheet.h b/Classes/Utils/DTFoundation/DTActionSheet.h index 2c2a8b23d..71ab47650 100755 --- a/Classes/Utils/DTFoundation/DTActionSheet.h +++ b/Classes/Utils/DTFoundation/DTActionSheet.h @@ -42,8 +42,9 @@ typedef void (^DTActionSheetBlock)(void); Since there can only be one cancel button a previously marked cancel button becomes a normal button. @param title The title of the new button. + @param block The block to execute when the button is tapped. @returns The index of the new button. Button indices start at 0 and increase in the order they are added. */ -- (NSInteger)addCancelButtonWithTitle:(NSString *)title; +- (NSInteger)addCancelButtonWithTitle:(NSString *)title block:(DTActionSheetBlock)block; @end diff --git a/Classes/Utils/DTFoundation/DTActionSheet.m b/Classes/Utils/DTFoundation/DTActionSheet.m index eeb2161bc..070d974de 100755 --- a/Classes/Utils/DTFoundation/DTActionSheet.m +++ b/Classes/Utils/DTFoundation/DTActionSheet.m @@ -74,9 +74,9 @@ return retIndex; } -- (NSInteger)addCancelButtonWithTitle:(NSString *)title +- (NSInteger)addCancelButtonWithTitle:(NSString *)title block:(DTActionSheetBlock)block { - NSInteger retIndex = [self addButtonWithTitle:title]; + NSInteger retIndex = [self addButtonWithTitle:title block:block]; [self setCancelButtonIndex:retIndex]; return retIndex; diff --git a/submodules/externals/exosip b/submodules/externals/exosip index 80eaf27de..ea5d69281 160000 --- a/submodules/externals/exosip +++ b/submodules/externals/exosip @@ -1 +1 @@ -Subproject commit 80eaf27dea428effe7a176d6d2032c1b3d2eea5e +Subproject commit ea5d692816953ac506464a53238f2103cda8cfee diff --git a/submodules/linphone b/submodules/linphone index 3b722ada2..2584c08c3 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 3b722ada225c8adfcb19a0784f05288f8abfcada +Subproject commit 2584c08c313799871cdef3926f311e9a673674e4