Replace all proxy configs with account, and include the new push notification features from the 5.0 SDK

This commit is contained in:
QuentinArguillere 2021-04-30 09:27:18 +02:00
parent a1e3989d0a
commit 7ea46b5aab
27 changed files with 560 additions and 617 deletions

View file

@ -67,23 +67,24 @@
linphone_account_creator_cbs_set_activate_alias(linphone_account_creator_get_callbacks(account_creator), linphone_account_creator_cbs_set_activate_alias(linphone_account_creator_get_callbacks(account_creator),
assistant_activate_phone_number_link); assistant_activate_phone_number_link);
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *acc = linphone_core_get_default_account(LC);
if (cfg && LinphoneAccountParams const *accParams = linphone_account_get_params(acc);
if (acc &&
strcmp([LinphoneManager.instance lpConfigStringForKey:@"domain_name" strcmp([LinphoneManager.instance lpConfigStringForKey:@"domain_name"
inSection:@"app" inSection:@"app"
withDefault:@"sip.linphone.org"] withDefault:@"sip.linphone.org"]
.UTF8String, .UTF8String,
linphone_proxy_config_get_domain(cfg)) == 0) { linphone_account_params_get_domain(accParams)) == 0) {
linphone_account_creator_set_username( linphone_account_creator_set_username(
account_creator, linphone_address_get_username(linphone_proxy_config_get_identity_address(cfg))); account_creator, linphone_address_get_username(linphone_account_params_get_identity_address(accParams)));
const LinphoneAuthInfo *info = linphone_proxy_config_find_auth_info(cfg); const LinphoneAuthInfo *info = linphone_account_find_auth_info(acc);
if (info) { if (info) {
if (linphone_auth_info_get_passwd(info)) if (linphone_auth_info_get_passwd(info))
linphone_account_creator_set_password(account_creator, linphone_auth_info_get_passwd(info)); linphone_account_creator_set_password(account_creator, linphone_auth_info_get_passwd(info));
else else
linphone_account_creator_set_ha1(account_creator, linphone_auth_info_get_ha1(info)); linphone_account_creator_set_ha1(account_creator, linphone_auth_info_get_ha1(info));
} }
linphone_account_creator_set_domain(account_creator, linphone_proxy_config_get_domain(cfg)); linphone_account_creator_set_domain(account_creator, linphone_account_params_get_domain(accParams));
} else { } else {
LOGW(@"Default proxy is NOT a sip.linphone.org, aborting"); LOGW(@"Default proxy is NOT a sip.linphone.org, aborting");
[PhoneMainView.instance popToView:DialerView.compositeViewDescription]; [PhoneMainView.instance popToView:DialerView.compositeViewDescription];
@ -215,12 +216,14 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph
if (status == LinphoneAccountCreatorStatusAccountActivated) { if (status == LinphoneAccountCreatorStatusAccountActivated) {
[LinphoneManager.instance lpConfigSetInt:0 forKey:@"must_link_account_time"]; [LinphoneManager.instance lpConfigSetInt:0 forKey:@"must_link_account_time"];
// save country code prefix if none is already entered // save country code prefix if none is already entered
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *acc = linphone_core_get_default_account(LC);
if (linphone_proxy_config_get_dial_prefix(cfg) == NULL) { LinphoneAccountParams const *accParams = linphone_account_get_params(acc);
if (linphone_account_params_get_international_prefix(accParams) == NULL) {
const char *prefix = thiz.countryCodeField.text.UTF8String; const char *prefix = thiz.countryCodeField.text.UTF8String;
linphone_proxy_config_edit(cfg); LinphoneAccountParams * newPrefixAccountParams = linphone_account_params_clone(accParams);
linphone_proxy_config_set_dial_prefix(cfg, prefix[0] == '+' ? &prefix[1] : prefix); linphone_account_params_set_international_prefix(newPrefixAccountParams, prefix[0] == '+' ? &prefix[1] : prefix);
linphone_proxy_config_done(cfg); linphone_account_set_params(acc, newPrefixAccountParams);
linphone_account_params_unref(newPrefixAccountParams);
} }
[PhoneMainView.instance popToView:DialerView.compositeViewDescription]; [PhoneMainView.instance popToView:DialerView.compositeViewDescription];
[[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneAddressBookUpdate object:NULL]; [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneAddressBookUpdate object:NULL];

View file

@ -29,8 +29,8 @@
UIView *currentView; UIView *currentView;
UIView *nextView; UIView *nextView;
NSMutableArray *historyViews; NSMutableArray *historyViews;
LinphoneProxyConfig *new_config; LinphoneAccount *new_account;
size_t number_of_configs_before; size_t number_of_accounts_before;
BOOL mustRestoreView; BOOL mustRestoreView;
long phone_number_length; long phone_number_length;
BOOL acceptTerms; BOOL acceptTerms;

View file

@ -111,8 +111,8 @@ static UICompositeViewDescription *compositeDescription = nil;
} }
if (!mustRestoreView) { if (!mustRestoreView) {
new_config = NULL; new_account = NULL;
number_of_configs_before = bctbx_list_size(linphone_core_get_proxy_config_list(LC)); number_of_accounts_before = bctbx_list_size(linphone_core_get_account_list(LC));
[self resetTextFields]; [self resetTextFields];
[self changeView:_welcomeView back:FALSE animation:FALSE]; [self changeView:_welcomeView back:FALSE animation:FALSE];
} }
@ -437,18 +437,91 @@ static UICompositeViewDescription *compositeDescription = nil;
} }
// remove previous proxy config, if any // remove previous proxy config, if any
if (new_config != NULL) { if (new_account != NULL) {
const LinphoneAuthInfo *auth = linphone_proxy_config_find_auth_info(new_config); const LinphoneAuthInfo *auth = linphone_account_find_auth_info(new_account);
linphone_core_remove_proxy_config(LC, new_config); linphone_core_remove_account(LC, new_account);
if (auth) { if (auth) {
linphone_core_remove_auth_info(LC, auth); linphone_core_remove_auth_info(LC, auth);
} }
} }
new_config = linphone_account_creator_create_proxy_config(account_creator); // Used to be linphone_account_creator_create_proxy_config, which is now deprecated and has no "account" equivalent since linphone_account_creator_create_account is a very different function.
/** start of linphone_account_creator_create_proxy_config re-implementation for accounts **/
LinphoneAuthInfo *info;
LinphoneAccountParams *accountParams = linphone_core_create_account_params(LC);
char *identity_str = _get_identity(account_creator);
LinphoneAddress *identity = linphone_address_new(identity_str);
if (new_config) { ms_free(identity_str);
[lm configurePushTokenForProxyConfig:new_config]; char const *creatorDisplayName = linphone_account_creator_get_display_name(account_creator);
linphone_core_set_default_proxy_config(LC, new_config); if (creatorDisplayName) {
linphone_address_set_display_name(identity, creatorDisplayName);
}
linphone_account_params_set_identity_address(accountParams, identity);
if (linphone_account_creator_get_phone_country_code(account_creator)) {
linphone_account_params_set_international_prefix(accountParams, linphone_account_creator_get_phone_country_code(account_creator));
} else if (linphone_account_creator_get_phone_number(account_creator)) {
int dial_prefix_number = linphone_dial_plan_lookup_ccc_from_e164(linphone_account_creator_get_phone_number(account_creator));
char buff[4];
snprintf(buff, sizeof(buff), "%d", dial_prefix_number);
linphone_account_params_set_international_prefix(accountParams, buff);
}
char const* creatorDomain = linphone_account_creator_get_domain(account_creator);
if (linphone_account_params_get_server_addr(accountParams) == NULL && creatorDomain != NULL) {
char *url = ms_strdup_printf("sip:%s", creatorDomain);
LinphoneAddress *proxy_addr = linphone_address_new(url);
if (proxy_addr) {
linphone_address_set_transport(proxy_addr, linphone_account_creator_get_transport(account_creator));
linphone_account_params_set_server_addr(accountParams, linphone_address_as_string_uri_only(proxy_addr));
linphone_address_unref(proxy_addr);
} else {
linphone_account_params_set_server_addr(accountParams, creatorDomain);
}
ms_free(url);
}
linphone_account_params_set_register_enabled(accountParams, TRUE);
const char* creatorPassword = linphone_account_creator_get_password(account_creator);
const char* creatorHa1 = linphone_account_creator_get_ha1(account_creator);
info = linphone_auth_info_new_for_algorithm(linphone_address_get_username(identity), // username
NULL, //user id
creatorPassword, // passwd
creatorPassword ? NULL : creatorHa1, // ha1
!creatorPassword && creatorHa1 ? linphone_address_get_domain(identity) : NULL, // realm - assumed to be domain
linphone_address_get_domain(identity), // domain
creatorPassword ? NULL : linphone_account_creator_get_algorithm(account_creator) //if clear text password is given, allow its usage with all algorithms.
);
linphone_core_add_auth_info(LC, info);
linphone_address_unref(identity);
new_account = linphone_core_create_account(LC, accountParams);
linphone_account_params_unref(accountParams);
if (linphone_core_add_account(LC, new_account) != -1) {
if (linphone_account_creator_get_set_as_default(account_creator)) {
linphone_core_set_default_account(LC, new_account);
}
}
else {
linphone_core_remove_auth_info(LC, info);
linphone_auth_info_unref(info);
new_account = NULL;
}
/** end of linphone_account_creator_create_proxy_config re-implementation for accounts **/
if (new_account) {
LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(new_account));
LinphonePushNotificationConfig *pushConfig = linphone_account_params_get_push_notification_config(newAccountParams);
#ifdef DEBUG
#define PROVIDER_NAME "apns.dev"
#else
#define PROVIDER_NAME "apns"
#endif
linphone_push_notification_config_set_provider(pushConfig, PROVIDER_NAME);
linphone_account_set_params(new_account, newAccountParams);
linphone_account_params_unref(newAccountParams);
linphone_core_set_default_account(LC, new_account);
// reload address book to prepend proxy config domain to contacts' phone number // reload address book to prepend proxy config domain to contacts' phone number
// todo: STOP doing that! // todo: STOP doing that!
[[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread]; [[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread];
@ -612,8 +685,9 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)fillDefaultValues { - (void)fillDefaultValues {
[self resetTextFields]; [self resetTextFields];
LinphoneProxyConfig *default_conf = linphone_core_create_proxy_config(LC); LinphoneAccountParams *default_account_params = linphone_core_create_account_params(LC);
const char *identity = linphone_proxy_config_get_identity(default_conf); LinphoneAccount *default_account = linphone_core_create_account(LC, default_account_params);
const char *identity = linphone_account_params_get_identity(linphone_account_get_params(default_account));
if (identity) { if (identity) {
LinphoneAddress *default_addr = linphone_core_interpret_url(LC, identity); LinphoneAddress *default_addr = linphone_core_interpret_url(LC, identity);
if (default_addr) { if (default_addr) {
@ -630,7 +704,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[self changeView:_remoteProvisioningLoginView back:FALSE animation:TRUE]; [self changeView:_remoteProvisioningLoginView back:FALSE animation:TRUE];
linphone_proxy_config_unref(default_conf); linphone_account_params_unref(default_account_params);
} }
- (void)resetTextFields { - (void)resetTextFields {
@ -854,15 +928,15 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)registrationUpdateEvent:(NSNotification *)notif { - (void)registrationUpdateEvent:(NSNotification *)notif {
NSString *message = [notif.userInfo objectForKey:@"message"]; NSString *message = [notif.userInfo objectForKey:@"message"];
[self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue] [self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue]
forProxy:[[notif.userInfo objectForKeyedSubscript:@"cfg"] pointerValue] forAccount:[[notif.userInfo objectForKeyedSubscript:@"account"] pointerValue]
message:message]; message:message];
} }
- (void)registrationUpdate:(LinphoneRegistrationState)state - (void)registrationUpdate:(LinphoneRegistrationState)state
forProxy:(LinphoneProxyConfig *)proxy forAccount:(LinphoneAccount *)account
message:(NSString *)message { message:(NSString *)message {
// in assistant we only care about ourself // in assistant we only care about ourself
if (proxy != new_config) { if (account != new_account) {
return; return;
} }
@ -920,7 +994,7 @@ static UICompositeViewDescription *compositeDescription = nil;
// we successfully loaded a remote provisioned config, go to dialer // we successfully loaded a remote provisioned config, go to dialer
[LinphoneManager.instance lpConfigSetInt:[NSDate new].timeIntervalSince1970 [LinphoneManager.instance lpConfigSetInt:[NSDate new].timeIntervalSince1970
forKey:@"must_link_account_time"]; forKey:@"must_link_account_time"];
if (number_of_configs_before < bctbx_list_size(linphone_core_get_proxy_config_list(LC))) { if (number_of_accounts_before < bctbx_list_size(linphone_core_get_account_list(LC))) {
LOGI(@"A proxy config was set up with the remote provisioning, skip assistant"); LOGI(@"A proxy config was set up with the remote provisioning, skip assistant");
[self onDialerClick:nil]; [self onDialerClick:nil];
} }
@ -1404,7 +1478,7 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun
NSString *username = [self findTextField:ViewElement_Username].text; NSString *username = [self findTextField:ViewElement_Username].text;
NSString *displayName = [self findTextField:ViewElement_DisplayName].text; NSString *displayName = [self findTextField:ViewElement_DisplayName].text;
NSString *pwd = [self findTextField:ViewElement_Password].text; NSString *pwd = [self findTextField:ViewElement_Password].text;
LinphoneProxyConfig *config = linphone_core_create_proxy_config(LC); LinphoneAccountParams *accountParams = linphone_core_create_account_params(LC);
LinphoneAddress *addr = linphone_address_new(NULL); LinphoneAddress *addr = linphone_address_new(NULL);
LinphoneAddress *tmpAddr = linphone_address_new([NSString stringWithFormat:@"sip:%@",domain].UTF8String); LinphoneAddress *tmpAddr = linphone_address_new([NSString stringWithFormat:@"sip:%@",domain].UTF8String);
if (tmpAddr == nil) { if (tmpAddr == nil) {
@ -1418,26 +1492,23 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun
if (displayName && ![displayName isEqualToString:@""]) { if (displayName && ![displayName isEqualToString:@""]) {
linphone_address_set_display_name(addr, displayName.UTF8String); linphone_address_set_display_name(addr, displayName.UTF8String);
} }
linphone_proxy_config_set_identity_address(config, addr);
linphone_account_params_set_identity_address(accountParams, addr);
// set transport // set transport
UISegmentedControl *transports = (UISegmentedControl *)[self findView:ViewElement_Transport UISegmentedControl *transports = (UISegmentedControl *)[self findView:ViewElement_Transport
inView:self.contentView inView:self.contentView
ofType:UISegmentedControl.class]; ofType:UISegmentedControl.class];
if (transports) { if (transports) {
NSString *type = [transports titleForSegmentAtIndex:[transports selectedSegmentIndex]]; NSString *type = [transports titleForSegmentAtIndex:[transports selectedSegmentIndex]];
linphone_proxy_config_set_route( LinphoneAddress *transportAddr = linphone_address_new([NSString stringWithFormat:@"sip:%s;transport=%s", domain.UTF8String, type.lowercaseString.UTF8String].UTF8String);
config, linphone_account_params_set_routes_addresses(accountParams, bctbx_list_new(transportAddr));
[NSString stringWithFormat:@"%s;transport=%s", domain.UTF8String, type.lowercaseString.UTF8String] linphone_account_params_set_server_addr(accountParams, [NSString stringWithFormat:@"%s;transport=%s", domain.UTF8String, type.lowercaseString.UTF8String].UTF8String);
.UTF8String);
linphone_proxy_config_set_server_addr( linphone_address_unref(transportAddr);
config,
[NSString stringWithFormat:@"%s;transport=%s", domain.UTF8String, type.lowercaseString.UTF8String]
.UTF8String);
} }
linphone_account_params_set_publish_enabled(accountParams, FALSE);
linphone_proxy_config_enable_publish(config, FALSE); linphone_account_params_set_register_enabled(accountParams, TRUE);
linphone_proxy_config_enable_register(config, TRUE);
LinphoneAuthInfo *info = LinphoneAuthInfo *info =
linphone_auth_info_new(linphone_address_get_username(addr), // username linphone_auth_info_new(linphone_address_get_username(addr), // username
NULL, // user id NULL, // user id
@ -1449,11 +1520,12 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun
linphone_core_add_auth_info(LC, info); linphone_core_add_auth_info(LC, info);
linphone_address_unref(addr); linphone_address_unref(addr);
linphone_address_unref(tmpAddr); linphone_address_unref(tmpAddr);
if (config) { LinphoneAccount *account = linphone_core_create_account(LC, accountParams);
[[LinphoneManager instance] configurePushTokenForProxyConfig:config]; linphone_account_params_unref(accountParams);
if (linphone_core_add_proxy_config(LC, config) != -1) { if (account) {
linphone_core_set_default_proxy_config(LC, config); if (linphone_core_add_account(LC, account) != -1) {
linphone_core_set_default_account(LC, account);
// reload address book to prepend proxy config domain to contacts' phone number // reload address book to prepend proxy config domain to contacts' phone number
// todo: STOP doing that! // todo: STOP doing that!
[[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread]; [[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread];
@ -1477,7 +1549,7 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun
- (IBAction)onRemoteProvisioningDownloadClick:(id)sender { - (IBAction)onRemoteProvisioningDownloadClick:(id)sender {
ONNEWCLICKBUTTON(sender, 100, { ONNEWCLICKBUTTON(sender, 100, {
if (number_of_configs_before > 0) { if (number_of_accounts_before > 0) {
// TODO remove ME when it is fixed in SDK. // TODO remove ME when it is fixed in SDK.
linphone_core_set_provisioning_uri(LC, NULL); linphone_core_set_provisioning_uri(LC, NULL);
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Provisioning Load error", nil) UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Provisioning Load error", nil)

View file

@ -188,12 +188,6 @@ import AVFoundation
@objc func displayIncomingCall(callId: String) { @objc func displayIncomingCall(callId: String) {
let uuid = CallManager.instance().providerDelegate.uuids["\(callId)"] let uuid = CallManager.instance().providerDelegate.uuids["\(callId)"]
if (uuid != nil) { if (uuid != nil) {
let callInfo = providerDelegate.callInfos[uuid!]
if (callInfo?.declined ?? false) {
// This call was declined.
providerDelegate.reportIncomingCall(call:nil, uuid: uuid!, handle: "Calling", hasVideo: true, displayName: callInfo?.displayName ?? "Calling")
providerDelegate.endCall(uuid: uuid!)
}
return return
} }
@ -378,7 +372,6 @@ import AVFoundation
let uuid = UUID() let uuid = UUID()
providerDelegate.uuids.updateValue(uuid, forKey: callId) providerDelegate.uuids.updateValue(uuid, forKey: callId)
let callInfo = CallInfo.newIncomingCallInfo(callId: callId) let callInfo = CallInfo.newIncomingCallInfo(callId: callId)
callInfo.declined = true
callInfo.reason = Reason.Busy callInfo.reason = Reason.Busy
providerDelegate.callInfos.updateValue(callInfo, forKey: uuid) providerDelegate.callInfos.updateValue(callInfo, forKey: uuid)
} else { } else {
@ -461,166 +454,162 @@ import AVFoundation
} }
func onCallStateChanged(core: Core, call: Call, state cstate: Call.State, message: String) { func onCallStateChanged(core: Core, call: Call, state cstate: Call.State, message: String) {
let addr = call.remoteAddress;
let displayName = FastAddressBook.displayName(for: addr?.getCobject) ?? "Unknow"
let callLog = call.callLog let callLog = call.callLog
let callId = callLog?.callId let callId = callLog?.callId
let video = UIApplication.shared.applicationState == .active && (core.videoActivationPolicy?.automaticallyAccept ?? false) && (call.remoteParams?.videoEnabled ?? false) if (cstate == .PushIncomingReceived) {
// we keep the speaker auto-enabled state in this static so that we don't displayIncomingCall(call: call, handle: "Calling", hasVideo: false, callId: callId!, displayName: "Calling")
// force-enable it on ICE re-invite if the user disabled it. } else {
CallManager.speaker_already_enabled = false let addr = call.remoteAddress;
let displayName = FastAddressBook.displayName(for: addr?.getCobject) ?? "Unknow"
let video = UIApplication.shared.applicationState == .active && (core.videoActivationPolicy?.automaticallyAccept ?? false) && (call.remoteParams?.videoEnabled ?? false)
// we keep the speaker auto-enabled state in this static so that we don't
// force-enable it on ICE re-invite if the user disabled it.
CallManager.speaker_already_enabled = false
if (call.userData == nil) { if (call.userData == nil) {
let appData = CallAppData() let appData = CallAppData()
CallManager.setAppData(sCall: call, appData: appData) CallManager.setAppData(sCall: call, appData: appData)
} }
switch cstate { switch cstate {
case .IncomingReceived: case .IncomingReceived:
if (CallManager.callKitEnabled()) { if (CallManager.callKitEnabled()) {
let uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"] let uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
if (uuid != nil) { if (uuid != nil) {
// Tha app is now registered, updated the call already existed. // Tha app is now registered, updated the call already existed.
CallManager.instance().providerDelegate.updateCall(uuid: uuid!, handle: addr!.asStringUriOnly(), hasVideo: video, displayName: displayName) CallManager.instance().providerDelegate.updateCall(uuid: uuid!, handle: addr!.asStringUriOnly(), hasVideo: video, displayName: displayName)
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!] } else {
if (callInfo?.declined ?? false) { CallManager.instance().displayIncomingCall(call: call, handle: addr!.asStringUriOnly(), hasVideo: video, callId: callId!, displayName: displayName)
DispatchQueue.main.asyncAfter(deadline: .now()) {try? call.decline(reason: callInfo!.reason)}
} else if (callInfo?.accepted ?? false) {
// The call is already answered.
CallManager.instance().acceptCall(call: call, hasVideo: video)
} }
} else { } else if (UIApplication.shared.applicationState != .active) {
CallManager.instance().displayIncomingCall(call: call, handle: addr!.asStringUriOnly(), hasVideo: video, callId: callId!, displayName: displayName) // not support callkit , use notif
let content = UNMutableNotificationContent()
content.title = NSLocalizedString("Incoming call", comment: "")
content.body = displayName
content.sound = UNNotificationSound.init(named: UNNotificationSoundName.init("notes_of_the_optimistic.caf"))
content.categoryIdentifier = "call_cat"
content.userInfo = ["CallId" : callId!]
let req = UNNotificationRequest.init(identifier: "call_request", content: content, trigger: nil)
UNUserNotificationCenter.current().add(req, withCompletionHandler: nil)
} }
} else if (UIApplication.shared.applicationState != .active) { break
// not support callkit , use notif case .StreamsRunning:
let content = UNMutableNotificationContent() if (CallManager.callKitEnabled()) {
content.title = NSLocalizedString("Incoming call", comment: "") let uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
content.body = displayName if (uuid != nil) {
content.sound = UNNotificationSound.init(named: UNNotificationSoundName.init("notes_of_the_optimistic.caf")) let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!]
content.categoryIdentifier = "call_cat" if (callInfo != nil && callInfo!.isOutgoing && !callInfo!.connected) {
content.userInfo = ["CallId" : callId!] Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: outgoing call connected with uuid \(uuid!) and callId \(callId!)")
let req = UNNotificationRequest.init(identifier: "call_request", content: content, trigger: nil) CallManager.instance().providerDelegate.reportOutgoingCallConnected(uuid: uuid!)
UNUserNotificationCenter.current().add(req, withCompletionHandler: nil) callInfo!.connected = true
} CallManager.instance().providerDelegate.callInfos.updateValue(callInfo!, forKey: uuid!)
break }
case .StreamsRunning: }
if (CallManager.callKitEnabled()) { }
let uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
if (uuid != nil) { if (CallManager.instance().speakerBeforePause) {
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!] CallManager.instance().speakerBeforePause = false
if (callInfo != nil && callInfo!.isOutgoing && !callInfo!.connected) { CallManager.instance().enableSpeaker(enable: true)
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: outgoing call connected with uuid \(uuid!) and callId \(callId!)") CallManager.speaker_already_enabled = true
CallManager.instance().providerDelegate.reportOutgoingCallConnected(uuid: uuid!) }
callInfo!.connected = true break
case .OutgoingInit,
.OutgoingProgress,
.OutgoingRinging,
.OutgoingEarlyMedia:
if (CallManager.callKitEnabled()) {
let uuid = CallManager.instance().providerDelegate.uuids[""]
if (uuid != nil) {
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!]
callInfo!.callId = callId!
CallManager.instance().providerDelegate.callInfos.updateValue(callInfo!, forKey: uuid!) CallManager.instance().providerDelegate.callInfos.updateValue(callInfo!, forKey: uuid!)
CallManager.instance().providerDelegate.uuids.removeValue(forKey: "")
CallManager.instance().providerDelegate.uuids.updateValue(uuid!, forKey: callId!)
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: outgoing call started connecting with uuid \(uuid!) and callId \(callId!)")
CallManager.instance().providerDelegate.reportOutgoingCallStartedConnecting(uuid: uuid!)
} else {
CallManager.instance().referedToCall = callId
} }
} }
} break
case .End,
.Error:
UIDevice.current.isProximityMonitoringEnabled = false
CallManager.speaker_already_enabled = false
if (CallManager.instance().lc!.callsNb == 0) {
CallManager.instance().enableSpeaker(enable: false)
// disable this because I don't find anygood reason for it: _bluetoothAvailable = FALSE;
// furthermore it introduces a bug when calling multiple times since route may not be
// reconfigured between cause leading to bluetooth being disabled while it should not
CallManager.instance().bluetoothEnabled = false
}
if (CallManager.instance().speakerBeforePause) { if UIApplication.shared.applicationState != .active && (callLog == nil || callLog?.status == .Missed || callLog?.status == .Aborted || callLog?.status == .EarlyAborted) {
CallManager.instance().speakerBeforePause = false // Configure the notification's payload.
let content = UNMutableNotificationContent()
content.title = NSString.localizedUserNotificationString(forKey: NSLocalizedString("Missed call", comment: ""), arguments: nil)
content.body = NSString.localizedUserNotificationString(forKey: displayName, arguments: nil)
// Deliver the notification.
let request = UNNotificationRequest(identifier: "call_request", content: content, trigger: nil) // Schedule the notification.
let center = UNUserNotificationCenter.current()
center.add(request) { (error : Error?) in
if error != nil {
Log.directLog(BCTBX_LOG_ERROR, text: "Error while adding notification request : \(error!.localizedDescription)")
}
}
}
if (CallManager.callKitEnabled()) {
var uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
if (callId == CallManager.instance().referedToCall) {
// refered call ended before connecting
Log.directLog(BCTBX_LOG_MESSAGE, text: "Callkit: end refered to call : \(String(describing: CallManager.instance().referedToCall))")
CallManager.instance().referedFromCall = nil
CallManager.instance().referedToCall = nil
}
if uuid == nil {
// the call not yet connected
uuid = CallManager.instance().providerDelegate.uuids[""]
}
if (uuid != nil) {
if (callId == CallManager.instance().referedFromCall) {
Log.directLog(BCTBX_LOG_MESSAGE, text: "Callkit: end refered from call : \(String(describing: CallManager.instance().referedFromCall))")
CallManager.instance().referedFromCall = nil
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!]
callInfo!.callId = CallManager.instance().referedToCall ?? ""
CallManager.instance().providerDelegate.callInfos.updateValue(callInfo!, forKey: uuid!)
CallManager.instance().providerDelegate.uuids.removeValue(forKey: callId!)
CallManager.instance().providerDelegate.uuids.updateValue(uuid!, forKey: callInfo!.callId)
CallManager.instance().referedToCall = nil
break
}
let transaction = CXTransaction(action:
CXEndCallAction(call: uuid!))
CallManager.instance().requestTransaction(transaction, action: "endCall")
}
}
break
case .Released:
call.userData = nil
break
case .Referred:
CallManager.instance().referedFromCall = call.callLog?.callId
break
default:
break
}
if (cstate == .IncomingReceived || cstate == .OutgoingInit || cstate == .Connected || cstate == .StreamsRunning) {
if ((call.currentParams?.videoEnabled ?? false) && !CallManager.speaker_already_enabled && !CallManager.instance().bluetoothEnabled) {
CallManager.instance().enableSpeaker(enable: true) CallManager.instance().enableSpeaker(enable: true)
CallManager.speaker_already_enabled = true CallManager.speaker_already_enabled = true
} }
break
case .OutgoingInit,
.OutgoingProgress,
.OutgoingRinging,
.OutgoingEarlyMedia:
if (CallManager.callKitEnabled()) {
let uuid = CallManager.instance().providerDelegate.uuids[""]
if (uuid != nil) {
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!]
callInfo!.callId = callId!
CallManager.instance().providerDelegate.callInfos.updateValue(callInfo!, forKey: uuid!)
CallManager.instance().providerDelegate.uuids.removeValue(forKey: "")
CallManager.instance().providerDelegate.uuids.updateValue(uuid!, forKey: callId!)
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: outgoing call started connecting with uuid \(uuid!) and callId \(callId!)")
CallManager.instance().providerDelegate.reportOutgoingCallStartedConnecting(uuid: uuid!)
} else {
CallManager.instance().referedToCall = callId
}
}
break
case .End,
.Error:
UIDevice.current.isProximityMonitoringEnabled = false
CallManager.speaker_already_enabled = false
if (CallManager.instance().lc!.callsNb == 0) {
CallManager.instance().enableSpeaker(enable: false)
// disable this because I don't find anygood reason for it: _bluetoothAvailable = FALSE;
// furthermore it introduces a bug when calling multiple times since route may not be
// reconfigured between cause leading to bluetooth being disabled while it should not
CallManager.instance().bluetoothEnabled = false
}
if UIApplication.shared.applicationState != .active && (callLog == nil || callLog?.status == .Missed || callLog?.status == .Aborted || callLog?.status == .EarlyAborted) {
// Configure the notification's payload.
let content = UNMutableNotificationContent()
content.title = NSString.localizedUserNotificationString(forKey: NSLocalizedString("Missed call", comment: ""), arguments: nil)
content.body = NSString.localizedUserNotificationString(forKey: displayName, arguments: nil)
// Deliver the notification.
let request = UNNotificationRequest(identifier: "call_request", content: content, trigger: nil) // Schedule the notification.
let center = UNUserNotificationCenter.current()
center.add(request) { (error : Error?) in
if error != nil {
Log.directLog(BCTBX_LOG_ERROR, text: "Error while adding notification request : \(error!.localizedDescription)")
}
}
}
if (CallManager.callKitEnabled()) {
var uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
if (callId == CallManager.instance().referedToCall) {
// refered call ended before connecting
Log.directLog(BCTBX_LOG_MESSAGE, text: "Callkit: end refered to call : \(String(describing: CallManager.instance().referedToCall))")
CallManager.instance().referedFromCall = nil
CallManager.instance().referedToCall = nil
}
if uuid == nil {
// the call not yet connected
uuid = CallManager.instance().providerDelegate.uuids[""]
}
if (uuid != nil) {
if (callId == CallManager.instance().referedFromCall) {
Log.directLog(BCTBX_LOG_MESSAGE, text: "Callkit: end refered from call : \(String(describing: CallManager.instance().referedFromCall))")
CallManager.instance().referedFromCall = nil
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!]
callInfo!.callId = CallManager.instance().referedToCall ?? ""
CallManager.instance().providerDelegate.callInfos.updateValue(callInfo!, forKey: uuid!)
CallManager.instance().providerDelegate.uuids.removeValue(forKey: callId!)
CallManager.instance().providerDelegate.uuids.updateValue(uuid!, forKey: callInfo!.callId)
CallManager.instance().referedToCall = nil
break
}
let transaction = CXTransaction(action:
CXEndCallAction(call: uuid!))
CallManager.instance().requestTransaction(transaction, action: "endCall")
}
}
break
case .Released:
call.userData = nil
break
case .Referred:
CallManager.instance().referedFromCall = call.callLog?.callId
break
default:
break
}
if (cstate == .IncomingReceived || cstate == .OutgoingInit || cstate == .Connected || cstate == .StreamsRunning) {
if ((call.currentParams?.videoEnabled ?? false) && !CallManager.speaker_already_enabled && !CallManager.instance().bluetoothEnabled) {
CallManager.instance().enableSpeaker(enable: true)
CallManager.speaker_already_enabled = true
} }
} }
// post Notification kLinphoneCallUpdate // post Notification kLinphoneCallUpdate
NotificationCenter.default.post(name: Notification.Name("LinphoneCallUpdate"), object: self, userInfo: [ NotificationCenter.default.post(name: Notification.Name("LinphoneCallUpdate"), object: self, userInfo: [
AnyHashable("call"): NSValue.init(pointer:UnsafeRawPointer(call.getCobject)), AnyHashable("call"): NSValue.init(pointer:UnsafeRawPointer(call.getCobject)),

View file

@ -106,15 +106,15 @@
continue; continue;
} }
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
if (cfg) { if (account) {
const char *normalizedPhoneNumber = linphone_proxy_config_normalize_phone_number(cfg, phoneNumber); const char *normalizedPhoneNumber = linphone_account_normalize_phone_number(account, phoneNumber);
if (!normalizedPhoneNumber) { if (!normalizedPhoneNumber) {
// get invalid phone number, continue // get invalid phone number, continue
results = results->next; results = results->next;
continue; continue;
} }
addr = linphone_proxy_config_normalize_sip_uri(cfg, normalizedPhoneNumber); addr = linphone_account_normalize_sip_uri(account, normalizedPhoneNumber);
uri = linphone_address_as_string_uri_only(addr); uri = linphone_address_as_string_uri_only(addr);
address = [NSString stringWithUTF8String:uri]; address = [NSString stringWithUTF8String:uri];
} }
@ -188,8 +188,8 @@
if (!cell.userInteractionEnabled) if (!cell.userInteractionEnabled)
return; return;
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
if (!(cfg && linphone_proxy_config_get_conference_factory_uri(cfg)) || !_isGroupChat) { if (!(defaultAccount && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(defaultAccount))) || !_isGroupChat) {
LinphoneAddress *addr = linphone_address_new(cell.addressLabel.text.UTF8String); LinphoneAddress *addr = linphone_address_new(cell.addressLabel.text.UTF8String);
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:_isEncrypted]; [PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:_isEncrypted];
if (!addr) { if (!addr) {

View file

@ -72,8 +72,8 @@ static UICompositeViewDescription *compositeDescription = nil;
selector:@selector(viewUpdateEvent:) selector:@selector(viewUpdateEvent:)
name:kLinphoneChatCreateViewChange name:kLinphoneChatCreateViewChange
object:nil]; object:nil];
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
_chiffreOptionView.hidden = !(cfg && linphone_proxy_config_get_conference_factory_uri(cfg)); _chiffreOptionView.hidden = !(defaultAccount && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(defaultAccount)));
if ([LinphoneManager.instance lpConfigBoolForKey:@"hide_linphone_contacts" inSection:@"app"]) { if ([LinphoneManager.instance lpConfigBoolForKey:@"hide_linphone_contacts" inSection:@"app"]) {
self.linphoneButton.hidden = TRUE; self.linphoneButton.hidden = TRUE;
self.selectedButtonImage.hidden = TRUE; self.selectedButtonImage.hidden = TRUE;

View file

@ -38,8 +38,8 @@
[_backToCallButton update]; [_backToCallButton update];
self.tableController.waitView = _waitView; self.tableController.waitView = _waitView;
[self setEditing:NO]; [self setEditing:NO];
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
_addGroupChatButton.hidden = !(cfg && linphone_proxy_config_get_conference_factory_uri(cfg)); _addGroupChatButton.hidden = !(defaultAccount && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(defaultAccount)));
[_toggleSelectionButton setImage:[UIImage imageNamed:@"select_all_default.png"] forState:UIControlStateSelected]; [_toggleSelectionButton setImage:[UIImage imageNamed:@"select_all_default.png"] forState:UIControlStateSelected];
// For testing crashlytics // For testing crashlytics

View file

@ -312,7 +312,7 @@ static UICompositeViewDescription *compositeDescription = nil;
UIAlertAction* remAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Remove account(s) and self destruct", nil) UIAlertAction* remAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Remove account(s) and self destruct", nil)
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) { handler:^(UIAlertAction * action) {
linphone_core_clear_proxy_config([LinphoneManager getLc]); linphone_core_clear_accounts([LinphoneManager getLc]);
linphone_core_clear_all_auth_info([LinphoneManager getLc]); linphone_core_clear_all_auth_info([LinphoneManager getLc]);
@try { @try {
[LinphoneManager.instance destroyLinphoneCore]; [LinphoneManager.instance destroyLinphoneCore];

View file

@ -69,11 +69,11 @@ static UICompositeViewDescription *compositeDescription = nil;
object:nil]; object:nil];
// Update on show // Update on show
const MSList *list = linphone_core_get_proxy_config_list([LinphoneManager getLc]); const MSList *list = linphone_core_get_account_list([LinphoneManager getLc]);
if (list != NULL) { if (list != NULL) {
LinphoneProxyConfig *config = (LinphoneProxyConfig *)list->data; LinphoneAccount *account = (LinphoneAccount *)list->data;
if (config) { if (account) {
[self registrationUpdate:linphone_proxy_config_get_state(config)]; [self registrationUpdate:linphone_account_get_state(account)];
} }
} }

View file

@ -148,8 +148,8 @@ static UICompositeViewDescription *compositeDescription = nil;
const LinphonePresenceModel *model = contact.friend ? linphone_friend_get_presence_model(contact.friend) : NULL; const LinphonePresenceModel *model = contact.friend ? linphone_friend_get_presence_model(contact.friend) : NULL;
_linphoneImage.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"hide_linphone_contacts" inSection:@"app"] || _linphoneImage.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"hide_linphone_contacts" inSection:@"app"] ||
! ((model && linphone_presence_model_get_basic_status(model) == LinphonePresenceBasicStatusOpen) || [FastAddressBook contactHasValidSipDomain:contact]); ! ((model && linphone_presence_model_get_basic_status(model) == LinphonePresenceBasicStatusOpen) || [FastAddressBook contactHasValidSipDomain:contact]);
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
[self shouldHideEncryptedChatView:cfg && linphone_proxy_config_get_conference_factory_uri(cfg) && model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityLimeX3dh)]; [self shouldHideEncryptedChatView:defaultAccount && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(defaultAccount)) && model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityLimeX3dh)];
char *addrURI = linphone_address_as_string_uri_only(addr); char *addrURI = linphone_address_as_string_uri_only(addr);
ms_free(addrURI); ms_free(addrURI);

View file

@ -288,9 +288,9 @@
- (NSString *)getPhoneNumber { - (NSString *)getPhoneNumber {
NSString *phoneNumber = @""; NSString *phoneNumber = @"";
LinphoneProxyConfig *config = linphone_core_get_default_proxy_config(LC); LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
if (config) { if (defaultAccount) {
const LinphoneAddress *identity = linphone_proxy_config_get_identity_address(config); const LinphoneAddress *identity = linphone_account_params_get_identity_address(linphone_account_get_params(defaultAccount));
if (identity) { if (identity) {
phoneNumber = [NSString stringWithUTF8String:linphone_address_get_username(identity)]; phoneNumber = [NSString stringWithUTF8String:linphone_address_get_username(identity)];
} }
@ -300,14 +300,14 @@
- (NSString *)getPassword { - (NSString *)getPassword {
NSString *pass; NSString *pass;
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
if (cfg && if (defaultAccount &&
strcmp([LinphoneManager.instance lpConfigStringForKey:@"domain_name" strcmp([LinphoneManager.instance lpConfigStringForKey:@"domain_name"
inSection:@"app" inSection:@"app"
withDefault:@"sip.linphone.org"] withDefault:@"sip.linphone.org"]
.UTF8String, .UTF8String,
linphone_proxy_config_get_domain(cfg)) == 0) { linphone_account_params_get_domain(linphone_account_get_params(defaultAccount))) == 0) {
const LinphoneAuthInfo *info = linphone_proxy_config_find_auth_info(cfg); const LinphoneAuthInfo *info = linphone_account_find_auth_info(defaultAccount);
const char *tmpPass; const char *tmpPass;
if (linphone_auth_info_get_passwd(info)) { if (linphone_auth_info_get_passwd(info)) {
tmpPass = linphone_auth_info_get_passwd(info); tmpPass = linphone_auth_info_get_passwd(info);

View file

@ -18,7 +18,6 @@
*/ */
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <PushKit/PushKit.h>
#import "LinphoneCoreSettingsStore.h" #import "LinphoneCoreSettingsStore.h"
#import <UserNotifications/UserNotifications.h> #import <UserNotifications/UserNotifications.h>
@ -27,19 +26,16 @@
#import "linphoneapp-Swift.h" #import "linphoneapp-Swift.h"
@interface LinphoneAppDelegate : NSObject <UIApplicationDelegate, PKPushRegistryDelegate, UNUserNotificationCenterDelegate, CLLocationManagerDelegate> { @interface LinphoneAppDelegate : NSObject <UIApplicationDelegate, UNUserNotificationCenterDelegate, CLLocationManagerDelegate> {
@private @private
UIBackgroundTaskIdentifier bgStartId; UIBackgroundTaskIdentifier bgStartId;
BOOL startedInBackground; BOOL startedInBackground;
CLLocationManager* locationManager; CLLocationManager* locationManager;
} }
- (void)registerForNotifications;
@property (nonatomic, retain) UIAlertController *waitingIndicator; @property (nonatomic, retain) UIAlertController *waitingIndicator;
@property (nonatomic, retain) NSString *configURL; @property (nonatomic, retain) NSString *configURL;
@property (nonatomic, strong) UIWindow* window; @property (nonatomic, strong) UIWindow* window;
@property PKPushRegistry* voipRegistry;
@property BOOL onlyPortrait; @property BOOL onlyPortrait;
@property UIApplicationShortcutItem *shortcutItem; @property UIApplicationShortcutItem *shortcutItem;

View file

@ -83,6 +83,7 @@
LOGI(@"%@", NSStringFromSelector(_cmd)); LOGI(@"%@", NSStringFromSelector(_cmd));
[LinphoneManager.instance startLinphoneCore]; [LinphoneManager.instance startLinphoneCore];
[LinphoneManager.instance.fastAddressBook reloadFriends]; [LinphoneManager.instance.fastAddressBook reloadFriends];
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil]; [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil];
} }
@ -168,18 +169,6 @@
return; return;
CallManager.instance.alreadyRegisteredForNotification = true; CallManager.instance.alreadyRegisteredForNotification = true;
self.voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
self.voipRegistry.delegate = self;
// Initiate registration.
LOGI(@"[PushKit] Connecting for push notifications");
self.voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
int num = [LinphoneManager.instance lpConfigIntForKey:@"unexpected_pushkit" withDefault:0];
if (num > 3) {
LOGI(@"[PushKit] unexpected pushkit notifications received %d, please clean your sip account.", num);
}
// Register for remote notifications. // Register for remote notifications.
LOGI(@"[APNs] register for push notif"); LOGI(@"[APNs] register for push notif");
[[UIApplication sharedApplication] registerForRemoteNotifications]; [[UIApplication sharedApplication] registerForRemoteNotifications];
@ -283,7 +272,7 @@
UIApplicationState state = app.applicationState; UIApplicationState state = app.applicationState;
LinphoneManager *instance = [LinphoneManager instance]; LinphoneManager *instance = [LinphoneManager instance];
//init logs asap //init logs asapt
[Log enableLogs:[[LinphoneManager instance] lpConfigIntForKey:@"debugenable_preference"]]; [Log enableLogs:[[LinphoneManager instance] lpConfigIntForKey:@"debugenable_preference"]];
@ -556,45 +545,6 @@
[LinphoneManager.instance setRemoteNotificationToken:nil]; [LinphoneManager.instance setRemoteNotificationToken:nil];
} }
#pragma mark - PushKit Functions
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(PKPushType)type {
LOGI(@"[PushKit] credentials updated with voip token: %@", credentials.token);
dispatch_async(dispatch_get_main_queue(), ^{
[LinphoneManager.instance setPushKitToken:credentials.token];
});
}
- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(NSString *)type {
LOGI(@"[PushKit] Token invalidated");
dispatch_async(dispatch_get_main_queue(), ^{[LinphoneManager.instance setPushKitToken:nil];});
}
- (void)processPush:(NSDictionary *)userInfo {
LOGI(@"[PushKit] Notification [%p] received with payload : %@", userInfo, userInfo.description);
// prevent app to crash if PushKit received for msg
if ([userInfo[@"aps"][@"loc-key"] isEqualToString:@"IM_MSG"]) {
LOGE(@"Received a legacy PushKit notification for a chat message");
[LinphoneManager.instance lpConfigSetInt:[LinphoneManager.instance lpConfigIntForKey:@"unexpected_pushkit" withDefault:0]+1 forKey:@"unexpected_pushkit"];
return;
}
[LinphoneManager.instance startLinphoneCore];
[self configureUINotification];
//to avoid IOS to suspend the app before being able to launch long running task
[self processRemoteNotification:userInfo];
}
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
[self processPush:payload.dictionaryPayload];
dispatch_async(dispatch_get_main_queue(), ^{completion();});
}
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
[self processPush:payload.dictionaryPayload];
}
#pragma mark - UNUserNotifications Framework #pragma mark - UNUserNotifications Framework
- (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { - (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {

View file

@ -140,13 +140,13 @@
} }
- (void)transformAccountToKeys:(NSString *)username { - (void)transformAccountToKeys:(NSString *)username {
const MSList *proxies = linphone_core_get_proxy_config_list(LC); const MSList *accountList = linphone_core_get_account_list(LC);
while (username && proxies && while (username && accountList &&
strcmp(username.UTF8String, strcmp(username.UTF8String,
linphone_address_get_username(linphone_proxy_config_get_identity_address(proxies->data))) != 0) { linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(accountList->data)))) != 0) {
proxies = proxies->next; accountList = accountList->next;
} }
LinphoneProxyConfig *proxy = NULL; LinphoneAccount *account = NULL;
// default values // default values
{ {
@ -171,15 +171,16 @@
[self setCString:"" forKey:@"account_stun_preference"]; [self setCString:"" forKey:@"account_stun_preference"];
} }
if (proxies) { if (accountList) {
proxy = proxies->data; account = accountList->data;
LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
// root section // root section
{ {
BOOL pushEnabled = linphone_proxy_config_is_push_notification_allowed(proxy); BOOL pushEnabled = linphone_account_params_get_push_notification_allowed(accountParams);
[self setBool:pushEnabled forKey:@"account_pushnotification_preference"]; [self setBool:pushEnabled forKey:@"account_pushnotification_preference"];
const LinphoneAddress *identity_addr = linphone_proxy_config_get_identity_address(proxy); const LinphoneAddress *identity_addr = linphone_account_params_get_identity_address(accountParams);
const char *server_addr = linphone_proxy_config_get_server_addr(proxy); const char *server_addr = linphone_account_params_get_server_addr(accountParams);
LinphoneAddress *proxy_addr = linphone_core_interpret_url(LC, server_addr); LinphoneAddress *proxy_addr = linphone_core_interpret_url(LC, server_addr);
if (identity_addr && proxy_addr) { if (identity_addr && proxy_addr) {
int port = linphone_address_get_port(proxy_addr); int port = linphone_address_get_port(proxy_addr);
@ -214,10 +215,10 @@
[self setCString:tname forKey:@"account_transport_preference"]; [self setCString:tname forKey:@"account_transport_preference"];
} }
[self setBool:(linphone_proxy_config_get_route(proxy) != NULL) forKey:@"account_outbound_proxy_preference"]; [self setBool:(linphone_account_params_get_routes_addresses(accountParams) != NULL) forKey:@"account_outbound_proxy_preference"];
[self setBool:linphone_proxy_config_avpf_enabled(proxy) forKey:@"account_avpf_preference"]; [self setBool:linphone_account_is_avpf_enabled(account) forKey:@"account_avpf_preference"];
[self setBool:linphone_proxy_config_register_enabled(proxy) forKey:@"account_is_enabled_preference"]; [self setBool:linphone_account_params_get_register_enabled(accountParams) forKey:@"account_is_enabled_preference"];
[self setBool:(linphone_core_get_default_proxy_config(LC) == proxy) [self setBool:(linphone_core_get_default_account(LC) == account)
forKey:@"account_is_default_preference"]; forKey:@"account_is_default_preference"];
const LinphoneAuthInfo *ai = linphone_core_find_auth_info( const LinphoneAuthInfo *ai = linphone_core_find_auth_info(
@ -230,13 +231,13 @@
[self setCString:linphone_auth_info_get_ha1(ai) forKey:@"ha1_preference"]; [self setCString:linphone_auth_info_get_ha1(ai) forKey:@"ha1_preference"];
} }
int idx = (int)bctbx_list_index(linphone_core_get_proxy_config_list(LC), proxy); int idx = (int)bctbx_list_index(linphone_core_get_account_list(LC), account);
[self setInteger:idx forKey:@"current_proxy_config_preference"]; [self setInteger:idx forKey:@"current_proxy_config_preference"];
int expires = linphone_proxy_config_get_expires(proxy); int expires = linphone_account_params_get_expires(accountParams);
[self setInteger:expires forKey:@"account_expire_preference"]; [self setInteger:expires forKey:@"account_expire_preference"];
LinphoneNatPolicy *policy = linphone_proxy_config_get_nat_policy(proxy); LinphoneNatPolicy *policy = linphone_account_params_get_nat_policy(accountParams);
if (policy) { if (policy) {
[self setBool:linphone_nat_policy_ice_enabled(policy) forKey:@"account_ice_preference"]; [self setBool:linphone_nat_policy_ice_enabled(policy) forKey:@"account_ice_preference"];
[self setCString:linphone_nat_policy_get_stun_server(policy) forKey:@"account_stun_preference"]; [self setCString:linphone_nat_policy_get_stun_server(policy) forKey:@"account_stun_preference"];
@ -245,9 +246,9 @@
// call section // call section
{ {
const char *dial_prefix = linphone_proxy_config_get_dial_prefix(proxy); const char *dial_prefix = linphone_account_params_get_international_prefix(accountParams);
[self setCString:dial_prefix forKey:@"account_prefix_preference"]; [self setCString:dial_prefix forKey:@"account_prefix_preference"];
BOOL dial_escape_plus = linphone_proxy_config_get_dial_escape_plus(proxy); BOOL dial_escape_plus = linphone_account_params_get_dial_escape_plus_enabled(accountParams);
[self setBool:dial_escape_plus forKey:@"account_substitute_+_by_00_preference"]; [self setBool:dial_escape_plus forKey:@"account_substitute_+_by_00_preference"];
} }
} }
@ -258,12 +259,12 @@
// root section // root section
{ {
const bctbx_list_t *accounts = linphone_core_get_proxy_config_list(LC); const bctbx_list_t *accounts = linphone_core_get_account_list(LC);
size_t count = bctbx_list_size(accounts); size_t count = bctbx_list_size(accounts);
for (size_t i = 1; i <= count; i++, accounts = accounts->next) { for (size_t i = 1; i <= count; i++, accounts = accounts->next) {
NSString *key = [NSString stringWithFormat:@"menu_account_%lu", i]; NSString *key = [NSString stringWithFormat:@"menu_account_%lu", i];
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)accounts->data; LinphoneAccount *account = (LinphoneAccount *)accounts->data;
[self setCString:linphone_address_get_username(linphone_proxy_config_get_identity_address(proxy)) [self setCString:linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(account)))
forKey:key]; forKey:key];
} }
@ -456,7 +457,8 @@
- (void)synchronizeAccounts { - (void)synchronizeAccounts {
LOGI(@"Account changed, synchronizing."); LOGI(@"Account changed, synchronizing.");
LinphoneManager *lm = LinphoneManager.instance; LinphoneManager *lm = LinphoneManager.instance;
LinphoneProxyConfig *proxyCfg = NULL; LinphoneAccount *account = NULL;
LinphoneAccountParams *newAccountParams = NULL;
NSString *error = nil; NSString *error = nil;
int port_preference = [self integerForKey:@"port_preference"]; int port_preference = [self integerForKey:@"port_preference"];
@ -530,17 +532,18 @@
proxy = linphone_address_as_string_uri_only(proxy_addr); proxy = linphone_address_as_string_uri_only(proxy_addr);
} }
proxyCfg = bctbx_list_nth_data(linphone_core_get_proxy_config_list(LC), account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
[self integerForKey:@"current_proxy_config_preference"]); [self integerForKey:@"current_proxy_config_preference"]);
// if account was deleted, it is not present anymore // if account was deleted, it is not present anymore
if (proxyCfg == NULL) if (account == NULL)
goto bad_proxy; goto bad_proxy;
LinphoneAddress *linphoneAddress = linphone_core_interpret_url(LC, "sip:user@domain.com"); LinphoneAddress *linphoneAddress = linphone_core_interpret_url(LC, "sip:user@domain.com");
linphone_address_set_username(linphoneAddress, username.UTF8String); linphone_address_set_username(linphoneAddress, username.UTF8String);
if ([LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number" inSection:@"assistant"]) { if ([LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number" inSection:@"assistant"]) {
char *user = linphone_proxy_config_normalize_phone_number(proxyCfg, username.UTF8String); char *user = linphone_account_normalize_phone_number(account, username.UTF8String);
if (user) { if (user) {
linphone_address_set_username(linphoneAddress, user); linphone_address_set_username(linphoneAddress, user);
ms_free(user); ms_free(user);
@ -551,58 +554,61 @@
const char *password = [accountPassword UTF8String]; const char *password = [accountPassword UTF8String];
const char *ha1 = [accountHa1 UTF8String]; const char *ha1 = [accountHa1 UTF8String];
if (linphone_proxy_config_set_identity_address(proxyCfg, linphoneAddress) == -1) { newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
if (linphone_account_params_set_identity_address(newAccountParams, linphoneAddress) == -1) {
error = NSLocalizedString(@"Invalid username or domain", nil); error = NSLocalizedString(@"Invalid username or domain", nil);
goto bad_proxy; goto bad_proxy;
} }
// use proxy as route if outbound_proxy is enabled // use proxy as route if outbound_proxy is enabled
route = isOutboundProxy ? proxy : NULL; route = isOutboundProxy ? proxy : NULL;
if (linphone_proxy_config_set_server_addr(proxyCfg, proxy) == -1) { if (linphone_account_params_set_server_addr(newAccountParams, proxy) == -1) {
error = NSLocalizedString(@"Invalid proxy address", nil); error = NSLocalizedString(@"Invalid proxy address", nil);
goto bad_proxy; goto bad_proxy;
} }
if (linphone_proxy_config_set_route(proxyCfg, route) == -1) { if (linphone_account_params_set_routes_addresses(newAccountParams, bctbx_list_new((void*)route)) == -1) {
error = NSLocalizedString(@"Invalid route", nil); error = NSLocalizedString(@"Invalid route", nil);
goto bad_proxy; goto bad_proxy;
} }
LinphoneNatPolicy *policy = linphone_proxy_config_get_nat_policy(proxyCfg) ?: linphone_core_create_nat_policy(LC); LinphoneNatPolicy *policy = linphone_account_params_get_nat_policy(newAccountParams) ?: linphone_core_create_nat_policy(LC);
linphone_nat_policy_enable_stun(policy, use_ice); // We always use STUN with ICE linphone_nat_policy_enable_stun(policy, use_ice); // We always use STUN with ICE
linphone_nat_policy_enable_ice(policy, use_ice); linphone_nat_policy_enable_ice(policy, use_ice);
linphone_nat_policy_set_stun_server(policy, stun_preference.UTF8String); linphone_nat_policy_set_stun_server(policy, stun_preference.UTF8String);
linphone_proxy_config_set_nat_policy(proxyCfg, policy); linphone_account_params_set_nat_policy(newAccountParams, policy);
if ([prefix length] > 0) { if ([prefix length] > 0) {
linphone_proxy_config_set_dial_prefix(proxyCfg, [prefix UTF8String]); linphone_account_params_set_international_prefix(newAccountParams, [prefix UTF8String]);
} }
if ([self objectForKey:@"account_substitute_+_by_00_preference"]) { if ([self objectForKey:@"account_substitute_+_by_00_preference"]) {
bool substitute_plus_by_00 = [self boolForKey:@"account_substitute_+_by_00_preference"]; bool substitute_plus_by_00 = [self boolForKey:@"account_substitute_+_by_00_preference"];
linphone_proxy_config_set_dial_escape_plus(proxyCfg, substitute_plus_by_00); linphone_account_params_set_dial_escape_plus_enabled(newAccountParams, substitute_plus_by_00);
} }
// use empty string "" instead of NULL to avoid being overwritten by default proxy config values // use empty string "" instead of NULL to avoid being overwritten by default proxy config values
linphone_proxy_config_set_push_notification_allowed(proxyCfg, pushnotification); linphone_account_params_set_push_notification_allowed(newAccountParams, pushnotification);
[LinphoneManager.instance configurePushTokenForProxyConfig:proxyCfg]; linphone_account_params_set_remote_push_notification_allowed(newAccountParams, pushnotification);
linphone_proxy_config_enable_register(proxyCfg, is_enabled); linphone_account_params_set_register_enabled(newAccountParams, is_enabled);
linphone_proxy_config_set_avpf_mode(proxyCfg, use_avpf); linphone_account_params_set_avpf_mode(newAccountParams, use_avpf);
linphone_proxy_config_set_expires(proxyCfg, expire); linphone_account_params_set_expires(newAccountParams, expire);
linphone_account_set_params(account, newAccountParams);
linphone_account_params_unref(newAccountParams);
if (is_default) { if (is_default) {
linphone_core_set_default_proxy_config(LC, proxyCfg); linphone_core_set_default_account(LC, account);
} else if (linphone_core_get_default_proxy_config(LC) == proxyCfg) { } else if (linphone_core_get_default_account(LC) == account) {
linphone_core_set_default_proxy_config(LC, NULL); linphone_core_set_default_account(LC, NULL);
} }
LinphoneAuthInfo *proxyAi = (LinphoneAuthInfo *)linphone_proxy_config_find_auth_info(proxyCfg); LinphoneAuthInfo *proxyAi = (LinphoneAuthInfo *)linphone_account_find_auth_info(account);
char *realm; char *realm;
if (proxyAi) { if (proxyAi) {
realm = ms_strdup(linphone_auth_info_get_realm(proxyAi)); realm = ms_strdup(linphone_auth_info_get_realm(proxyAi));
} else { } else {
realm = NULL; realm = NULL;
} }
// setup new proxycfg
linphone_proxy_config_done(proxyCfg);
// modify auth info only after finishing editting the proxy config, so that // modify auth info only after finishing editting the proxy config, so that
// UNREGISTER succeed // UNREGISTER succeed
@ -621,12 +627,12 @@
LinphoneAuthInfo *info; LinphoneAuthInfo *info;
if (password) { if (password) {
info = linphone_auth_info_new(linphone_address_get_username(from), userid_str, password, NULL, info = linphone_auth_info_new(linphone_address_get_username(from), userid_str, password, NULL,
linphone_proxy_config_get_realm(proxyCfg), linphone_account_params_get_realm(newAccountParams),
linphone_proxy_config_get_domain(proxyCfg)); linphone_account_params_get_domain(newAccountParams));
} else { } else {
info = linphone_auth_info_new(linphone_address_get_username(from), userid_str, NULL, ha1, info = linphone_auth_info_new(linphone_address_get_username(from), userid_str, NULL, ha1,
realm ? realm : linphone_proxy_config_get_realm(proxyCfg), realm ? realm : linphone_account_params_get_realm(newAccountParams),
linphone_proxy_config_get_domain(proxyCfg)); linphone_account_params_get_domain(newAccountParams));
} }
linphone_address_unref(from); linphone_address_unref(from);
@ -634,7 +640,7 @@
linphone_auth_info_destroy(info); linphone_auth_info_destroy(info);
ms_free(realm); ms_free(realm);
} }
bad_proxy: bad_proxy:
if (proxy) if (proxy)
ms_free(proxy); ms_free(proxy);
@ -643,7 +649,10 @@
// in case of error, show an alert to the user // in case of error, show an alert to the user
if (error != nil) { if (error != nil) {
linphone_proxy_config_done(proxyCfg); if (newAccountParams != NULL) { // If we get here, then we're also sure that Account != NULL
linphone_account_params_unref(newAccountParams);
}
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error", nil) UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error", nil)
message:error message:error
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
@ -655,6 +664,7 @@
[errView addAction:defaultAction]; [errView addAction:defaultAction];
[PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; [PhoneMainView.instance presentViewController:errView animated:YES completion:nil];
} }
} }
// reload address book to prepend proxy config domain to contacts' phone number // reload address book to prepend proxy config domain to contacts' phone number
[[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread]; [[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread];
@ -907,17 +917,17 @@
NSString *rls_uri = [lm lpConfigStringForKey:@"rls_uri" inSection:@"sip" withDefault:@"sips:rls@sip.linphone.org"]; NSString *rls_uri = [lm lpConfigStringForKey:@"rls_uri" inSection:@"sip" withDefault:@"sips:rls@sip.linphone.org"];
LinphoneAddress *rls_addr = linphone_address_new(rls_uri.UTF8String); LinphoneAddress *rls_addr = linphone_address_new(rls_uri.UTF8String);
const char *rls_domain = linphone_address_get_domain(rls_addr); const char *rls_domain = linphone_address_get_domain(rls_addr);
const MSList *proxies = linphone_core_get_proxy_config_list(LC); const MSList *accounts = linphone_core_get_account_list(LC);
if (!proxies) // Enable it if no proxy config for first launch of app if (!accounts) // Enable it if no proxy config for first launch of app
[self setInteger:1 forKey:@"use_rls_presence"]; [self setInteger:1 forKey:@"use_rls_presence"];
else { else {
while (proxies) { while (accounts) {
const char *proxy_domain = linphone_proxy_config_get_domain(proxies->data); const char *proxy_domain = linphone_account_params_get_domain(linphone_account_get_params(accounts->data));
if (strcmp(rls_domain, proxy_domain) == 0) { if (strcmp(rls_domain, proxy_domain) == 0) {
[self setInteger:1 forKey:@"use_rls_presence"]; [self setInteger:1 forKey:@"use_rls_presence"];
break; break;
} }
proxies = proxies->next; accounts = accounts->next;
} }
} }
linphone_address_unref(rls_addr); linphone_address_unref(rls_addr);
@ -962,7 +972,7 @@
} }
- (void)removeAccount { - (void)removeAccount {
LinphoneProxyConfig *config = bctbx_list_nth_data(linphone_core_get_proxy_config_list(LC), LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
[self integerForKey:@"current_proxy_config_preference"]); [self integerForKey:@"current_proxy_config_preference"]);
const MSList *lists = linphone_core_get_friends_lists(LC); const MSList *lists = linphone_core_get_friends_lists(LC);
@ -971,10 +981,10 @@
linphone_friend_list_update_subscriptions(lists->data); linphone_friend_list_update_subscriptions(lists->data);
lists = lists->next; lists = lists->next;
} }
BOOL isDefault = (linphone_core_get_default_proxy_config(LC) == config); BOOL isDefault = (linphone_core_get_default_account(LC) == account);
const LinphoneAuthInfo *ai = linphone_proxy_config_find_auth_info(config); const LinphoneAuthInfo *ai = linphone_account_find_auth_info(account);
linphone_core_remove_proxy_config(LC, config); linphone_core_remove_account(LC, account);
if (ai) { if (ai) {
// Friend list unsubscription above is not instantanous, so give a bit of a time margin before finishing the removal of the auth info // Friend list unsubscription above is not instantanous, so give a bit of a time margin before finishing the removal of the auth info
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@ -985,8 +995,8 @@
if (isDefault) { if (isDefault) {
// if we removed the default proxy config, set another one instead // if we removed the default proxy config, set another one instead
if (linphone_core_get_proxy_config_list(LC) != NULL) { if (linphone_core_get_account_list(LC) != NULL) {
linphone_core_set_default_proxy_config(LC, (LinphoneProxyConfig *)(linphone_core_get_proxy_config_list(LC)->data)); linphone_core_set_default_account(LC, (LinphoneAccount *)(linphone_core_get_account_list(LC)->data));
} }
} }
[self transformLinphoneCoreToKeys]; [self transformLinphoneCoreToKeys];

View file

@ -124,8 +124,6 @@ typedef struct _LinphoneManagerSounds {
- (void)becomeActive; - (void)becomeActive;
- (BOOL)enterBackgroundMode; - (BOOL)enterBackgroundMode;
- (void)addPushCallId:(NSString*) callid; - (void)addPushCallId:(NSString*) callid;
- (void)configurePushTokenForProxyConfigs;
- (void)configurePushTokenForProxyConfig: (LinphoneProxyConfig*)cfg;
- (BOOL)popPushCallID:(NSString*) callId; - (BOOL)popPushCallID:(NSString*) callId;
- (void)acceptCallForCallId:(NSString*)callid; - (void)acceptCallForCallId:(NSString*)callid;
+ (BOOL)langageDirectionIsRTL; + (BOOL)langageDirectionIsRTL;
@ -218,7 +216,6 @@ typedef struct _LinphoneManagerSounds {
@property NSDictionary *pushDict; @property NSDictionary *pushDict;
@property(strong, nonatomic) OrderedDictionary *linphoneManagerAddressBookMap; @property(strong, nonatomic) OrderedDictionary *linphoneManagerAddressBookMap;
@property (nonatomic, assign) BOOL contactsUpdated; @property (nonatomic, assign) BOOL contactsUpdated;
@property (nonatomic, assign) BOOL canConfigurePushTokenForProxyConfigs; // used to register at the right time when receiving push notif tokens
@property UIImage *avatar; @property UIImage *avatar;
@end @end

View file

@ -242,7 +242,6 @@ struct codec_name_pref_table codec_pref_table[] = {{"speex", 8000, "speex_8k_pre
_pushDict = [[NSMutableDictionary alloc] init]; _pushDict = [[NSMutableDictionary alloc] init];
_database = NULL; _database = NULL;
_conf = FALSE; _conf = FALSE;
_canConfigurePushTokenForProxyConfigs = FALSE;
_fileTransferDelegates = [[NSMutableArray alloc] init]; _fileTransferDelegates = [[NSMutableArray alloc] init];
_linphoneManagerAddressBookMap = [[OrderedDictionary alloc] init]; _linphoneManagerAddressBookMap = [[OrderedDictionary alloc] init];
pushCallIDs = [[NSMutableArray alloc] init]; pushCallIDs = [[NSMutableArray alloc] init];
@ -377,10 +376,12 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
- (void)migrationLinphoneSettings { - (void)migrationLinphoneSettings {
/* AVPF migration */ /* AVPF migration */
if ([self lpConfigBoolForKey:@"avpf_migration_done"] == FALSE) { if ([self lpConfigBoolForKey:@"avpf_migration_done"] == FALSE) {
const MSList *proxies = linphone_core_get_proxy_config_list(theLinphoneCore); const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
while (proxies) { while (accounts)
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)proxies->data; {
const char *addr = linphone_proxy_config_get_addr(proxy); LinphoneAccount *account = (LinphoneAccount *)accounts->data;
LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
const char *addr = linphone_account_params_get_server_addr(newAccountParams);
// we want to enable AVPF for the proxies // we want to enable AVPF for the proxies
if (addr && if (addr &&
strstr(addr, [LinphoneManager.instance lpConfigStringForKey:@"domain_name" strstr(addr, [LinphoneManager.instance lpConfigStringForKey:@"domain_name"
@ -388,18 +389,22 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
withDefault:@"sip.linphone.org"] withDefault:@"sip.linphone.org"]
.UTF8String) != 0) { .UTF8String) != 0) {
LOGI(@"Migrating proxy config to use AVPF"); LOGI(@"Migrating proxy config to use AVPF");
linphone_proxy_config_set_avpf_mode(proxy, LinphoneAVPFEnabled); linphone_account_params_set_avpf_mode(newAccountParams, LinphoneAVPFEnabled);
linphone_account_set_params(account, newAccountParams);
} }
proxies = proxies->next; accounts = accounts->next;
linphone_account_params_unref(newAccountParams);
} }
[self lpConfigSetBool:TRUE forKey:@"avpf_migration_done"]; [self lpConfigSetBool:TRUE forKey:@"avpf_migration_done"];
} }
/* Quality Reporting migration */ /* Quality Reporting migration */
if ([self lpConfigBoolForKey:@"quality_report_migration_done"] == FALSE) { if ([self lpConfigBoolForKey:@"quality_report_migration_done"] == FALSE) {
const MSList *proxies = linphone_core_get_proxy_config_list(theLinphoneCore); const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
while (proxies) { while (accounts)
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)proxies->data; {
const char *addr = linphone_proxy_config_get_addr(proxy); LinphoneAccount *account = (LinphoneAccount *)accounts->data;
LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
const char *addr = linphone_account_params_get_server_addr(newAccountParams);
// we want to enable quality reporting for the proxies that are on linphone.org // we want to enable quality reporting for the proxies that are on linphone.org
if (addr && if (addr &&
strstr(addr, [LinphoneManager.instance lpConfigStringForKey:@"domain_name" strstr(addr, [LinphoneManager.instance lpConfigStringForKey:@"domain_name"
@ -407,12 +412,15 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
withDefault:@"sip.linphone.org"] withDefault:@"sip.linphone.org"]
.UTF8String) != 0) { .UTF8String) != 0) {
LOGI(@"Migrating proxy config to send quality report"); LOGI(@"Migrating proxy config to send quality report");
linphone_proxy_config_set_quality_reporting_collector(
proxy, "sip:voip-metrics@sip.linphone.org;transport=tls"); linphone_account_params_set_quality_reporting_collector(
linphone_proxy_config_set_quality_reporting_interval(proxy, 180); newAccountParams, "sip:voip-metrics@sip.linphone.org;transport=tls");
linphone_proxy_config_enable_quality_reporting(proxy, TRUE); linphone_account_params_set_quality_reporting_interval(newAccountParams, 180);
linphone_account_params_set_quality_reporting_enabled(newAccountParams, TRUE);
linphone_account_set_params(account, newAccountParams);
} }
proxies = proxies->next; accounts = accounts->next;
linphone_account_params_unref(newAccountParams);
} }
[self lpConfigSetBool:TRUE forKey:@"quality_report_migration_done"]; [self lpConfigSetBool:TRUE forKey:@"quality_report_migration_done"];
} }
@ -425,59 +433,73 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
} }
if ([self lpConfigBoolForKey:@"lime_migration_done"] == FALSE) { if ([self lpConfigBoolForKey:@"lime_migration_done"] == FALSE) {
const MSList *proxies = linphone_core_get_proxy_config_list(LC); const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
while (proxies) { while (accounts)
if (!strcmp(linphone_proxy_config_get_domain((LinphoneProxyConfig *)proxies->data),"sip.linphone.org")) { {
if (!strcmp(linphone_account_params_get_domain(linphone_account_get_params((LinphoneAccount *)accounts->data)),"sip.linphone.org")) {
linphone_core_set_lime_x3dh_server_url(LC, "https://lime.linphone.org/lime-server/lime-server.php"); linphone_core_set_lime_x3dh_server_url(LC, "https://lime.linphone.org/lime-server/lime-server.php");
break; break;
} }
proxies = proxies->next; accounts = accounts->next;
} }
[self lpConfigSetBool:TRUE forKey:@"lime_migration_done"]; [self lpConfigSetBool:TRUE forKey:@"lime_migration_done"];
} }
if ([self lpConfigBoolForKey:@"push_notification_migration_done"] == FALSE) { if ([self lpConfigBoolForKey:@"push_notification_migration_done"] == FALSE) {
const MSList *proxies = linphone_core_get_proxy_config_list(LC); const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
bool_t pushEnabled; bool_t pushEnabled;
while (proxies) { while (accounts)
const char *refkey = linphone_proxy_config_get_ref_key(proxies->data); {
LinphoneAccount *account = (LinphoneAccount *)accounts->data;
LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
const char *refkey = linphone_account_params_get_ref_key(newAccountParams);
if (refkey) { if (refkey) {
pushEnabled = (strcmp(refkey, "push_notification") == 0); pushEnabled = (strcmp(refkey, "push_notification") == 0);
} else { } else {
pushEnabled = true; pushEnabled = true;
} }
linphone_proxy_config_set_push_notification_allowed(proxies->data, pushEnabled); linphone_account_params_set_push_notification_allowed(newAccountParams, pushEnabled);
proxies = proxies->next; linphone_account_params_set_remote_push_notification_allowed(newAccountParams, pushEnabled);
linphone_account_set_params(account, newAccountParams);
linphone_account_params_unref(newAccountParams);
accounts = accounts->next;
} }
[self lpConfigSetBool:TRUE forKey:@"push_notification_migration_done"]; [self lpConfigSetBool:TRUE forKey:@"push_notification_migration_done"];
} }
} }
- (void)migrationPerAccount { - (void)migrationPerAccount {
const bctbx_list_t * proxies = linphone_core_get_proxy_config_list(LC); const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
NSString *appDomain = [LinphoneManager.instance lpConfigStringForKey:@"domain_name" NSString *appDomain = [LinphoneManager.instance lpConfigStringForKey:@"domain_name"
inSection:@"app" inSection:@"app"
withDefault:@"sip.linphone.org"]; withDefault:@"sip.linphone.org"];
while (proxies) { while (accounts) {
LinphoneProxyConfig *config = proxies->data; LinphoneAccount *account = accounts->data;
// can not create group chat without conference factory LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
if (!linphone_proxy_config_get_conference_factory_uri(config)) { // can not create group chat without conference factory
if (strcmp(appDomain.UTF8String, linphone_proxy_config_get_domain(config)) == 0) { if (!linphone_account_params_get_conference_factory_uri(newAccountParams)) {
linphone_proxy_config_set_conference_factory_uri(config, "sip:conference-factory@sip.linphone.org"); if (strcmp(appDomain.UTF8String, linphone_account_params_get_domain(newAccountParams)) == 0) {
} linphone_account_params_set_conference_factory_uri(newAccountParams, "sip:conference-factory@sip.linphone.org");
} linphone_account_set_params(account, newAccountParams);
proxies = proxies->next; }
} }
linphone_account_params_unref(newAccountParams);
accounts = accounts->next;
}
NSString *s = [self lpConfigStringForKey:@"pushnotification_preference"]; NSString *s = [self lpConfigStringForKey:@"pushnotification_preference"];
if (s && s.boolValue) { if (s && s.boolValue) {
LOGI(@"Migrating push notification per account, enabling for ALL"); LOGI(@"Migrating push notification per account, enabling for ALL");
[self lpConfigSetBool:NO forKey:@"pushnotification_preference"]; [self lpConfigSetBool:NO forKey:@"pushnotification_preference"];
const MSList *proxies = linphone_core_get_proxy_config_list(LC); const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
while (proxies) { while (accounts) {
linphone_proxy_config_set_push_notification_allowed(proxies->data, true); LinphoneAccount *account = accounts->data;
[self configurePushTokenForProxyConfig:proxies->data]; LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
proxies = proxies->next; linphone_account_params_set_push_notification_allowed(newAccountParams, true);
linphone_account_params_set_remote_push_notification_allowed(newAccountParams, true);
linphone_account_set_params(account, newAccountParams);
linphone_account_params_unref(newAccountParams);
accounts = accounts->next;
} }
} }
} }
@ -621,26 +643,15 @@ static void linphone_iphone_configuring_status_changed(LinphoneCore *lc, Linphon
}); });
} }
- (void)configuringStateChangedNotificationHandler:(NSNotification *)notif {
_wasRemoteProvisioned = ((LinphoneConfiguringState)[[[notif userInfo] valueForKey:@"state"] integerValue] ==
LinphoneConfiguringSuccessful);
if (_wasRemoteProvisioned) {
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
if (cfg) {
[self configurePushTokenForProxyConfig:cfg];
}
}
}
#pragma mark - Registration State Functions #pragma mark - Registration State Functions
- (void)onRegister:(LinphoneCore *)lc - (void)onRegister:(LinphoneCore *)lc
cfg:(LinphoneProxyConfig *)cfg account:(LinphoneAccount *)account
state:(LinphoneRegistrationState)state state:(LinphoneRegistrationState)state
message:(const char *)cmessage { message:(const char *)cmessage {
LOGI(@"New registration state: %s (message: %s)", linphone_registration_state_to_string(state), cmessage); LOGI(@"New registration state: %s (message: %s)", linphone_registration_state_to_string(state), cmessage);
LinphoneReason reason = linphone_proxy_config_get_error(cfg); LinphoneReason reason = linphone_account_get_error(account);
NSString *message = nil; NSString *message = nil;
switch (reason) { switch (reason) {
case LinphoneReasonBadCredentials: case LinphoneReasonBadCredentials:
@ -701,13 +712,13 @@ message:(const char *)cmessage {
// Post event // Post event
NSDictionary *dict = NSDictionary *dict =
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:state], @"state", [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:state], @"state",
[NSValue valueWithPointer:cfg], @"cfg", message, @"message", nil]; [NSValue valueWithPointer:account], @"account", message, @"message", nil];
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneRegistrationUpdate object:self userInfo:dict]; [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneRegistrationUpdate object:self userInfo:dict];
} }
static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyConfig *cfg, static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneAccount *account,
LinphoneRegistrationState state, const char *message) { LinphoneRegistrationState state, const char *message) {
[(__bridge LinphoneManager *)linphone_core_cbs_get_user_data(linphone_core_get_current_callbacks(lc)) onRegister:lc cfg:cfg state:state message:message]; [(__bridge LinphoneManager *)linphone_core_cbs_get_user_data(linphone_core_get_current_callbacks(lc)) onRegister:lc account:account state:state message:message];
} }
#pragma mark - Auth info Function #pragma mark - Auth info Function
@ -722,13 +733,14 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut
// InstantMessageDeliveryNotifications from previous accounts can trigger some pop-up spam asking for indentification // InstantMessageDeliveryNotifications from previous accounts can trigger some pop-up spam asking for indentification
// Try to filter the popup password request to avoid displaying those that do not matter and can be handled through a simple warning // Try to filter the popup password request to avoid displaying those that do not matter and can be handled through a simple warning
const MSList *configList = linphone_core_get_proxy_config_list(LC); const MSList *accountList = linphone_core_get_account_list(LC);
bool foundMatchingConfig = false; bool foundMatchingConfig = false;
while (configList && !foundMatchingConfig) { while (accountList && !foundMatchingConfig) {
const char * configUsername = linphone_proxy_config_get_identity(configList->data); LinphoneAccountParams const *accountParams = linphone_account_get_params(accountList->data);
const char * configDomain = linphone_proxy_config_get_domain(configList->data); const char * configUsername = linphone_account_params_get_identity(accountParams);
const char * configDomain = linphone_account_params_get_domain(accountParams);
foundMatchingConfig = (strcmp(configUsername, usernameC) == 0) && (strcmp(configDomain, domainC) == 0); foundMatchingConfig = (strcmp(configUsername, usernameC) == 0) && (strcmp(configDomain, domainC) == 0);
configList = configList->next; accountList = accountList->next;
} }
if (!foundMatchingConfig) { if (!foundMatchingConfig) {
LOGW(@"Received an authentication request from %s@%s, but ignored it did not match any current user", usernameC, domainC); LOGW(@"Received an authentication request from %s@%s, but ignored it did not match any current user", usernameC, domainC);
@ -1215,16 +1227,17 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
if (status == LinphoneAccountCreatorStatusAccountLinked) { if (status == LinphoneAccountCreatorStatusAccountLinked) {
[LinphoneManager.instance lpConfigSetInt:0 forKey:@"must_link_account_time"]; [LinphoneManager.instance lpConfigSetInt:0 forKey:@"must_link_account_time"];
} else { } else {
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
if (cfg && LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
strcmp(linphone_proxy_config_get_domain(cfg), if (account &&
strcmp(linphone_account_params_get_domain(accountParams),
[LinphoneManager.instance lpConfigStringForKey:@"domain_name" [LinphoneManager.instance lpConfigStringForKey:@"domain_name"
inSection:@"app" inSection:@"app"
withDefault:@"sip.linphone.org"] withDefault:@"sip.linphone.org"]
.UTF8String) == 0) { .UTF8String) == 0) {
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Link your account", nil) UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Link your account", nil)
message:[NSString stringWithFormat:NSLocalizedString(@"Link your Linphone.org account %s to your phone number.", nil), message:[NSString stringWithFormat:NSLocalizedString(@"Link your Linphone.org account %s to your phone number.", nil),
linphone_address_get_username(linphone_proxy_config_get_identity_address(cfg))] linphone_address_get_username(linphone_account_params_get_identity_address(accountParams))]
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Maybe later", nil) UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Maybe later", nil)
@ -1256,9 +1269,9 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
[NSDate dateWithTimeIntervalSince1970:[self lpConfigIntForKey:@"must_link_account_time" withDefault:1]]; [NSDate dateWithTimeIntervalSince1970:[self lpConfigIntForKey:@"must_link_account_time" withDefault:1]];
NSDate *now = [NSDate date]; NSDate *now = [NSDate date];
if (nextTime.timeIntervalSince1970 > 0 && [now earlierDate:nextTime] == nextTime) { if (nextTime.timeIntervalSince1970 > 0 && [now earlierDate:nextTime] == nextTime) {
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
if (cfg) { if (account) {
const char *username = linphone_address_get_username(linphone_proxy_config_get_identity_address(cfg)); const char *username = linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(account)));
LinphoneAccountCreator *account_creator = linphone_account_creator_new( LinphoneAccountCreator *account_creator = linphone_account_creator_new(
LC, LC,
[LinphoneManager.instance lpConfigStringForKey:@"xmlrpc_url" inSection:@"assistant" withDefault:@""] [LinphoneManager.instance lpConfigStringForKey:@"xmlrpc_url" inSection:@"assistant" withDefault:@""]
@ -1273,7 +1286,28 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
} }
- (void)startLinphoneCore { - (void)startLinphoneCore {
linphone_core_start([LinphoneManager getLc]); bool pushEnabled = [self lpConfigIntForKey:@"proxy" inSection:@"push_notification_allowed"];
const MSList *accountsList = linphone_core_get_account_list(theLinphoneCore);
while (accountsList) {
LinphoneAccount * account = accountsList->data;
LinphoneAccountParams * accountParams = linphone_account_params_clone(linphone_account_get_params(account));
linphone_account_params_set_push_notification_allowed(accountParams, pushEnabled);
linphone_account_params_set_remote_push_notification_allowed(accountParams, true);
LinphonePushNotificationConfig *pushConfig = linphone_account_params_get_push_notification_config(accountParams);
#ifdef DEBUG
#define PROVIDER_NAME "apns.dev"
#else
#define PROVIDER_NAME "apns"
#endif
linphone_push_notification_config_set_provider(pushConfig, PROVIDER_NAME);
linphone_account_set_params(account, accountParams);
linphone_account_params_unref(accountParams);
accountsList = accountsList->next;
}
linphone_core_start([LinphoneManager getLc]);
} }
- (void)createLinphoneCore { - (void)createLinphoneCore {
@ -1303,7 +1337,7 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
LinphoneFactory *factory = linphone_factory_get(); LinphoneFactory *factory = linphone_factory_get();
LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(factory); LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(factory);
linphone_core_cbs_set_registration_state_changed(cbs,linphone_iphone_registration_state); linphone_core_cbs_set_account_registration_state_changed(cbs,linphone_iphone_registration_state);
linphone_core_cbs_set_notify_presence_received_for_uri_or_tel(cbs, linphone_iphone_notify_presence_received_for_uri_or_tel); linphone_core_cbs_set_notify_presence_received_for_uri_or_tel(cbs, linphone_iphone_notify_presence_received_for_uri_or_tel);
linphone_core_cbs_set_authentication_requested(cbs, linphone_iphone_popup_password_request); linphone_core_cbs_set_authentication_requested(cbs, linphone_iphone_popup_password_request);
linphone_core_cbs_set_message_received(cbs, linphone_iphone_message_received); linphone_core_cbs_set_message_received(cbs, linphone_iphone_message_received);
@ -1326,8 +1360,8 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
[CallManager.instance setCoreWithCore:theLinphoneCore]; [CallManager.instance setCoreWithCore:theLinphoneCore];
[ConfigManager.instance setDbWithDb:_configDb]; [ConfigManager.instance setDbWithDb:_configDb];
linphone_core_start(theLinphoneCore); [LinphoneManager.instance startLinphoneCore];
// Let the core handle cbs // Let the core handle cbs
linphone_core_cbs_unref(cbs); linphone_core_cbs_unref(cbs);
@ -1358,10 +1392,6 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
selector:@selector(globalStateChangedNotificationHandler:) selector:@selector(globalStateChangedNotificationHandler:)
name:kLinphoneGlobalStateUpdate name:kLinphoneGlobalStateUpdate
object:nil]; object:nil];
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(configuringStateChangedNotificationHandler:)
name:kLinphoneConfiguringStateUpdate
object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(inappReady:) name:kIAPReady object:nil]; [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(inappReady:) name:kIAPReady object:nil];
/*call iterate once immediately in order to initiate background connections with sip server or remote provisioning /*call iterate once immediately in order to initiate background connections with sip server or remote provisioning
@ -1487,13 +1517,14 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
linphone_core_set_presence_model(LC, linphone_core_create_presence_model_with_activity(LC, LinphonePresenceActivityTV, NULL)); linphone_core_set_presence_model(LC, linphone_core_create_presence_model_with_activity(LC, LinphonePresenceActivityTV, NULL));
} }
const MSList *proxies = linphone_core_get_proxy_config_list(LC); const MSList *accounts = linphone_core_get_account_list(LC);
while (proxies) { while (accounts) {
LinphoneProxyConfig *cfg = proxies->data; LinphoneAccount *account = accounts->data;
linphone_proxy_config_edit(cfg); LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
linphone_proxy_config_enable_publish(cfg, enabled); linphone_account_params_set_publish_enabled(newAccountParams, enabled);
linphone_proxy_config_done(cfg); linphone_account_set_params(account, newAccountParams);
proxies = proxies->next; linphone_account_params_unref(newAccountParams);
accounts = accounts->next;
} }
// force registration update first, then update friend list subscription // force registration update first, then update friend list subscription
[self iterate]; [self iterate];
@ -1503,15 +1534,16 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
} }
- (BOOL)enterBackgroundMode { - (BOOL)enterBackgroundMode {
LinphoneProxyConfig *proxyCfg = linphone_core_get_default_proxy_config(theLinphoneCore); LinphoneAccount *account = linphone_core_get_default_account(theLinphoneCore);
BOOL shouldEnterBgMode = FALSE; BOOL shouldEnterBgMode = FALSE;
// disable presence // disable presence
[self enableProxyPublish:NO]; [self enableProxyPublish:NO];
// handle proxy config if any // handle proxy config if any
if (proxyCfg) { if (account) {
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg); LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
BOOL pushNotifEnabled = linphone_account_params_get_push_notification_allowed(accountParams);
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] || pushNotifEnabled) { if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] || pushNotifEnabled) {
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
// For registration register // For registration register
@ -1564,12 +1596,15 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
LOGI(@"Entering [%s] bg mode", shouldEnterBgMode ? "normal" : "lite"); LOGI(@"Entering [%s] bg mode", shouldEnterBgMode ? "normal" : "lite");
if (!shouldEnterBgMode && floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { if (!shouldEnterBgMode && floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg); if (account) {
if (pushNotifEnabled) { LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
LOGI(@"Keeping lc core to handle push"); BOOL pushNotifEnabled = linphone_account_params_get_push_notification_allowed(accountParams);
return YES; if (pushNotifEnabled) {
LOGI(@"Keeping lc core to handle push");
return YES;
}
return NO;
} }
return NO;
} }
return YES; return YES;
} }
@ -1802,116 +1837,12 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
} }
#pragma mark - Property Functions #pragma mark - Property Functions
- (void)setPushKitToken:(NSData *)pushKitToken {
if (pushKitToken == _pushKitToken) {
return;
}
_pushKitToken = pushKitToken;
[self configurePushTokenForProxyConfigs];
}
- (void)setRemoteNotificationToken:(NSData *)remoteNotificationToken { - (void)setRemoteNotificationToken:(NSData *)remoteNotificationToken {
if (remoteNotificationToken == _remoteNotificationToken) { if (remoteNotificationToken == _remoteNotificationToken) {
return; return;
} }
_remoteNotificationToken = remoteNotificationToken; _remoteNotificationToken = remoteNotificationToken;
linphone_core_did_register_for_remote_push(LC, (__bridge void*)remoteNotificationToken);
[self configurePushTokenForProxyConfigs];
}
- (void)configurePushTokenForProxyConfigs {
// we register only when the second token is set
if (_canConfigurePushTokenForProxyConfigs) {
@try {
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
while (proxies) {
[self configurePushTokenForProxyConfig:proxies->data];
proxies = proxies->next;
}
} @catch (NSException* e) {
LOGW(@"%s: linphone core not ready yet, ignoring push token", __FUNCTION__);
}
} else {
_canConfigurePushTokenForProxyConfigs = YES;
}
}
- (void)configurePushTokenForProxyConfig:(LinphoneProxyConfig *)proxyCfg {
linphone_proxy_config_edit(proxyCfg);
NSData *remoteTokenData = _remoteNotificationToken;
NSData *PKTokenData = _pushKitToken;
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg);
if ((remoteTokenData != nil || PKTokenData != nil) && pushNotifEnabled) {
const unsigned char *remoteTokenBuffer = [remoteTokenData bytes];
NSMutableString *remoteTokenString = [NSMutableString stringWithCapacity:[remoteTokenData length] * 2];
for (int i = 0; i < [remoteTokenData length]; ++i) {
[remoteTokenString appendFormat:@"%02X", (unsigned int)remoteTokenBuffer[i]];
}
const unsigned char *PKTokenBuffer = [PKTokenData bytes];
NSMutableString *PKTokenString = [NSMutableString stringWithCapacity:[PKTokenData length] * 2];
for (int i = 0; i < [PKTokenData length]; ++i) {
[PKTokenString appendFormat:@"%02X", (unsigned int)PKTokenBuffer[i]];
}
NSString *token;
NSString *services;
if (remoteTokenString && PKTokenString) {
token = [NSString stringWithFormat:@"%@:remote&%@:voip", remoteTokenString, PKTokenString];
services = @"remote&voip";
} else if (remoteTokenString) {
token = [NSString stringWithFormat:@"%@:remote", remoteTokenString];
services = @"remote";
} else {
token = [NSString stringWithFormat:@"%@:voip", PKTokenString];
services = @"voip";
}
// NSLocalizedString(@"IC_MSG", nil); // Fake for genstrings
// NSLocalizedString(@"IM_MSG", nil); // Fake for genstrings
// NSLocalizedString(@"IM_FULLMSG", nil); // Fake for genstrings
#ifdef DEBUG
#define APPMODE_SUFFIX @".dev"
#else
#define APPMODE_SUFFIX @""
#endif
NSString *ring =
([LinphoneManager bundleFile:[self lpConfigStringForKey:@"local_ring" inSection:@"sound"].lastPathComponent]
?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"])
.lastPathComponent;
NSString *timeout;
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) {
timeout = @";pn-timeout=0";
} else {
timeout = @"";
}
// dummy value, for later use
NSString *teamId = @"ABCD1234";
NSString *params = [NSString
stringWithFormat:@"pn-provider=apns%@;pn-prid=%@;pn-param=%@.%@.%@;pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-groupchat-str=GC_MSG;pn-"
@"call-snd=%@;pn-msg-snd=msg.caf%@;pn-silent=1",
APPMODE_SUFFIX, token, teamId, [[NSBundle mainBundle] bundleIdentifier], services, ring, timeout];
LOGI(@"Proxy config %s configured for push notifications with contact: %@",
linphone_proxy_config_get_identity(proxyCfg), params);
linphone_proxy_config_set_contact_uri_parameters(proxyCfg, [params UTF8String]);
linphone_proxy_config_set_contact_parameters(proxyCfg, NULL);
} else {
LOGI(@"Proxy config %s NOT configured for push notifications", linphone_proxy_config_get_identity(proxyCfg));
// no push token:
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 #pragma mark - Misc Functions
@ -2192,9 +2123,10 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
- (NSString *)contactFilter { - (NSString *)contactFilter {
NSString *filter = @"*"; NSString *filter = @"*";
if ([self lpConfigBoolForKey:@"contact_filter_on_default_domain"]) { if ([self lpConfigBoolForKey:@"contact_filter_on_default_domain"]) {
LinphoneProxyConfig *proxy_cfg = linphone_core_get_default_proxy_config(theLinphoneCore); LinphoneAccount *account = linphone_core_get_default_account(theLinphoneCore);
if (proxy_cfg && linphone_proxy_config_get_addr(proxy_cfg)) { LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
return [NSString stringWithCString:linphone_proxy_config_get_domain(proxy_cfg) if (account && linphone_account_params_get_server_addr(accountParams)) {
return [NSString stringWithCString:linphone_account_params_get_domain(accountParams)
encoding:[NSString defaultCStringEncoding]]; encoding:[NSString defaultCStringEncoding]];
} }
} }
@ -2211,7 +2143,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
#pragma mark - #pragma mark -
- (void)removeAllAccounts { - (void)removeAllAccounts {
linphone_core_clear_proxy_config(LC); linphone_core_clear_accounts(LC);
linphone_core_clear_all_auth_info(LC); linphone_core_clear_all_auth_info(LC);
} }
@ -2219,12 +2151,12 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
if (!addr) if (!addr)
return NO; return NO;
const MSList *it = linphone_core_get_proxy_config_list(LC); const MSList *accounts = linphone_core_get_account_list(LC);
while (it) { while (accounts) {
if (linphone_address_weak_equal(addr, linphone_proxy_config_get_identity_address(it->data))) { if (linphone_address_weak_equal(addr, linphone_account_params_get_identity_address(linphone_account_get_params(accounts->data)))) {
return YES; return YES;
} }
it = it->next; accounts = accounts->next;
} }
return NO; return NO;
} }

View file

@ -71,10 +71,10 @@
object:nil]; object:nil];
// Update to default state // Update to default state
LinphoneProxyConfig *config = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
messagesUnreadCount = linphone_config_get_int(linphone_core_get_config(LC), "app", "voice_mail_messages_count", 0); messagesUnreadCount = linphone_config_get_int(linphone_core_get_config(LC), "app", "voice_mail_messages_count", 0);
[self proxyConfigUpdate:config]; [self accountUpdate:account];
[self updateUI:linphone_core_get_calls_nb(LC)]; [self updateUI:linphone_core_get_calls_nb(LC)];
[self updateVoicemail]; [self updateVoicemail];
} }
@ -107,8 +107,8 @@
#pragma mark - Event Functions #pragma mark - Event Functions
- (void)registrationUpdate:(NSNotification *)notif { - (void)registrationUpdate:(NSNotification *)notif {
LinphoneProxyConfig *config = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
[self proxyConfigUpdate:config]; [self accountUpdate:account];
} }
- (void)globalStateUpdate:(NSNotification *)notif { - (void)globalStateUpdate:(NSNotification *)notif {
@ -180,7 +180,7 @@
return [UIImage imageNamed:@"led_connected.png"]; return [UIImage imageNamed:@"led_connected.png"];
} }
} }
- (void)proxyConfigUpdate:(LinphoneProxyConfig *)config { - (void)accountUpdate:(LinphoneAccount *)account {
LinphoneRegistrationState state = LinphoneRegistrationNone; LinphoneRegistrationState state = LinphoneRegistrationNone;
NSString *message = nil; NSString *message = nil;
LinphoneGlobalState gstate = linphone_core_get_global_state(LC); LinphoneGlobalState gstate = linphone_core_get_global_state(LC);
@ -191,16 +191,16 @@
message = NSLocalizedString(@"Network down", nil); message = NSLocalizedString(@"Network down", nil);
} else if (gstate == LinphoneGlobalConfiguring) { } else if (gstate == LinphoneGlobalConfiguring) {
message = NSLocalizedString(@"Fetching remote configuration", nil); message = NSLocalizedString(@"Fetching remote configuration", nil);
} else if (config == NULL) { } else if (account == NULL) {
state = LinphoneRegistrationNone; state = LinphoneRegistrationNone;
if (linphone_core_get_proxy_config_list(LC) != NULL) { if (linphone_core_get_account_list(LC) != NULL) {
message = NSLocalizedString(@"No default account", nil); message = NSLocalizedString(@"No default account", nil);
} else { } else {
message = NSLocalizedString(@"No account configured", nil); message = NSLocalizedString(@"No account configured", nil);
} }
} else { } else {
state = linphone_proxy_config_get_state(config); state = linphone_account_get_state(account);
switch (state) { switch (state) {
case LinphoneRegistrationOk: case LinphoneRegistrationOk:
@ -406,9 +406,9 @@
} }
- (IBAction)onRegistrationStateClick:(id)sender { - (IBAction)onRegistrationStateClick:(id)sender {
if (linphone_core_get_default_proxy_config(LC)) { if (linphone_core_get_default_account(LC)) {
linphone_core_refresh_registers(LC); linphone_core_refresh_registers(LC);
} else if (linphone_core_get_proxy_config_list(LC)) { } else if (linphone_core_get_account_list(LC)) {
[PhoneMainView.instance changeCurrentView:SettingsView.compositeViewDescription]; [PhoneMainView.instance changeCurrentView:SettingsView.compositeViewDescription];
} else { } else {
[PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription]; [PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription];

View file

@ -66,11 +66,11 @@
const LinphoneAddress *to = linphone_call_log_get_to_address(log); const LinphoneAddress *to = linphone_call_log_get_to_address(log);
const char *domain = linphone_address_get_domain(to); const char *domain = linphone_address_get_domain(to);
char *bis_address = NULL; char *bis_address = NULL;
LinphoneProxyConfig *def_proxy = linphone_core_get_default_proxy_config(LC); LinphoneAccount *def_account = linphone_core_get_default_account(LC);
// if the 'to' address is on the default proxy, only present the username // if the 'to' address is on the default proxy, only present the username
if (def_proxy) { if (def_account) {
const char *def_domain = linphone_proxy_config_get_domain(def_proxy); const char *def_domain = linphone_account_params_get_domain(linphone_account_get_params(def_account));
if (def_domain && domain && !strcmp(domain, def_domain)) { if (def_domain && domain && !strcmp(domain, def_domain)) {
bis_address = ms_strdup(linphone_address_get_username(to)); bis_address = ms_strdup(linphone_address_get_username(to));
} }

View file

@ -344,8 +344,8 @@ static RootViewManager *rootViewManagerInstance = nil;
LinphoneGlobalState state = (LinphoneGlobalState)[[[notif userInfo] valueForKey:@"state"] integerValue]; LinphoneGlobalState state = (LinphoneGlobalState)[[[notif userInfo] valueForKey:@"state"] integerValue];
static BOOL already_shown = FALSE; static BOOL already_shown = FALSE;
if (state == LinphoneGlobalOn && !already_shown && LinphoneManager.instance.wasRemoteProvisioned) { if (state == LinphoneGlobalOn && !already_shown && LinphoneManager.instance.wasRemoteProvisioned) {
LinphoneProxyConfig *conf = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
if ([LinphoneManager.instance lpConfigBoolForKey:@"show_login_view" inSection:@"app"] && conf == NULL) { if ([LinphoneManager.instance lpConfigBoolForKey:@"show_login_view" inSection:@"app"] && account == NULL) {
already_shown = TRUE; already_shown = TRUE;
AssistantView *view = VIEW(AssistantView); AssistantView *view = VIEW(AssistantView);
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
@ -487,8 +487,8 @@ static RootViewManager *rootViewManagerInstance = nil;
} else { } else {
// always start to dialer when testing // always start to dialer when testing
// Change to default view // Change to default view
const MSList *list = linphone_core_get_proxy_config_list(LC); const MSList *accountList = linphone_core_get_account_list(LC);
if (list != NULL || if (accountList != NULL ||
([lm lpConfigBoolForKey:@"hide_assistant_preference"] == ([lm lpConfigBoolForKey:@"hide_assistant_preference"] ==
true) || true) ||
lm.isTesting) { lm.isTesting) {
@ -702,9 +702,9 @@ static RootViewManager *rootViewManagerInstance = nil;
NSString *lMessage; NSString *lMessage;
NSString *lTitle; NSString *lTitle;
// get default proxy // get default account
LinphoneProxyConfig *proxyCfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
if (proxyCfg == nil) { if (account == nil) {
lMessage = NSLocalizedString(@"Please make sure your device is connected to the internet and double check your " lMessage = NSLocalizedString(@"Please make sure your device is connected to the internet and double check your "
@"SIP account configuration in the settings.", @"SIP account configuration in the settings.",
nil); nil);
@ -839,9 +839,9 @@ static RootViewManager *rootViewManagerInstance = nil;
} }
LinphoneAddress *local; LinphoneAddress *local;
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
if (cfg) { if (account) {
local = linphone_address_clone(linphone_proxy_config_get_contact(cfg)); local = linphone_address_clone(linphone_account_get_contact_address(account));
} else { } else {
local = linphone_core_create_primary_contact_parsed(LC); local = linphone_core_create_primary_contact_parsed(LC);
} }
@ -859,8 +859,8 @@ static RootViewManager *rootViewManagerInstance = nil;
} }
- (LinphoneChatRoom *)createChatRoom:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView isEncrypted:(BOOL)isEncrypted isGroup:(BOOL)isGroup{ - (LinphoneChatRoom *)createChatRoom:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView isEncrypted:(BOOL)isEncrypted isGroup:(BOOL)isGroup{
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
if (!(cfg && linphone_proxy_config_get_conference_factory_uri(cfg)) if (!(account && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(account)))
|| ((bctbx_list_size(addresses) == 1) && !isGroup && ([[LinphoneManager instance] lpConfigBoolForKey:@"prefer_basic_chat_room" inSection:@"misc"] || !isEncrypted))) { || ((bctbx_list_size(addresses) == 1) && !isGroup && ([[LinphoneManager instance] lpConfigBoolForKey:@"prefer_basic_chat_room" inSection:@"misc"] || !isEncrypted))) {
// If there's no factory uri, create a basic chat room // If there's no factory uri, create a basic chat room
if (bctbx_list_size(addresses) != 1) { if (bctbx_list_size(addresses) != 1) {

View file

@ -26,11 +26,9 @@ import os
@objc class CallInfo: NSObject { @objc class CallInfo: NSObject {
var callId: String = "" var callId: String = ""
var accepted = false
var toAddr: Address? var toAddr: Address?
var isOutgoing = false var isOutgoing = false
var sasEnabled = false var sasEnabled = false
var declined = false
var connected = false var connected = false
var reason: Reason = Reason.None var reason: Reason = Reason.None
var displayName: String? var displayName: String?
@ -109,7 +107,6 @@ class ProviderDelegate: NSObject {
default: default:
callInfo?.reason = Reason.Unknown callInfo?.reason = Reason.Unknown
} }
callInfo?.declined = true
self.callInfos.updateValue(callInfo!, forKey: uuid) self.callInfos.updateValue(callInfo!, forKey: uuid)
try? call?.decline(reason: callInfo!.reason) try? call?.decline(reason: callInfo!.reason)
} }
@ -181,14 +178,7 @@ extension ProviderDelegate: CXProviderDelegate {
let call = CallManager.instance().callByCallId(callId: callId) let call = CallManager.instance().callByCallId(callId: callId)
CallManager.instance().lc?.configureAudioSession() CallManager.instance().lc?.configureAudioSession()
if (call == nil || call?.state != Call.State.IncomingReceived) { CallManager.instance().acceptCall(call: call!, hasVideo: call!.params?.videoEnabled ?? false)
// The application is not yet registered or the call is not yet received, mark the call as accepted. The audio session must be configured here.
callInfo?.accepted = true
callInfos.updateValue(callInfo!, forKey: uuid)
CallManager.instance().providerDelegate.endCallNotExist(uuid: uuid, timeout: .now() + 10)
} else {
CallManager.instance().acceptCall(call: call!, hasVideo: call!.params?.videoEnabled ?? false)
}
action.fulfill() action.fulfill()
} }

View file

@ -440,10 +440,10 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
linphone_account_creator_set_password(creator, _tmpPwd.UTF8String); linphone_account_creator_set_password(creator, _tmpPwd.UTF8String);
[settingsStore setObject:_tmpPwd forKey:@"account_mandatory_password_preference"]; [settingsStore setObject:_tmpPwd forKey:@"account_mandatory_password_preference"];
LinphoneProxyConfig *config = bctbx_list_nth_data(linphone_core_get_proxy_config_list(LC), LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
[settingsStore integerForKey:@"current_proxy_config_preference"]); [settingsStore integerForKey:@"current_proxy_config_preference"]);
if (config != NULL) { if (account != NULL) {
const LinphoneAuthInfo *auth = linphone_proxy_config_find_auth_info(config); const LinphoneAuthInfo *auth = linphone_account_find_auth_info(account);
if (auth) { if (auth) {
LinphoneAuthInfo * newAuth = linphone_auth_info_clone(auth); LinphoneAuthInfo * newAuth = linphone_auth_info_clone(auth);
linphone_auth_info_set_passwd(newAuth, _tmpPwd.UTF8String); linphone_auth_info_set_passwd(newAuth, _tmpPwd.UTF8String);
@ -578,12 +578,12 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
} }
if ([specifier.key hasPrefix:@"menu_account_"]) { if ([specifier.key hasPrefix:@"menu_account_"]) {
const bctbx_list_t *accounts = linphone_core_get_proxy_config_list(LC); const bctbx_list_t *accounts = linphone_core_get_account_list(LC);
int index = [specifier.key substringFromIndex:@"menu_account_".length].intValue - 1; int index = [specifier.key substringFromIndex:@"menu_account_".length].intValue - 1;
if (index < bctbx_list_size(accounts)) { if (index < bctbx_list_size(accounts)) {
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)bctbx_list_nth_data(accounts, index); LinphoneAccount *account = (LinphoneAccount *)bctbx_list_nth_data(accounts, index);
NSString *name = [NSString NSString *name = [NSString
stringWithUTF8String:linphone_address_get_username(linphone_proxy_config_get_identity_address(proxy))]; stringWithUTF8String:linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(account)))];
[specifier.specifierDict setValue:name forKey:kIASKTitle]; [specifier.specifierDict setValue:name forKey:kIASKTitle];
} }
} }
@ -595,7 +595,7 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
LinphoneManager *lm = LinphoneManager.instance; LinphoneManager *lm = LinphoneManager.instance;
NSMutableSet *hiddenKeys = [NSMutableSet set]; NSMutableSet *hiddenKeys = [NSMutableSet set];
const MSList *accounts = linphone_core_get_proxy_config_list(LC); const MSList *accounts = linphone_core_get_account_list(LC);
for (size_t i = bctbx_list_size(accounts) + 1; i <= 5; i++) { for (size_t i = bctbx_list_size(accounts) + 1; i <= 5; i++) {
[hiddenKeys addObject:[NSString stringWithFormat:@"menu_account_%lu", i]]; [hiddenKeys addObject:[NSString stringWithFormat:@"menu_account_%lu", i]];
} }
@ -847,9 +847,9 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
if (pwd && ![pwd isEqualToString:@""]) { if (pwd && ![pwd isEqualToString:@""]) {
if ([pwd isEqualToString:conf_pwd]) { if ([pwd isEqualToString:conf_pwd]) {
_tmpPwd = pwd; _tmpPwd = pwd;
LinphoneProxyConfig *config = bctbx_list_nth_data(linphone_core_get_proxy_config_list(LC), LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
[settingsStore integerForKey:@"current_proxy_config_preference"]); [settingsStore integerForKey:@"current_proxy_config_preference"]);
const LinphoneAuthInfo *ai = linphone_proxy_config_find_auth_info(config); const LinphoneAuthInfo *ai = linphone_account_find_auth_info(account);
LinphoneAccountCreator *account_creator = linphone_account_creator_new( LinphoneAccountCreator *account_creator = linphone_account_creator_new(
LC, [LinphoneManager.instance lpConfigStringForKey:@"xmlrpc_url" inSection:@"assistant" withDefault:@""] LC, [LinphoneManager.instance lpConfigStringForKey:@"xmlrpc_url" inSection:@"assistant" withDefault:@""]

View file

@ -116,9 +116,9 @@
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) { if (section == 0) {
BOOL hasDefault = (linphone_core_get_default_proxy_config(LC) != NULL); BOOL hasDefault = (linphone_core_get_default_account(LC) != NULL);
// default account is shown in the header already // default account is shown in the header already
size_t count = bctbx_list_size(linphone_core_get_proxy_config_list(LC)); size_t count = bctbx_list_size(linphone_core_get_account_list(LC));
return MAX(0, (int)count - (hasDefault ? 1 : 0)); return MAX(0, (int)count - (hasDefault ? 1 : 0));
} else { } else {
return [_sideMenuEntries count]; return [_sideMenuEntries count];
@ -132,14 +132,14 @@
if (indexPath.section == 0 && [LinphoneManager isLcInitialized]) { if (indexPath.section == 0 && [LinphoneManager isLcInitialized]) {
// do not display default account here, it is already in header view // do not display default account here, it is already in header view
int idx = int idx =
linphone_core_get_default_proxy_config(LC) linphone_core_get_default_account(LC)
? bctbx_list_index(linphone_core_get_proxy_config_list(LC), linphone_core_get_default_proxy_config(LC)) ? bctbx_list_index(linphone_core_get_account_list(LC), linphone_core_get_default_account(LC))
: HUGE_VAL; : HUGE_VAL;
LinphoneProxyConfig *proxy = bctbx_list_nth_data(linphone_core_get_proxy_config_list(LC), LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
(int)indexPath.row + (idx <= indexPath.row ? 1 : 0)); (int)indexPath.row + (idx <= indexPath.row ? 1 : 0));
if (proxy) { if (account) {
cell.textLabel.text = [NSString stringWithUTF8String:linphone_proxy_config_get_identity(proxy)]; cell.textLabel.text = [NSString stringWithUTF8String:linphone_account_params_get_identity(linphone_account_get_params(account))];
cell.imageView.image = [StatusBarView imageForState:linphone_proxy_config_get_state(proxy)]; cell.imageView.image = [StatusBarView imageForState:linphone_account_get_state(account)];
} else { } else {
LOGE(@"Invalid index requested, no proxy for row %d", indexPath.row); LOGE(@"Invalid index requested, no proxy for row %d", indexPath.row);
} }

View file

@ -61,17 +61,16 @@
} }
- (void)updateHeader { - (void)updateHeader {
LinphoneProxyConfig *default_proxy = linphone_core_get_default_proxy_config(LC); LinphoneAccount *default_account = linphone_core_get_default_account(LC);
if (default_proxy != NULL) { if (default_account != NULL) {
const LinphoneAddress *addr = linphone_proxy_config_get_identity_address(default_proxy); const LinphoneAddress *addr = linphone_account_params_get_identity_address(linphone_account_get_params(default_account));
[ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr];
char *str = addr ? linphone_address_as_string(addr) : nil; char *str = addr ? linphone_address_as_string(addr) : nil;
_addressLabel.text = str ? [NSString stringWithUTF8String:str] : NSLocalizedString(@"No address", nil); _addressLabel.text = str ? [NSString stringWithUTF8String:str] : NSLocalizedString(@"No address", nil);
if (str) ms_free(str); if (str) ms_free(str);
_presenceImage.image = [StatusBarView imageForState:linphone_proxy_config_get_state(default_proxy)];
} else { } else {
_nameLabel.text = linphone_core_get_proxy_config_list(LC) ? NSLocalizedString(@"No default account", nil) : NSLocalizedString(@"No account", nil); _nameLabel.text = linphone_core_get_account_list(LC) ? NSLocalizedString(@"No default account", nil) : NSLocalizedString(@"No account", nil);
// display direct IP:port address so that we can be reached // display direct IP:port address so that we can be reached
LinphoneAddress *addr = linphone_core_get_primary_contact_parsed(LC); LinphoneAddress *addr = linphone_core_get_primary_contact_parsed(LC);
if (addr) { if (addr) {

View file

@ -85,11 +85,11 @@
MSList *numbers = linphone_friend_get_phone_numbers(friend); MSList *numbers = linphone_friend_get_phone_numbers(friend);
while (numbers) { while (numbers) {
NSString *phone = [NSString stringWithUTF8String:numbers->data]; NSString *phone = [NSString stringWithUTF8String:numbers->data];
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
if (cfg) { if (account) {
const char *normvalue = linphone_proxy_config_normalize_phone_number(cfg, phone.UTF8String); const char *normvalue = linphone_account_normalize_phone_number(account, phone.UTF8String);
LinphoneAddress *addr = linphone_proxy_config_normalize_sip_uri(cfg, normvalue); LinphoneAddress *addr = linphone_account_normalize_sip_uri(account, normvalue);
char *phone_addr = linphone_address_as_string_uri_only(addr); char *phone_addr = linphone_address_as_string_uri_only(addr);
contact = [FastAddressBook getContact:[NSString stringWithUTF8String:phone_addr]]; contact = [FastAddressBook getContact:[NSString stringWithUTF8String:phone_addr]];
ms_free(phone_addr); ms_free(phone_addr);
@ -242,11 +242,11 @@
Contact* mContact = contact; Contact* mContact = contact;
if (!_addressBookMap) if (!_addressBookMap)
return; return;
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); LinphoneAccount *account = linphone_core_get_default_account(LC);
for (NSString *phone in mContact.phones) { for (NSString *phone in mContact.phones) {
char *normalizedPhone = cfg? linphone_proxy_config_normalize_phone_number(cfg, phone.UTF8String) : nil; char *normalizedPhone = account? linphone_account_normalize_phone_number(account, phone.UTF8String) : nil;
NSString *name = [FastAddressBook normalizeSipURI:normalizedPhone ? [NSString stringWithUTF8String:normalizedPhone] : phone]; NSString *name = [FastAddressBook normalizeSipURI:normalizedPhone ? [NSString stringWithUTF8String:normalizedPhone] : phone];
if (phone != NULL) if (phone != NULL)
[_addressBookMap setObject:mContact forKey:(name ?: [FastAddressBook localizedLabel:phone])]; [_addressBookMap setObject:mContact forKey:(name ?: [FastAddressBook localizedLabel:phone])];
@ -552,9 +552,10 @@
NSMutableDictionary *displayNames = [[NSMutableDictionary alloc] initWithDictionary:[defaults dictionaryForKey:@"addressBook"]]; NSMutableDictionary *displayNames = [[NSMutableDictionary alloc] initWithDictionary:[defaults dictionaryForKey:@"addressBook"]];
if (displayNames == nil) return; if (displayNames == nil) return;
LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(LC);
LinphoneAccount *account = linphone_core_get_default_account(LC);
for (NSString *phone in contact.phones) { for (NSString *phone in contact.phones) {
char *normalizedPhone = cfg? linphone_proxy_config_normalize_phone_number(linphone_core_get_default_proxy_config(LC), phone.UTF8String) : nil; char *normalizedPhone = account? linphone_account_normalize_phone_number(account, phone.UTF8String) : nil;
NSString *name = [FastAddressBook normalizeSipURI:normalizedPhone ? [NSString stringWithUTF8String:normalizedPhone] : phone]; NSString *name = [FastAddressBook normalizeSipURI:normalizedPhone ? [NSString stringWithUTF8String:normalizedPhone] : phone];
if (phone != NULL) { if (phone != NULL) {
if ([FastAddressBook isSipURI:displayNames[name]]) { if ([FastAddressBook isSipURI:displayNames[name]]) {

View file

@ -15,6 +15,7 @@
<entry name="realm" overwrite="true">sip.linphone.org</entry> <entry name="realm" overwrite="true">sip.linphone.org</entry>
<entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</entry> <entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</entry>
<entry name="push_notification_allowed" overwrite="true">1</entry> <entry name="push_notification_allowed" overwrite="true">1</entry>
<entry name="remote_push_notification_allowed" overwrite="true">1</entry>
<entry name="conference_factory_uri" overwrite="true">sip:conference-factory@sip.linphone.org</entry> <entry name="conference_factory_uri" overwrite="true">sip:conference-factory@sip.linphone.org</entry>
</section> </section>

View file

@ -15,6 +15,7 @@
<entry name="realm" overwrite="true">sip.linphone.org</entry> <entry name="realm" overwrite="true">sip.linphone.org</entry>
<entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</entry> <entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</entry>
<entry name="push_notification_allowed" overwrite="true">1</entry> <entry name="push_notification_allowed" overwrite="true">1</entry>
<entry name="remote_push_notification_allowed" overwrite="true">1</entry>
<entry name="conference_factory_uri" overwrite="true">sip:conference-factory@sip.linphone.org</entry> <entry name="conference_factory_uri" overwrite="true">sip:conference-factory@sip.linphone.org</entry>
</section> </section>

View file

@ -27,6 +27,8 @@ use_callkit=1
accept_early_media=0 accept_early_media=0
[proxy_default_values]
remote_push_notification_allowed=1
[sip] [sip]
deliver_imdn=1 deliver_imdn=1