Commit b0b23090 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Prevent the params of the contact address from being erased.

parent b5c4007d
......@@ -3467,10 +3467,11 @@ void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const Linphon
sal_op_set_sent_custom_header(op,headers);
sal_op_set_realm(op,linphone_proxy_config_get_realm(proxy));
if (with_contact && proxy && proxy->op){
const SalAddress *contact;
contact=sal_op_get_contact_address(proxy->op);
SalAddress *new_contact = contact ? sal_address_clone(contact) : NULL;
sal_op_set_and_clean_contact_address(proxy->op, new_contact);
const LinphoneAddress *contact = linphone_proxy_config_get_contact(proxy);
SalAddress *salAddress = nullptr;
if (contact)
salAddress = sal_address_clone(const_cast<SalAddress *>(L_GET_PRIVATE_FROM_C_OBJECT(contact)->getInternalAddress()));
sal_op_set_contact_address(op, salAddress);
}
sal_op_cnx_ip_to_0000_if_sendonly_enable(op, !!lp_config_get_default_int(lc->config,"sip","cnx_ip_to_0000_if_sendonly_enabled",0)); /*also set in linphone_call_new_incoming*/
}
......
......@@ -296,6 +296,7 @@ LinphoneEvent *linphone_proxy_config_create_publish(LinphoneProxyConfig *cfg, co
* Can be NULL
* */
const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphoneProxyConfig* cfg);
const LinphoneAddress *_linphone_proxy_config_get_contact_without_params (const LinphoneProxyConfig *cfg);
void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list);
void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, LinphoneEvent *lev, const LinphoneContent *body);
......@@ -476,6 +477,8 @@ struct _LinphoneProxyConfig
char *reg_proxy;
char *reg_identity;
LinphoneAddress* identity_address;
LinphoneAddress *contact_address;
LinphoneAddress *contact_address_without_params;
char *reg_route;
char *quality_reporting_collector;
char *realm;
......@@ -517,10 +520,6 @@ struct _LinphoneProxyConfig
char *refkey;
char *sip_etag; /*publish context*/
// For migration purpose. (Do not use directly!)
// Cache.
LinphoneAddress *contact_address;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneProxyConfig);
......
......@@ -438,35 +438,30 @@ void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig * cfg){
}
}
LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *cfg){
LinphoneAddress *ret=NULL;
LinphoneAddress *proxy=linphone_address_new(cfg->reg_proxy);
const char *host;
if (proxy==NULL) return NULL;
host=linphone_address_get_domain(proxy);
if (host!=NULL){
int localport = -1;
const char *localip = NULL;
LinphoneAddress *contact=linphone_address_clone(cfg->identity_address);
linphone_address_clean(contact);
static void guess_contact_for_register (LinphoneProxyConfig *cfg) {
linphone_address_unref(cfg->contact_address);
cfg->contact_address = nullptr;
linphone_address_unref(cfg->contact_address_without_params);
cfg->contact_address_without_params = nullptr;
LinphoneAddress *proxy = linphone_address_new(cfg->reg_proxy);
if (!proxy)
return;
const char *host = linphone_address_get_domain(proxy);
if (host) {
cfg->contact_address_without_params = linphone_address_clone(cfg->identity_address);
linphone_address_clean(cfg->contact_address_without_params);
linphone_address_set_port(cfg->contact_address_without_params, -1);
linphone_address_set_domain(cfg->contact_address_without_params, nullptr);
linphone_address_set_display_name(cfg->contact_address_without_params, nullptr);
cfg->contact_address = linphone_address_clone(cfg->contact_address_without_params);
if (cfg->contact_params) {
// We want to add a list of contacts params to the linphone address
linphone_address_set_params(contact,cfg->contact_params);
linphone_address_set_params(cfg->contact_address, cfg->contact_params);
}
if (cfg->contact_uri_params){
linphone_address_set_uri_params(contact,cfg->contact_uri_params);
}
linphone_address_set_port(contact,localport);
linphone_address_set_domain(contact,localip);
linphone_address_set_display_name(contact,NULL);
ret=contact;
if (cfg->contact_uri_params)
linphone_address_set_uri_params(cfg->contact_address, cfg->contact_uri_params);
}
linphone_address_unref(proxy);
return ret;
}
void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj) {
......@@ -481,7 +476,6 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *cfg){
LinphoneAddress* proxy=linphone_address_new(cfg->reg_proxy);
char* proxy_string;
char * from = linphone_address_as_string(cfg->identity_address);
LinphoneAddress *contact;
ms_message("LinphoneProxyConfig [%p] about to register (LinphoneCore version: %s)",cfg,linphone_core_get_version());
proxy_string=linphone_address_as_string_uri_only(proxy);
linphone_address_unref(proxy);
......@@ -491,12 +485,10 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *cfg){
linphone_configure_op(cfg->lc, cfg->op, cfg->identity_address, cfg->sent_headers, FALSE);
if ((contact=guess_contact_for_register(cfg))) {
sal_op_set_contact_address(cfg->op, L_GET_PRIVATE_FROM_C_OBJECT(contact)->getInternalAddress());
linphone_address_unref(contact);
}
sal_op_set_user_pointer(cfg->op,cfg);
guess_contact_for_register(cfg);
if (cfg->contact_address)
sal_op_set_contact_address(cfg->op, L_GET_PRIVATE_FROM_C_OBJECT(cfg->contact_address)->getInternalAddress());
sal_op_set_user_pointer(cfg->op, cfg);
if (sal_register(
cfg->op,
......@@ -1431,18 +1423,14 @@ uint8_t linphone_proxy_config_get_avpf_rr_interval(const LinphoneProxyConfig *cf
return cfg->avpf_rr_interval;
}
const LinphoneAddress* linphone_proxy_config_get_contact(const LinphoneProxyConfig *cfg) {
// Workaround for wrapping.
if (cfg->contact_address)
linphone_address_unref(cfg->contact_address);
char *buf = sal_address_as_string(sal_op_get_contact_address(cfg->op));
const_cast<LinphoneProxyConfig *>(cfg)->contact_address = linphone_address_new(buf);
ms_free(buf);
const LinphoneAddress *linphone_proxy_config_get_contact (const LinphoneProxyConfig *cfg) {
return cfg->contact_address;
}
const LinphoneAddress *_linphone_proxy_config_get_contact_without_params (const LinphoneProxyConfig *cfg) {
return cfg->contact_address_without_params;
}
const struct _LinphoneAuthInfo* linphone_proxy_config_find_auth_info(const LinphoneProxyConfig *cfg) {
const char* username = cfg->identity_address ? linphone_address_get_username(cfg->identity_address) : NULL;
const char* domain = cfg->identity_address ? linphone_address_get_domain(cfg->identity_address) : NULL;
......
......@@ -518,19 +518,6 @@ void sal_op_set_contact_address(SalOp *op, const SalAddress *address){
((SalOpBase*)op)->contact_address=address?sal_address_clone(address):NULL;
}
void sal_op_set_and_clean_contact_address(SalOp *op, SalAddress *contact) {
if (contact){
SalTransport tport = sal_address_get_transport((SalAddress*)contact);
const char* gruu = bctbx_strdup(sal_address_get_uri_param(contact, "gr"));
sal_address_clean((SalAddress*)contact); /* clean out contact_params that come from proxy config*/
sal_address_set_transport((SalAddress*)contact,tport);
if(gruu)
sal_address_set_uri_param(contact, "gr", gruu);
sal_op_set_contact_address(op, contact);
sal_address_unref(contact);
}
}
const SalAddress* sal_op_get_contact_address(const SalOp *op) {
return ((SalOpBase*)op)->contact_address;
}
......
......@@ -674,7 +674,6 @@ SalOp * sal_op_new(Sal *sal);
/*generic SalOp API, working for all operations */
Sal *sal_op_get_sal(const SalOp *op);
void sal_op_set_contact_address(SalOp *op, const SalAddress* address);
void sal_op_set_and_clean_contact_address(SalOp *op, SalAddress* address);
void sal_op_set_route(SalOp *op, const char *route);
void sal_op_set_route_address(SalOp *op, const SalAddress* address);
void sal_op_add_route_address(SalOp *op, const SalAddress* address);
......
......@@ -602,8 +602,8 @@ void CallSessionPrivate::setContactOp () {
salAddress = const_cast<SalAddress *>(L_GET_PRIVATE_FROM_C_OBJECT(contact)->getInternalAddress());
sal_address_ref(salAddress);
linphone_address_unref(contact);
sal_op_set_contact_address(op, salAddress);
}
sal_op_set_and_clean_contact_address(op, salAddress);
}
// -----------------------------------------------------------------------------
......@@ -645,12 +645,10 @@ LinphoneAddress * CallSessionPrivate::getFixedContact () const {
char *addr = sal_address_as_string(sal_op_get_contact_address(pingOp));
result = linphone_address_new(addr);
ms_free(addr);
} else if (destProxy && destProxy->op && sal_op_get_contact_address(destProxy->op)) {
} else if (destProxy && destProxy->op && _linphone_proxy_config_get_contact_without_params(destProxy)) {
/* If using a proxy, use the contact address as guessed with the REGISTERs */
lInfo() << "Contact has been fixed using proxy";
char *addr = sal_address_as_string(sal_op_get_contact_address(destProxy->op));
result = linphone_address_new(addr);
ms_free(addr);
result = linphone_address_clone(_linphone_proxy_config_get_contact_without_params(destProxy));
} else {
result = linphone_core_get_primary_contact_parsed(core);
if (result) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment