Commit 48421099 authored by jehan's avatar jehan
Browse files

remove contact as const char* from op->contact in case of bellesip

parent 673ddcae
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<folderInfo id="0.2079208171." name="/" resourcePath=""> <folderInfo id="0.2079208171." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.2084203071" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain"> <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.2084203071" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform binaryParser="org.eclipse.cdt.core.MachO64;org.eclipse.cdt.core.ELF" id="org.eclipse.cdt.build.core.prefbase.toolchain.2084203071.81924294" name=""/> <targetPlatform binaryParser="org.eclipse.cdt.core.MachO64;org.eclipse.cdt.core.ELF" id="org.eclipse.cdt.build.core.prefbase.toolchain.2084203071.81924294" name=""/>
<builder arguments="CFLAGS=&quot;-g -Werror -Wall&quot; CXXFLAGS=&quot;-g&quot; V=1" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.731584538" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/> <builder arguments="-j4 CFLAGS=&quot;-g -Werror -Wall&quot; CXXFLAGS=&quot;-g&quot;" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.731584538" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1252970003" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/> <tool id="org.eclipse.cdt.build.core.settings.holder.libs.1252970003" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.1371414073" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder"> <tool id="org.eclipse.cdt.build.core.settings.holder.1371414073" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.306286573" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.306286573" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
AM_CPPFLAGS=\ AM_CPPFLAGS=\
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(top_srcdir)/coreapi \ -I$(top_srcdir)/coreapi \
-I$(top_srcdir)/include \
-I$(top_srcdir)/exosip -I$(top_srcdir)/exosip
COMMON_CFLAGS=\ COMMON_CFLAGS=\
......
...@@ -16,10 +16,9 @@ You should have received a copy of the GNU General Public License ...@@ -16,10 +16,9 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "sal_impl.h" #include "sal_impl.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
void _belle_sip_log(belle_sip_log_level lev, const char *fmt, va_list args) { void _belle_sip_log(belle_sip_log_level lev, const char *fmt, va_list args) {
int ortp_level; int ortp_level;
...@@ -232,30 +231,11 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even ...@@ -232,30 +231,11 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
via_header= (belle_sip_header_via_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(response),BELLE_SIP_VIA); via_header= (belle_sip_header_via_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(response),BELLE_SIP_VIA);
received = belle_sip_header_via_get_received(via_header); received = belle_sip_header_via_get_received(via_header);
rport = belle_sip_header_via_get_rport(via_header); rport = belle_sip_header_via_get_rport(via_header);
if (!sal_op_get_contact(op)) { if ((original_contact=belle_sip_message_get_header_by_type(request,belle_sip_header_contact_t))) {
/*check if contqct set in reauest*/ /*update contact with sent values in any cases*/
contact_address=belle_sip_header_address_create(NULL,belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(original_contact)));
if ((original_contact=belle_sip_message_get_header_by_type(request,belle_sip_header_contact_t))) { sal_op_set_contact_address(op,(const SalAddress *)contact_address);
/*no contact set yet, try to see if sip tack has an updated one*/ belle_sip_object_unref(contact_address);
contact_address=belle_sip_header_address_create(NULL,belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(original_contact)));
sal_op_set_contact_address(op,(const SalAddress *)contact_address);
belle_sip_object_unref(contact_address);
} else {
/*hmm update contact from via, maybe useless, some op may not need any contact at all*/
contact_address=belle_sip_header_address_new();
contact_uri=belle_sip_uri_create(NULL,belle_sip_header_via_get_host(via_header));
belle_sip_header_address_set_uri(contact_address,contact_uri);
if (strcasecmp(belle_sip_header_via_get_transport(via_header),"UDP")!=0) {
belle_sip_uri_set_transport_param(contact_uri,belle_sip_header_via_get_transport_lowercase(via_header));
}
if (belle_sip_header_via_get_listening_port(via_header)
!= belle_sip_listening_point_get_well_known_port(belle_sip_header_via_get_transport(via_header))) {
belle_sip_uri_set_port(contact_uri,belle_sip_header_via_get_listening_port(via_header) );
}
contact_updated=TRUE;
}
} }
if (received!=NULL || rport>0) { if (received!=NULL || rport>0) {
...@@ -289,10 +269,12 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even ...@@ -289,10 +269,12 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
} }
} }
if (contact_updated) { if (contact_updated) {
char* old_contact=belle_sip_object_to_string(BELLE_SIP_OBJECT(sal_op_get_contact_address(op)));
new_contact=belle_sip_object_to_string(BELLE_SIP_OBJECT(contact_address)); new_contact=belle_sip_object_to_string(BELLE_SIP_OBJECT(contact_address));
ms_message("Updating contact from [%s] to [%s] for [%p]",sal_op_get_contact(op),new_contact,op); ms_message("Updating contact from [%s] to [%s] for [%p]",old_contact,new_contact,op);
sal_op_set_contact(op,new_contact); sal_op_set_contact_address(op,(const SalAddress *)contact_address);
belle_sip_free(new_contact); belle_sip_free(new_contact);
belle_sip_free(old_contact);
} }
if (contact_address)belle_sip_object_unref(contact_address); if (contact_address)belle_sip_object_unref(contact_address);
} }
......
...@@ -19,10 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -19,10 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SAL_IMPL_H_ #ifndef SAL_IMPL_H_
#define SAL_IMPL_H_ #define SAL_IMPL_H_
#include "sal/sal.h" #include "sal/sal.h"
#include "belle-sip/belle-sip.h" #include "belle-sip/belle-sip.h"
#include "belle-sip/belle-sdp.h" #include "belle-sip/belle-sdp.h"
struct Sal{ struct Sal{
SalCallbacks callbacks; SalCallbacks callbacks;
MSList *pending_auths;/*MSList of SalOp */ MSList *pending_auths;/*MSList of SalOp */
......
...@@ -108,7 +108,6 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){ ...@@ -108,7 +108,6 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){
char *friend=NULL; char *friend=NULL;
const char *route=NULL; const char *route=NULL;
const char *from=NULL; const char *from=NULL;
const char *fixed_contact=NULL;
LinphoneProxyConfig *cfg; LinphoneProxyConfig *cfg;
friend=linphone_address_as_string(fr->uri); friend=linphone_address_as_string(fr->uri);
...@@ -116,12 +115,6 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){ ...@@ -116,12 +115,6 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){
if (cfg!=NULL){ if (cfg!=NULL){
route=linphone_proxy_config_get_route(cfg); route=linphone_proxy_config_get_route(cfg);
from=linphone_proxy_config_get_identity(cfg); from=linphone_proxy_config_get_identity(cfg);
if (cfg->op){
fixed_contact=sal_op_get_contact(cfg->op);
if (fixed_contact) {
ms_message("Contact for subscribe has been fixed using proxy to %s",fixed_contact);
}
}
}else from=linphone_core_get_primary_contact(fr->lc); }else from=linphone_core_get_primary_contact(fr->lc);
if (fr->outsub==NULL){ if (fr->outsub==NULL){
/* people for which we don't have yet an answer should appear as offline */ /* people for which we don't have yet an answer should appear as offline */
...@@ -136,7 +129,10 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){ ...@@ -136,7 +129,10 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){
} }
fr->outsub=sal_op_new(fr->lc->sal); fr->outsub=sal_op_new(fr->lc->sal);
sal_op_set_route(fr->outsub,route); sal_op_set_route(fr->outsub,route);
sal_op_set_contact(fr->outsub,fixed_contact); if (cfg && cfg->op && sal_op_get_contact(cfg->op))
sal_op_set_contact(fr->outsub,sal_op_get_contact(cfg->op));
else
sal_op_set_contact(fr->outsub,NULL);
sal_subscribe_presence(fr->outsub,from,friend); sal_subscribe_presence(fr->outsub,from,friend);
fr->subscribe_active=TRUE; fr->subscribe_active=TRUE;
ms_free(friend); ms_free(friend);
......
...@@ -2318,54 +2318,68 @@ const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAdd ...@@ -2318,54 +2318,68 @@ const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAdd
} }
return linphone_core_get_primary_contact (lc); return linphone_core_get_primary_contact (lc);
} }
#ifndef USE_BELLESIP
static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphoneProxyConfig *dest_proxy){ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphoneProxyConfig *dest_proxy){
LinphoneAddress *ctt; #else
static LinphoneAddress *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphoneProxyConfig *dest_proxy){
#endif
LinphoneAddress *ctt=NULL;
#ifdef USE_BELLESIP
LinphoneAddress *ret;
#else
char* ret;
#endif
const char *localip=call->localip; const char *localip=call->localip;
/* first use user's supplied ip address if asked*/ /* first use user's supplied ip address if asked*/
if (linphone_core_get_firewall_policy(lc)==LinphonePolicyUseNatAddress){ if (linphone_core_get_firewall_policy(lc)==LinphonePolicyUseNatAddress){
ctt=linphone_core_get_primary_contact_parsed(lc); ctt=linphone_core_get_primary_contact_parsed(lc);
return ms_strdup_printf("sip:%s@%s",linphone_address_get_username(ctt), linphone_address_set_domain(ctt,linphone_core_get_nat_address_resolved(lc));
linphone_core_get_nat_address_resolved(lc)); #ifdef USE_BELLESIP
} ret=ctt;
#else
/* if already choosed, don't change it */ ret=linphone_adress_as_string(ctt);
if (call->op && sal_op_get_contact(call->op)!=NULL){ #endif
} else if (call->op && sal_op_get_contact(call->op)!=NULL){
/* if already choosed, don't change it */
return NULL; return NULL;
} } else if (call->ping_op && sal_op_get_contact(call->ping_op)) {
/* if the ping OPTIONS request succeeded use the contact guessed from the /* if the ping OPTIONS request succeeded use the contact guessed from the
received, rport*/ received, rport*/
if (call->ping_op){ ms_message("Contact has been fixed using OPTIONS"/* to %s",guessed*/);
const char *guessed=sal_op_get_contact(call->ping_op); #ifdef USE_BELLESIP
if (guessed){ ret=linphone_address_clone(sal_op_get_contact(call->ping_op));;
ms_message("Contact has been fixed using OPTIONS to %s",guessed); #else
return ms_strdup(guessed); ret=ms_strdup(sal_op_get_contact(call->ping_op));
} #endif
} } else if (dest_proxy && dest_proxy->op && sal_op_get_contact(dest_proxy->op)){
/*if using a proxy, use the contact address as guessed with the REGISTERs*/ /*if using a proxy, use the contact address as guessed with the REGISTERs*/
if (dest_proxy && dest_proxy->op){ ms_message("Contact has been fixed using proxy" /*to %s",fixed_contact*/);
const char *fixed_contact=sal_op_get_contact(dest_proxy->op); #ifdef USE_BELLESIP
if (fixed_contact) { ret=linphone_address_clone(sal_op_get_contact(dest_proxy->op));
ms_message("Contact has been fixed using proxy to %s",fixed_contact); #else
return ms_strdup(fixed_contact); ret=ms_strdup(sal_op_get_contact(dest_proxy->op));
#endif
} else {
ctt=linphone_core_get_primary_contact_parsed(lc);
if (ctt!=NULL){
/*otherwise use supllied localip*/
linphone_address_set_domain(ctt,localip);
linphone_address_set_port_int(ctt,linphone_core_get_sip_port(lc));
ms_message("Contact has been fixed using local ip"/* to %s",ret*/);
#ifdef USE_BELLESIP
ret=ctt;
#else
ret=linphone_address_as_string_uri_only(ctt);
#endif
} }
} }
#ifndef USE_BELLESIP
if (ctt) linphone_address_destroy(ctt);
#endif
return ret;
ctt=linphone_core_get_primary_contact_parsed(lc);
if (ctt!=NULL){
char *ret;
/*otherwise use supllied localip*/
linphone_address_set_domain(ctt,localip);
linphone_address_set_port_int(ctt,linphone_core_get_sip_port(lc));
ret=linphone_address_as_string_uri_only(ctt);
linphone_address_destroy(ctt);
ms_message("Contact has been fixed using local ip to %s",ret);
return ret;
}
return NULL;
} }
int linphone_core_proceed_with_invite_if_ready(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy){ int linphone_core_proceed_with_invite_if_ready(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy){
...@@ -2401,7 +2415,12 @@ int linphone_core_proceed_with_invite_if_ready(LinphoneCore *lc, LinphoneCall *c ...@@ -2401,7 +2415,12 @@ int linphone_core_proceed_with_invite_if_ready(LinphoneCore *lc, LinphoneCall *c
int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call){ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call){
int err; int err;
#ifndef USE_BELLESIP
char *contact; char *contact;
#else
LinphoneAddress *contact;
#endif
char *real_url,*barmsg; char *real_url,*barmsg;
char *from; char *from;
LinphoneProxyConfig *dest_proxy=call->dest_proxy; LinphoneProxyConfig *dest_proxy=call->dest_proxy;
...@@ -2410,7 +2429,12 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call){ ...@@ -2410,7 +2429,12 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call){
contact=get_fixed_contact(lc,call,dest_proxy); contact=get_fixed_contact(lc,call,dest_proxy);
if (contact){ if (contact){
sal_op_set_contact(call->op, contact); sal_op_set_contact(call->op, contact);
#ifndef USE_BELLESIP
ms_free(contact); ms_free(contact);
#else
linphone_address_destroy(contact);
#endif
} }
linphone_core_stop_dtmf_stream(lc); linphone_core_stop_dtmf_stream(lc);
linphone_call_init_media_streams(call); linphone_call_init_media_streams(call);
...@@ -3103,7 +3127,11 @@ int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call){ ...@@ -3103,7 +3127,11 @@ int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call){
int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params) int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params)
{ {
LinphoneProxyConfig *cfg=NULL; LinphoneProxyConfig *cfg=NULL;
const char *contact=NULL; #ifndef USE_BELLESIP
char *contact=NULL;
#else
LinphoneAddress *contact=NULL;
#endif
SalOp *replaced; SalOp *replaced;
SalMediaDescription *new_md; SalMediaDescription *new_md;
bool_t was_ringing=FALSE; bool_t was_ringing=FALSE;
...@@ -3159,9 +3187,14 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, ...@@ -3159,9 +3187,14 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call,
} }
/*try to be best-effort in giving real local or routable contact address*/ /*try to be best-effort in giving real local or routable contact address*/
contact=get_fixed_contact(lc,call,call->dest_proxy); contact=get_fixed_contact(lc,call,call->dest_proxy);
if (contact) if (contact) {
sal_op_set_contact(call->op,contact); sal_op_set_contact(call->op,contact);
#ifdef USE_BELLESIP
linphone_address_destroy(contact);
#else
ms_free(contact);
#endif
}
if (params){ if (params){
const SalMediaDescription *md = sal_call_get_remote_media_description(call->op); const SalMediaDescription *md = sal_call_get_remote_media_description(call->op);
_linphone_call_params_copy(&call->params,params); _linphone_call_params_copy(&call->params,params);
......
...@@ -58,7 +58,6 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){ ...@@ -58,7 +58,6 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){
char *tmp; char *tmp;
LinphoneAddress *uri; LinphoneAddress *uri;
LinphoneProxyConfig *cfg; LinphoneProxyConfig *cfg;
const char *fixed_contact;
uri=linphone_address_new(from); uri=linphone_address_new(from);
linphone_address_clean(uri); linphone_address_clean(uri);
...@@ -68,10 +67,9 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){ ...@@ -68,10 +67,9 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){
cfg=linphone_core_lookup_known_proxy(lc,uri); cfg=linphone_core_lookup_known_proxy(lc,uri);
if (cfg!=NULL){ if (cfg!=NULL){
if (cfg->op){ if (cfg->op){
fixed_contact=sal_op_get_contact(cfg->op); if (sal_op_get_contact(cfg->op)) {
if (fixed_contact) { sal_op_set_contact (op,sal_op_get_contact(cfg->op));
sal_op_set_contact (op,fixed_contact); ms_message("Contact for next subscribe answer has been fixed using proxy "/*to %s",fixed_contact*/);
ms_message("Contact for next subscribe answer has been fixed using proxy to %s",fixed_contact);
} }
} }
} }
......
...@@ -255,49 +255,62 @@ void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc) ...@@ -255,49 +255,62 @@ void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc)
obj->lc=lc; obj->lc=lc;
linphone_proxy_config_done(obj); linphone_proxy_config_done(obj);
} }
#ifndef USE_BELLESIP
static char *guess_contact_for_register(LinphoneProxyConfig *obj){ static char *guess_contact_for_register(LinphoneProxyConfig *obj){
LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy);
char *ret=NULL; char *ret=NULL;
#else
LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){
LinphoneAddress *ret=NULL;
#endif
LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy);
const char *host; const char *host;
if (proxy==NULL) return NULL; if (proxy==NULL) return NULL;
host=linphone_address_get_domain (proxy); host=linphone_address_get_domain (proxy);
if (host!=NULL){ if (host!=NULL){
int localport = -1; int localport = -1;
char localip_tmp[LINPHONE_IPADDR_SIZE] = {'\0'};
const char *localip = NULL; const char *localip = NULL;
char *tmp; char *tmp;
LCSipTransports tr; LCSipTransports tr;
LinphoneAddress *contact; LinphoneAddress *contact=linphone_address_new(obj->reg_identity);
if (obj->contact_params)
tmp=ms_strdup_printf("<sip:%s@%s;%s>",linphone_address_get_username(contact)
,linphone_address_get_domain(contact)
,obj->contact_params);
else
tmp=ms_strdup_printf("<sip:%s@%s>",linphone_address_get_username(contact)
,linphone_address_get_domain(contact));
contact=linphone_address_new(obj->reg_identity); linphone_address_destroy(contact);
contact=linphone_address_new(tmp);
#ifdef BUILD_UPNP #ifdef BUILD_UPNP
if (obj->lc->upnp != NULL && linphone_core_get_firewall_policy(obj->lc)==LinphonePolicyUseUpnp && if (obj->lc->upnp != NULL && linphone_core_get_firewall_policy(obj->lc)==LinphonePolicyUseUpnp &&
linphone_upnp_context_get_state(obj->lc->upnp) == LinphoneUpnpStateOk) { linphone_upnp_context_get_state(obj->lc->upnp) == LinphoneUpnpStateOk) {
localip = linphone_upnp_context_get_external_ipaddress(obj->lc->upnp); localip = linphone_upnp_context_get_external_ipaddress(obj->lc->upnp);
localport = linphone_upnp_context_get_external_port(obj->lc->upnp); localport = linphone_upnp_context_get_external_port(obj->lc->upnp);
linphone_core_get_sip_transports(obj->lc,&tr);
if (tr.udp_port <= 0) {
if (tr.tcp_port>0) {
sal_address_set_param(contact,"transport","tcp");
} else if (tr.tls_port>0) {
sal_address_set_param(contact,"transport","tls");
}
}
} }
#endif //BUILD_UPNP #endif //BUILD_UPNP
#ifdef USE_BELLESIP
#ifdef BUILD_UPNP #ifndef USE_BELLESIP
else
#endif /*BUILD_UPNP*/
{
linphone_address_destroy(contact);
return NULL;
}
#endif /*USE_BELLESIP*/
if(localip == NULL) { if(localip == NULL) {
char localip_tmp[LINPHONE_IPADDR_SIZE] = {'\0'};
localip = localip_tmp; localip = localip_tmp;
linphone_core_get_local_ip(obj->lc,host,localip_tmp); linphone_core_get_local_ip(obj->lc,host,localip_tmp);
} }
if(localport == -1) { if(localport == -1) {
localport = linphone_core_get_sip_port(obj->lc); localport = linphone_core_get_sip_port(obj->lc);
} }
linphone_address_set_port_int(contact,localport);
linphone_address_set_domain(contact,localip);
linphone_address_set_display_name(contact,NULL);
linphone_core_get_sip_transports(obj->lc,&tr); linphone_core_get_sip_transports(obj->lc,&tr);
if (tr.udp_port <= 0) { if (tr.udp_port <= 0) {
if (tr.tcp_port>0) { if (tr.tcp_port>0) {
...@@ -306,27 +319,41 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ ...@@ -306,27 +319,41 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){
sal_address_set_param(contact,"transport","tls"); sal_address_set_param(contact,"transport","tls");
} }
} }
#endif
tmp=linphone_address_as_string_uri_only(contact); linphone_address_set_port_int(contact,localport);
if (obj->contact_params) linphone_address_set_domain(contact,localip);
ret=ms_strdup_printf("<%s;%s>",tmp,obj->contact_params); linphone_address_set_display_name(contact,NULL);
else ret=ms_strdup_printf("<%s>",tmp);
#ifndef USE_BELLESIP
ret = linphone_address_as_string(contact);
linphone_address_destroy(contact); linphone_address_destroy(contact);
#else
ret=contact;
#endif /*USE_BELLESIP*/
linphone_address_destroy (proxy);
ms_free(tmp); ms_free(tmp);
} }
linphone_address_destroy (proxy);
return ret; return ret;
} }
static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
if (obj->reg_sendregister){ if (obj->reg_sendregister){
#ifndef USE_BELLESIP
char *contact; char *contact;
#else
LinphoneAddress *contact;
#endif
if (obj->op) if (obj->op)
sal_op_release(obj->op); sal_op_release(obj->op);
obj->op=sal_op_new(obj->lc->sal); obj->op=sal_op_new(obj->lc->sal);
if ((contact=guess_contact_for_register(obj))) { if ((contact=guess_contact_for_register(obj))) {
sal_op_set_contact(obj->op,contact); sal_op_set_contact(obj->op,contact);
#ifndef USE_BELLESIP
ms_free(contact); ms_free(contact);
#else
linphone_address_destroy(contact);
#endif
} }
sal_op_set_user_pointer(obj->op,obj); sal_op_set_user_pointer(obj->op,obj);
if (sal_register(obj->op,obj->reg_proxy,obj->reg_identity,obj->expires)==0) { if (sal_register(obj->op,obj->reg_proxy,obj->reg_identity,obj->expires)==0) {
......
...@@ -22,7 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -22,7 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The purpose of this layer is too allow experiment different call signaling The purpose of this layer is too allow experiment different call signaling
protocols and implementations under linphone, for example SIP, JINGLE... protocols and implementations under linphone, for example SIP, JINGLE...
**/ **/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "sal/sal.h" #include "sal/sal.h"
const char* sal_transport_to_string(SalTransport transport) { const char* sal_transport_to_string(SalTransport transport) {
switch (transport) { switch (transport) {
...@@ -246,16 +248,15 @@ static void assign_string(char **str, const char *arg){ ...@@ -246,16 +248,15 @@ static void assign_string(char **str, const char *arg){
*str=ms_strdup(arg); *str=ms_strdup(arg);
} }
#ifdef USE_BELLESIP
void sal_op_set_contact_address(SalOp *op, const SalAddress *address){ void sal_op_set_contact_address(SalOp *op, const SalAddress *address){
char* address_string=sal_address_as_string(address); /*can probably be optimized*/ if (((SalOpBase*)op)->contact_address) sal_address_destroy(((SalOpBase*)op)->contact_address);
sal_op_set_contact(op,address_string); ((SalOpBase*)op)->contact_address=address?sal_address_clone(address):NULL;
ms_free(address_string);
} }
const SalAddress* sal_op_get_contact_address(const SalOp *op) { const SalAddress* sal_op_get_contact_address(const SalOp *op) {
return ((SalOpBase*)op)->contact_address; return ((SalOpBase*)op)->contact_address;
} }
#endif
#define SET_PARAM(op,name) \ #define SET_PARAM(op,name) \