mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
add linphone_proxy_config_set_contact_uri_parameters()
This commit is contained in:
parent
5f28f81f4b
commit
c53381e0b5
5 changed files with 55 additions and 45 deletions
|
|
@ -150,6 +150,17 @@ void sal_address_set_param(SalAddress *addr,const char* name,const char* value){
|
|||
return ;
|
||||
}
|
||||
|
||||
|
||||
void sal_address_set_params(SalAddress *addr, const char *params){
|
||||
belle_sip_parameters_t* parameters = BELLE_SIP_PARAMETERS(addr);
|
||||
belle_sip_parameters_set(parameters,params);
|
||||
}
|
||||
|
||||
void sal_address_set_uri_params(SalAddress *addr, const char *params){
|
||||
belle_sip_parameters_t* parameters = BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr)));
|
||||
belle_sip_parameters_set(parameters,params);
|
||||
}
|
||||
|
||||
void sal_address_set_transport(SalAddress* addr,SalTransport transport){
|
||||
if (!sal_address_is_secure(addr)){
|
||||
SAL_ADDRESS_SET(addr,transport_param,sal_transport_to_string(transport));
|
||||
|
|
|
|||
|
|
@ -752,6 +752,8 @@ LINPHONE_PUBLIC bool_t linphone_proxy_config_register_enabled(const LinphoneProx
|
|||
LINPHONE_PUBLIC void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj);
|
||||
LINPHONE_PUBLIC const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj);
|
||||
LINPHONE_PUBLIC void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params);
|
||||
LINPHONE_PUBLIC void linphone_proxy_config_set_contact_uri_parameters(LinphoneProxyConfig *obj, const char *contact_uri_params);
|
||||
LINPHONE_PUBLIC const char* linphone_proxy_config_get_contact_uri_parameters(const LinphoneProxyConfig *obj);
|
||||
|
||||
/**
|
||||
* Get the #LinphoneCore object to which is associated the #LinphoneProxyConfig.
|
||||
|
|
|
|||
|
|
@ -392,6 +392,7 @@ struct _LinphoneProxyConfig
|
|||
char *reg_route;
|
||||
char *realm;
|
||||
char *contact_params;
|
||||
char *contact_uri_params;
|
||||
int expires;
|
||||
SalOp *op;
|
||||
char *type;
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ void linphone_proxy_config_destroy(LinphoneProxyConfig *obj){
|
|||
if (obj->op) sal_op_release(obj->op);
|
||||
if (obj->publish_op) sal_op_release(obj->publish_op);
|
||||
if (obj->contact_params) ms_free(obj->contact_params);
|
||||
if (obj->contact_uri_params) ms_free(obj->contact_uri_params);
|
||||
ms_free(obj);
|
||||
}
|
||||
|
||||
|
|
@ -280,69 +281,37 @@ void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig *obj){
|
|||
LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){
|
||||
LinphoneAddress *ret=NULL;
|
||||
LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy);
|
||||
|
||||
const char *host;
|
||||
|
||||
if (proxy==NULL) return NULL;
|
||||
host=linphone_address_get_domain (proxy);
|
||||
host=linphone_address_get_domain(proxy);
|
||||
if (host!=NULL){
|
||||
int localport = -1;
|
||||
const char *localip = NULL;
|
||||
char *tmp;
|
||||
char *tmp2;
|
||||
LinphoneAddress *identity;
|
||||
LinphoneAddress *contact;
|
||||
LinphoneAddress *contact=linphone_address_new(obj->reg_identity);
|
||||
|
||||
if (obj->contact_params) {
|
||||
// We want to add a list of contacts params to the linphone address
|
||||
// We remove the display name in the identity (if present) to prevent a failure in the parsing of the address due to the quotes
|
||||
identity = linphone_address_new(obj->reg_identity);
|
||||
if (identity) {
|
||||
tmp2 = linphone_address_as_string_uri_only(identity);
|
||||
tmp = ms_strdup_printf("%s;%s", tmp2, obj->contact_params);
|
||||
linphone_address_destroy(identity);
|
||||
ms_free(tmp2);
|
||||
} else {
|
||||
tmp = ms_strdup_printf("%s;%s", obj->reg_identity, obj->contact_params);
|
||||
}
|
||||
sal_address_set_params(contact,obj->contact_params);
|
||||
}
|
||||
else {
|
||||
tmp = strdup(obj->reg_identity);
|
||||
if (obj->contact_uri_params){
|
||||
sal_address_set_uri_params(contact,obj->contact_uri_params);
|
||||
}
|
||||
|
||||
contact = linphone_address_new(tmp);
|
||||
if (!contact) {
|
||||
ms_error("No valid contact_params for [%s]",linphone_address_get_domain(proxy));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef BUILD_UPNP
|
||||
if (obj->lc->upnp != NULL && linphone_core_get_firewall_policy(obj->lc)==LinphonePolicyUseUpnp &&
|
||||
linphone_upnp_context_get_state(obj->lc->upnp) == LinphoneUpnpStateOk) {
|
||||
LCSipTransports tr;
|
||||
localip = linphone_upnp_context_get_external_ipaddress(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
|
||||
|
||||
|
||||
linphone_address_set_port(contact,localport);
|
||||
linphone_address_set_domain(contact,localip);
|
||||
linphone_address_set_display_name(contact,NULL);
|
||||
|
||||
ret=contact;
|
||||
|
||||
linphone_address_destroy (proxy);
|
||||
ms_free(tmp);
|
||||
}
|
||||
linphone_address_destroy(proxy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -911,7 +880,7 @@ bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj){
|
|||
* @param contact_params a string contaning the additional parameters in text form, like "myparam=something;myparam2=something_else"
|
||||
*
|
||||
* The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id.
|
||||
* As an example, the contact address in the SIP register sent will look like <sip:joe@15.128.128.93:50421;apple-push-id=43143-DFE23F-2323-FA2232>.
|
||||
* As an example, the contact address in the SIP register sent will look like <sip:joe@15.128.128.93:50421>;apple-push-id=43143-DFE23F-2323-FA2232.
|
||||
**/
|
||||
void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params){
|
||||
if (obj->contact_params) {
|
||||
|
|
@ -923,6 +892,24 @@ void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, cons
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set optional contact parameters that will be added to the contact information sent in the registration, inside the URI.
|
||||
* @param obj the proxy config object
|
||||
* @param contact_params a string contaning the additional parameters in text form, like "myparam=something;myparam2=something_else"
|
||||
*
|
||||
* The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id.
|
||||
* As an example, the contact address in the SIP register sent will look like <sip:joe@15.128.128.93:50421;apple-push-id=43143-DFE23F-2323-FA2232>.
|
||||
**/
|
||||
void linphone_proxy_config_set_contact_uri_parameters(LinphoneProxyConfig *obj, const char *contact_uri_params){
|
||||
if (obj->contact_uri_params) {
|
||||
ms_free(obj->contact_uri_params);
|
||||
obj->contact_uri_params=NULL;
|
||||
}
|
||||
if (contact_uri_params){
|
||||
obj->contact_uri_params=ms_strdup(contact_uri_params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns previously set contact parameters.
|
||||
**/
|
||||
|
|
@ -930,6 +917,13 @@ const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConf
|
|||
return obj->contact_params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns previously set contact URI parameters.
|
||||
**/
|
||||
const char *linphone_proxy_config_get_contact_uri_parameters(const LinphoneProxyConfig *obj){
|
||||
return obj->contact_uri_params;
|
||||
}
|
||||
|
||||
struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj){
|
||||
return obj->lc;
|
||||
}
|
||||
|
|
@ -1059,6 +1053,9 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC
|
|||
if (obj->contact_params!=NULL){
|
||||
lp_config_set_string(config,key,"contact_parameters",obj->contact_params);
|
||||
}
|
||||
if (obj->contact_uri_params!=NULL){
|
||||
lp_config_set_string(config,key,"contact_uri_parameters",obj->contact_uri_params);
|
||||
}
|
||||
lp_config_set_int(config,key,"reg_expires",obj->expires);
|
||||
lp_config_set_int(config,key,"reg_sendregister",obj->reg_sendregister);
|
||||
lp_config_set_int(config,key,"publish",obj->publish);
|
||||
|
|
@ -1096,6 +1093,8 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config
|
|||
|
||||
linphone_proxy_config_set_contact_parameters(cfg,lp_config_get_string(config,key,"contact_parameters",NULL));
|
||||
|
||||
linphone_proxy_config_set_contact_uri_parameters(cfg,lp_config_get_string(config,key,"contact_uri_parameters",NULL));
|
||||
|
||||
linphone_proxy_config_expires(cfg,lp_config_get_int(config,key,"reg_expires",LP_CONFIG_DEFAULT_INT(config,"reg_expires",600)));
|
||||
linphone_proxy_config_enableregister(cfg,lp_config_get_int(config,key,"reg_sendregister",0));
|
||||
|
||||
|
|
|
|||
|
|
@ -94,12 +94,7 @@ const char* sal_address_get_transport_name(const SalAddress* addr);
|
|||
void sal_address_set_display_name(SalAddress *addr, const char *display_name);
|
||||
void sal_address_set_username(SalAddress *addr, const char *username);
|
||||
void sal_address_set_domain(SalAddress *addr, const char *host);
|
||||
#ifdef USE_BELLESIP
|
||||
void sal_address_set_port(SalAddress *uri, int port);
|
||||
#else
|
||||
void sal_address_set_port(SalAddress *addr, const char *port);
|
||||
void sal_address_set_port_int(SalAddress *uri, int port);
|
||||
#endif
|
||||
void sal_address_clean(SalAddress *addr);
|
||||
char *sal_address_as_string(const SalAddress *u);
|
||||
char *sal_address_as_string_uri_only(const SalAddress *u);
|
||||
|
|
@ -107,6 +102,8 @@ void sal_address_destroy(SalAddress *u);
|
|||
void sal_address_set_param(SalAddress *u,const char* name,const char* value);
|
||||
void sal_address_set_transport(SalAddress* addr,SalTransport transport);
|
||||
void sal_address_set_transport_name(SalAddress* addr,const char* transport);
|
||||
void sal_address_set_params(SalAddress *addr, const char *params);
|
||||
void sal_address_set_uri_params(SalAddress *addr, const char *params);
|
||||
|
||||
Sal * sal_init();
|
||||
void sal_uninit(Sal* sal);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue