From 1a4efce512e24fd1e598c4bae8bc44e4018b5f58 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 22 Feb 2017 14:03:04 +0100 Subject: [PATCH] add enable smart address book in settings to enable presence --- Classes/LinphoneCoreSettingsStore.m | 31 ++++++++++++++++++++ Settings/InAppSettings.bundle/Advanced.plist | 16 ++++++++++ 2 files changed, 47 insertions(+) diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 29ec05216..012fac885 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -407,6 +407,7 @@ [self setBool:[lm lpConfigBoolForKey:@"start_at_boot_preference"] forKey:@"start_at_boot_preference"]; [self setBool:[lm lpConfigBoolForKey:@"autoanswer_notif_preference"] forKey:@"autoanswer_notif_preference"]; [self setBool:[lm lpConfigBoolForKey:@"show_msg_in_notif" withDefault:YES] forKey:@"show_msg_in_notif"]; + [self setBool:[lm lpConfigBoolForKey:@"use_rls_presence" withDefault:YES] forKey:@"use_rls_presence"]; [self setBool:[lm lpConfigBoolForKey:@"enable_first_login_view_preference"] forKey:@"enable_first_login_view_preference"]; LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(LC); @@ -908,6 +909,36 @@ 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; + } + } + 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"]; diff --git a/Settings/InAppSettings.bundle/Advanced.plist b/Settings/InAppSettings.bundle/Advanced.plist index d97e858c8..9bfd8c7a0 100644 --- a/Settings/InAppSettings.bundle/Advanced.plist +++ b/Settings/InAppSettings.bundle/Advanced.plist @@ -4,6 +4,22 @@ PreferenceSpecifiers + + Title + Presence + Type + PSGroupSpecifier + + + Type + PSToggleSwitchSpecifier + Title + Enable smart address book + Key + use_rls_presence + DefaultValue + YES + Title Debug