forked from mirrors/linphone-iphone
Replace all proxy configs with account, and include the new push notification features from the 5.0 SDK
This commit is contained in:
parent
a1e3989d0a
commit
7ea46b5aab
27 changed files with 560 additions and 617 deletions
|
|
@ -67,23 +67,24 @@
|
|||
linphone_account_creator_cbs_set_activate_alias(linphone_account_creator_get_callbacks(account_creator),
|
||||
assistant_activate_phone_number_link);
|
||||
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (cfg &&
|
||||
LinphoneAccount *acc = linphone_core_get_default_account(LC);
|
||||
LinphoneAccountParams const *accParams = linphone_account_get_params(acc);
|
||||
if (acc &&
|
||||
strcmp([LinphoneManager.instance lpConfigStringForKey:@"domain_name"
|
||||
inSection:@"app"
|
||||
withDefault:@"sip.linphone.org"]
|
||||
.UTF8String,
|
||||
linphone_proxy_config_get_domain(cfg)) == 0) {
|
||||
linphone_account_params_get_domain(accParams)) == 0) {
|
||||
linphone_account_creator_set_username(
|
||||
account_creator, linphone_address_get_username(linphone_proxy_config_get_identity_address(cfg)));
|
||||
const LinphoneAuthInfo *info = linphone_proxy_config_find_auth_info(cfg);
|
||||
account_creator, linphone_address_get_username(linphone_account_params_get_identity_address(accParams)));
|
||||
const LinphoneAuthInfo *info = linphone_account_find_auth_info(acc);
|
||||
if (info) {
|
||||
if (linphone_auth_info_get_passwd(info))
|
||||
linphone_account_creator_set_password(account_creator, linphone_auth_info_get_passwd(info));
|
||||
else
|
||||
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 {
|
||||
LOGW(@"Default proxy is NOT a sip.linphone.org, aborting");
|
||||
[PhoneMainView.instance popToView:DialerView.compositeViewDescription];
|
||||
|
|
@ -215,12 +216,14 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph
|
|||
if (status == LinphoneAccountCreatorStatusAccountActivated) {
|
||||
[LinphoneManager.instance lpConfigSetInt:0 forKey:@"must_link_account_time"];
|
||||
// save country code prefix if none is already entered
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (linphone_proxy_config_get_dial_prefix(cfg) == NULL) {
|
||||
LinphoneAccount *acc = linphone_core_get_default_account(LC);
|
||||
LinphoneAccountParams const *accParams = linphone_account_get_params(acc);
|
||||
if (linphone_account_params_get_international_prefix(accParams) == NULL) {
|
||||
const char *prefix = thiz.countryCodeField.text.UTF8String;
|
||||
linphone_proxy_config_edit(cfg);
|
||||
linphone_proxy_config_set_dial_prefix(cfg, prefix[0] == '+' ? &prefix[1] : prefix);
|
||||
linphone_proxy_config_done(cfg);
|
||||
LinphoneAccountParams * newPrefixAccountParams = linphone_account_params_clone(accParams);
|
||||
linphone_account_params_set_international_prefix(newPrefixAccountParams, prefix[0] == '+' ? &prefix[1] : prefix);
|
||||
linphone_account_set_params(acc, newPrefixAccountParams);
|
||||
linphone_account_params_unref(newPrefixAccountParams);
|
||||
}
|
||||
[PhoneMainView.instance popToView:DialerView.compositeViewDescription];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneAddressBookUpdate object:NULL];
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
UIView *currentView;
|
||||
UIView *nextView;
|
||||
NSMutableArray *historyViews;
|
||||
LinphoneProxyConfig *new_config;
|
||||
size_t number_of_configs_before;
|
||||
LinphoneAccount *new_account;
|
||||
size_t number_of_accounts_before;
|
||||
BOOL mustRestoreView;
|
||||
long phone_number_length;
|
||||
BOOL acceptTerms;
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
|
||||
if (!mustRestoreView) {
|
||||
new_config = NULL;
|
||||
number_of_configs_before = bctbx_list_size(linphone_core_get_proxy_config_list(LC));
|
||||
new_account = NULL;
|
||||
number_of_accounts_before = bctbx_list_size(linphone_core_get_account_list(LC));
|
||||
[self resetTextFields];
|
||||
[self changeView:_welcomeView back:FALSE animation:FALSE];
|
||||
}
|
||||
|
|
@ -437,18 +437,91 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
|
||||
// remove previous proxy config, if any
|
||||
if (new_config != NULL) {
|
||||
const LinphoneAuthInfo *auth = linphone_proxy_config_find_auth_info(new_config);
|
||||
linphone_core_remove_proxy_config(LC, new_config);
|
||||
if (new_account != NULL) {
|
||||
const LinphoneAuthInfo *auth = linphone_account_find_auth_info(new_account);
|
||||
linphone_core_remove_account(LC, new_account);
|
||||
if (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) {
|
||||
[lm configurePushTokenForProxyConfig:new_config];
|
||||
linphone_core_set_default_proxy_config(LC, new_config);
|
||||
ms_free(identity_str);
|
||||
char const *creatorDisplayName = linphone_account_creator_get_display_name(account_creator);
|
||||
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
|
||||
// todo: STOP doing that!
|
||||
[[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread];
|
||||
|
|
@ -612,8 +685,9 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
- (void)fillDefaultValues {
|
||||
[self resetTextFields];
|
||||
|
||||
LinphoneProxyConfig *default_conf = linphone_core_create_proxy_config(LC);
|
||||
const char *identity = linphone_proxy_config_get_identity(default_conf);
|
||||
LinphoneAccountParams *default_account_params = linphone_core_create_account_params(LC);
|
||||
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) {
|
||||
LinphoneAddress *default_addr = linphone_core_interpret_url(LC, identity);
|
||||
if (default_addr) {
|
||||
|
|
@ -630,7 +704,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
[self changeView:_remoteProvisioningLoginView back:FALSE animation:TRUE];
|
||||
|
||||
linphone_proxy_config_unref(default_conf);
|
||||
linphone_account_params_unref(default_account_params);
|
||||
}
|
||||
|
||||
- (void)resetTextFields {
|
||||
|
|
@ -854,15 +928,15 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
- (void)registrationUpdateEvent:(NSNotification *)notif {
|
||||
NSString *message = [notif.userInfo objectForKey:@"message"];
|
||||
[self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue]
|
||||
forProxy:[[notif.userInfo objectForKeyedSubscript:@"cfg"] pointerValue]
|
||||
forAccount:[[notif.userInfo objectForKeyedSubscript:@"account"] pointerValue]
|
||||
message:message];
|
||||
}
|
||||
|
||||
- (void)registrationUpdate:(LinphoneRegistrationState)state
|
||||
forProxy:(LinphoneProxyConfig *)proxy
|
||||
forAccount:(LinphoneAccount *)account
|
||||
message:(NSString *)message {
|
||||
// in assistant we only care about ourself
|
||||
if (proxy != new_config) {
|
||||
if (account != new_account) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -920,7 +994,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
// we successfully loaded a remote provisioned config, go to dialer
|
||||
[LinphoneManager.instance lpConfigSetInt:[NSDate new].timeIntervalSince1970
|
||||
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");
|
||||
[self onDialerClick:nil];
|
||||
}
|
||||
|
|
@ -1404,7 +1478,7 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun
|
|||
NSString *username = [self findTextField:ViewElement_Username].text;
|
||||
NSString *displayName = [self findTextField:ViewElement_DisplayName].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 *tmpAddr = linphone_address_new([NSString stringWithFormat:@"sip:%@",domain].UTF8String);
|
||||
if (tmpAddr == nil) {
|
||||
|
|
@ -1418,26 +1492,23 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun
|
|||
if (displayName && ![displayName isEqualToString:@""]) {
|
||||
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
|
||||
UISegmentedControl *transports = (UISegmentedControl *)[self findView:ViewElement_Transport
|
||||
inView:self.contentView
|
||||
ofType:UISegmentedControl.class];
|
||||
if (transports) {
|
||||
NSString *type = [transports titleForSegmentAtIndex:[transports selectedSegmentIndex]];
|
||||
linphone_proxy_config_set_route(
|
||||
config,
|
||||
[NSString stringWithFormat:@"%s;transport=%s", domain.UTF8String, type.lowercaseString.UTF8String]
|
||||
.UTF8String);
|
||||
linphone_proxy_config_set_server_addr(
|
||||
config,
|
||||
[NSString stringWithFormat:@"%s;transport=%s", domain.UTF8String, type.lowercaseString.UTF8String]
|
||||
.UTF8String);
|
||||
LinphoneAddress *transportAddr = linphone_address_new([NSString stringWithFormat:@"sip:%s;transport=%s", domain.UTF8String, type.lowercaseString.UTF8String].UTF8String);
|
||||
linphone_account_params_set_routes_addresses(accountParams, bctbx_list_new(transportAddr));
|
||||
linphone_account_params_set_server_addr(accountParams, [NSString stringWithFormat:@"%s;transport=%s", domain.UTF8String, type.lowercaseString.UTF8String].UTF8String);
|
||||
|
||||
linphone_address_unref(transportAddr);
|
||||
}
|
||||
|
||||
linphone_proxy_config_enable_publish(config, FALSE);
|
||||
linphone_proxy_config_enable_register(config, TRUE);
|
||||
|
||||
linphone_account_params_set_publish_enabled(accountParams, FALSE);
|
||||
linphone_account_params_set_register_enabled(accountParams, TRUE);
|
||||
|
||||
LinphoneAuthInfo *info =
|
||||
linphone_auth_info_new(linphone_address_get_username(addr), // username
|
||||
NULL, // user id
|
||||
|
|
@ -1449,11 +1520,12 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun
|
|||
linphone_core_add_auth_info(LC, info);
|
||||
linphone_address_unref(addr);
|
||||
linphone_address_unref(tmpAddr);
|
||||
|
||||
if (config) {
|
||||
[[LinphoneManager instance] configurePushTokenForProxyConfig:config];
|
||||
if (linphone_core_add_proxy_config(LC, config) != -1) {
|
||||
linphone_core_set_default_proxy_config(LC, config);
|
||||
|
||||
LinphoneAccount *account = linphone_core_create_account(LC, accountParams);
|
||||
linphone_account_params_unref(accountParams);
|
||||
if (account) {
|
||||
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
|
||||
// todo: STOP doing that!
|
||||
[[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread];
|
||||
|
|
@ -1477,7 +1549,7 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun
|
|||
|
||||
- (IBAction)onRemoteProvisioningDownloadClick:(id)sender {
|
||||
ONNEWCLICKBUTTON(sender, 100, {
|
||||
if (number_of_configs_before > 0) {
|
||||
if (number_of_accounts_before > 0) {
|
||||
// TODO remove ME when it is fixed in SDK.
|
||||
linphone_core_set_provisioning_uri(LC, NULL);
|
||||
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Provisioning Load error", nil)
|
||||
|
|
|
|||
|
|
@ -188,12 +188,6 @@ import AVFoundation
|
|||
@objc func displayIncomingCall(callId: String) {
|
||||
let uuid = CallManager.instance().providerDelegate.uuids["\(callId)"]
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +372,6 @@ import AVFoundation
|
|||
let uuid = UUID()
|
||||
providerDelegate.uuids.updateValue(uuid, forKey: callId)
|
||||
let callInfo = CallInfo.newIncomingCallInfo(callId: callId)
|
||||
callInfo.declined = true
|
||||
callInfo.reason = Reason.Busy
|
||||
providerDelegate.callInfos.updateValue(callInfo, forKey: uuid)
|
||||
} else {
|
||||
|
|
@ -461,166 +454,162 @@ import AVFoundation
|
|||
}
|
||||
|
||||
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 callId = callLog?.callId
|
||||
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 (cstate == .PushIncomingReceived) {
|
||||
displayIncomingCall(call: call, handle: "Calling", hasVideo: false, callId: callId!, displayName: "Calling")
|
||||
} else {
|
||||
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) {
|
||||
let appData = CallAppData()
|
||||
CallManager.setAppData(sCall: call, appData: appData)
|
||||
}
|
||||
if (call.userData == nil) {
|
||||
let appData = CallAppData()
|
||||
CallManager.setAppData(sCall: call, appData: appData)
|
||||
}
|
||||
|
||||
|
||||
switch cstate {
|
||||
case .IncomingReceived:
|
||||
if (CallManager.callKitEnabled()) {
|
||||
let uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
|
||||
if (uuid != nil) {
|
||||
// Tha app is now registered, updated the call already existed.
|
||||
CallManager.instance().providerDelegate.updateCall(uuid: uuid!, handle: addr!.asStringUriOnly(), hasVideo: video, displayName: displayName)
|
||||
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!]
|
||||
if (callInfo?.declined ?? false) {
|
||||
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)
|
||||
switch cstate {
|
||||
case .IncomingReceived:
|
||||
if (CallManager.callKitEnabled()) {
|
||||
let uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
|
||||
if (uuid != nil) {
|
||||
// Tha app is now registered, updated the call already existed.
|
||||
CallManager.instance().providerDelegate.updateCall(uuid: uuid!, handle: addr!.asStringUriOnly(), hasVideo: video, displayName: displayName)
|
||||
} else {
|
||||
CallManager.instance().displayIncomingCall(call: call, handle: addr!.asStringUriOnly(), hasVideo: video, callId: callId!, displayName: displayName)
|
||||
}
|
||||
} else {
|
||||
CallManager.instance().displayIncomingCall(call: call, handle: addr!.asStringUriOnly(), hasVideo: video, callId: callId!, displayName: displayName)
|
||||
} else if (UIApplication.shared.applicationState != .active) {
|
||||
// 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) {
|
||||
// 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)
|
||||
}
|
||||
break
|
||||
case .StreamsRunning:
|
||||
if (CallManager.callKitEnabled()) {
|
||||
let uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
|
||||
if (uuid != nil) {
|
||||
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!]
|
||||
if (callInfo != nil && callInfo!.isOutgoing && !callInfo!.connected) {
|
||||
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: outgoing call connected with uuid \(uuid!) and callId \(callId!)")
|
||||
CallManager.instance().providerDelegate.reportOutgoingCallConnected(uuid: uuid!)
|
||||
callInfo!.connected = true
|
||||
break
|
||||
case .StreamsRunning:
|
||||
if (CallManager.callKitEnabled()) {
|
||||
let uuid = CallManager.instance().providerDelegate.uuids["\(callId!)"]
|
||||
if (uuid != nil) {
|
||||
let callInfo = CallManager.instance().providerDelegate.callInfos[uuid!]
|
||||
if (callInfo != nil && callInfo!.isOutgoing && !callInfo!.connected) {
|
||||
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: outgoing call connected with uuid \(uuid!) and callId \(callId!)")
|
||||
CallManager.instance().providerDelegate.reportOutgoingCallConnected(uuid: uuid!)
|
||||
callInfo!.connected = true
|
||||
CallManager.instance().providerDelegate.callInfos.updateValue(callInfo!, forKey: uuid!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CallManager.instance().speakerBeforePause) {
|
||||
CallManager.instance().speakerBeforePause = false
|
||||
CallManager.instance().enableSpeaker(enable: 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 (CallManager.instance().speakerBeforePause) {
|
||||
CallManager.instance().speakerBeforePause = 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
|
||||
}
|
||||
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
|
||||
NotificationCenter.default.post(name: Notification.Name("LinphoneCallUpdate"), object: self, userInfo: [
|
||||
AnyHashable("call"): NSValue.init(pointer:UnsafeRawPointer(call.getCobject)),
|
||||
|
|
|
|||
|
|
@ -106,15 +106,15 @@
|
|||
continue;
|
||||
}
|
||||
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (cfg) {
|
||||
const char *normalizedPhoneNumber = linphone_proxy_config_normalize_phone_number(cfg, phoneNumber);
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
if (account) {
|
||||
const char *normalizedPhoneNumber = linphone_account_normalize_phone_number(account, phoneNumber);
|
||||
if (!normalizedPhoneNumber) {
|
||||
// get invalid phone number, continue
|
||||
results = results->next;
|
||||
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);
|
||||
address = [NSString stringWithUTF8String:uri];
|
||||
}
|
||||
|
|
@ -188,8 +188,8 @@
|
|||
if (!cell.userInteractionEnabled)
|
||||
return;
|
||||
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (!(cfg && linphone_proxy_config_get_conference_factory_uri(cfg)) || !_isGroupChat) {
|
||||
LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
|
||||
if (!(defaultAccount && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(defaultAccount))) || !_isGroupChat) {
|
||||
LinphoneAddress *addr = linphone_address_new(cell.addressLabel.text.UTF8String);
|
||||
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:_isEncrypted];
|
||||
if (!addr) {
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
selector:@selector(viewUpdateEvent:)
|
||||
name:kLinphoneChatCreateViewChange
|
||||
object:nil];
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
_chiffreOptionView.hidden = !(cfg && linphone_proxy_config_get_conference_factory_uri(cfg));
|
||||
LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
|
||||
_chiffreOptionView.hidden = !(defaultAccount && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(defaultAccount)));
|
||||
if ([LinphoneManager.instance lpConfigBoolForKey:@"hide_linphone_contacts" inSection:@"app"]) {
|
||||
self.linphoneButton.hidden = TRUE;
|
||||
self.selectedButtonImage.hidden = TRUE;
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@
|
|||
[_backToCallButton update];
|
||||
self.tableController.waitView = _waitView;
|
||||
[self setEditing:NO];
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
_addGroupChatButton.hidden = !(cfg && linphone_proxy_config_get_conference_factory_uri(cfg));
|
||||
LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
|
||||
_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];
|
||||
|
||||
// For testing crashlytics
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
UIAlertAction* remAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Remove account(s) and self destruct", nil)
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
linphone_core_clear_proxy_config([LinphoneManager getLc]);
|
||||
linphone_core_clear_accounts([LinphoneManager getLc]);
|
||||
linphone_core_clear_all_auth_info([LinphoneManager getLc]);
|
||||
@try {
|
||||
[LinphoneManager.instance destroyLinphoneCore];
|
||||
|
|
|
|||
|
|
@ -69,11 +69,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
object:nil];
|
||||
|
||||
// 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) {
|
||||
LinphoneProxyConfig *config = (LinphoneProxyConfig *)list->data;
|
||||
if (config) {
|
||||
[self registrationUpdate:linphone_proxy_config_get_state(config)];
|
||||
LinphoneAccount *account = (LinphoneAccount *)list->data;
|
||||
if (account) {
|
||||
[self registrationUpdate:linphone_account_get_state(account)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -148,8 +148,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
const LinphonePresenceModel *model = contact.friend ? linphone_friend_get_presence_model(contact.friend) : NULL;
|
||||
_linphoneImage.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"hide_linphone_contacts" inSection:@"app"] ||
|
||||
! ((model && linphone_presence_model_get_basic_status(model) == LinphonePresenceBasicStatusOpen) || [FastAddressBook contactHasValidSipDomain:contact]);
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
[self shouldHideEncryptedChatView:cfg && linphone_proxy_config_get_conference_factory_uri(cfg) && model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityLimeX3dh)];
|
||||
LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
|
||||
[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);
|
||||
ms_free(addrURI);
|
||||
|
||||
|
|
|
|||
|
|
@ -288,9 +288,9 @@
|
|||
|
||||
- (NSString *)getPhoneNumber {
|
||||
NSString *phoneNumber = @"";
|
||||
LinphoneProxyConfig *config = linphone_core_get_default_proxy_config(LC);
|
||||
if (config) {
|
||||
const LinphoneAddress *identity = linphone_proxy_config_get_identity_address(config);
|
||||
LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
|
||||
if (defaultAccount) {
|
||||
const LinphoneAddress *identity = linphone_account_params_get_identity_address(linphone_account_get_params(defaultAccount));
|
||||
if (identity) {
|
||||
phoneNumber = [NSString stringWithUTF8String:linphone_address_get_username(identity)];
|
||||
}
|
||||
|
|
@ -300,14 +300,14 @@
|
|||
|
||||
- (NSString *)getPassword {
|
||||
NSString *pass;
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (cfg &&
|
||||
LinphoneAccount *defaultAccount = linphone_core_get_default_account(LC);
|
||||
if (defaultAccount &&
|
||||
strcmp([LinphoneManager.instance lpConfigStringForKey:@"domain_name"
|
||||
inSection:@"app"
|
||||
withDefault:@"sip.linphone.org"]
|
||||
.UTF8String,
|
||||
linphone_proxy_config_get_domain(cfg)) == 0) {
|
||||
const LinphoneAuthInfo *info = linphone_proxy_config_find_auth_info(cfg);
|
||||
linphone_account_params_get_domain(linphone_account_get_params(defaultAccount))) == 0) {
|
||||
const LinphoneAuthInfo *info = linphone_account_find_auth_info(defaultAccount);
|
||||
const char *tmpPass;
|
||||
if (linphone_auth_info_get_passwd(info)) {
|
||||
tmpPass = linphone_auth_info_get_passwd(info);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <PushKit/PushKit.h>
|
||||
|
||||
#import "LinphoneCoreSettingsStore.h"
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
|
|
@ -27,19 +26,16 @@
|
|||
#import "linphoneapp-Swift.h"
|
||||
|
||||
|
||||
@interface LinphoneAppDelegate : NSObject <UIApplicationDelegate, PKPushRegistryDelegate, UNUserNotificationCenterDelegate, CLLocationManagerDelegate> {
|
||||
@interface LinphoneAppDelegate : NSObject <UIApplicationDelegate, UNUserNotificationCenterDelegate, CLLocationManagerDelegate> {
|
||||
@private
|
||||
UIBackgroundTaskIdentifier bgStartId;
|
||||
BOOL startedInBackground;
|
||||
CLLocationManager* locationManager;
|
||||
}
|
||||
|
||||
- (void)registerForNotifications;
|
||||
|
||||
@property (nonatomic, retain) UIAlertController *waitingIndicator;
|
||||
@property (nonatomic, retain) NSString *configURL;
|
||||
@property (nonatomic, strong) UIWindow* window;
|
||||
@property PKPushRegistry* voipRegistry;
|
||||
@property BOOL onlyPortrait;
|
||||
@property UIApplicationShortcutItem *shortcutItem;
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@
|
|||
LOGI(@"%@", NSStringFromSelector(_cmd));
|
||||
[LinphoneManager.instance startLinphoneCore];
|
||||
[LinphoneManager.instance.fastAddressBook reloadFriends];
|
||||
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil];
|
||||
}
|
||||
|
||||
|
|
@ -168,18 +169,6 @@
|
|||
return;
|
||||
|
||||
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.
|
||||
LOGI(@"[APNs] register for push notif");
|
||||
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
||||
|
|
@ -283,7 +272,7 @@
|
|||
UIApplicationState state = app.applicationState;
|
||||
|
||||
LinphoneManager *instance = [LinphoneManager instance];
|
||||
//init logs asap
|
||||
//init logs asapt
|
||||
[Log enableLogs:[[LinphoneManager instance] lpConfigIntForKey:@"debugenable_preference"]];
|
||||
|
||||
|
||||
|
|
@ -556,45 +545,6 @@
|
|||
[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
|
||||
|
||||
- (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
|
||||
|
|
|
|||
|
|
@ -140,13 +140,13 @@
|
|||
}
|
||||
|
||||
- (void)transformAccountToKeys:(NSString *)username {
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
while (username && proxies &&
|
||||
const MSList *accountList = linphone_core_get_account_list(LC);
|
||||
while (username && accountList &&
|
||||
strcmp(username.UTF8String,
|
||||
linphone_address_get_username(linphone_proxy_config_get_identity_address(proxies->data))) != 0) {
|
||||
proxies = proxies->next;
|
||||
linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(accountList->data)))) != 0) {
|
||||
accountList = accountList->next;
|
||||
}
|
||||
LinphoneProxyConfig *proxy = NULL;
|
||||
LinphoneAccount *account = NULL;
|
||||
|
||||
// default values
|
||||
{
|
||||
|
|
@ -171,15 +171,16 @@
|
|||
[self setCString:"" forKey:@"account_stun_preference"];
|
||||
}
|
||||
|
||||
if (proxies) {
|
||||
proxy = proxies->data;
|
||||
if (accountList) {
|
||||
account = accountList->data;
|
||||
LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
|
||||
// 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"];
|
||||
|
||||
const LinphoneAddress *identity_addr = linphone_proxy_config_get_identity_address(proxy);
|
||||
const char *server_addr = linphone_proxy_config_get_server_addr(proxy);
|
||||
const LinphoneAddress *identity_addr = linphone_account_params_get_identity_address(accountParams);
|
||||
const char *server_addr = linphone_account_params_get_server_addr(accountParams);
|
||||
LinphoneAddress *proxy_addr = linphone_core_interpret_url(LC, server_addr);
|
||||
if (identity_addr && proxy_addr) {
|
||||
int port = linphone_address_get_port(proxy_addr);
|
||||
|
|
@ -214,10 +215,10 @@
|
|||
[self setCString:tname forKey:@"account_transport_preference"];
|
||||
}
|
||||
|
||||
[self setBool:(linphone_proxy_config_get_route(proxy) != NULL) forKey:@"account_outbound_proxy_preference"];
|
||||
[self setBool:linphone_proxy_config_avpf_enabled(proxy) forKey:@"account_avpf_preference"];
|
||||
[self setBool:linphone_proxy_config_register_enabled(proxy) forKey:@"account_is_enabled_preference"];
|
||||
[self setBool:(linphone_core_get_default_proxy_config(LC) == proxy)
|
||||
[self setBool:(linphone_account_params_get_routes_addresses(accountParams) != NULL) forKey:@"account_outbound_proxy_preference"];
|
||||
[self setBool:linphone_account_is_avpf_enabled(account) forKey:@"account_avpf_preference"];
|
||||
[self setBool:linphone_account_params_get_register_enabled(accountParams) forKey:@"account_is_enabled_preference"];
|
||||
[self setBool:(linphone_core_get_default_account(LC) == account)
|
||||
forKey:@"account_is_default_preference"];
|
||||
|
||||
const LinphoneAuthInfo *ai = linphone_core_find_auth_info(
|
||||
|
|
@ -230,13 +231,13 @@
|
|||
[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"];
|
||||
|
||||
int expires = linphone_proxy_config_get_expires(proxy);
|
||||
int expires = linphone_account_params_get_expires(accountParams);
|
||||
[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) {
|
||||
[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"];
|
||||
|
|
@ -245,9 +246,9 @@
|
|||
|
||||
// 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"];
|
||||
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"];
|
||||
}
|
||||
}
|
||||
|
|
@ -258,12 +259,12 @@
|
|||
|
||||
// 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);
|
||||
for (size_t i = 1; i <= count; i++, accounts = accounts->next) {
|
||||
NSString *key = [NSString stringWithFormat:@"menu_account_%lu", i];
|
||||
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)accounts->data;
|
||||
[self setCString:linphone_address_get_username(linphone_proxy_config_get_identity_address(proxy))
|
||||
LinphoneAccount *account = (LinphoneAccount *)accounts->data;
|
||||
[self setCString:linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(account)))
|
||||
forKey:key];
|
||||
}
|
||||
|
||||
|
|
@ -456,7 +457,8 @@
|
|||
- (void)synchronizeAccounts {
|
||||
LOGI(@"Account changed, synchronizing.");
|
||||
LinphoneManager *lm = LinphoneManager.instance;
|
||||
LinphoneProxyConfig *proxyCfg = NULL;
|
||||
LinphoneAccount *account = NULL;
|
||||
LinphoneAccountParams *newAccountParams = NULL;
|
||||
NSString *error = nil;
|
||||
|
||||
int port_preference = [self integerForKey:@"port_preference"];
|
||||
|
|
@ -530,17 +532,18 @@
|
|||
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"]);
|
||||
|
||||
// if account was deleted, it is not present anymore
|
||||
if (proxyCfg == NULL)
|
||||
if (account == NULL)
|
||||
goto bad_proxy;
|
||||
|
||||
|
||||
LinphoneAddress *linphoneAddress = linphone_core_interpret_url(LC, "sip:user@domain.com");
|
||||
linphone_address_set_username(linphoneAddress, username.UTF8String);
|
||||
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) {
|
||||
linphone_address_set_username(linphoneAddress, user);
|
||||
ms_free(user);
|
||||
|
|
@ -551,58 +554,61 @@
|
|||
const char *password = [accountPassword 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);
|
||||
goto bad_proxy;
|
||||
}
|
||||
// use proxy as route if outbound_proxy is enabled
|
||||
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);
|
||||
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);
|
||||
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_ice(policy, use_ice);
|
||||
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) {
|
||||
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"]) {
|
||||
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
|
||||
linphone_proxy_config_set_push_notification_allowed(proxyCfg, pushnotification);
|
||||
[LinphoneManager.instance configurePushTokenForProxyConfig:proxyCfg];
|
||||
linphone_account_params_set_push_notification_allowed(newAccountParams, pushnotification);
|
||||
linphone_account_params_set_remote_push_notification_allowed(newAccountParams, pushnotification);
|
||||
|
||||
linphone_proxy_config_enable_register(proxyCfg, is_enabled);
|
||||
linphone_proxy_config_set_avpf_mode(proxyCfg, use_avpf);
|
||||
linphone_proxy_config_set_expires(proxyCfg, expire);
|
||||
linphone_account_params_set_register_enabled(newAccountParams, is_enabled);
|
||||
linphone_account_params_set_avpf_mode(newAccountParams, use_avpf);
|
||||
linphone_account_params_set_expires(newAccountParams, expire);
|
||||
|
||||
linphone_account_set_params(account, newAccountParams);
|
||||
linphone_account_params_unref(newAccountParams);
|
||||
if (is_default) {
|
||||
linphone_core_set_default_proxy_config(LC, proxyCfg);
|
||||
} else if (linphone_core_get_default_proxy_config(LC) == proxyCfg) {
|
||||
linphone_core_set_default_proxy_config(LC, NULL);
|
||||
linphone_core_set_default_account(LC, account);
|
||||
} else if (linphone_core_get_default_account(LC) == account) {
|
||||
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;
|
||||
if (proxyAi) {
|
||||
realm = ms_strdup(linphone_auth_info_get_realm(proxyAi));
|
||||
} else {
|
||||
realm = NULL;
|
||||
}
|
||||
// setup new proxycfg
|
||||
linphone_proxy_config_done(proxyCfg);
|
||||
|
||||
// modify auth info only after finishing editting the proxy config, so that
|
||||
// UNREGISTER succeed
|
||||
|
|
@ -621,12 +627,12 @@
|
|||
LinphoneAuthInfo *info;
|
||||
if (password) {
|
||||
info = linphone_auth_info_new(linphone_address_get_username(from), userid_str, password, NULL,
|
||||
linphone_proxy_config_get_realm(proxyCfg),
|
||||
linphone_proxy_config_get_domain(proxyCfg));
|
||||
linphone_account_params_get_realm(newAccountParams),
|
||||
linphone_account_params_get_domain(newAccountParams));
|
||||
} else {
|
||||
info = linphone_auth_info_new(linphone_address_get_username(from), userid_str, NULL, ha1,
|
||||
realm ? realm : linphone_proxy_config_get_realm(proxyCfg),
|
||||
linphone_proxy_config_get_domain(proxyCfg));
|
||||
realm ? realm : linphone_account_params_get_realm(newAccountParams),
|
||||
linphone_account_params_get_domain(newAccountParams));
|
||||
}
|
||||
|
||||
linphone_address_unref(from);
|
||||
|
|
@ -634,7 +640,7 @@
|
|||
linphone_auth_info_destroy(info);
|
||||
ms_free(realm);
|
||||
}
|
||||
|
||||
|
||||
bad_proxy:
|
||||
if (proxy)
|
||||
ms_free(proxy);
|
||||
|
|
@ -643,7 +649,10 @@
|
|||
|
||||
// in case of error, show an alert to the user
|
||||
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)
|
||||
message:error
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
|
@ -655,6 +664,7 @@
|
|||
[errView addAction:defaultAction];
|
||||
[PhoneMainView.instance presentViewController:errView animated:YES completion:nil];
|
||||
}
|
||||
|
||||
}
|
||||
// reload address book to prepend proxy config domain to contacts' phone number
|
||||
[[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread];
|
||||
|
|
@ -907,17 +917,17 @@
|
|||
NSString *rls_uri = [lm lpConfigStringForKey:@"rls_uri" inSection:@"sip" withDefault:@"sips:rls@sip.linphone.org"];
|
||||
LinphoneAddress *rls_addr = linphone_address_new(rls_uri.UTF8String);
|
||||
const char *rls_domain = linphone_address_get_domain(rls_addr);
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
if (!proxies) // Enable it if no proxy config for first launch of app
|
||||
const MSList *accounts = linphone_core_get_account_list(LC);
|
||||
if (!accounts) // Enable it if no proxy config for first launch of app
|
||||
[self setInteger:1 forKey:@"use_rls_presence"];
|
||||
else {
|
||||
while (proxies) {
|
||||
const char *proxy_domain = linphone_proxy_config_get_domain(proxies->data);
|
||||
while (accounts) {
|
||||
const char *proxy_domain = linphone_account_params_get_domain(linphone_account_get_params(accounts->data));
|
||||
if (strcmp(rls_domain, proxy_domain) == 0) {
|
||||
[self setInteger:1 forKey:@"use_rls_presence"];
|
||||
break;
|
||||
}
|
||||
proxies = proxies->next;
|
||||
accounts = accounts->next;
|
||||
}
|
||||
}
|
||||
linphone_address_unref(rls_addr);
|
||||
|
|
@ -962,7 +972,7 @@
|
|||
}
|
||||
|
||||
- (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"]);
|
||||
|
||||
const MSList *lists = linphone_core_get_friends_lists(LC);
|
||||
|
|
@ -971,10 +981,10 @@
|
|||
linphone_friend_list_update_subscriptions(lists->data);
|
||||
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);
|
||||
linphone_core_remove_proxy_config(LC, config);
|
||||
const LinphoneAuthInfo *ai = linphone_account_find_auth_info(account);
|
||||
linphone_core_remove_account(LC, account);
|
||||
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
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
|
|
@ -985,8 +995,8 @@
|
|||
|
||||
if (isDefault) {
|
||||
// if we removed the default proxy config, set another one instead
|
||||
if (linphone_core_get_proxy_config_list(LC) != NULL) {
|
||||
linphone_core_set_default_proxy_config(LC, (LinphoneProxyConfig *)(linphone_core_get_proxy_config_list(LC)->data));
|
||||
if (linphone_core_get_account_list(LC) != NULL) {
|
||||
linphone_core_set_default_account(LC, (LinphoneAccount *)(linphone_core_get_account_list(LC)->data));
|
||||
}
|
||||
}
|
||||
[self transformLinphoneCoreToKeys];
|
||||
|
|
|
|||
|
|
@ -124,8 +124,6 @@ typedef struct _LinphoneManagerSounds {
|
|||
- (void)becomeActive;
|
||||
- (BOOL)enterBackgroundMode;
|
||||
- (void)addPushCallId:(NSString*) callid;
|
||||
- (void)configurePushTokenForProxyConfigs;
|
||||
- (void)configurePushTokenForProxyConfig: (LinphoneProxyConfig*)cfg;
|
||||
- (BOOL)popPushCallID:(NSString*) callId;
|
||||
- (void)acceptCallForCallId:(NSString*)callid;
|
||||
+ (BOOL)langageDirectionIsRTL;
|
||||
|
|
@ -218,7 +216,6 @@ typedef struct _LinphoneManagerSounds {
|
|||
@property NSDictionary *pushDict;
|
||||
@property(strong, nonatomic) OrderedDictionary *linphoneManagerAddressBookMap;
|
||||
@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;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -242,7 +242,6 @@ struct codec_name_pref_table codec_pref_table[] = {{"speex", 8000, "speex_8k_pre
|
|||
_pushDict = [[NSMutableDictionary alloc] init];
|
||||
_database = NULL;
|
||||
_conf = FALSE;
|
||||
_canConfigurePushTokenForProxyConfigs = FALSE;
|
||||
_fileTransferDelegates = [[NSMutableArray alloc] init];
|
||||
_linphoneManagerAddressBookMap = [[OrderedDictionary 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 {
|
||||
/* AVPF migration */
|
||||
if ([self lpConfigBoolForKey:@"avpf_migration_done"] == FALSE) {
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(theLinphoneCore);
|
||||
while (proxies) {
|
||||
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)proxies->data;
|
||||
const char *addr = linphone_proxy_config_get_addr(proxy);
|
||||
const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
|
||||
while (accounts)
|
||||
{
|
||||
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
|
||||
if (addr &&
|
||||
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"]
|
||||
.UTF8String) != 0) {
|
||||
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"];
|
||||
}
|
||||
/* Quality Reporting migration */
|
||||
if ([self lpConfigBoolForKey:@"quality_report_migration_done"] == FALSE) {
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(theLinphoneCore);
|
||||
while (proxies) {
|
||||
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)proxies->data;
|
||||
const char *addr = linphone_proxy_config_get_addr(proxy);
|
||||
const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
|
||||
while (accounts)
|
||||
{
|
||||
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
|
||||
if (addr &&
|
||||
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"]
|
||||
.UTF8String) != 0) {
|
||||
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_proxy_config_set_quality_reporting_interval(proxy, 180);
|
||||
linphone_proxy_config_enable_quality_reporting(proxy, TRUE);
|
||||
|
||||
linphone_account_params_set_quality_reporting_collector(
|
||||
newAccountParams, "sip:voip-metrics@sip.linphone.org;transport=tls");
|
||||
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"];
|
||||
}
|
||||
|
|
@ -425,59 +433,73 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
|
|||
}
|
||||
|
||||
if ([self lpConfigBoolForKey:@"lime_migration_done"] == FALSE) {
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
while (proxies) {
|
||||
if (!strcmp(linphone_proxy_config_get_domain((LinphoneProxyConfig *)proxies->data),"sip.linphone.org")) {
|
||||
const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
|
||||
while (accounts)
|
||||
{
|
||||
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");
|
||||
break;
|
||||
}
|
||||
proxies = proxies->next;
|
||||
accounts = accounts->next;
|
||||
}
|
||||
[self lpConfigSetBool:TRUE forKey:@"lime_migration_done"];
|
||||
}
|
||||
|
||||
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;
|
||||
while (proxies) {
|
||||
const char *refkey = linphone_proxy_config_get_ref_key(proxies->data);
|
||||
while (accounts)
|
||||
{
|
||||
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) {
|
||||
pushEnabled = (strcmp(refkey, "push_notification") == 0);
|
||||
} else {
|
||||
pushEnabled = true;
|
||||
}
|
||||
linphone_proxy_config_set_push_notification_allowed(proxies->data, pushEnabled);
|
||||
proxies = proxies->next;
|
||||
linphone_account_params_set_push_notification_allowed(newAccountParams, pushEnabled);
|
||||
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"];
|
||||
}
|
||||
}
|
||||
|
||||
- (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"
|
||||
inSection:@"app"
|
||||
withDefault:@"sip.linphone.org"];
|
||||
while (proxies) {
|
||||
LinphoneProxyConfig *config = proxies->data;
|
||||
// can not create group chat without conference factory
|
||||
if (!linphone_proxy_config_get_conference_factory_uri(config)) {
|
||||
if (strcmp(appDomain.UTF8String, linphone_proxy_config_get_domain(config)) == 0) {
|
||||
linphone_proxy_config_set_conference_factory_uri(config, "sip:conference-factory@sip.linphone.org");
|
||||
}
|
||||
}
|
||||
proxies = proxies->next;
|
||||
}
|
||||
while (accounts) {
|
||||
LinphoneAccount *account = accounts->data;
|
||||
LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
|
||||
// can not create group chat without conference factory
|
||||
if (!linphone_account_params_get_conference_factory_uri(newAccountParams)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
linphone_account_params_unref(newAccountParams);
|
||||
accounts = accounts->next;
|
||||
}
|
||||
|
||||
NSString *s = [self lpConfigStringForKey:@"pushnotification_preference"];
|
||||
if (s && s.boolValue) {
|
||||
LOGI(@"Migrating push notification per account, enabling for ALL");
|
||||
[self lpConfigSetBool:NO forKey:@"pushnotification_preference"];
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
while (proxies) {
|
||||
linphone_proxy_config_set_push_notification_allowed(proxies->data, true);
|
||||
[self configurePushTokenForProxyConfig:proxies->data];
|
||||
proxies = proxies->next;
|
||||
const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
|
||||
while (accounts) {
|
||||
LinphoneAccount *account = accounts->data;
|
||||
LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
|
||||
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
|
||||
|
||||
- (void)onRegister:(LinphoneCore *)lc
|
||||
cfg:(LinphoneProxyConfig *)cfg
|
||||
account:(LinphoneAccount *)account
|
||||
state:(LinphoneRegistrationState)state
|
||||
message:(const char *)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;
|
||||
switch (reason) {
|
||||
case LinphoneReasonBadCredentials:
|
||||
|
|
@ -701,13 +712,13 @@ message:(const char *)cmessage {
|
|||
// Post event
|
||||
NSDictionary *dict =
|
||||
[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];
|
||||
}
|
||||
|
||||
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) {
|
||||
[(__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
|
||||
|
|
@ -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
|
||||
// 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;
|
||||
while (configList && !foundMatchingConfig) {
|
||||
const char * configUsername = linphone_proxy_config_get_identity(configList->data);
|
||||
const char * configDomain = linphone_proxy_config_get_domain(configList->data);
|
||||
while (accountList && !foundMatchingConfig) {
|
||||
LinphoneAccountParams const *accountParams = linphone_account_get_params(accountList->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);
|
||||
configList = configList->next;
|
||||
accountList = accountList->next;
|
||||
}
|
||||
if (!foundMatchingConfig) {
|
||||
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) {
|
||||
[LinphoneManager.instance lpConfigSetInt:0 forKey:@"must_link_account_time"];
|
||||
} else {
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (cfg &&
|
||||
strcmp(linphone_proxy_config_get_domain(cfg),
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
|
||||
if (account &&
|
||||
strcmp(linphone_account_params_get_domain(accountParams),
|
||||
[LinphoneManager.instance lpConfigStringForKey:@"domain_name"
|
||||
inSection:@"app"
|
||||
withDefault:@"sip.linphone.org"]
|
||||
.UTF8String) == 0) {
|
||||
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Link your account", 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];
|
||||
|
||||
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 *now = [NSDate date];
|
||||
if (nextTime.timeIntervalSince1970 > 0 && [now earlierDate:nextTime] == nextTime) {
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (cfg) {
|
||||
const char *username = linphone_address_get_username(linphone_proxy_config_get_identity_address(cfg));
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
if (account) {
|
||||
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(
|
||||
LC,
|
||||
[LinphoneManager.instance lpConfigStringForKey:@"xmlrpc_url" inSection:@"assistant" withDefault:@""]
|
||||
|
|
@ -1273,7 +1286,28 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
|
|||
}
|
||||
|
||||
- (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 {
|
||||
|
|
@ -1303,7 +1337,7 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
|
|||
|
||||
LinphoneFactory *factory = linphone_factory_get();
|
||||
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_authentication_requested(cbs, linphone_iphone_popup_password_request);
|
||||
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];
|
||||
[ConfigManager.instance setDbWithDb:_configDb];
|
||||
|
||||
linphone_core_start(theLinphoneCore);
|
||||
|
||||
[LinphoneManager.instance startLinphoneCore];
|
||||
|
||||
// Let the core handle cbs
|
||||
linphone_core_cbs_unref(cbs);
|
||||
|
|
@ -1358,10 +1392,6 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
|
|||
selector:@selector(globalStateChangedNotificationHandler:)
|
||||
name:kLinphoneGlobalStateUpdate
|
||||
object:nil];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self
|
||||
selector:@selector(configuringStateChangedNotificationHandler:)
|
||||
name:kLinphoneConfiguringStateUpdate
|
||||
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
|
||||
|
|
@ -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));
|
||||
}
|
||||
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
while (proxies) {
|
||||
LinphoneProxyConfig *cfg = proxies->data;
|
||||
linphone_proxy_config_edit(cfg);
|
||||
linphone_proxy_config_enable_publish(cfg, enabled);
|
||||
linphone_proxy_config_done(cfg);
|
||||
proxies = proxies->next;
|
||||
const MSList *accounts = linphone_core_get_account_list(LC);
|
||||
while (accounts) {
|
||||
LinphoneAccount *account = accounts->data;
|
||||
LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
|
||||
linphone_account_params_set_publish_enabled(newAccountParams, enabled);
|
||||
linphone_account_set_params(account, newAccountParams);
|
||||
linphone_account_params_unref(newAccountParams);
|
||||
accounts = accounts->next;
|
||||
}
|
||||
// force registration update first, then update friend list subscription
|
||||
[self iterate];
|
||||
|
|
@ -1503,15 +1534,16 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
|
||||
- (BOOL)enterBackgroundMode {
|
||||
LinphoneProxyConfig *proxyCfg = linphone_core_get_default_proxy_config(theLinphoneCore);
|
||||
LinphoneAccount *account = linphone_core_get_default_account(theLinphoneCore);
|
||||
BOOL shouldEnterBgMode = FALSE;
|
||||
|
||||
// disable presence
|
||||
[self enableProxyPublish:NO];
|
||||
|
||||
// handle proxy config if any
|
||||
if (proxyCfg) {
|
||||
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg);
|
||||
if (account) {
|
||||
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 (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
// 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");
|
||||
if (!shouldEnterBgMode && floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg);
|
||||
if (pushNotifEnabled) {
|
||||
LOGI(@"Keeping lc core to handle push");
|
||||
return YES;
|
||||
if (account) {
|
||||
LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
|
||||
BOOL pushNotifEnabled = linphone_account_params_get_push_notification_allowed(accountParams);
|
||||
if (pushNotifEnabled) {
|
||||
LOGI(@"Keeping lc core to handle push");
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
|
@ -1802,116 +1837,12 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
|
||||
#pragma mark - Property Functions
|
||||
|
||||
- (void)setPushKitToken:(NSData *)pushKitToken {
|
||||
if (pushKitToken == _pushKitToken) {
|
||||
return;
|
||||
}
|
||||
_pushKitToken = pushKitToken;
|
||||
|
||||
[self configurePushTokenForProxyConfigs];
|
||||
}
|
||||
|
||||
- (void)setRemoteNotificationToken:(NSData *)remoteNotificationToken {
|
||||
if (remoteNotificationToken == _remoteNotificationToken) {
|
||||
return;
|
||||
}
|
||||
_remoteNotificationToken = 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);
|
||||
linphone_core_did_register_for_remote_push(LC, (__bridge void*)remoteNotificationToken);
|
||||
}
|
||||
|
||||
#pragma mark - Misc Functions
|
||||
|
|
@ -2192,9 +2123,10 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
- (NSString *)contactFilter {
|
||||
NSString *filter = @"*";
|
||||
if ([self lpConfigBoolForKey:@"contact_filter_on_default_domain"]) {
|
||||
LinphoneProxyConfig *proxy_cfg = linphone_core_get_default_proxy_config(theLinphoneCore);
|
||||
if (proxy_cfg && linphone_proxy_config_get_addr(proxy_cfg)) {
|
||||
return [NSString stringWithCString:linphone_proxy_config_get_domain(proxy_cfg)
|
||||
LinphoneAccount *account = linphone_core_get_default_account(theLinphoneCore);
|
||||
LinphoneAccountParams const *accountParams = linphone_account_get_params(account);
|
||||
if (account && linphone_account_params_get_server_addr(accountParams)) {
|
||||
return [NSString stringWithCString:linphone_account_params_get_domain(accountParams)
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
}
|
||||
|
|
@ -2211,7 +2143,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
#pragma mark -
|
||||
|
||||
- (void)removeAllAccounts {
|
||||
linphone_core_clear_proxy_config(LC);
|
||||
linphone_core_clear_accounts(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)
|
||||
return NO;
|
||||
|
||||
const MSList *it = linphone_core_get_proxy_config_list(LC);
|
||||
while (it) {
|
||||
if (linphone_address_weak_equal(addr, linphone_proxy_config_get_identity_address(it->data))) {
|
||||
const MSList *accounts = linphone_core_get_account_list(LC);
|
||||
while (accounts) {
|
||||
if (linphone_address_weak_equal(addr, linphone_account_params_get_identity_address(linphone_account_get_params(accounts->data)))) {
|
||||
return YES;
|
||||
}
|
||||
it = it->next;
|
||||
accounts = accounts->next;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,10 +71,10 @@
|
|||
object:nil];
|
||||
|
||||
// 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);
|
||||
|
||||
[self proxyConfigUpdate:config];
|
||||
[self accountUpdate:account];
|
||||
[self updateUI:linphone_core_get_calls_nb(LC)];
|
||||
[self updateVoicemail];
|
||||
}
|
||||
|
|
@ -107,8 +107,8 @@
|
|||
#pragma mark - Event Functions
|
||||
|
||||
- (void)registrationUpdate:(NSNotification *)notif {
|
||||
LinphoneProxyConfig *config = linphone_core_get_default_proxy_config(LC);
|
||||
[self proxyConfigUpdate:config];
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
[self accountUpdate:account];
|
||||
}
|
||||
|
||||
- (void)globalStateUpdate:(NSNotification *)notif {
|
||||
|
|
@ -180,7 +180,7 @@
|
|||
return [UIImage imageNamed:@"led_connected.png"];
|
||||
}
|
||||
}
|
||||
- (void)proxyConfigUpdate:(LinphoneProxyConfig *)config {
|
||||
- (void)accountUpdate:(LinphoneAccount *)account {
|
||||
LinphoneRegistrationState state = LinphoneRegistrationNone;
|
||||
NSString *message = nil;
|
||||
LinphoneGlobalState gstate = linphone_core_get_global_state(LC);
|
||||
|
|
@ -191,16 +191,16 @@
|
|||
message = NSLocalizedString(@"Network down", nil);
|
||||
} else if (gstate == LinphoneGlobalConfiguring) {
|
||||
message = NSLocalizedString(@"Fetching remote configuration", nil);
|
||||
} else if (config == NULL) {
|
||||
} else if (account == NULL) {
|
||||
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);
|
||||
} else {
|
||||
message = NSLocalizedString(@"No account configured", nil);
|
||||
}
|
||||
|
||||
} else {
|
||||
state = linphone_proxy_config_get_state(config);
|
||||
state = linphone_account_get_state(account);
|
||||
|
||||
switch (state) {
|
||||
case LinphoneRegistrationOk:
|
||||
|
|
@ -406,9 +406,9 @@
|
|||
}
|
||||
|
||||
- (IBAction)onRegistrationStateClick:(id)sender {
|
||||
if (linphone_core_get_default_proxy_config(LC)) {
|
||||
if (linphone_core_get_default_account(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];
|
||||
} else {
|
||||
[PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription];
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@
|
|||
const LinphoneAddress *to = linphone_call_log_get_to_address(log);
|
||||
const char *domain = linphone_address_get_domain(to);
|
||||
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 (def_proxy) {
|
||||
const char *def_domain = linphone_proxy_config_get_domain(def_proxy);
|
||||
if (def_account) {
|
||||
const char *def_domain = linphone_account_params_get_domain(linphone_account_get_params(def_account));
|
||||
if (def_domain && domain && !strcmp(domain, def_domain)) {
|
||||
bis_address = ms_strdup(linphone_address_get_username(to));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,8 +344,8 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
LinphoneGlobalState state = (LinphoneGlobalState)[[[notif userInfo] valueForKey:@"state"] integerValue];
|
||||
static BOOL already_shown = FALSE;
|
||||
if (state == LinphoneGlobalOn && !already_shown && LinphoneManager.instance.wasRemoteProvisioned) {
|
||||
LinphoneProxyConfig *conf = linphone_core_get_default_proxy_config(LC);
|
||||
if ([LinphoneManager.instance lpConfigBoolForKey:@"show_login_view" inSection:@"app"] && conf == NULL) {
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
if ([LinphoneManager.instance lpConfigBoolForKey:@"show_login_view" inSection:@"app"] && account == NULL) {
|
||||
already_shown = TRUE;
|
||||
AssistantView *view = VIEW(AssistantView);
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
|
|
@ -487,8 +487,8 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
} else {
|
||||
// always start to dialer when testing
|
||||
// Change to default view
|
||||
const MSList *list = linphone_core_get_proxy_config_list(LC);
|
||||
if (list != NULL ||
|
||||
const MSList *accountList = linphone_core_get_account_list(LC);
|
||||
if (accountList != NULL ||
|
||||
([lm lpConfigBoolForKey:@"hide_assistant_preference"] ==
|
||||
true) ||
|
||||
lm.isTesting) {
|
||||
|
|
@ -702,9 +702,9 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
NSString *lMessage;
|
||||
NSString *lTitle;
|
||||
|
||||
// get default proxy
|
||||
LinphoneProxyConfig *proxyCfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (proxyCfg == nil) {
|
||||
// get default account
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
if (account == nil) {
|
||||
lMessage = NSLocalizedString(@"Please make sure your device is connected to the internet and double check your "
|
||||
@"SIP account configuration in the settings.",
|
||||
nil);
|
||||
|
|
@ -839,9 +839,9 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
}
|
||||
|
||||
LinphoneAddress *local;
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (cfg) {
|
||||
local = linphone_address_clone(linphone_proxy_config_get_contact(cfg));
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
if (account) {
|
||||
local = linphone_address_clone(linphone_account_get_contact_address(account));
|
||||
} else {
|
||||
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{
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
if (!(cfg && linphone_proxy_config_get_conference_factory_uri(cfg))
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
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))) {
|
||||
// If there's no factory uri, create a basic chat room
|
||||
if (bctbx_list_size(addresses) != 1) {
|
||||
|
|
|
|||
|
|
@ -26,11 +26,9 @@ import os
|
|||
|
||||
@objc class CallInfo: NSObject {
|
||||
var callId: String = ""
|
||||
var accepted = false
|
||||
var toAddr: Address?
|
||||
var isOutgoing = false
|
||||
var sasEnabled = false
|
||||
var declined = false
|
||||
var connected = false
|
||||
var reason: Reason = Reason.None
|
||||
var displayName: String?
|
||||
|
|
@ -109,7 +107,6 @@ class ProviderDelegate: NSObject {
|
|||
default:
|
||||
callInfo?.reason = Reason.Unknown
|
||||
}
|
||||
callInfo?.declined = true
|
||||
self.callInfos.updateValue(callInfo!, forKey: uuid)
|
||||
try? call?.decline(reason: callInfo!.reason)
|
||||
}
|
||||
|
|
@ -181,14 +178,7 @@ extension ProviderDelegate: CXProviderDelegate {
|
|||
|
||||
let call = CallManager.instance().callByCallId(callId: callId)
|
||||
CallManager.instance().lc?.configureAudioSession()
|
||||
if (call == nil || call?.state != Call.State.IncomingReceived) {
|
||||
// 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)
|
||||
}
|
||||
CallManager.instance().acceptCall(call: call!, hasVideo: call!.params?.videoEnabled ?? false)
|
||||
action.fulfill()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -440,10 +440,10 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
|
|||
linphone_account_creator_set_password(creator, _tmpPwd.UTF8String);
|
||||
[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"]);
|
||||
if (config != NULL) {
|
||||
const LinphoneAuthInfo *auth = linphone_proxy_config_find_auth_info(config);
|
||||
if (account != NULL) {
|
||||
const LinphoneAuthInfo *auth = linphone_account_find_auth_info(account);
|
||||
if (auth) {
|
||||
LinphoneAuthInfo * newAuth = linphone_auth_info_clone(auth);
|
||||
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_"]) {
|
||||
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;
|
||||
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
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
|
@ -595,7 +595,7 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
|
|||
LinphoneManager *lm = LinphoneManager.instance;
|
||||
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++) {
|
||||
[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 isEqualToString:conf_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"]);
|
||||
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(
|
||||
LC, [LinphoneManager.instance lpConfigStringForKey:@"xmlrpc_url" inSection:@"assistant" withDefault:@""]
|
||||
|
|
|
|||
|
|
@ -116,9 +116,9 @@
|
|||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
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
|
||||
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));
|
||||
} else {
|
||||
return [_sideMenuEntries count];
|
||||
|
|
@ -132,14 +132,14 @@
|
|||
if (indexPath.section == 0 && [LinphoneManager isLcInitialized]) {
|
||||
// do not display default account here, it is already in header view
|
||||
int idx =
|
||||
linphone_core_get_default_proxy_config(LC)
|
||||
? bctbx_list_index(linphone_core_get_proxy_config_list(LC), linphone_core_get_default_proxy_config(LC))
|
||||
linphone_core_get_default_account(LC)
|
||||
? bctbx_list_index(linphone_core_get_account_list(LC), linphone_core_get_default_account(LC))
|
||||
: 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));
|
||||
if (proxy) {
|
||||
cell.textLabel.text = [NSString stringWithUTF8String:linphone_proxy_config_get_identity(proxy)];
|
||||
cell.imageView.image = [StatusBarView imageForState:linphone_proxy_config_get_state(proxy)];
|
||||
if (account) {
|
||||
cell.textLabel.text = [NSString stringWithUTF8String:linphone_account_params_get_identity(linphone_account_get_params(account))];
|
||||
cell.imageView.image = [StatusBarView imageForState:linphone_account_get_state(account)];
|
||||
} else {
|
||||
LOGE(@"Invalid index requested, no proxy for row %d", indexPath.row);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,17 +61,16 @@
|
|||
}
|
||||
|
||||
- (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) {
|
||||
const LinphoneAddress *addr = linphone_proxy_config_get_identity_address(default_proxy);
|
||||
if (default_account != NULL) {
|
||||
const LinphoneAddress *addr = linphone_account_params_get_identity_address(linphone_account_get_params(default_account));
|
||||
[ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr];
|
||||
char *str = addr ? linphone_address_as_string(addr) : nil;
|
||||
_addressLabel.text = str ? [NSString stringWithUTF8String:str] : NSLocalizedString(@"No address", nil);
|
||||
if (str) ms_free(str);
|
||||
_presenceImage.image = [StatusBarView imageForState:linphone_proxy_config_get_state(default_proxy)];
|
||||
} 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
|
||||
LinphoneAddress *addr = linphone_core_get_primary_contact_parsed(LC);
|
||||
if (addr) {
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@
|
|||
MSList *numbers = linphone_friend_get_phone_numbers(friend);
|
||||
while (numbers) {
|
||||
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) {
|
||||
const char *normvalue = linphone_proxy_config_normalize_phone_number(cfg, phone.UTF8String);
|
||||
LinphoneAddress *addr = linphone_proxy_config_normalize_sip_uri(cfg, normvalue);
|
||||
if (account) {
|
||||
const char *normvalue = linphone_account_normalize_phone_number(account, phone.UTF8String);
|
||||
LinphoneAddress *addr = linphone_account_normalize_sip_uri(account, normvalue);
|
||||
char *phone_addr = linphone_address_as_string_uri_only(addr);
|
||||
contact = [FastAddressBook getContact:[NSString stringWithUTF8String:phone_addr]];
|
||||
ms_free(phone_addr);
|
||||
|
|
@ -242,11 +242,11 @@
|
|||
Contact* mContact = contact;
|
||||
if (!_addressBookMap)
|
||||
return;
|
||||
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
|
||||
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];
|
||||
if (phone != NULL)
|
||||
[_addressBookMap setObject:mContact forKey:(name ?: [FastAddressBook localizedLabel:phone])];
|
||||
|
|
@ -552,9 +552,10 @@
|
|||
NSMutableDictionary *displayNames = [[NSMutableDictionary alloc] initWithDictionary:[defaults dictionaryForKey:@"addressBook"]];
|
||||
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) {
|
||||
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];
|
||||
if (phone != NULL) {
|
||||
if ([FastAddressBook isSipURI:displayNames[name]]) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<entry name="realm" overwrite="true">sip.linphone.org</entry>
|
||||
<entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</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>
|
||||
</section>
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<entry name="realm" overwrite="true">sip.linphone.org</entry>
|
||||
<entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</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>
|
||||
</section>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ use_callkit=1
|
|||
|
||||
accept_early_media=0
|
||||
|
||||
[proxy_default_values]
|
||||
remote_push_notification_allowed=1
|
||||
|
||||
[sip]
|
||||
deliver_imdn=1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue