pushnotif: push notifications are now set per account

This commit is contained in:
Gautier Pelloux-Prayer 2016-04-05 11:47:40 +02:00
parent 7e57f2f4cf
commit 86a55fd9c9
13 changed files with 197 additions and 187 deletions

View file

@ -13,6 +13,8 @@ Group changes to describe their impact on the project, as follows:
## [Unreleased]
### Added
- Added "Forgot your password?" link in Linphone account assistant
### Changed
- Push notifications are now configurable per account
### Fixed
- Fix invalid photo rotation when using Camera for avatars
- Parse user input as SIP address or phone number depending on default account settings: if "substitute + by country code" is set,

View file

@ -124,6 +124,7 @@
// default values
{
[self setBool:NO forKey:@"account_pushnotification_preference"];
[self setObject:@"" forKey:@"account_mandatory_username_preference"];
[self setObject:@"" forKey:@"account_mandatory_domain_preference"];
[self setCString:"" forKey:@"account_display_name_preference"];
@ -146,6 +147,11 @@
proxy = proxies->data;
// root section
{
const char *refkey = linphone_proxy_config_get_ref_key(proxy);
if (refkey) {
BOOL pushEnabled = (strcmp(refkey, "push_notification") == 0);
[self setBool:pushEnabled forKey:@"account_pushnotification_preference"];
}
const LinphoneAddress *identity_addr = linphone_proxy_config_get_identity_address(proxy);
if (identity_addr) {
const char *server_addr = linphone_proxy_config_get_server_addr(proxy);
@ -336,8 +342,6 @@
break;
}
[self setCString:val forKey:@"media_encryption_preference"];
[self setBool:[lm lpConfigBoolForKey:@"pushnotification_preference" withDefault:NO]
forKey:@"pushnotification_preference"];
[self setInteger:linphone_core_get_upload_bandwidth(LC) forKey:@"upload_bandwidth_preference"];
[self setInteger:linphone_core_get_download_bandwidth(LC) forKey:@"download_bandwidth_preference"];
[self setBool:linphone_core_adaptive_rate_control_enabled(LC) forKey:@"adaptive_rate_control_preference"];
@ -443,7 +447,7 @@
if (username && [username length] > 0 && domain && [domain length] > 0) {
int expire = [self integerForKey:@"account_expire_preference"];
BOOL isWifiOnly = [self boolForKey:@"wifi_only_preference"];
BOOL pushnotification = [self boolForKey:@"pushnotification_preference"];
BOOL pushnotification = [self boolForKey:@"account_pushnotification_preference"];
NSString *prefix = [self stringForKey:@"account_prefix_preference"];
NSString *proxyAddress = [self stringForKey:@"account_proxy_preference"];
@ -522,7 +526,7 @@
linphone_proxy_config_set_dial_escape_plus(proxyCfg, substitute_plus_by_00);
}
[lm lpConfigSetInt:pushnotification forKey:@"pushnotification_preference"];
linphone_proxy_config_set_ref_key(proxyCfg, pushnotification ? "push_notification" : NULL);
[LinphoneManager.instance configurePushTokenForProxyConfig:proxyCfg];
linphone_proxy_config_enable_register(proxyCfg, is_enabled);
@ -599,7 +603,6 @@
account_changed |= [self valueChangedForKey:@"port_preference"];
account_changed |= [self valueChangedForKey:@"random_port_preference"];
account_changed |= [self valueChangedForKey:@"use_ipv6"];
account_changed |= [self valueChangedForKey:@"pushnotification_preference"];
if (account_changed)
[self synchronizeAccounts];

View file

@ -520,6 +520,20 @@ static void migrateWizardToAssistant(const char *entry, void *user_data) {
// lp_config_for_each_entry(_configDb, "wizard", migrateWizardToAssistant, (__bridge void *)(self));
}
- (void)migratePushNotificationPerAccount {
NSString *s = [self lpConfigStringForKey:@"pushnotification_preference"];
if (s && s.boolValue) {
LOGI(@"Migrating push notification per account, enabling for ALL");
[self lpConfigSetBool:NO forKey:@"pushnotification_preference"];
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;
}
}
}
#pragma mark - Linphone Core Functions
+ (LinphoneCore *)getLc {
@ -533,27 +547,12 @@ static void migrateWizardToAssistant(const char *entry, void *user_data) {
#pragma mark Debug functions
struct _entry_data {
const LpConfig *conf;
const char *section;
};
static void dump_entry(const char *entry, void *data) {
struct _entry_data *d = (struct _entry_data *)data;
const char *value = lp_config_get_string(d->conf, d->section, entry, "");
LOGI(@"%s=%s", entry, value);
}
static void dump_section(const char *section, void *data) {
LOGI(@"[%s]", section);
struct _entry_data d = {(const LpConfig *)data, section};
lp_config_for_each_entry((const LpConfig *)data, section, dump_entry, &d);
}
+ (void)dumpLcConfig {
if (theLinphoneCore) {
LpConfig *conf = LinphoneManager.instance.configDb;
lp_config_for_each_section(conf, dump_section, conf);
char *config = lp_config_dump(conf);
LOGI(@"\n%s", config);
ms_free(config);
}
}
@ -825,9 +824,7 @@ static void linphone_iphone_configuring_status_changed(LinphoneCore *lc, Linphon
if (_wasRemoteProvisioned) {
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
if (cfg) {
linphone_proxy_config_edit(cfg);
[self configurePushTokenForProxyConfig:cfg];
linphone_proxy_config_done(cfg);
}
}
}
@ -1398,8 +1395,8 @@ static LinphoneCoreVTable linphonec_vtable = {
linphone_core_set_call_logs_database_path(theLinphoneCore, [chatDBFileName UTF8String]);
[self migrationLinphoneSettings];
[self migrationFromVersion2To3];
[self migratePushNotificationPerAccount];
[self setupNetworkReachabilityCallback];
@ -1686,9 +1683,9 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
// handle proxy config if any
if (proxyCfg) {
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] ||
[LinphoneManager.instance lpConfigBoolForKey:@"pushnotification_preference"]) {
const char *refkey = linphone_proxy_config_get_ref_key(proxyCfg);
BOOL pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0);
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] || pushNotifEnabled) {
// For registration register
[self refreshRegisters];
}
@ -1739,7 +1736,9 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
LOGI(@"Entering [%s] bg mode", shouldEnterBgMode ? "normal" : "lite");
if (!shouldEnterBgMode) {
if ([LinphoneManager.instance lpConfigBoolForKey:@"pushnotification_preference"]) {
const char *refkey = linphone_proxy_config_get_ref_key(proxyCfg);
BOOL pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0);
if (pushNotifEnabled) {
LOGI(@"Keeping lc core to handle push");
/*destroy voip socket if any and reset connectivity mode*/
connectivity = none;
@ -2052,17 +2051,21 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
}
_pushNotificationToken = apushNotificationToken;
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(theLinphoneCore);
if (cfg) {
linphone_proxy_config_edit(cfg);
[self configurePushTokenForProxyConfig:cfg];
linphone_proxy_config_done(cfg);
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;
}
}
- (void)configurePushTokenForProxyConfig:(LinphoneProxyConfig *)proxyCfg {
linphone_proxy_config_edit(proxyCfg);
NSData *tokenData = _pushNotificationToken;
if (tokenData != nil && [self lpConfigBoolForKey:@"pushnotification_preference"]) {
const char *refkey = linphone_proxy_config_get_ref_key(proxyCfg);
BOOL pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0);
if (tokenData != nil && pushNotifEnabled) {
const unsigned char *tokenBuffer = [tokenData bytes];
NSMutableString *tokenString = [NSMutableString stringWithCapacity:[tokenData length] * 2];
for (int i = 0; i < [tokenData length]; ++i) {
@ -2092,6 +2095,8 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
linphone_proxy_config_set_contact_uri_parameters(proxyCfg, NULL);
linphone_proxy_config_set_contact_parameters(proxyCfg, NULL);
}
linphone_proxy_config_done(proxyCfg);
}
#pragma mark - Misc Functions

View file

@ -9,6 +9,7 @@
<entry name="reg_proxy" overwrite="true"></entry>
<entry name="reg_route" overwrite="true"></entry>
<entry name="reg_sendregister" overwrite="true">1</entry>
<entry name="refkey" overwrite="true"></entry>
</section>
<section name="assistant">

View file

@ -11,6 +11,7 @@
<entry name="reg_expires" overwrite="true">1314000</entry>
<entry name="reg_identity" overwrite="true">sip:?@sip.linphone.org</entry>
<entry name="reg_sendregister" overwrite="true">1</entry>
<entry name="refkey" overwrite="true">push_notification</entry>
</section>
<section name="assistant">

View file

@ -11,6 +11,7 @@
<entry name="reg_expires" overwrite="true">1314000</entry>
<entry name="reg_identity" overwrite="true">sip:?@sip.linphone.org</entry>
<entry name="reg_sendregister" overwrite="true">1</entry>
<entry name="refkey" overwrite="true">push_notification</entry>
</section>
<section name="assistant">

View file

@ -9,6 +9,7 @@
<entry name="reg_proxy" overwrite="true"></entry>
<entry name="reg_route" overwrite="true"></entry>
<entry name="reg_sendregister" overwrite="true">1</entry>
<entry name="refkey" overwrite="true"></entry>
</section>
<section name="assistant">

View file

@ -1,73 +1,69 @@
[net]
mtu=1300
activate_edge_workarounds=0
edge_ping_time=10
edge_bw=10
[sip]
contact="Linphone iPhone" <sip:linphone.iphone@unknown-host>
keepalive_period=30000
sip_port=-1
sip_tcp_port=-1
use_ipv6=0
inc_timeout=45
use_info=0
guess_hostname=1
register_only_when_network_is_up=1
auto_net_state_mon=0
keepalive_period=30000
ping_with_options=0
rtcp_xr_enabled=1
rtcp_xr_rcvr_rtt_mode=all
rtcp_xr_rcvr_rtt_max_size=10000
rtcp_xr_stat_summary_enabled=1
rtcp_xr_voip_metrics_enabled=1
[rtp]
audio_rtp_port=7200-7299
video_rtp_port=9200-9299
audio_jitt_comp=60
video_jitt_comp=60
nortp_timeout=30
[video]
display=1
capture=1
show_local=0
enabled=1
size=qvga
automatically_initiate=0
automatically_accept=0
[net]
download_bw=380
upload_bw=380
firewall_policy=ice
stun_server=stun.linphone.org
[sound]
playback_dev_id=AU: Audio Unit Receiver
capture_dev_id=AU: Audio Unit Receiver
eq_active=0
[app]
preview_preference=0
animations_preference=1
edge_opt_preference=0
start_at_boot_preference=1
backgroundmode_preference=1
autoanswer_notif_preference=1
voiceproc_preference=1
backgroundmode_preference=1
edge_opt_preference=0
enable_log_collect=0
file_transfer_migration_done=1
pushnotification_preference=1
ice_preference=1
stun_preference=stun.linphone.org
preview_preference=0
random_port_preference=1
start_at_boot_preference=1
stun_preference=stun.linphone.org
voiceproc_preference=1
[default_values]
reg_expires=1314000
[misc]
max_calls=3
file_transfer_server_url=https://www.linphone.org:444/lft.php
max_calls=3
[net]
download_bw=380
edge_bw=10
edge_ping_time=10
firewall_policy=ice
mtu=1300
stun_server=stun.linphone.org
upload_bw=380
[rtp]
audio_jitt_comp=60
audio_rtp_port=7200-7299
nortp_timeout=30
video_jitt_comp=60
video_rtp_port=9200-9299
[sip]
auto_net_state_mon=0
contact="Linphone iPhone" <sip:linphone.iphone@unknown-host>
guess_hostname=1
inc_timeout=45
keepalive_period=30000
ping_with_options=0
register_only_when_network_is_up=1
rtcp_xr_enabled=1
rtcp_xr_rcvr_rtt_max_size=10000
rtcp_xr_rcvr_rtt_mode=all
rtcp_xr_stat_summary_enabled=1
rtcp_xr_voip_metrics_enabled=1
sip_port=-1
sip_tcp_port=-1
use_info=0
use_ipv6=0
[sound]
capture_dev_id=AU: Audio Unit Receiver
eq_active=0
playback_dev_id=AU: Audio Unit Receiver
[video]
automatically_accept=0
automatically_initiate=0
capture=1
display=1
enabled=1
show_local=0
size=qvga

View file

@ -1,32 +1,37 @@
[app]
#contact_display_username_only=1
#contact_filter_on_default_domain=1
#debug_popup_magic=**00**
debug_popup_email=linphone-iphone@belledonne-communications.com
send_logs_include_linphonerc_and_chathistory=0
#use_phone_number=0
[assistant]
password_length=-1
username_length=-1
[misc]
add_missing_audio_codecs=0
add_missing_video_codecs=0
#by default it is set to 30 by liblinphone
history_max_size=-1
[sip]
sip_random_port=0
store_ha1_passwd=0
[sound]
ringer_dev_id=AQ: Audio Queue Device
echocancellation=0
dtmf_player_amp=0.007
eq_location=mic
echocancellation=0
eq_gains=50:2:50 100:2:50
eq_location=mic
ringer_dev_id=AQ: Audio Queue Device
[video]
display_filter_auto_rotate=0
[app]
#contact_display_username_only=1
#contact_filter_on_default_domain=1
#use_phone_number=0
send_logs_include_linphonerc_and_chathistory=0
#debug_popup_magic=**00**
debug_popup_email=linphone-iphone@belledonne-communications.com
[proxy_0]
lol=toto
[assistant]
username_length=-1
password_length=-1
[in_app_purchase]
enabled=0
[misc]
#by default it is set to 30 by liblinphone
history_max_size=-1
[misc234]
lol=tata

View file

@ -1,73 +1,68 @@
[net]
mtu=1300
activate_edge_workarounds=0
edge_ping_time=10
edge_bw=10
[sip]
contact="Linphone iPhone" <sip:linphone.iphone@unknown-host>
keepalive_period=30000
sip_port=-1
sip_tcp_port=-1
use_ipv6=0
inc_timeout=45
use_info=0
guess_hostname=1
register_only_when_network_is_up=1
auto_net_state_mon=0
keepalive_period=30000
ping_with_options=0
rtcp_xr_enabled=1
rtcp_xr_rcvr_rtt_mode=all
rtcp_xr_rcvr_rtt_max_size=10000
rtcp_xr_stat_summary_enabled=1
rtcp_xr_voip_metrics_enabled=1
[rtp]
audio_rtp_port=7200-7299
video_rtp_port=9200-9299
audio_jitt_comp=60
video_jitt_comp=60
nortp_timeout=30
[video]
display=1
capture=1
show_local=1
enabled=1
size=vga
automatically_initiate=0
automatically_accept=0
[net]
download_bw=512
upload_bw=512
firewall_policy=ice
stun_server=stun.linphone.org
[sound]
playback_dev_id=AU: Audio Unit Receiver
capture_dev_id=AU: Audio Unit Receiver
eq_active=0
[app]
preview_preference=1
animations_preference=1
edge_opt_preference=0
start_at_boot_preference=1
backgroundmode_preference=1
autoanswer_notif_preference=1
voiceproc_preference=1
backgroundmode_preference=1
edge_opt_preference=0
enable_log_collect=0
file_transfer_migration_done=1
pushnotification_preference=1
ice_preference=1
stun_preference=stun.linphone.org
preview_preference=1
random_port_preference=1
start_at_boot_preference=1
stun_preference=stun.linphone.org
voiceproc_preference=1
[default_values]
reg_expires=1314000
[misc]
max_calls=3
file_transfer_server_url=https://www.linphone.org:444/lft.php
max_calls=3
[net]
download_bw=512
edge_bw=10
edge_ping_time=10
firewall_policy=ice
mtu=1300
stun_server=stun.linphone.org
upload_bw=512
[rtp]
audio_jitt_comp=60
audio_rtp_port=7200-7299
nortp_timeout=30
video_jitt_comp=60
video_rtp_port=9200-9299
[sip]
auto_net_state_mon=0
contact="Linphone iPhone" <sip:linphone.iphone@unknown-host>
guess_hostname=1
inc_timeout=45
keepalive_period=30000
ping_with_options=0
register_only_when_network_is_up=1
rtcp_xr_enabled=1
rtcp_xr_rcvr_rtt_max_size=10000
rtcp_xr_rcvr_rtt_mode=all
rtcp_xr_stat_summary_enabled=1
rtcp_xr_voip_metrics_enabled=1
sip_port=-1
sip_tcp_port=-1
use_info=0
use_ipv6=0
[sound]
capture_dev_id=AU: Audio Unit Receiver
eq_active=0
playback_dev_id=AU: Audio Unit Receiver
[video]
automatically_accept=0
automatically_initiate=0
capture=1
display=1
enabled=1
show_local=1
size=vga

View file

@ -24,6 +24,16 @@
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Title</key>
<string>Push Notification</string>
<key>Key</key>
<string>account_pushnotification_preference</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>

View file

@ -136,16 +136,6 @@
<string>DTLS</string>
</array>
</dict>
<dict>
<key>Title</key>
<string>Push Notification</string>
<key>Key</key>
<string>pushnotification_preference</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Key</key>
<string>network_limit_group</string>

@ -1 +1 @@
Subproject commit 0b69dbaa216cf5e6b6160da4f990345cf34f37f3
Subproject commit b105e0b38b340ca4cd29f0c72263950add70aca6