mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
refactor
This commit is contained in:
parent
f4a211023e
commit
b72f37ac0a
1 changed files with 34 additions and 44 deletions
|
|
@ -454,53 +454,43 @@
|
|||
}
|
||||
|
||||
+ (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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
const char *normvalue;
|
||||
normvalue = linphone_proxy_config_is_phone_number(cfg, value.UTF8String)
|
||||
? linphone_proxy_config_normalize_phone_number(cfg, value.UTF8String)
|
||||
: value.UTF8String;
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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];
|
||||
|
||||
return 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 && cfg) {
|
||||
if (linphone_proxy_config_get_dial_escape_plus(cfg) && 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