]> sjero.net Git - linphone/commitdiff
Apply the user agent as soon as it is changed.
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Tue, 11 Dec 2012 09:36:27 +0000 (10:36 +0100)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Tue, 11 Dec 2012 09:38:57 +0000 (10:38 +0100)
The user agent is no longer global and now depends on the linphone core
(kind of, there is still a global variable behind to hold its value).

coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/linphonecore_jni.cc
gtk/main.c

index e52bef3f7c13d995638f9c7403b160dcee108b31..e52fff00ebf228c9157a75e1241dfe0b81921151 100644 (file)
@@ -1671,9 +1671,10 @@ static void apply_user_agent(LinphoneCore *lc){
  *
  * @ingroup misc
 **/
-void linphone_core_set_user_agent(const char *name, const char *ver){
+void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char *ver){
        strncpy(_ua_name,name,sizeof(_ua_name)-1);
        strncpy(_ua_version,ver,sizeof(_ua_version));
+       apply_user_agent(lc);
 }
 
 const char *linphone_core_get_user_agent_name(void){
index 17234a600c382444d49c458fcb1f7c51fe40770f..f1a9174c8e3ad0c03447d8a01ad6e053e7676359 100644 (file)
@@ -901,8 +901,6 @@ typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *contex
 void linphone_core_enable_logs(FILE *file);
 void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
 void linphone_core_disable_logs(void);
-/*sets the user-agent string in sip messages, must be set before linphone_core_new() or linphone_core_init() */
-void linphone_core_set_user_agent(const char *ua_name, const char *version);
 const char *linphone_core_get_version(void);
 const char *linphone_core_get_user_agent_name(void);
 const char *linphone_core_get_user_agent_version(void);
@@ -932,6 +930,9 @@ const char*  linphone_core_get_device_identifier(const LinphoneCore *lc);
 
 #endif
 
+/*sets the user-agent string in sip messages, ideally called just after linphone_core_new() or linphone_core_init() */
+void linphone_core_set_user_agent(LinphoneCore *lc, const char *ua_name, const char *version);
+
 LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url);
 
 LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url);
index 99d46fb18fee807ab35ad6187e2a0abbc2ded245..06188f411a864e113072fb237e42fe9db200dcf1 100644 (file)
@@ -2141,7 +2141,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env
 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
        const char* cname=env->GetStringUTFChars(name, NULL);
        const char* cversion=env->GetStringUTFChars(version, NULL);
-       linphone_core_set_user_agent(cname,cversion);
+       linphone_core_set_user_agent((LinphoneCore *)pCore,cname,cversion);
        env->ReleaseStringUTFChars(name, cname);
        env->ReleaseStringUTFChars(version, cversion);
 }
index b773a5b7faed3b92e8bb2a608b1832bb46c9e119..48bf27a089ed729dd0dc0adc8bd6136aa9a5110d 100644 (file)
@@ -239,8 +239,8 @@ static void linphone_gtk_init_liblinphone(const char *config_file,
        vtable.call_encryption_changed=linphone_gtk_call_encryption_changed;
        vtable.transfer_state_changed=linphone_gtk_transfer_state_changed;
 
-       linphone_core_set_user_agent("Linphone", LINPHONE_VERSION);
        the_core=linphone_core_new(&vtable,config_file,factory_config_file,NULL);
+       linphone_core_set_user_agent(the_core,"Linphone", LINPHONE_VERSION);
        linphone_core_set_waiting_callback(the_core,linphone_gtk_wait,NULL);
        linphone_core_set_zrtp_secrets_file(the_core,secrets_file);
        g_free(secrets_file);