]> sjero.net Git - linphone/commitdiff
add API to set custom parameters in the SIP contact address of registers.
authorSimon Morlat <simon.morlat@linphone.org>
Fri, 3 Aug 2012 14:33:22 +0000 (16:33 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Fri, 3 Aug 2012 14:33:22 +0000 (16:33 +0200)
coreapi/linphonecore.h
coreapi/private.h
coreapi/proxy.c
mediastreamer2

index 81044fff54e5c6373b74958ae34f47b7aa64a022..a269bc4766eb57c5582120fe0e9673a5ffce58dc 100644 (file)
@@ -474,6 +474,8 @@ const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj);
 int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj);
 bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj);
 void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj);
+const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj);
+void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params);
 struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
 
 bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg);
index 1ab7a6a7de5390ba236faf161f9b114bf78e7190..bc035f215d44b2f81655acd549cfaceb158aaed0 100644 (file)
@@ -270,6 +270,7 @@ struct _LinphoneProxyConfig
        char *reg_identity;
        char *reg_route;
        char *realm;
+       char *contact_params;
        int expires;
        int reg_time;
        SalOp *op;
index 1676e0918c6278737e65490bd0810090466822cc..8e066ea33fa340d22e73e95dbf2fd92612a6580a 100644 (file)
@@ -256,9 +256,10 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){
        if (proxy==NULL) return NULL;
        host=linphone_address_get_domain (proxy);
        if (host!=NULL){
-               LinphoneAddress *contact;
                char localip[LINPHONE_IPADDR_SIZE];
+               char *tmp;
                LCSipTransports tr;
+               LinphoneAddress *contact;
                
                linphone_core_get_local_ip(obj->lc,host,localip);
                contact=linphone_address_new(obj->reg_identity);
@@ -274,8 +275,12 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){
                                sal_address_set_param(contact,"transport","tls");
                        }
                }
-               ret=linphone_address_as_string(contact);
+               tmp=linphone_address_as_string_uri_only(contact);
+               if (obj->contact_params)
+                       ret=ms_strdup_printf("<%s;%s>",tmp,obj->contact_params);
+               else ret=ms_strdup_printf("<%s>",tmp);
                linphone_address_destroy(contact);
+               ms_free(tmp);
        }
        linphone_address_destroy (proxy);
        return ret;
@@ -511,6 +516,31 @@ bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj){
        return obj->reg_sendregister;
 }
 
+/**
+ * Set optional contact parameters that will be added to the contact information sent in the registration.
+ * @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_parameters(LinphoneProxyConfig *obj, const char *contact_params){
+       if (obj->contact_params) {
+               ms_free(obj->contact_params);
+               obj->contact_params=NULL;
+       }
+       if (contact_params){
+               obj->contact_params=ms_strdup(contact_params);
+       }
+}
+
+/**
+ * Returns previously set contact parameters.
+**/
+const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj){
+       return obj->contact_params;
+}
+
 struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj){
        return obj->lc;
 }
index 94eb4afe778c5fab72ca3e4defca42bc2a4d8118..ec0a638d5c487ca8b7916094d14ad3967db62ce3 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 94eb4afe778c5fab72ca3e4defca42bc2a4d8118
+Subproject commit ec0a638d5c487ca8b7916094d14ad3967db62ce3