From 3d5f8b04474ed6b50c819ca3c8a21b94934ea121 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 10 Jan 2018 13:48:52 +0100 Subject: [PATCH 01/11] enhance proximity sensor support --- Classes/LinphoneManager.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index dfcacb693..22d3a9bb8 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -989,8 +989,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char if (state == LinphoneCallConnected && !mCallCenter) { /*only register CT call center CB for connected call*/ [self setupGSMInteraction]; - if (!_bluetoothEnabled) - [self setSpeakerEnabled:FALSE]; + [[UIDevice currentDevice] setProximityMonitoringEnabled:!(_speakerEnabled || _bluetoothEnabled)]; } // Post event From dd22e69cebfc9a89f318da2ec8dcb4e18ecdf4b2 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 10 Jan 2018 14:32:17 +0100 Subject: [PATCH 02/11] Do not crash on null call id when trying to recreate a callkit call --- Classes/LinphoneManager.m | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 22d3a9bb8..51adf746a 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -895,30 +895,23 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char : @""; NSUUID *uuid = (NSUUID *)[self.providerDelegate.uuids objectForKey:callId2]; if (uuid) { - if (linphone_core_get_calls_nb(LC) > 0 && !_conf) { + LinphoneCall *callKit_call = (LinphoneCall *)linphone_core_get_calls(LC)->data; + const char *callKit_callId = callKit_call + ? linphone_call_log_get_call_id(linphone_call_get_call_log(callKit_call)) + : NULL; + if (callKit_callId && !_conf) { // Create a CallKit call because there's not ! - _conf = FALSE; - LinphoneCall *callKit_call = (LinphoneCall *)linphone_core_get_calls(LC)->data; - NSString *callKit_callId = [NSString stringWithUTF8String: - linphone_call_log_get_call_id(linphone_call_get_call_log(callKit_call))]; + NSString *callKit_callIdNS = [NSString stringWithUTF8String:linphone_call_log_get_call_id(linphone_call_get_call_log(callKit_call))]; NSUUID *callKit_uuid = [NSUUID UUID]; - [LinphoneManager.instance.providerDelegate.uuids setObject:callKit_uuid - forKey:callKit_callId]; - [LinphoneManager.instance.providerDelegate.calls setObject:callKit_callId - forKey:callKit_uuid]; - NSString *address = [FastAddressBook displayNameForAddress: - linphone_call_get_remote_address(callKit_call)]; - CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric - value:address]; - CXStartCallAction *act = [[CXStartCallAction alloc] initWithCallUUID:callKit_uuid - handle:handle]; + [LinphoneManager.instance.providerDelegate.uuids setObject:callKit_uuid forKey:callKit_callIdNS]; + [LinphoneManager.instance.providerDelegate.calls setObject:callKit_callIdNS forKey:callKit_uuid]; + NSString *address = [FastAddressBook displayNameForAddress:linphone_call_get_remote_address(callKit_call)]; + CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:address]; + CXStartCallAction *act = [[CXStartCallAction alloc] initWithCallUUID:callKit_uuid handle:handle]; CXTransaction *tr = [[CXTransaction alloc] initWithAction:act]; - [LinphoneManager.instance.providerDelegate.controller requestTransaction:tr - completion:^(NSError *err){}]; - [LinphoneManager.instance.providerDelegate.provider reportOutgoingCallWithUUID:callKit_uuid - startedConnectingAtDate:nil]; - [LinphoneManager.instance.providerDelegate.provider reportOutgoingCallWithUUID:callKit_uuid - connectedAtDate:nil]; + [LinphoneManager.instance.providerDelegate.controller requestTransaction:tr completion:^(NSError *err){}]; + [LinphoneManager.instance.providerDelegate.provider reportOutgoingCallWithUUID:callKit_uuid startedConnectingAtDate:nil]; + [LinphoneManager.instance.providerDelegate.provider reportOutgoingCallWithUUID:callKit_uuid connectedAtDate:nil]; } CXEndCallAction *act = [[CXEndCallAction alloc] initWithCallUUID:uuid]; From 776450cd1571d507a2f676939bd034d3ca573aa6 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 10 Jan 2018 14:33:19 +0100 Subject: [PATCH 03/11] use variable instead of recalling a method --- Classes/LinphoneManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 51adf746a..e8c1f3e84 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -901,7 +901,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char : NULL; if (callKit_callId && !_conf) { // Create a CallKit call because there's not ! - NSString *callKit_callIdNS = [NSString stringWithUTF8String:linphone_call_log_get_call_id(linphone_call_get_call_log(callKit_call))]; + NSString *callKit_callIdNS = [NSString stringWithUTF8String:callKit_callId]; NSUUID *callKit_uuid = [NSUUID UUID]; [LinphoneManager.instance.providerDelegate.uuids setObject:callKit_uuid forKey:callKit_callIdNS]; [LinphoneManager.instance.providerDelegate.calls setObject:callKit_callIdNS forKey:callKit_uuid]; From ca1af98af0dd139f69c647c6e665ee2cbecd8761 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 10 Jan 2018 15:22:11 +0100 Subject: [PATCH 04/11] do not crash when syncing settings & core destroyed --- Classes/DialerView.m | 3 +- Classes/LinphoneCoreSettingsStore.m | 424 +++++++++++++--------------- 2 files changed, 197 insertions(+), 230 deletions(-) diff --git a/Classes/DialerView.m b/Classes/DialerView.m index a22ea7415..27e6d40ff 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -204,8 +204,7 @@ static UICompositeViewDescription *compositeDescription = nil; [_videoCameraSwitch setHidden:TRUE]; } } - } - @catch (NSException *exception) { + } @catch (NSException *exception) { if ([exception.name isEqualToString:@"LinphoneCoreException"]) { LOGE(@"Core already destroyed"); return; diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index baa3c7f3c..9b3b5d1fa 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -651,11 +651,10 @@ } - (BOOL)synchronize { - //@try { + @try { + LinphoneManager *lm = LinphoneManager.instance; - LinphoneManager *lm = LinphoneManager.instance; - // root section - { + // root section BOOL account_changed = NO; for (NSString *key in self->changedDict) { if ([key hasPrefix:@"account_"] && [self valueChangedForKey:key]) { @@ -676,10 +675,8 @@ bool enableAutoAnswer = [self boolForKey:@"enable_auto_answer_preference"]; [LinphoneManager.instance lpConfigSetBool:enableAutoAnswer forKey:@"auto_answer"]; - } - // audio section - { + // audio section [self synchronizeCodecs:linphone_core_get_audio_codecs(LC)]; float playback_gain = [self floatForKey:@"playback_gain_preference"]; @@ -701,256 +698,222 @@ [LinphoneManager.instance configureVbrCodecs]; NSString *au_device = @"AU: Audio Unit Receiver"; - if (!voice_processing) { + if (!voice_processing) au_device = @"AU: Audio Unit NoVoiceProc"; - } + linphone_core_set_capture_device(LC, [au_device UTF8String]); linphone_core_set_playback_device(LC, [au_device UTF8String]); - } // video section - { - [self synchronizeCodecs:linphone_core_get_video_codecs(LC)]; + [self synchronizeCodecs:linphone_core_get_video_codecs(LC)]; - LinphoneVideoPolicy policy; - policy.automatically_initiate = [self boolForKey:@"start_video_preference"]; - policy.automatically_accept = [self boolForKey:@"accept_video_preference"]; - linphone_core_set_video_policy(LC, &policy); - linphone_core_enable_self_view(LC, [self boolForKey:@"self_video_preference"]); - BOOL preview_preference = IPAD && [self boolForKey:@"preview_preference"]; - [lm lpConfigSetInt:preview_preference forKey:@"preview_preference"]; + LinphoneVideoPolicy policy; + policy.automatically_initiate = [self boolForKey:@"start_video_preference"]; + policy.automatically_accept = [self boolForKey:@"accept_video_preference"]; + linphone_core_set_video_policy(LC, &policy); + linphone_core_enable_self_view(LC, [self boolForKey:@"self_video_preference"]); + BOOL preview_preference = IPAD && [self boolForKey:@"preview_preference"]; + [lm lpConfigSetInt:preview_preference forKey:@"preview_preference"]; - NSString *videoPreset = [self stringForKey:@"video_preset_preference"]; - linphone_core_set_video_preset(LC, [videoPreset UTF8String]); - MSVideoSize vsize; - switch ([self integerForKey:@"video_preferred_size_preference"]) { - case 0: - MS_VIDEO_SIZE_ASSIGN(vsize, 720P); - break; - case 1: - MS_VIDEO_SIZE_ASSIGN(vsize, VGA); - break; - case 2: - default: - MS_VIDEO_SIZE_ASSIGN(vsize, QVGA); - break; - } - linphone_core_set_preferred_video_size(LC, vsize); - if (![videoPreset isEqualToString:@"custom"]) { - [self setInteger:0 forKey:@"video_preferred_fps_preference"]; - [self setInteger:0 forKey:@"download_bandwidth_preference"]; - } - linphone_core_set_preferred_framerate(LC, [self integerForKey:@"video_preferred_fps_preference"]); - linphone_core_set_download_bandwidth(LC, [self integerForKey:@"download_bandwidth_preference"]); - linphone_core_set_upload_bandwidth(LC, [self integerForKey:@"download_bandwidth_preference"]); + NSString *videoPreset = [self stringForKey:@"video_preset_preference"]; + linphone_core_set_video_preset(LC, [videoPreset UTF8String]); + MSVideoSize vsize; + switch ([self integerForKey:@"video_preferred_size_preference"]) { + case 0: + MS_VIDEO_SIZE_ASSIGN(vsize, 720P); + break; + case 1: + MS_VIDEO_SIZE_ASSIGN(vsize, VGA); + break; + case 2: + default: + MS_VIDEO_SIZE_ASSIGN(vsize, QVGA); + break; } + linphone_core_set_preferred_video_size(LC, vsize); + if (![videoPreset isEqualToString:@"custom"]) { + [self setInteger:0 forKey:@"video_preferred_fps_preference"]; + [self setInteger:0 forKey:@"download_bandwidth_preference"]; + } + linphone_core_set_preferred_framerate(LC, [self integerForKey:@"video_preferred_fps_preference"]); + linphone_core_set_download_bandwidth(LC, [self integerForKey:@"download_bandwidth_preference"]); + linphone_core_set_upload_bandwidth(LC, [self integerForKey:@"download_bandwidth_preference"]); // call section - { - linphone_core_set_use_rfc2833_for_dtmf(LC, [self boolForKey:@"rfc_dtmf_preference"]); - linphone_core_set_use_info_for_dtmf(LC, [self boolForKey:@"sipinfo_dtmf_preference"]); - linphone_core_set_inc_timeout(LC, [self integerForKey:@"incoming_call_timeout_preference"]); - linphone_core_set_in_call_timeout(LC, [self integerForKey:@"in_call_timeout_preference"]); - [lm lpConfigSetString:[self stringForKey:@"voice_mail_uri_preference"] forKey:@"voice_mail_uri"]; - [lm lpConfigSetBool:[self boolForKey:@"repeat_call_notification_preference"] - forKey:@"repeat_call_notification"]; - } + linphone_core_set_use_rfc2833_for_dtmf(LC, [self boolForKey:@"rfc_dtmf_preference"]); + linphone_core_set_use_info_for_dtmf(LC, [self boolForKey:@"sipinfo_dtmf_preference"]); + linphone_core_set_inc_timeout(LC, [self integerForKey:@"incoming_call_timeout_preference"]); + linphone_core_set_in_call_timeout(LC, [self integerForKey:@"in_call_timeout_preference"]); + [lm lpConfigSetString:[self stringForKey:@"voice_mail_uri_preference"] forKey:@"voice_mail_uri"]; + [lm lpConfigSetBool:[self boolForKey:@"repeat_call_notification_preference"] forKey:@"repeat_call_notification"]; // chat section - { - int val = [self integerForKey:@"use_lime_preference"]; - linphone_core_enable_lime(LC, val); - if (val == LinphoneLimeMandatory && - (linphone_core_get_media_encryption(LC) != LinphoneMediaEncryptionZRTP)) { - linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionZRTP); - [self setCString:"ZRTP" forKey:@"media_encryption_preference"]; - UIAlertController *errView = [UIAlertController - alertControllerWithTitle:NSLocalizedString(@"ZRTP activation", nil) - message: - NSLocalizedString( - @"LIME requires ZRTP encryption.\n" - @"By activating LIME you automatically activate ZRTP media encryption.", - nil) - preferredStyle:UIAlertControllerStyleAlert]; + int val = [self integerForKey:@"use_lime_preference"]; + linphone_core_enable_lime(LC, val); + if (val == LinphoneLimeMandatory && (linphone_core_get_media_encryption(LC) != LinphoneMediaEncryptionZRTP)) { + linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionZRTP); + [self setCString:"ZRTP" forKey:@"media_encryption_preference"]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"ZRTP activation", nil) + message:NSLocalizedString(@"LIME requires ZRTP encryption.\n" + @"By activating LIME you automatically activate ZRTP media encryption.", + nil) + preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"OK" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action){ - }]; - [errView addAction:defaultAction]; - [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; - } - linphone_core_set_file_transfer_server( - LC, [[self stringForKey:@"file_transfer_server_url_preference"] UTF8String]); + UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action){}]; + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } + linphone_core_set_file_transfer_server(LC, [self stringForKey:@"file_transfer_server_url_preference"].UTF8String); // network section - { - BOOL edgeOpt = [self boolForKey:@"edge_opt_preference"]; - [lm lpConfigSetInt:edgeOpt forKey:@"edge_opt_preference"]; + BOOL edgeOpt = [self boolForKey:@"edge_opt_preference"]; + [lm lpConfigSetInt:edgeOpt forKey:@"edge_opt_preference"]; - BOOL wifiOnly = [self boolForKey:@"wifi_only_preference"]; - [lm lpConfigSetInt:wifiOnly forKey:@"wifi_only_preference"]; - if ([self valueChangedForKey:@"wifi_only_preference"]) { - [LinphoneManager.instance setupNetworkReachabilityCallback]; + BOOL wifiOnly = [self boolForKey:@"wifi_only_preference"]; + [lm lpConfigSetInt:wifiOnly forKey:@"wifi_only_preference"]; + if ([self valueChangedForKey:@"wifi_only_preference"]) + [LinphoneManager.instance setupNetworkReachabilityCallback]; + + LinphoneNatPolicy *LNP = linphone_core_get_nat_policy(LC); + NSString *stun_server = [self stringForKey:@"stun_preference"]; + if ([stun_server length] > 0) { + linphone_core_set_stun_server(LC, [stun_server UTF8String]); + linphone_nat_policy_set_stun_server(LNP, [stun_server UTF8String]); + BOOL ice_preference = [self boolForKey:@"ice_preference"]; + linphone_nat_policy_enable_ice(LNP, ice_preference); + linphone_nat_policy_enable_turn(LNP, [self boolForKey:@"turn_preference"]); + NSString *turn_username = [self stringForKey:@"turn_username"]; + NSString *turn_password = [self stringForKey:@"turn_password"]; + + if ([turn_username length] > 0) { + const LinphoneAuthInfo *turnAuthInfo = nil; + if ([turn_password length] > 0){ + turnAuthInfo = linphone_auth_info_new([turn_username UTF8String], NULL, [turn_password UTF8String], NULL, NULL, NULL); + linphone_core_add_auth_info(LC, turnAuthInfo); + } else + turnAuthInfo = linphone_core_find_auth_info(LC, NULL, [turn_username UTF8String], NULL); + + linphone_nat_policy_set_stun_server_username(LNP, [turn_username UTF8String]); } - - LinphoneNatPolicy *LNP = linphone_core_get_nat_policy(LC); - NSString *stun_server = [self stringForKey:@"stun_preference"]; - if ([stun_server length] > 0) { - linphone_core_set_stun_server(LC, [stun_server UTF8String]); - linphone_nat_policy_set_stun_server(LNP, [stun_server UTF8String]); - BOOL ice_preference = [self boolForKey:@"ice_preference"]; - linphone_nat_policy_enable_ice(LNP, ice_preference); - linphone_nat_policy_enable_turn(LNP, [self boolForKey:@"turn_preference"]); - NSString *turn_username = [self stringForKey:@"turn_username"]; - NSString *turn_password = [self stringForKey:@"turn_password"]; - - if ([turn_username length] > 0) { - const LinphoneAuthInfo *turnAuthInfo = nil; - if ([turn_password length] > 0){ - turnAuthInfo = linphone_auth_info_new([turn_username UTF8String], NULL, - [turn_password UTF8String], NULL, NULL, NULL); - linphone_core_add_auth_info(LC, turnAuthInfo); - }else{ - turnAuthInfo = linphone_core_find_auth_info(LC, NULL, [turn_username UTF8String], NULL); - } - linphone_nat_policy_set_stun_server_username(LNP, [turn_username UTF8String]); - } - } else { - linphone_nat_policy_enable_stun(LNP, FALSE); - linphone_nat_policy_set_stun_server(LNP, NULL); - linphone_core_set_stun_server(LC, NULL); - } - linphone_core_set_nat_policy(LC, LNP); - { - NSString *audio_port_preference = [self stringForKey:@"audio_port_preference"]; - int minPort, maxPort; - [LinphoneCoreSettingsStore parsePortRange:audio_port_preference minPort:&minPort maxPort:&maxPort]; - linphone_core_set_audio_port_range(LC, minPort, maxPort); - } - { - NSString *video_port_preference = [self stringForKey:@"video_port_preference"]; - int minPort, maxPort; - [LinphoneCoreSettingsStore parsePortRange:video_port_preference minPort:&minPort maxPort:&maxPort]; - - linphone_core_set_video_port_range(LC, minPort, maxPort); - } - - NSString *menc = [self stringForKey:@"media_encryption_preference"]; - if (menc && [menc compare:@"SRTP"] == NSOrderedSame) - linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionSRTP); - else if (menc && [menc compare:@"ZRTP"] == NSOrderedSame) - linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionZRTP); - else if (menc && [menc compare:@"DTLS"] == NSOrderedSame) - linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionDTLS); - else - linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionNone); - - linphone_core_enable_adaptive_rate_control(LC, [self boolForKey:@"adaptive_rate_control_preference"]); + } else { + linphone_nat_policy_enable_stun(LNP, FALSE); + linphone_nat_policy_set_stun_server(LNP, NULL); + linphone_core_set_stun_server(LC, NULL); } + linphone_core_set_nat_policy(LC, LNP); + + NSString *audio_port_preference = [self stringForKey:@"audio_port_preference"]; + int audioMinPort, audioMaxPort; + [LinphoneCoreSettingsStore parsePortRange:audio_port_preference minPort:&audioMinPort maxPort:&audioMaxPort]; + linphone_core_set_audio_port_range(LC, audioMinPort, audioMaxPort); + + NSString *video_port_preference = [self stringForKey:@"video_port_preference"]; + int videoMinPort, videoMaxPort; + [LinphoneCoreSettingsStore parsePortRange:video_port_preference minPort:&videoMinPort maxPort:&videoMaxPort]; + linphone_core_set_video_port_range(LC, videoMinPort, videoMaxPort); + + NSString *menc = [self stringForKey:@"media_encryption_preference"]; + if (menc && [menc compare:@"SRTP"] == NSOrderedSame) + linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionSRTP); + else if (menc && [menc compare:@"ZRTP"] == NSOrderedSame) + linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionZRTP); + else if (menc && [menc compare:@"DTLS"] == NSOrderedSame) + linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionDTLS); + else + linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionNone); + + linphone_core_enable_adaptive_rate_control(LC, [self boolForKey:@"adaptive_rate_control_preference"]); // tunnel section - { - if (linphone_core_tunnel_available()) { - NSString *lTunnelPrefMode = [self stringForKey:@"tunnel_mode_preference"]; - NSString *lTunnelPrefAddress = [self stringForKey:@"tunnel_address_preference"]; - int lTunnelPrefPort = [self integerForKey:@"tunnel_port_preference"]; - LinphoneTunnel *tunnel = linphone_core_get_tunnel(LC); - LinphoneTunnelMode mode = LinphoneTunnelModeDisable; - int lTunnelPort = 443; - if (lTunnelPrefPort) { - lTunnelPort = lTunnelPrefPort; - } + if (linphone_core_tunnel_available()) { + NSString *lTunnelPrefMode = [self stringForKey:@"tunnel_mode_preference"]; + NSString *lTunnelPrefAddress = [self stringForKey:@"tunnel_address_preference"]; + int lTunnelPrefPort = [self integerForKey:@"tunnel_port_preference"]; + LinphoneTunnel *tunnel = linphone_core_get_tunnel(LC); + LinphoneTunnelMode mode = LinphoneTunnelModeDisable; + int lTunnelPort = 443; + if (lTunnelPrefPort) + lTunnelPort = lTunnelPrefPort; - linphone_tunnel_clean_servers(tunnel); - if (lTunnelPrefAddress && [lTunnelPrefAddress length]) { - LinphoneTunnelConfig *ltc = linphone_tunnel_config_new(); - linphone_tunnel_config_set_host(ltc, [lTunnelPrefAddress UTF8String]); - linphone_tunnel_config_set_port(ltc, lTunnelPort); - linphone_tunnel_add_server(tunnel, ltc); + linphone_tunnel_clean_servers(tunnel); + if (lTunnelPrefAddress && [lTunnelPrefAddress length]) { + LinphoneTunnelConfig *ltc = linphone_tunnel_config_new(); + linphone_tunnel_config_set_host(ltc, [lTunnelPrefAddress UTF8String]); + linphone_tunnel_config_set_port(ltc, lTunnelPort); + linphone_tunnel_add_server(tunnel, ltc); - if ([lTunnelPrefMode isEqualToString:@"off"]) { - mode = LinphoneTunnelModeDisable; - } else if ([lTunnelPrefMode isEqualToString:@"on"]) { - mode = LinphoneTunnelModeEnable; - } else if ([lTunnelPrefMode isEqualToString:@"auto"]) { - mode = LinphoneTunnelModeAuto; - } else { - LOGE(@"Unexpected tunnel mode [%s]", [lTunnelPrefMode UTF8String]); - } - } - - [lm lpConfigSetString:lTunnelPrefMode forKey:@"tunnel_mode_preference"]; - linphone_tunnel_set_mode(tunnel, mode); + if ([lTunnelPrefMode isEqualToString:@"off"]) + mode = LinphoneTunnelModeDisable; + else if ([lTunnelPrefMode isEqualToString:@"on"]) + mode = LinphoneTunnelModeEnable; + else if ([lTunnelPrefMode isEqualToString:@"auto"]) + mode = LinphoneTunnelModeAuto; + else + LOGE(@"Unexpected tunnel mode [%s]", [lTunnelPrefMode UTF8String]); } + + [lm lpConfigSetString:lTunnelPrefMode forKey:@"tunnel_mode_preference"]; + linphone_tunnel_set_mode(tunnel, mode); } // advanced section - { - BOOL animations = [self boolForKey:@"animations_preference"]; - [lm lpConfigSetInt:animations forKey:@"animations_preference"]; + BOOL animations = [self boolForKey:@"animations_preference"]; + [lm lpConfigSetInt:animations forKey:@"animations_preference"]; - UIDevice *device = [UIDevice currentDevice]; - bool backgroundSupported = - [device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported]; - BOOL isbackgroundModeEnabled = backgroundSupported && [self boolForKey:@"backgroundmode_preference"]; - [lm lpConfigSetInt:isbackgroundModeEnabled forKey:@"backgroundmode_preference"]; + UIDevice *device = [UIDevice currentDevice]; + BOOL backgroundSupported = [device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported]; + BOOL isbackgroundModeEnabled = backgroundSupported && [self boolForKey:@"backgroundmode_preference"]; + [lm lpConfigSetInt:isbackgroundModeEnabled forKey:@"backgroundmode_preference"]; + [lm lpConfigSetInt:[self integerForKey:@"start_at_boot_preference"] forKey:@"start_at_boot_preference"]; + [lm lpConfigSetInt:[self integerForKey:@"autoanswer_notif_preference"] forKey:@"autoanswer_notif_preference"]; + [lm lpConfigSetInt:[self integerForKey:@"show_msg_in_notif"] forKey:@"show_msg_in_notif"]; - [lm lpConfigSetInt:[self integerForKey:@"start_at_boot_preference"] forKey:@"start_at_boot_preference"]; - [lm lpConfigSetInt:[self integerForKey:@"autoanswer_notif_preference"] - forKey:@"autoanswer_notif_preference"]; - [lm lpConfigSetInt:[self integerForKey:@"show_msg_in_notif"] forKey:@"show_msg_in_notif"]; - - if ([self integerForKey:@"use_rls_presence"]) { - [self setInteger:0 forKey:@"use_rls_presence"]; - NSString *rls_uri = - [lm lpConfigStringForKey:@"rls_uri" inSection:@"sip" withDefault:@"sips:rls@sip.linphone.org"]; - LinphoneAddress *rls_addr = linphone_address_new(rls_uri.UTF8String); - const char *rls_domain = linphone_address_get_domain(rls_addr); - const MSList *proxies = linphone_core_get_proxy_config_list(LC); - if (!proxies) { - // Enable it if no proxy config for first launch of app - [self setInteger:1 forKey:@"use_rls_presence"]; - } else { - while (proxies) { - const char *proxy_domain = linphone_proxy_config_get_domain(proxies->data); - if (strcmp(rls_domain, proxy_domain) == 0) { - [self setInteger:1 forKey:@"use_rls_presence"]; - break; - } - proxies = proxies->next; + if ([self integerForKey:@"use_rls_presence"]) { + [self setInteger:0 forKey:@"use_rls_presence"]; + NSString *rls_uri = [lm lpConfigStringForKey:@"rls_uri" inSection:@"sip" withDefault:@"sips:rls@sip.linphone.org"]; + LinphoneAddress *rls_addr = linphone_address_new(rls_uri.UTF8String); + const char *rls_domain = linphone_address_get_domain(rls_addr); + const MSList *proxies = linphone_core_get_proxy_config_list(LC); + if (!proxies) // Enable it if no proxy config for first launch of app + [self setInteger:1 forKey:@"use_rls_presence"]; + else { + while (proxies) { + const char *proxy_domain = linphone_proxy_config_get_domain(proxies->data); + if (strcmp(rls_domain, proxy_domain) == 0) { + [self setInteger:1 forKey:@"use_rls_presence"]; + break; } + proxies = proxies->next; } - linphone_address_unref(rls_addr); } - [lm lpConfigSetInt:[self integerForKey:@"use_rls_presence"] forKey:@"use_rls_presence"]; - - const MSList *lists = linphone_core_get_friends_lists(LC); - while (lists) { - linphone_friend_list_enable_subscriptions(lists->data, [self integerForKey:@"use_rls_presence"]); - lists = lists->next; - } - - BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"]; - [lm lpConfigSetInt:firstloginview forKey:@"enable_first_login_view_preference"]; - - NSString *displayname = [self stringForKey:@"primary_displayname_preference"]; - NSString *username = [self stringForKey:@"primary_username_preference"]; - LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(LC); - if (parsed != NULL) { - linphone_address_set_display_name(parsed, [displayname UTF8String]); - linphone_address_set_username(parsed, [username UTF8String]); - char *contact = linphone_address_as_string(parsed); - linphone_core_set_primary_contact(LC, contact); - ms_free(contact); - linphone_address_destroy(parsed); - } - - [lm lpConfigSetInt:[self integerForKey:@"account_mandatory_advanced_preference"] - forKey:@"account_mandatory_advanced_preference"]; + linphone_address_unref(rls_addr); } + [lm lpConfigSetInt:[self integerForKey:@"use_rls_presence"] forKey:@"use_rls_presence"]; + const MSList *lists = linphone_core_get_friends_lists(LC); + while (lists) { + linphone_friend_list_enable_subscriptions(lists->data, [self integerForKey:@"use_rls_presence"]); + lists = lists->next; + } + + BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"]; + [lm lpConfigSetInt:firstloginview forKey:@"enable_first_login_view_preference"]; + + NSString *displayname = [self stringForKey:@"primary_displayname_preference"]; + NSString *username = [self stringForKey:@"primary_username_preference"]; + LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(LC); + if (parsed != NULL) { + linphone_address_set_display_name(parsed, [displayname UTF8String]); + linphone_address_set_username(parsed, [username UTF8String]); + char *contact = linphone_address_as_string(parsed); + linphone_core_set_primary_contact(LC, contact); + ms_free(contact); + linphone_address_destroy(parsed); + } + [lm lpConfigSetInt:[self integerForKey:@"account_mandatory_advanced_preference"] forKey:@"account_mandatory_advanced_preference"]; + changedDict = [[NSMutableDictionary alloc] init]; // Post event @@ -958,11 +921,16 @@ [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneSettingsUpdate object:self userInfo:eventDic]; return YES; - //} @catch (NSException *e) { - // // may happen when application is terminated, since we are destroying the core - // LOGI(@"Core probably already destroyed, cannot synchronize settings. Skipping. %@", [e callStackSymbols]); - //} - // return NO; + } @catch (NSException *exception) { + // may happen when application is terminated, since we are destroying the core + if ([exception.name isEqualToString:@"LinphoneCoreException"]) { + LOGE(@"Core already destroyed, settings not synchronized"); + return NO; + } + LOGE(@"Uncaught exception : %@", exception.description); + abort(); + } + return NO; } - (void)removeAccount { From 5be5030c42bd9c179774c85fae703ba80212ccd6 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 10 Jan 2018 15:25:19 +0100 Subject: [PATCH 05/11] fix coding style --- Classes/LinphoneManager.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index e8c1f3e84..dd798ade9 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1684,7 +1684,7 @@ static void networkReachabilityNotification(CFNotificationCenterRef center, void return; - if (newSSID != Nil && newSSID.length > 0 && mgr.SSID != Nil && newSSID.length > 0){ + if (newSSID != Nil && newSSID.length > 0 && mgr.SSID != Nil && newSSID.length > 0) { if (SCNetworkReachabilityGetFlags([mgr getProxyReachability], &flags)) { LOGI(@"Wifi SSID changed, resesting transports."); mgr.connectivity=none; //this will trigger a connectivity change in networkReachabilityCallback. @@ -1692,8 +1692,6 @@ static void networkReachabilityNotification(CFNotificationCenterRef center, void } } mgr.SSID = newSSID; - - } void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *nilCtx) { From d02fa8b42a02e12e6aa17a56caa65d67d0c08cbe Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 10 Jan 2018 17:04:30 +0100 Subject: [PATCH 06/11] fix coding style --- Classes/LinphoneManager.m | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index dd798ade9..8ec77bd14 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -865,25 +865,15 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char || linphone_call_log_get_status(UNlog) == LinphoneCallMissed || linphone_call_log_get_status(UNlog) == LinphoneCallAborted || linphone_call_log_get_status(UNlog) == LinphoneCallEarlyAborted)) { - UNMutableNotificationContent *missed_content = - [[UNMutableNotificationContent alloc] init]; + UNMutableNotificationContent *missed_content = [[UNMutableNotificationContent alloc] init]; missed_content.title = NSLocalizedString(@"Missed call", nil); missed_content.body = address; UNNotificationRequest *missed_req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:missed_content trigger:NULL]; - [[UNUserNotificationCenter currentNotificationCenter] - addNotificationRequest:missed_req - withCompletionHandler:^( - NSError *_Nullable error) { - // Enable or disable features based on - // authorization. - if (error) { - LOGD(@"Error while adding " - @"notification request :"); - LOGD(error.description); - } - }]; + [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:missed_req + withCompletionHandler:^(NSError *_Nullable error) + {if (error) LOGD(@"Error while adding notification request : %@", error.description);}]; } linphone_core_set_network_reachable(LC, FALSE); LinphoneManager.instance.connectivity = none; From 9dc29432e8c0b7fc6668b7d64c261e56e34eee31 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 10 Jan 2018 17:13:53 +0100 Subject: [PATCH 07/11] update linphone --- submodules/linphone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/linphone b/submodules/linphone index ce5be0725..fd4827f90 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit ce5be07253ae8bd0315455d5b298071aa84ce404 +Subproject commit fd4827f907e7b24ae97e675f52204a321ec1ce57 From d9a264b150ba6f4ac7ce7ce9a4e1686c45677d61 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 11 Jan 2018 10:52:36 +0100 Subject: [PATCH 08/11] display username in contact if not null --- Classes/Contact.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/Contact.m b/Classes/Contact.m index b377b2d54..d7a5ad375 100644 --- a/Classes/Contact.m +++ b/Classes/Contact.m @@ -39,7 +39,9 @@ if ([_person respondsToSelector:NSSelectorFromString( CNInstantMessageAddressUsernameKey)] || [_person respondsToSelector:NSSelectorFromString(CNContactInstantMessageAddressesKey)]) { if (_person.instantMessageAddresses != NULL) { for (CNLabeledValue *sipAddr in _person.instantMessageAddresses) { - [_sipAddresses addObject:sipAddr.value.username]; + NSString *username = sipAddr.value.username; + if (username) + [_sipAddresses addObject:username]; } } } From b95587069787b8e2b4e59660e03253571221c7a3 Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Thu, 11 Jan 2018 15:11:05 +0100 Subject: [PATCH 09/11] [CallKit] fix callKit_call linphone_core_get_call list null --- Classes/LinphoneManager.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 8ec77bd14..a6f68c166 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -885,7 +885,9 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char : @""; NSUUID *uuid = (NSUUID *)[self.providerDelegate.uuids objectForKey:callId2]; if (uuid) { - LinphoneCall *callKit_call = (LinphoneCall *)linphone_core_get_calls(LC)->data; + LinphoneCall *callKit_call = (LinphoneCall *)linphone_core_get_calls(LC) + ? linphone_core_get_calls(LC)->data + : NULL; const char *callKit_callId = callKit_call ? linphone_call_log_get_call_id(linphone_call_get_call_log(callKit_call)) : NULL; From e2ce82e1311f34f73cb00aa91d21fc7aeba7dacc Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Thu, 11 Jan 2018 15:14:06 +0100 Subject: [PATCH 10/11] [ChatContactList] fix contactList sorted alphabetically --- Classes/ChatConversationCreateTableView.m | 38 +++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/Classes/ChatConversationCreateTableView.m b/Classes/ChatConversationCreateTableView.m index aaa9cd5e9..ed1a66f14 100644 --- a/Classes/ChatConversationCreateTableView.m +++ b/Classes/ChatConversationCreateTableView.m @@ -15,6 +15,8 @@ @property(nonatomic, strong) NSMutableDictionary *contacts; @property(nonatomic, strong) NSDictionary *allContacts; +@property(nonatomic, strong) NSArray *sortedKeys; +@property(nonatomic, strong) NSArray *sortedAddresses; @end @implementation ChatConversationCreateTableView @@ -22,7 +24,18 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.allContacts = - [[NSDictionary alloc] initWithDictionary:LinphoneManager.instance.fastAddressBook.addressBookMap]; + [[NSMutableDictionary alloc] initWithDictionary:LinphoneManager.instance.fastAddressBook.addressBookMap]; + self.sortedKeys = [[LinphoneManager.instance.fastAddressBook.addressBookMap allKeys] sortedArrayUsingSelector: @selector(compare:)]; + + self.sortedAddresses = [[LinphoneManager.instance.fastAddressBook.addressBookMap allKeys] sortedArrayUsingComparator:^NSComparisonResult(id a, id b) { + Contact* first = [_allContacts objectForKey:a]; + Contact* second = [_allContacts objectForKey:b]; + + if([[first.firstName lowercaseString] compare:[second.firstName lowercaseString]] == NSOrderedSame) + return [[first.lastName lowercaseString] compare:[second.lastName lowercaseString]]; + else + return [[first.firstName lowercaseString] compare:[second.firstName lowercaseString]]; + }]; self.contacts = [[NSMutableDictionary alloc] initWithCapacity:_allContacts.count]; [_searchBar becomeFirstResponder]; [_searchBar setText:@""]; @@ -33,15 +46,14 @@ - (void)reloadDataWithFilter:(NSString *)filter { [_contacts removeAllObjects]; - [_allContacts enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) { - NSString *address = (NSString *)key; - NSString *name = [FastAddressBook displayNameForContact:value]; - if ((filter.length == 0) || ([name.lowercaseString containsSubstring:filter.lowercaseString]) || - ([address.lowercaseString containsSubstring:filter.lowercaseString])) { - _contacts[address] = name; - } - - }]; + for (NSString* key in _sortedAddresses){ + NSString *address = (NSString *)key; + NSString *name = [FastAddressBook displayNameForContact:[_allContacts objectForKey:key]]; + if ((filter.length == 0) || ([name.lowercaseString containsSubstring:filter.lowercaseString]) || + ([address.lowercaseString containsSubstring:filter.lowercaseString])) { + [_contacts setObject:name forKey:address] ; + } + } // also add current entry, if not listed NSString *nsuri = filter.lowercaseString; LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:nsuri]; @@ -72,8 +84,8 @@ if (cell == nil) { cell = [[UIChatCreateCell alloc] initWithIdentifier:kCellId]; } - cell.displayNameLabel.text = [_contacts.allValues objectAtIndex:indexPath.row]; - LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:[_contacts.allKeys objectAtIndex:indexPath.row]]; + LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:[_sortedAddresses objectAtIndex:indexPath.row]]; + cell.displayNameLabel.text = [_contacts objectForKey:[_sortedAddresses objectAtIndex:indexPath.row]]; if (addr) { cell.addressLabel.text = [NSString stringWithUTF8String:linphone_address_as_string(addr)]; } else { @@ -85,7 +97,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; NSString *uri; - LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:[_contacts.allKeys objectAtIndex:indexPath.row]]; + LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:[_sortedAddresses objectAtIndex:indexPath.row]]; if (addr) { uri = [NSString stringWithUTF8String:linphone_address_as_string(addr)]; } else { From 8e0270067caa790dcfa53f162498a12f6215806a Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Thu, 11 Jan 2018 15:15:47 +0100 Subject: [PATCH 11/11] [ContactDisplay] add settings to display phone only or displayName + sipAddress --- Classes/CallIncomingView.m | 3 +-- Classes/CallOutgoingView.m | 3 +-- Classes/HistoryDetailsView.m | 3 +-- Classes/Utils/Utils.h | 1 + Classes/Utils/Utils.m | 14 ++++++++++++++ Resources/linphonerc | 1 + 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Classes/CallIncomingView.m b/Classes/CallIncomingView.m index 17cd56edf..c81d20549 100644 --- a/Classes/CallIncomingView.m +++ b/Classes/CallIncomingView.m @@ -95,9 +95,8 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)update { const LinphoneAddress *addr = linphone_call_get_remote_address(_call); - [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; + [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr withAddressLabel:_addressLabel]; char *uri = linphone_address_as_string_uri_only(addr); - _addressLabel.text = [NSString stringWithUTF8String:uri]; ms_free(uri); [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:YES withRoundedRadius:YES]; diff --git a/Classes/CallOutgoingView.m b/Classes/CallOutgoingView.m index 4d6d6958f..292217a7b 100644 --- a/Classes/CallOutgoingView.m +++ b/Classes/CallOutgoingView.m @@ -63,9 +63,8 @@ static UICompositeViewDescription *compositeDescription = nil; } const LinphoneAddress *addr = linphone_call_get_remote_address(call); - [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; + [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr withAddressLabel:_addressLabel]; char *uri = linphone_address_as_string_uri_only(addr); - _addressLabel.text = [NSString stringWithUTF8String:uri]; ms_free(uri); [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m index d33dbc4d7..6bd1648d3 100644 --- a/Classes/HistoryDetailsView.m +++ b/Classes/HistoryDetailsView.m @@ -144,10 +144,9 @@ static UICompositeViewDescription *compositeDescription = nil; LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); _addContactButton.hidden = ([FastAddressBook getContactWithAddress:addr] != nil); - [ContactDisplay setDisplayNameLabel:_contactLabel forAddress:addr]; + [ContactDisplay setDisplayNameLabel:_contactLabel forAddress:addr withAddressLabel:_addressLabel]; [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; char *addrURI = linphone_address_as_string_uri_only(addr); - _addressLabel.text = [NSString stringWithUTF8String:addrURI]; ms_free(addrURI); [_tableView loadDataForAddress:(callLog ? linphone_call_log_get_remote_address(callLog) : NULL)]; diff --git a/Classes/Utils/Utils.h b/Classes/Utils/Utils.h index 4fc336c75..fde7484e5 100644 --- a/Classes/Utils/Utils.h +++ b/Classes/Utils/Utils.h @@ -73,6 +73,7 @@ typedef enum { @interface ContactDisplay : NSObject + (void)setDisplayNameLabel:(UILabel *)label forContact:(Contact *)contact; + (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr; ++ (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr withAddressLabel:(UILabel*)addressLabel; @end #import diff --git a/Classes/Utils/Utils.m b/Classes/Utils/Utils.m index 5aaa54dcc..1899e3b48 100644 --- a/Classes/Utils/Utils.m +++ b/Classes/Utils/Utils.m @@ -571,6 +571,20 @@ } } ++ (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr withAddressLabel:(UILabel*)addressLabel{ + Contact *contact = [FastAddressBook getContactWithAddress:addr]; + if (contact) { + [ContactDisplay setDisplayNameLabel:label forContact:contact]; + } else { + label.text = [FastAddressBook displayNameForAddress:addr]; + } + if([LinphoneManager.instance lpConfigStringForKey:@"display_phone_only" inSection:@"app"]) + addressLabel.text = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(addr)]; + else + addressLabel.hidden = TRUE; +} + + @end @implementation UIImage (squareCrop) diff --git a/Resources/linphonerc b/Resources/linphonerc index 9fe2fff69..e2861ccd8 100644 --- a/Resources/linphonerc +++ b/Resources/linphonerc @@ -13,6 +13,7 @@ start_at_boot_preference=1 stun_preference=stun.linphone.org voiceproc_preference=1 repeat_call_notification=1 +display_phone_only=0 [in_app_purchase] #set to 1 if in-app purchases are to be shown in the application