forked from mirrors/linphone-iphone
[DialPrefix] fix country code prefix automatically added on call
This commit is contained in:
parent
e28918bbdf
commit
870852c522
1 changed files with 39 additions and 45 deletions
|
|
@ -454,53 +454,47 @@
|
|||
}
|
||||
|
||||
+ (LinphoneAddress *)normalizeSipOrPhoneAddress:(NSString *)value {
|
||||
if (!value || [value isEqualToString:@""]) {
|
||||
return NULL;
|
||||
}
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
const char *normvalue;
|
||||
if (linphone_proxy_config_is_phone_number(cfg, value.UTF8String)) {
|
||||
normvalue =
|
||||
linphone_proxy_config_normalize_phone_number(cfg, value.UTF8String);
|
||||
} else {
|
||||
normvalue = value.UTF8String;
|
||||
}
|
||||
LinphoneAddress *addr =
|
||||
linphone_proxy_config_normalize_sip_uri(cfg, normvalue);
|
||||
// first try to find a friend with the given address
|
||||
Contact *c = [FastAddressBook getContactWithAddress:addr];
|
||||
if (!value || [value isEqualToString:@""]) {
|
||||
return NULL;
|
||||
}
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
const char *normvalue;
|
||||
if (linphone_proxy_config_is_phone_number(cfg, value.UTF8String)) {
|
||||
normvalue = linphone_proxy_config_normalize_phone_number(cfg, value.UTF8String);
|
||||
} else {
|
||||
normvalue = value.UTF8String;
|
||||
}
|
||||
LinphoneAddress *addr = linphone_proxy_config_normalize_sip_uri(cfg, normvalue);
|
||||
// first try to find a friend with the given address
|
||||
Contact *c = [FastAddressBook getContactWithAddress:addr];
|
||||
|
||||
if (c && c.friend) {
|
||||
LinphoneFriend *f = c.friend;
|
||||
const LinphonePresenceModel *m =
|
||||
f ? linphone_friend_get_presence_model_for_uri_or_tel(f,
|
||||
value.UTF8String)
|
||||
: NULL;
|
||||
const char *contact = m ? linphone_presence_model_get_contact(m) : NULL;
|
||||
if (contact) {
|
||||
LinphoneAddress *contact_addr = linphone_address_new(contact);
|
||||
if (contact_addr) {
|
||||
linphone_address_destroy(addr);
|
||||
return contact_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c && c.friend) {
|
||||
LinphoneFriend *f = c.friend;
|
||||
const LinphonePresenceModel *m = f ? linphone_friend_get_presence_model_for_uri_or_tel(f, value.UTF8String) : NULL;
|
||||
const char *contact = m ? linphone_presence_model_get_contact(m) : NULL;
|
||||
if (contact) {
|
||||
LinphoneAddress *contact_addr = linphone_address_new(contact);
|
||||
if (contact_addr) {
|
||||
linphone_address_destroy(addr);
|
||||
return contact_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// since user wants to escape plus, we assume it expects to have phone
|
||||
// numbers by default
|
||||
if (addr) {
|
||||
if (cfg && (linphone_proxy_config_get_dial_escape_plus(cfg))) {
|
||||
if (linphone_proxy_config_is_phone_number(cfg, normvalue)) {
|
||||
linphone_address_set_username(addr, normvalue);
|
||||
}
|
||||
} else {
|
||||
if (linphone_proxy_config_is_phone_number(cfg, value.UTF8String)) {
|
||||
linphone_address_set_username(addr, value.UTF8String);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return addr;
|
||||
// since user wants to escape plus, we assume it expects to have phone
|
||||
// numbers by default
|
||||
if (addr) {
|
||||
if (cfg || (linphone_proxy_config_get_dial_escape_plus(cfg))) {
|
||||
if (linphone_proxy_config_is_phone_number(cfg, normvalue)) {
|
||||
linphone_address_set_username(addr, normvalue);
|
||||
}
|
||||
} else {
|
||||
if (linphone_proxy_config_is_phone_number(cfg, value.UTF8String)) {
|
||||
linphone_address_set_username(addr, value.UTF8String);
|
||||
}
|
||||
}
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue