Remove isLCReady method and don't remove the core when going into background mode.

This removes a lot of code complexity and makes some strange simulator / device bugs workable (especially the very first start of the app).
This commit is contained in:
Guillaume BIENKOWSKI 2014-10-27 17:05:03 +01:00
parent ab48064b08
commit 2c67a6c460
20 changed files with 261 additions and 422 deletions

View file

@ -170,10 +170,6 @@ static UICompositeViewDescription *compositeDescription = nil;
selector:@selector(textComposeEvent:)
name:kLinphoneTextComposeEvent
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(coreUpdateEvent:)
name:kLinphoneCoreUpdate
object:nil];
if([tableController isEditing])
[tableController setEditing:FALSE animated:FALSE];
[editButton setOff];
@ -215,9 +211,6 @@ static UICompositeViewDescription *compositeDescription = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UITextViewTextDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:kLinphoneCoreUpdate
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:kLinphoneTextComposeEvent
object:nil];
@ -312,10 +305,6 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
}
- (BOOL)sendMessage:(NSString *)message withExterlBodyUrl:(NSURL*)externalUrl withInternalURL:(NSURL*)internalUrl {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot send message: Linphone core not ready"];
return FALSE;
}
if(chatRoom == NULL) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot send message: No chatroom"];
return FALSE;
@ -427,12 +416,6 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
#pragma mark - Event Functions
- (void)coreUpdateEvent:(NSNotification*)notif {
if(![LinphoneManager isLcReady]) {
chatRoom = NULL;
}
}
- (void)textReceivedEvent:(NSNotification *)notif {
LinphoneAddress * from = [[[notif userInfo] objectForKey:@"from_address"] pointerValue];
LinphoneChatRoom* room = [[notif.userInfo objectForKey:@"room"] pointerValue];

View file

@ -144,41 +144,39 @@ static UICompositeViewDescription *compositeDescription = nil;
[callButton setEnabled:TRUE];
// Update on show
if([LinphoneManager isLcReady]) {
LinphoneManager *mgr=[LinphoneManager instance];
LinphoneCore* lc = [LinphoneManager getLc];
LinphoneCall* call = linphone_core_get_current_call(lc);
LinphoneCallState state = (call != NULL)?linphone_call_get_state(call): 0;
[self callUpdate:call state:state];
LinphoneManager *mgr=[LinphoneManager instance];
LinphoneCore* lc = [LinphoneManager getLc];
LinphoneCall* call = linphone_core_get_current_call(lc);
LinphoneCallState state = (call != NULL)?linphone_call_get_state(call): 0;
[self callUpdate:call state:state];
if([LinphoneManager runningOnIpad]) {
if(linphone_core_video_enabled(lc) && [mgr lpConfigBoolForKey:@"preview_preference"]) {
linphone_core_set_native_preview_window_id(lc, (unsigned long)videoPreview);
[backgroundView setHidden:FALSE];
[videoCameraSwitch setHidden:FALSE];
} else {
linphone_core_set_native_preview_window_id(lc, (unsigned long)NULL);
linphone_core_enable_video_preview(lc, FALSE);
[backgroundView setHidden:TRUE];
[videoCameraSwitch setHidden:TRUE];
}
if([LinphoneManager runningOnIpad]) {
if(linphone_core_video_enabled(lc) && [mgr lpConfigBoolForKey:@"preview_preference"]) {
linphone_core_set_native_preview_window_id(lc, (unsigned long)videoPreview);
[backgroundView setHidden:FALSE];
[videoCameraSwitch setHidden:FALSE];
} else {
linphone_core_set_native_preview_window_id(lc, (unsigned long)NULL);
linphone_core_enable_video_preview(lc, FALSE);
[backgroundView setHidden:TRUE];
[videoCameraSwitch setHidden:TRUE];
}
}
[addressField setText:@""];
[addressField setText:@""];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0 // attributed string only available since iOS6
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
// fix placeholder bar color in iOS7
UIColor *color = [UIColor grayColor];
NSAttributedString* placeHolderString = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"Enter an address", @"Enter an address")
attributes:@{NSForegroundColorAttributeName: color}];
addressField.attributedPlaceholder = placeHolderString;
[placeHolderString release];
}
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
// fix placeholder bar color in iOS7
UIColor *color = [UIColor grayColor];
NSAttributedString* placeHolderString = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"Enter an address", @"Enter an address")
attributes:@{NSForegroundColorAttributeName: color}];
addressField.attributedPlaceholder = placeHolderString;
[placeHolderString release];
}
#endif
}
}
- (void)viewWillDisappear:(BOOL)animated {
@ -256,7 +254,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)coreUpdateEvent:(NSNotification*)notif {
if([LinphoneManager isLcReady] && [LinphoneManager runningOnIpad]) {
if([LinphoneManager runningOnIpad]) {
LinphoneCore* lc = [LinphoneManager getLc];
if(linphone_core_video_enabled(lc) && linphone_core_video_preview_enabled(lc)) {
linphone_core_set_native_preview_window_id(lc, (unsigned long)videoPreview);
@ -273,26 +271,24 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark -
- (void)callUpdate:(LinphoneCall*)call state:(LinphoneCallState)state {
if([LinphoneManager isLcReady]) {
LinphoneCore *lc = [LinphoneManager getLc];
if(linphone_core_get_calls_nb(lc) > 0) {
if(transferMode) {
[addCallButton setHidden:true];
[transferButton setHidden:false];
} else {
[addCallButton setHidden:false];
[transferButton setHidden:true];
}
[callButton setHidden:true];
[backButton setHidden:false];
[addContactButton setHidden:true];
} else {
LinphoneCore *lc = [LinphoneManager getLc];
if(linphone_core_get_calls_nb(lc) > 0) {
if(transferMode) {
[addCallButton setHidden:true];
[callButton setHidden:false];
[backButton setHidden:true];
[addContactButton setHidden:false];
[transferButton setHidden:false];
} else {
[addCallButton setHidden:false];
[transferButton setHidden:true];
}
[callButton setHidden:true];
[backButton setHidden:false];
[addContactButton setHidden:true];
} else {
[addCallButton setHidden:true];
[callButton setHidden:false];
[backButton setHidden:true];
[addContactButton setHidden:false];
[transferButton setHidden:true];
}
}

View file

@ -183,9 +183,6 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)update {
if(![LinphoneManager isLcReady]) {
return;
}
// Look for the call log
callLog = NULL;

View file

@ -111,19 +111,17 @@
- (void)loadData {
[callLogs removeAllObjects];
if([LinphoneManager isLcReady]) {
const MSList * logs = linphone_core_get_call_logs([LinphoneManager getLc]);
while(logs != NULL) {
LinphoneCallLog* log = (LinphoneCallLog *) logs->data;
if(missedFilter) {
if (linphone_call_log_get_status(log) == LinphoneCallMissed) {
[callLogs addObject:[NSValue valueWithPointer: log]];
}
} else {
const MSList * logs = linphone_core_get_call_logs([LinphoneManager getLc]);
while(logs != NULL) {
LinphoneCallLog* log = (LinphoneCallLog *) logs->data;
if(missedFilter) {
if (linphone_call_log_get_status(log) == LinphoneCallMissed) {
[callLogs addObject:[NSValue valueWithPointer: log]];
}
logs = ms_list_next(logs);
} else {
[callLogs addObject:[NSValue valueWithPointer: log]];
}
logs = ms_list_next(logs);
}
[[self tableView] reloadData];
}

View file

@ -56,13 +56,11 @@
- (void)applicationDidEnterBackground:(UIApplication *)application{
Linphone_log(@"%@", NSStringFromSelector(_cmd));
if(![LinphoneManager isLcReady]) return;
[[LinphoneManager instance] enterBackgroundMode];
}
- (void)applicationWillResignActive:(UIApplication *)application {
Linphone_log(@"%@", NSStringFromSelector(_cmd));
if(![LinphoneManager isLcReady]) return;
LinphoneCore* lc = [LinphoneManager getLc];
LinphoneCall* call = linphone_core_get_current_call(lc);
@ -87,7 +85,6 @@
- (void)applicationDidBecomeActive:(UIApplication *)application {
Linphone_log(@"%@", NSStringFromSelector(_cmd));
[self startApplication];
if( startedInBackground ){
startedInBackground = FALSE;
[[PhoneMainView instance] startUp];
@ -211,16 +208,13 @@
[[UIApplication sharedApplication] endBackgroundTask:bgStartId];
}];
[self startApplication];
[[LinphoneManager instance] startLibLinphone];
// initialize UI
[self.window makeKeyAndVisible];
[RootViewManager setupWithPortrait:(PhoneMainView*)self.window.rootViewController];
if( state == UIApplicationStateBackground ){
startedInBackground = TRUE;
} else {
[[PhoneMainView instance] startUp];
[[PhoneMainView instance] updateStatusBar:nil];
}
[[PhoneMainView instance] startUp];
[[PhoneMainView instance] updateStatusBar:nil];
NSDictionary *remoteNotif =[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
@ -233,13 +227,6 @@
return YES;
}
- (void)startApplication {
// Restart Linphone Core if needed
if(![LinphoneManager isLcReady]) {
[[LinphoneManager instance] startLibLinphone];
}
}
- (void)applicationWillTerminate:(UIApplication *)application {
Linphone_log(@"%@", NSStringFromSelector(_cmd));
}
@ -257,14 +244,11 @@
[confirmation show];
[confirmation release];
} else {
[self startApplication];
if([LinphoneManager isLcReady]) {
if([[url scheme] isEqualToString:@"sip"]) {
// Go to Dialer view
DialerViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[DialerViewController compositeViewDescription]], DialerViewController);
if(controller != nil) {
[controller setAddress:[url absoluteString]];
}
if([[url scheme] isEqualToString:@"sip"]) {
// Go to Dialer view
DialerViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[DialerViewController compositeViewDescription]], DialerViewController);
if(controller != nil) {
[controller setAddress:[url absoluteString]];
}
}
}
@ -387,11 +371,6 @@
return;
}
// check that linphone is still running
if( ![LinphoneManager isLcReady] )
[lm startLibLinphone];
// save the completion handler for later execution.
// 2 outcomes:
// - if a new call/message is received, the completion handler will be called with "NEWDATA"
@ -522,37 +501,20 @@
{
if ((alertView.tag == 1) && (buttonIndex==1)) {
[self showWaitingIndicator];
if([LinphoneManager isLcReady]) {
[self attemptRemoteConfiguration];
} else {
[[LinphoneManager instance] startLibLinphone];
[self performSelector:@selector(attemptRemoteConfiguration) withObject:NULL afterDelay:5.0];
}
[self attemptRemoteConfiguration];
}
}
- (void)attemptRemoteConfiguration {
if ([LinphoneManager isLcReady]) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(ConfigurationStateUpdateEvent:)
name:kLinphoneConfiguringStateUpdate
object:nil];
linphone_core_set_provisioning_uri([LinphoneManager getLc] , [configURL UTF8String]);
[[LinphoneManager instance] destroyLibLinphone];
[[LinphoneManager instance] startLibLinphone];
} else {
[_waitingIndicator dismissWithClickedButtonIndex:0 animated:true];
UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Failure",nil)
message:NSLocalizedString(@"Linphone is not ready.",nil)
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK",nil)
otherButtonTitles:nil];
[error show];
[error release];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(ConfigurationStateUpdateEvent:)
name:kLinphoneConfiguringStateUpdate
object:nil];
linphone_core_set_provisioning_uri([LinphoneManager getLc] , [configURL UTF8String]);
[[LinphoneManager instance] destroyLibLinphone];
[[LinphoneManager instance] startLibLinphone];
}

View file

@ -496,7 +496,6 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
}
- (BOOL)synchronize {
if (![LinphoneManager isLcReady]) return YES;
LinphoneCore *lc=[LinphoneManager getLc];
BOOL account_changed;

View file

@ -138,7 +138,7 @@ struct codec_name_pref_table codec_pref_table[]={
{ "h264", 90000, @"h264_preference"},
{ "vp8", 90000, @"vp8_preference"},
{ "mpeg4-generic", 16000, @"aaceld_16k_preference"},
{ "mpeg4-generic", 22050, @"aaceld_22k_preference"},
{ "mpeg4-generic", 22050, @"aaceld_22k_preference"},
{ "mpeg4-generic", 32000, @"aaceld_32k_preference"},
{ "mpeg4-generic", 44100, @"aaceld_44k_preference"},
{ "mpeg4-generic", 48000, @"aaceld_48k_preference"},
@ -1409,45 +1409,39 @@ static int comp_call_id(const LinphoneCall* call , const char *callid) {
}
- (void)cancelLocalNotifTimerForCallId:(NSString*)callid {
//first, make sure this callid is not already involved in a call
if ([LinphoneManager isLcReady]) {
MSList* calls = (MSList*)linphone_core_get_calls(theLinphoneCore);
MSList* call = ms_list_find_custom(calls, (MSCompareFunc)comp_call_id, [callid UTF8String]);
if (call != NULL) {
LinphoneCallAppData* data = linphone_call_get_user_pointer((LinphoneCall*)call->data);
if ( data->timer )
[data->timer invalidate];
data->timer = nil;
return;
}
}
//first, make sure this callid is not already involved in a call
MSList* calls = (MSList*)linphone_core_get_calls(theLinphoneCore);
MSList* call = ms_list_find_custom(calls, (MSCompareFunc)comp_call_id, [callid UTF8String]);
if (call != NULL) {
LinphoneCallAppData* data = linphone_call_get_user_pointer((LinphoneCall*)call->data);
if ( data->timer )
[data->timer invalidate];
data->timer = nil;
return;
}
}
- (void)acceptCallForCallId:(NSString*)callid {
//first, make sure this callid is not already involved in a call
if ([LinphoneManager isLcReady]) {
MSList* calls = (MSList*)linphone_core_get_calls(theLinphoneCore);
MSList* call = ms_list_find_custom(calls, (MSCompareFunc)comp_call_id, [callid UTF8String]);
if (call != NULL) {
[self acceptCall:(LinphoneCall*)call->data];
return;
};
}
//first, make sure this callid is not already involved in a call
MSList* calls = (MSList*)linphone_core_get_calls(theLinphoneCore);
MSList* call = ms_list_find_custom(calls, (MSCompareFunc)comp_call_id, [callid UTF8String]);
if (call != NULL) {
[self acceptCall:(LinphoneCall*)call->data];
return;
};
}
- (void)enableAutoAnswerForCallId:(NSString*) callid {
//first, make sure this callid is not already involved in a call
if ([LinphoneManager isLcReady]) {
MSList* calls = (MSList*)linphone_core_get_calls(theLinphoneCore);
if (ms_list_find_custom(calls, (MSCompareFunc)comp_call_id, [callid UTF8String])) {
[LinphoneLogger log:LinphoneLoggerWarning format:@"Call id [%@] already handled",callid];
return;
};
}
if ([pendindCallIdFromRemoteNotif count] > 10 /*max number of pending notif*/)
[pendindCallIdFromRemoteNotif removeObjectAtIndex:0];
[pendindCallIdFromRemoteNotif addObject:callid];
//first, make sure this callid is not already involved in a call
MSList* calls = (MSList*)linphone_core_get_calls(theLinphoneCore);
if (ms_list_find_custom(calls, (MSCompareFunc)comp_call_id, [callid UTF8String])) {
[LinphoneLogger log:LinphoneLoggerWarning format:@"Call id [%@] already handled",callid];
return;
};
if ([pendindCallIdFromRemoteNotif count] > 10 /*max number of pending notif*/)
[pendindCallIdFromRemoteNotif removeObjectAtIndex:0];
[pendindCallIdFromRemoteNotif addObject:callid];
}
- (BOOL)shouldAutoAcceptCallForCallId:(NSString*) callId {
@ -1549,7 +1543,6 @@ static int comp_call_state_paused (const LinphoneCall* call, const void* param)
linphone_core_set_network_reachable(theLinphoneCore, FALSE);
return YES;
}
[self destroyLibLinphone];
return NO;
} else
@ -1817,18 +1810,16 @@ static void audioRouteChangeListenerCallback (
pushNotificationToken = nil;
}
if(apushNotificationToken != nil) {
pushNotificationToken = [apushNotificationToken retain];
}
if([LinphoneManager isLcReady]) {
LinphoneProxyConfig *cfg=nil;
linphone_core_get_default_proxy(theLinphoneCore, &cfg);
if (cfg) {
linphone_proxy_config_edit(cfg);
[self addPushTokenToProxyConfig: cfg];
linphone_proxy_config_done(cfg);
}
}
if(apushNotificationToken != nil) {
pushNotificationToken = [apushNotificationToken retain];
}
LinphoneProxyConfig *cfg=nil;
linphone_core_get_default_proxy(theLinphoneCore, &cfg);
if (cfg) {
linphone_proxy_config_edit(cfg);
[self addPushTokenToProxyConfig: cfg];
linphone_proxy_config_done(cfg);
}
}
- (void)addPushTokenToProxyConfig:(LinphoneProxyConfig*)proxyCfg{
@ -1875,22 +1866,21 @@ static void audioRouteChangeListenerCallback (
if (! [[NSFileManager defaultManager] fileExistsAtPath:cachePath isDirectory:&isDir] && isDir == NO) {
[[NSFileManager defaultManager] createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:&error];
}
return cachePath;
return cachePath;
}
+ (int)unreadMessageCount {
int count = 0;
if( [LinphoneManager isLcReady] ){
MSList* rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]);
MSList* item = rooms;
while (item) {
LinphoneChatRoom* room = (LinphoneChatRoom*)item->data;
if( room ){
count += linphone_chat_room_get_unread_messages_count(room);
}
item = item->next;
MSList* rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]);
MSList* item = rooms;
while (item) {
LinphoneChatRoom* room = (LinphoneChatRoom*)item->data;
if( room ){
count += linphone_chat_room_get_unread_messages_count(room);
}
item = item->next;
}
return count;
}

View file

@ -289,10 +289,6 @@
#pragma mark -
- (void)callUpdate:(LinphoneCall*)call state:(LinphoneCallState)state {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot update call bar: Linphone core not ready"];
return;
}
LinphoneCore* lc = [LinphoneManager getLc];
[speakerButton update];

View file

@ -66,10 +66,6 @@
#pragma mark -
-(void) touchUp:(id) sender {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot tigger camswitch button: Linphone core not ready"];
return;
}
const char *currentCamId = (char*)linphone_core_get_video_device([LinphoneManager getLc]);
const char **cameras=linphone_core_get_video_devices([LinphoneManager getLc]);
const char *newCamId=NULL;

View file

@ -271,12 +271,10 @@
#pragma mark - Event Functions
- (void)orientationDidChange:(NSNotification*)notif {
if([LinphoneManager isLcReady]) {
// Update rotation
UIInterfaceOrientation correctOrientation = [self getCorrectInterfaceOrientation:[[UIDevice currentDevice] orientation]];
if(currentOrientation != correctOrientation) {
[UICompositeViewController setOrientation:correctOrientation animated:currentOrientation != UIDeviceOrientationUnknown];
}
// Update rotation
UIInterfaceOrientation correctOrientation = [self getCorrectInterfaceOrientation:[[UIDevice currentDevice] orientation]];
if(currentOrientation != correctOrientation) {
[UICompositeViewController setOrientation:correctOrientation animated:currentOrientation != UIDeviceOrientationUnknown];
}
}

View file

@ -69,11 +69,7 @@
#pragma mark - Actions Functions
- (void)touchDown:(id) sender {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot trigger digit button: Linphone core not ready"];
return;
}
if (addressField && (!dtmf || !linphone_core_in_call([LinphoneManager getLc]))) {
if (addressField && (!dtmf || !linphone_core_in_call([LinphoneManager getLc]))) {
NSString* newAddress = [NSString stringWithFormat:@"%@%c",addressField.text, digit];
[addressField setText:newAddress];
linphone_core_play_dtmf([LinphoneManager getLc], digit, -1);
@ -84,10 +80,6 @@
}
- (void)touchUp:(id) sender {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot trigger digit button: Linphone core not ready"];
return;
}
linphone_core_stop_dtmf([LinphoneManager getLc]);
}

View file

@ -36,11 +36,6 @@
}
- (BOOL) voiceMailEnabled {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger log:LinphoneLoggerWarning format:@"Cannot call voice mail: Linphone core not ready"];
return FALSE;
}
NSString * voiceMailUri = [[LinphoneManager instance] lpConfigStringForKey:@"voice_mail_uri" withDefault:NULL];
return (voiceMailUri != NULL);

View file

@ -84,18 +84,14 @@
#pragma mark -
- (void)update {
if([LinphoneManager isLcReady]) {
LinphoneCore * lc = [LinphoneManager getLc];
if(linphone_core_get_calls_nb(lc) == 1 || // One call
linphone_core_get_current_call(lc) != NULL || // In call
linphone_core_is_in_conference(lc) || // In conference
(linphone_core_get_conference_size(lc) > 0 && [UIHangUpButton callCount:lc] == 0) // Only one conf
) {
[self setEnabled:true];
return;
}
} else {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot update hangup button: Linphone core not ready"];
LinphoneCore * lc = [LinphoneManager getLc];
if(linphone_core_get_calls_nb(lc) == 1 || // One call
linphone_core_get_current_call(lc) != NULL || // In call
linphone_core_is_in_conference(lc) || // In conference
(linphone_core_get_conference_size(lc) > 0 && [UIHangUpButton callCount:lc] == 0) // Only one conf
) {
[self setEnabled:true];
return;
}
[self setEnabled:false];
}
@ -104,23 +100,19 @@
#pragma mark - Action Functions
-(void) touchUp:(id) sender {
if([LinphoneManager isLcReady]) {
LinphoneCore* lc = [LinphoneManager getLc];
LinphoneCall* currentcall = linphone_core_get_current_call(lc);
if (linphone_core_is_in_conference(lc) || // In conference
(linphone_core_get_conference_size(lc) > 0 && [UIHangUpButton callCount:lc] == 0) // Only one conf
) {
linphone_core_terminate_conference(lc);
} else if(currentcall != NULL) { // In a call
linphone_core_terminate_call(lc, currentcall);
} else {
const MSList* calls = linphone_core_get_calls(lc);
if (ms_list_size(calls) == 1) { // Only one call
linphone_core_terminate_call(lc,(LinphoneCall*)(calls->data));
}
}
LinphoneCore* lc = [LinphoneManager getLc];
LinphoneCall* currentcall = linphone_core_get_current_call(lc);
if (linphone_core_is_in_conference(lc) || // In conference
(linphone_core_get_conference_size(lc) > 0 && [UIHangUpButton callCount:lc] == 0) // Only one conf
) {
linphone_core_terminate_conference(lc);
} else if(currentcall != NULL) { // In a call
linphone_core_terminate_call(lc, currentcall);
} else {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot trigger hangup button: Linphone core not ready"];
const MSList* calls = linphone_core_get_calls(lc);
if (ms_list_size(calls) == 1) { // Only one call
linphone_core_terminate_call(lc,(LinphoneCall*)(calls->data));
}
}
}

View file

@ -250,11 +250,7 @@ static NSString * const kDisappearAnimation = @"disappear";
- (void)update:(BOOL)appear{
[self updateView:[[PhoneMainView instance] firstView]];
if([LinphoneManager isLcReady]) {
[self updateMissedCall:linphone_core_get_missed_calls_count([LinphoneManager getLc]) appear:appear];
} else {
[self updateMissedCall:0 appear:TRUE];
}
[self updateMissedCall:linphone_core_get_missed_calls_count([LinphoneManager getLc]) appear:appear];
[self updateUnreadMessage:appear];
}

View file

@ -24,28 +24,15 @@
@implementation UIMicroButton
- (void)onOn {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot toggle mic button: Linphone core not ready"];
return;
}
linphone_core_mute_mic([LinphoneManager getLc], false);
}
- (void)onOff {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot toggle mic button: Linphone core not ready"];
return;
}
linphone_core_mute_mic([LinphoneManager getLc], true);
}
- (bool)onUpdate {
if([LinphoneManager isLcReady]) {
return linphone_core_is_mic_muted([LinphoneManager getLc]) == false;
} else {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot update mic button: Linphone core not ready"];
return true;
}
return linphone_core_is_mic_muted([LinphoneManager getLc]) == false;
}
- (void)dealloc {

View file

@ -99,10 +99,6 @@
#pragma mark - UIToggleButtonDelegate Functions
- (void)onOn {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot toggle pause button: Linphone core not ready"];
return;
}
switch (type) {
case UIPauseButtonType_Call:
{
@ -135,10 +131,6 @@
}
- (void)onOff {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot toggle pause button: Linphone core not ready"];
return;
}
switch (type) {
case UIPauseButtonType_Call:
{
@ -172,52 +164,49 @@
- (bool)onUpdate {
bool ret = false;
// TODO: disable pause on not running call
if([LinphoneManager isLcReady]) {
LinphoneCore *lc = [LinphoneManager getLc];
switch (type) {
case UIPauseButtonType_Call:
{
if (call != nil) {
LinphoneCallState state = linphone_call_get_state(call);
if(state == LinphoneCallPaused || state == LinphoneCallPausing) {
ret = true;
}
[self setEnabled:TRUE];
} else {
[self setEnabled:FALSE];
LinphoneCore *lc = [LinphoneManager getLc];
switch (type) {
case UIPauseButtonType_Call:
{
if (call != nil) {
LinphoneCallState state = linphone_call_get_state(call);
if(state == LinphoneCallPaused || state == LinphoneCallPausing) {
ret = true;
}
break;
}
case UIPauseButtonType_Conference:
{
if(linphone_core_get_conference_size(lc) > 0) {
if (!linphone_core_is_in_conference(lc)) {
ret = true;
}
[self setEnabled:TRUE];
} else {
[self setEnabled:FALSE];
}
break;
}
case UIPauseButtonType_CurrentCall:
{
LinphoneCall* currentCall = [UIPauseButton getCall];
if (currentCall != nil) {
LinphoneCallState state = linphone_call_get_state(currentCall);
if(state == LinphoneCallPaused || state == LinphoneCallPausing) {
ret = true;
}
[self setEnabled:TRUE];
} else {
[self setEnabled:FALSE];
}
break;
[self setEnabled:TRUE];
} else {
[self setEnabled:FALSE];
}
break;
}
case UIPauseButtonType_Conference:
{
if(linphone_core_get_conference_size(lc) > 0) {
if (!linphone_core_is_in_conference(lc)) {
ret = true;
}
[self setEnabled:TRUE];
} else {
[self setEnabled:FALSE];
}
break;
}
case UIPauseButtonType_CurrentCall:
{
LinphoneCall* currentCall = [UIPauseButton getCall];
if (currentCall != nil) {
LinphoneCallState state = linphone_call_get_state(currentCall);
if(state == LinphoneCallPaused || state == LinphoneCallPausing) {
ret = true;
}
[self setEnabled:TRUE];
} else {
[self setEnabled:FALSE];
}
break;
}
} else {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot update pause button: Linphone core not ready"];
}
return ret;
}

View file

@ -106,13 +106,12 @@ int messagesUnreadCount;
[callQualityImage setHidden: true];
[callSecurityImage setHidden: true];
// Update to default state
LinphoneProxyConfig* config = NULL;
if([LinphoneManager isLcReady]) {
linphone_core_get_default_proxy([LinphoneManager getLc], &config);
messagesUnreadCount = lp_config_get_int(linphone_core_get_config([LinphoneManager getLc]), "app", "voice_mail_messages_count", 0);
}
[self proxyConfigUpdate: config];
// Update to default state
LinphoneProxyConfig* config = NULL;
linphone_core_get_default_proxy([LinphoneManager getLc], &config);
messagesUnreadCount = lp_config_get_int(linphone_core_get_config([LinphoneManager getLc]), "app", "voice_mail_messages_count", 0);
[self proxyConfigUpdate: config];
[self updateVoicemail];
}
@ -154,7 +153,7 @@ int messagesUnreadCount;
}
- (void) globalStateUpdate:(NSNotification*) notif {
if ([LinphoneManager isLcReady]) [self registrationUpdate:notif];
[self registrationUpdate:notif];
}
- (void) notifyReceived:(NSNotification*) notif {
@ -196,7 +195,7 @@ int messagesUnreadCount;
// LinphoneCall *call = [[notif.userInfo objectForKey: @"call"] pointerValue];
// LinphoneCallState state = [[notif.userInfo objectForKey: @"state"] intValue];
bool isOnCall = [LinphoneManager isLcReady] && (linphone_core_get_calls_nb([LinphoneManager getLc]) > 0);
bool isOnCall = (linphone_core_get_calls_nb([LinphoneManager getLc]) > 0);
//show voicemail only when there is no call
[self updateVoicemail];
@ -216,7 +215,7 @@ int messagesUnreadCount;
message = NSLocalizedString(@"Fetching remote configuration", nil);
} else if (config == NULL) {
state = LinphoneRegistrationNone;
if(![LinphoneManager isLcReady] || linphone_core_is_network_reachable([LinphoneManager getLc]))
if(linphone_core_is_network_reachable([LinphoneManager getLc]))
message = NSLocalizedString(@"No SIP account configured", nil);
else
message = NSLocalizedString(@"Network down", nil);
@ -268,10 +267,6 @@ int messagesUnreadCount;
BOOL pending = false;
BOOL security = true;
if(![LinphoneManager isLcReady]) {
[callSecurityImage setHidden:true];
return;
}
const MSList *list = linphone_core_get_calls([LinphoneManager getLc]);
if(list == NULL) {
@ -308,22 +303,20 @@ int messagesUnreadCount;
- (void)callQualityUpdate {
UIImage *image = nil;
if([LinphoneManager isLcReady]) {
LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]);
if(call != NULL) {
//FIXME double check call state before computing, may cause core dump
float quality = linphone_call_get_average_quality(call);
if(quality < 1) {
image = [UIImage imageNamed:@"call_quality_indicator_0.png"];
} else if (quality < 2) {
image = [UIImage imageNamed:@"call_quality_indicator_1.png"];
} else if (quality < 3) {
image = [UIImage imageNamed:@"call_quality_indicator_2.png"];
} else {
image = [UIImage imageNamed:@"call_quality_indicator_3.png"];
}
}
}
LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]);
if(call != NULL) {
//FIXME double check call state before computing, may cause core dump
float quality = linphone_call_get_average_quality(call);
if(quality < 1) {
image = [UIImage imageNamed:@"call_quality_indicator_0.png"];
} else if (quality < 2) {
image = [UIImage imageNamed:@"call_quality_indicator_1.png"];
} else if (quality < 3) {
image = [UIImage imageNamed:@"call_quality_indicator_2.png"];
} else {
image = [UIImage imageNamed:@"call_quality_indicator_3.png"];
}
}
if(image != nil) {
[callQualityImage setHidden:false];
[callQualityImage setImage:image];
@ -336,7 +329,7 @@ int messagesUnreadCount;
#pragma mark - Action Functions
- (IBAction)doSecurityClick:(id)sender {
if([LinphoneManager isLcReady] && linphone_core_get_calls_nb([LinphoneManager getLc])) {
if(linphone_core_get_calls_nb([LinphoneManager getLc])) {
LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]);
if(call != NULL) {
LinphoneMediaEncryption enc = linphone_call_params_get_media_encryption(linphone_call_get_current_params(call));

View file

@ -52,11 +52,6 @@
}
- (void)onOn {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot toggle video button: Linphone core not ready"];
return;
}
LinphoneCore* lc = [LinphoneManager getLc];
if (!linphone_core_video_enabled(lc))
@ -79,11 +74,6 @@
}
- (void)onOff {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot toggle video button: Linphone core not ready"];
return;
}
LinphoneCore* lc = [LinphoneManager getLc];
if (!linphone_core_video_enabled(lc))
@ -104,56 +94,51 @@
}
- (bool)onUpdate {
if([LinphoneManager isLcReady]) {
bool val = false;
bool val = false;
#ifdef VIDEO_ENABLED
if(linphone_core_video_enabled([LinphoneManager getLc])) {
LinphoneCall* currentCall = linphone_core_get_current_call([LinphoneManager getLc]);
if (currentCall) {
LinphoneCallState state = linphone_call_get_state(currentCall);
switch (state) {
case LinphoneCallUpdating:
{
[self setEnabled:FALSE];
break;
}
case LinphoneCallStreamsRunning:
{
[waitView stopAnimating];
[self setEnabled:TRUE];
if (linphone_call_params_video_enabled(linphone_call_get_current_params(currentCall))) {
val = true;
}
break;
}
default:
{
// Disable button if the call is not running
[self setEnabled:FALSE];
[waitView stopAnimating];
break;
}
if(linphone_core_video_enabled([LinphoneManager getLc])) {
LinphoneCall* currentCall = linphone_core_get_current_call([LinphoneManager getLc]);
if (currentCall) {
LinphoneCallState state = linphone_call_get_state(currentCall);
switch (state) {
case LinphoneCallUpdating:
{
[self setEnabled:FALSE];
break;
}
} else {
// Disable button if there is no call
[self setEnabled:FALSE];
[waitView stopAnimating];
case LinphoneCallStreamsRunning:
{
[waitView stopAnimating];
[self setEnabled:TRUE];
if (linphone_call_params_video_enabled(linphone_call_get_current_params(currentCall))) {
val = true;
}
break;
}
default:
{
// Disable button if the call is not running
[self setEnabled:FALSE];
[waitView stopAnimating];
break;
}
}
} else {
// Disable button if video is not enabled
// Disable button if there is no call
[self setEnabled:FALSE];
[waitView stopAnimating];
}
#else //VIDEO_ENABLED
[self setEnabled:FALSE];
#endif //VIDEO_ENABLED
return val;
} else {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot update video button: Linphone core not ready"];
return false;
}
// Disable button if video is not enabled
[self setEnabled:FALSE];
[waitView stopAnimating];
}
#else //VIDEO_ENABLED
[self setEnabled:FALSE];
#endif //VIDEO_ENABLED
return val;
}
- (void)dealloc {

View file

@ -710,7 +710,6 @@ static RootViewManager* rootViewManagerInstance = nil;
UIDeviceBatteryState state = [UIDevice currentDevice].batteryState;
[LinphoneLogger log:LinphoneLoggerLog format:@"Battery state:%d level:%.2f", state, level];
if (![LinphoneManager isLcReady]) return;
LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]);
if (call && linphone_call_params_video_enabled(linphone_call_get_current_params(call))) {
LinphoneCallAppData* callData = (LinphoneCallAppData*) linphone_call_get_user_pointer(call);

View file

@ -592,30 +592,29 @@ static UICompositeViewDescription *compositeDescription = nil;
return [[[IASKSpecifier alloc] initWithSpecifier:dict] autorelease];
}
#else
if([LinphoneManager isLcReady]) {
if ([[specifier key] isEqualToString:@"media_encryption_preference"]) {
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[specifier specifierDict]];
if(!linphone_core_media_encryption_supported([LinphoneManager getLc], LinphoneMediaEncryptionZRTP)) {
NSMutableArray *titles = [NSMutableArray arrayWithArray:[dict objectForKey:@"Titles"]];
[titles removeObject:@"ZRTP"];
[dict setObject:titles forKey:@"Titles"];
NSMutableArray *values = [NSMutableArray arrayWithArray:[dict objectForKey:@"Values"]];
[values removeObject:@"ZRTP"];
[dict setObject:values forKey:@"Values"];
}
if(!linphone_core_media_encryption_supported([LinphoneManager getLc], LinphoneMediaEncryptionSRTP)) {
NSMutableArray *titles = [NSMutableArray arrayWithArray:[dict objectForKey:@"Titles"]];
[titles removeObject:@"SRTP"];
[dict setObject:titles forKey:@"Titles"];
NSMutableArray *values = [NSMutableArray arrayWithArray:[dict objectForKey:@"Values"]];
[values removeObject:@"SRTP"];
[dict setObject:values forKey:@"Values"];
}
return [[[IASKSpecifier alloc] initWithSpecifier:dict] autorelease];
if ([[specifier key] isEqualToString:@"media_encryption_preference"]) {
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[specifier specifierDict]];
if(!linphone_core_media_encryption_supported([LinphoneManager getLc], LinphoneMediaEncryptionZRTP)) {
NSMutableArray *titles = [NSMutableArray arrayWithArray:[dict objectForKey:@"Titles"]];
[titles removeObject:@"ZRTP"];
[dict setObject:titles forKey:@"Titles"];
NSMutableArray *values = [NSMutableArray arrayWithArray:[dict objectForKey:@"Values"]];
[values removeObject:@"ZRTP"];
[dict setObject:values forKey:@"Values"];
}
if(!linphone_core_media_encryption_supported([LinphoneManager getLc], LinphoneMediaEncryptionSRTP)) {
NSMutableArray *titles = [NSMutableArray arrayWithArray:[dict objectForKey:@"Titles"]];
[titles removeObject:@"SRTP"];
[dict setObject:titles forKey:@"Titles"];
NSMutableArray *values = [NSMutableArray arrayWithArray:[dict objectForKey:@"Values"]];
[values removeObject:@"SRTP"];
[dict setObject:values forKey:@"Values"];
}
return [[[IASKSpecifier alloc] initWithSpecifier:dict] autorelease];
}
#endif //HAVE_SSL
// Add "build from source" if MPEG4 or H264 disabled
if ([[specifier key] isEqualToString:@"h264_preference"] && ![LinphoneManager isCodecSupported:"h264"]) {
@ -629,9 +628,6 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (NSSet*)findHiddenKeys {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger log:LinphoneLoggerWarning format:@"Can't filter settings: Linphone core not ready"];
}
LinphoneManager* lm = [LinphoneManager instance];
NSMutableSet *hiddenKeys = [NSMutableSet set];