mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
push: unregister proxy configs on destroy if remote pushes are not enabled
This commit is contained in:
parent
7e116b26b2
commit
6798dd0bda
4 changed files with 253 additions and 234 deletions
|
|
@ -27,6 +27,7 @@ Group changes to describe their impact on the project, as follows:
|
|||
consider inputs to be phone numbers, otherwise SIP addresses.
|
||||
- Automatically start call when answering from within notification in iOS9+
|
||||
- Contact details view is now scrollable to fix issue on small screens
|
||||
- Unregister accounts in case of application shutdown when remote push notifications are not enabled
|
||||
|
||||
## [3.12.1] - 2016-02-19
|
||||
|
||||
|
|
|
|||
|
|
@ -250,8 +250,19 @@
|
|||
// remote push notifications, we want to continue receiving them
|
||||
if (LinphoneManager.instance.pushNotificationToken != nil) {
|
||||
// trick me! setting network reachable to false will avoid sending unregister
|
||||
linphone_core_set_network_reachable(LC, FALSE);
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
BOOL pushNotifEnabled = NO;
|
||||
while (proxies) {
|
||||
const char *refkey = linphone_proxy_config_get_ref_key(proxies->data);
|
||||
pushNotifEnabled = pushNotifEnabled || (refkey && strcmp(refkey, "push_notification") == 0);
|
||||
proxies = proxies->next;
|
||||
}
|
||||
// but we only want to hack if at least one proxy config uses remote push..
|
||||
if (pushNotifEnabled) {
|
||||
linphone_core_set_network_reachable(LC, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
[LinphoneManager.instance destroyLinphoneCore];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -527,7 +527,8 @@
|
|||
linphone_proxy_config_set_dial_escape_plus(proxyCfg, substitute_plus_by_00);
|
||||
}
|
||||
|
||||
linphone_proxy_config_set_ref_key(proxyCfg, pushnotification ? "push_notification" : NULL);
|
||||
// use empty string "" instead of NULL to avoid being overwritten by default proxy config values
|
||||
linphone_proxy_config_set_ref_key(proxyCfg, pushnotification ? "push_notification" : "no_push_notification");
|
||||
[LinphoneManager.instance configurePushTokenForProxyConfig:proxyCfg];
|
||||
|
||||
linphone_proxy_config_enable_register(proxyCfg, is_enabled);
|
||||
|
|
@ -591,247 +592,255 @@
|
|||
}
|
||||
|
||||
- (BOOL)synchronize {
|
||||
LinphoneManager *lm = LinphoneManager.instance;
|
||||
// root section
|
||||
{
|
||||
BOOL account_changed = NO;
|
||||
for (NSString *key in self->changedDict) {
|
||||
if ([key hasPrefix:@"account_"] && [self valueChangedForKey:key]) {
|
||||
account_changed = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
account_changed |= [self valueChangedForKey:@"port_preference"];
|
||||
account_changed |= [self valueChangedForKey:@"random_port_preference"];
|
||||
account_changed |= [self valueChangedForKey:@"use_ipv6"];
|
||||
|
||||
if (account_changed)
|
||||
[self synchronizeAccounts];
|
||||
|
||||
bool enableVideo = [self boolForKey:@"enable_video_preference"];
|
||||
linphone_core_enable_video_capture(LC, enableVideo);
|
||||
linphone_core_enable_video_display(LC, enableVideo);
|
||||
|
||||
bool enableAutoAnswer = [self boolForKey:@"enable_auto_answer_preference"];
|
||||
[LinphoneManager.instance lpConfigSetBool:enableAutoAnswer forKey:@"auto_answer"];
|
||||
}
|
||||
|
||||
// audio section
|
||||
{
|
||||
[self synchronizeCodecs:linphone_core_get_audio_codecs(LC)];
|
||||
|
||||
float playback_gain = [self floatForKey:@"playback_gain_preference"];
|
||||
linphone_core_set_playback_gain_db(LC, playback_gain);
|
||||
|
||||
float mic_gain = [self floatForKey:@"microphone_gain_preference"];
|
||||
linphone_core_set_mic_gain_db(LC, mic_gain);
|
||||
|
||||
[lm lpConfigSetInt:[self integerForKey:@"audio_codec_bitrate_limit_preference"]
|
||||
forKey:@"codec_bitrate_limit"
|
||||
inSection:@"audio"];
|
||||
|
||||
BOOL voice_processing = [self boolForKey:@"voiceproc_preference"];
|
||||
[lm lpConfigSetInt:voice_processing forKey:@"voiceproc_preference"];
|
||||
|
||||
BOOL equalizer = [self boolForKey:@"eq_active"];
|
||||
[lm lpConfigSetBool:equalizer forKey:@"eq_active" inSection:@"sound"];
|
||||
|
||||
[LinphoneManager.instance configureVbrCodecs];
|
||||
|
||||
NSString *au_device = @"AU: Audio Unit Receiver";
|
||||
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)];
|
||||
|
||||
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]);
|
||||
int bw;
|
||||
MSVideoSize vsize;
|
||||
switch ([self integerForKey:@"video_preferred_size_preference"]) {
|
||||
case 0:
|
||||
MS_VIDEO_SIZE_ASSIGN(vsize, 720P);
|
||||
// 128 = margin for audio, the BW includes both video and audio
|
||||
bw = 1024 + 128;
|
||||
break;
|
||||
case 1:
|
||||
MS_VIDEO_SIZE_ASSIGN(vsize, VGA);
|
||||
// no margin for VGA or QVGA, because video encoders can encode the
|
||||
// target resulution in less than the asked bandwidth
|
||||
bw = 660;
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
MS_VIDEO_SIZE_ASSIGN(vsize, QVGA);
|
||||
bw = 380;
|
||||
break;
|
||||
}
|
||||
linphone_core_set_preferred_video_size(LC, vsize);
|
||||
if (![videoPreset isEqualToString:@"custom"]) {
|
||||
[self setInteger:0 forKey:@"video_preferred_fps_preference"];
|
||||
[self setInteger:bw 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"];
|
||||
}
|
||||
|
||||
// network section
|
||||
{
|
||||
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];
|
||||
}
|
||||
|
||||
NSString *stun_server = [self stringForKey:@"stun_preference"];
|
||||
if ([stun_server length] > 0) {
|
||||
linphone_core_set_stun_server(LC, [stun_server UTF8String]);
|
||||
BOOL ice_preference = [self boolForKey:@"ice_preference"];
|
||||
if (ice_preference) {
|
||||
linphone_core_set_firewall_policy(LC, LinphonePolicyUseIce);
|
||||
} else {
|
||||
linphone_core_set_firewall_policy(LC, LinphonePolicyUseStun);
|
||||
}
|
||||
} else {
|
||||
linphone_core_set_stun_server(LC, NULL);
|
||||
linphone_core_set_firewall_policy(LC, LinphonePolicyNoFirewall);
|
||||
}
|
||||
@try {
|
||||
|
||||
LinphoneManager *lm = LinphoneManager.instance;
|
||||
// root section
|
||||
{
|
||||
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"]);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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]);
|
||||
BOOL account_changed = NO;
|
||||
for (NSString *key in self->changedDict) {
|
||||
if ([key hasPrefix:@"account_"] && [self valueChangedForKey:key]) {
|
||||
account_changed = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
account_changed |= [self valueChangedForKey:@"port_preference"];
|
||||
account_changed |= [self valueChangedForKey:@"random_port_preference"];
|
||||
account_changed |= [self valueChangedForKey:@"use_ipv6"];
|
||||
|
||||
[lm lpConfigSetString:lTunnelPrefMode forKey:@"tunnel_mode_preference"];
|
||||
linphone_tunnel_set_mode(tunnel, mode);
|
||||
}
|
||||
}
|
||||
if (account_changed)
|
||||
[self synchronizeAccounts];
|
||||
|
||||
// advanced section
|
||||
{
|
||||
BOOL animations = [self boolForKey:@"animations_preference"];
|
||||
[lm lpConfigSetInt:animations forKey:@"animations_preference"];
|
||||
bool enableVideo = [self boolForKey:@"enable_video_preference"];
|
||||
linphone_core_enable_video_capture(LC, enableVideo);
|
||||
linphone_core_enable_video_display(LC, enableVideo);
|
||||
|
||||
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"];
|
||||
|
||||
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);
|
||||
bool enableAutoAnswer = [self boolForKey:@"enable_auto_answer_preference"];
|
||||
[LinphoneManager.instance lpConfigSetBool:enableAutoAnswer forKey:@"auto_answer"];
|
||||
}
|
||||
|
||||
[lm lpConfigSetInt:[self integerForKey:@"account_mandatory_advanced_preference"]
|
||||
forKey:@"account_mandatory_advanced_preference"];
|
||||
// audio section
|
||||
{
|
||||
[self synchronizeCodecs:linphone_core_get_audio_codecs(LC)];
|
||||
|
||||
linphone_core_set_file_transfer_server(LC,
|
||||
[[self stringForKey:@"file_transfer_server_url_preference"] UTF8String]);
|
||||
float playback_gain = [self floatForKey:@"playback_gain_preference"];
|
||||
linphone_core_set_playback_gain_db(LC, playback_gain);
|
||||
|
||||
float mic_gain = [self floatForKey:@"microphone_gain_preference"];
|
||||
linphone_core_set_mic_gain_db(LC, mic_gain);
|
||||
|
||||
[lm lpConfigSetInt:[self integerForKey:@"audio_codec_bitrate_limit_preference"]
|
||||
forKey:@"codec_bitrate_limit"
|
||||
inSection:@"audio"];
|
||||
|
||||
BOOL voice_processing = [self boolForKey:@"voiceproc_preference"];
|
||||
[lm lpConfigSetInt:voice_processing forKey:@"voiceproc_preference"];
|
||||
|
||||
BOOL equalizer = [self boolForKey:@"eq_active"];
|
||||
[lm lpConfigSetBool:equalizer forKey:@"eq_active" inSection:@"sound"];
|
||||
|
||||
[LinphoneManager.instance configureVbrCodecs];
|
||||
|
||||
NSString *au_device = @"AU: Audio Unit Receiver";
|
||||
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)];
|
||||
|
||||
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]);
|
||||
int bw;
|
||||
MSVideoSize vsize;
|
||||
switch ([self integerForKey:@"video_preferred_size_preference"]) {
|
||||
case 0:
|
||||
MS_VIDEO_SIZE_ASSIGN(vsize, 720P);
|
||||
// 128 = margin for audio, the BW includes both video and audio
|
||||
bw = 1024 + 128;
|
||||
break;
|
||||
case 1:
|
||||
MS_VIDEO_SIZE_ASSIGN(vsize, VGA);
|
||||
// no margin for VGA or QVGA, because video encoders can encode the
|
||||
// target resulution in less than the asked bandwidth
|
||||
bw = 660;
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
MS_VIDEO_SIZE_ASSIGN(vsize, QVGA);
|
||||
bw = 380;
|
||||
break;
|
||||
}
|
||||
linphone_core_set_preferred_video_size(LC, vsize);
|
||||
if (![videoPreset isEqualToString:@"custom"]) {
|
||||
[self setInteger:0 forKey:@"video_preferred_fps_preference"];
|
||||
[self setInteger:bw 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"];
|
||||
}
|
||||
|
||||
// network section
|
||||
{
|
||||
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];
|
||||
}
|
||||
|
||||
NSString *stun_server = [self stringForKey:@"stun_preference"];
|
||||
if ([stun_server length] > 0) {
|
||||
linphone_core_set_stun_server(LC, [stun_server UTF8String]);
|
||||
BOOL ice_preference = [self boolForKey:@"ice_preference"];
|
||||
if (ice_preference) {
|
||||
linphone_core_set_firewall_policy(LC, LinphonePolicyUseIce);
|
||||
} else {
|
||||
linphone_core_set_firewall_policy(LC, LinphonePolicyUseStun);
|
||||
}
|
||||
} else {
|
||||
linphone_core_set_stun_server(LC, NULL);
|
||||
linphone_core_set_firewall_policy(LC, LinphonePolicyNoFirewall);
|
||||
}
|
||||
|
||||
{
|
||||
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"]);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// advanced section
|
||||
{
|
||||
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"];
|
||||
|
||||
[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"];
|
||||
|
||||
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_core_set_file_transfer_server(
|
||||
LC, [[self stringForKey:@"file_transfer_server_url_preference"] UTF8String]);
|
||||
}
|
||||
|
||||
changedDict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
// Post event
|
||||
NSDictionary *eventDic = [NSDictionary dictionaryWithObject:self forKey:@"settings"];
|
||||
[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.");
|
||||
}
|
||||
|
||||
changedDict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
// Post event
|
||||
NSDictionary *eventDic = [NSDictionary dictionaryWithObject:self forKey:@"settings"];
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneSettingsUpdate object:self userInfo:eventDic];
|
||||
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)removeAccount {
|
||||
|
|
|
|||
|
|
@ -1678,7 +1678,6 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
|
||||
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"]) {
|
||||
|
||||
// register keepalive
|
||||
if ([[UIApplication sharedApplication]
|
||||
setKeepAliveTimeout:600 /*(NSTimeInterval)linphone_proxy_config_get_expires(proxyCfg)*/
|
||||
|
|
@ -2040,7 +2039,6 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
while (proxies) {
|
||||
linphone_proxy_config_set_ref_key(proxies->data, "push_notification");
|
||||
[self configurePushTokenForProxyConfig:proxies->data];
|
||||
proxies = proxies->next;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue