]> sjero.net Git - linphone/commitdiff
Option to store auth_info in linphonerc
authorGuillaume Beraudo <guillaume.beraudo@belledonne-communications.com>
Wed, 16 Jan 2013 09:53:39 +0000 (10:53 +0100)
committerGuillaume Beraudo <guillaume.beraudo@belledonne-communications.com>
Wed, 16 Jan 2013 13:53:24 +0000 (14:53 +0100)
Force value in user application after core creation in order to
prevent the passwords to be stored.

coreapi/authentication.c
coreapi/linphonecore_jni.cc
gtk/main.c
java/common/org/linphone/core/LinphoneCore.java
java/common/org/linphone/core/LpConfig.java [new file with mode: 0644]
java/impl/org/linphone/core/LinphoneCoreImpl.java
java/impl/org/linphone/core/LpConfigImpl.java [new file with mode: 0644]

index 1f7dfa91c853648902bd31d8928bc351309e4cec..4b5d10fa8560d9f1e146c714310638b2ab4254bd 100644 (file)
@@ -131,7 +131,7 @@ void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, in
        sprintf(key,"auth_info_%i",pos);
        lp_config_clean_section(config,key);
        
-       if (obj==NULL){
+       if (obj==NULL || lp_config_get_int(config, "sip", "store_auth_info", 1) == 0){
                return;
        }               
        if (obj->username!=NULL){
index 7871a105d0683bcda4149ddaa6f934e80e9d2ddf..4144c1441f54d07da534f7995313002d7f0f6c64 100644 (file)
@@ -23,9 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "linphonecore_utils.h"
 #include <ortp/zrtp.h>
 
-#ifdef TUNNEL_ENABLED
-#include "linphone_tunnel.h"
-#endif
 
 extern "C" {
 #include "mediastreamer2/mediastream.h"
@@ -34,6 +31,8 @@ extern "C" {
 #include "private.h"
 #include <cpu-features.h>
 
+#include "lpconfig.h"
+
 #ifdef ANDROID
 #include <android/log.h>
 extern "C" void libmsilbc_init();
@@ -2225,3 +2224,17 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv*  e
        jstring jvalue =env->NewStringUTF(linphone_core_get_version());
        return jvalue;
 }
+
+extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getConfig(JNIEnv *env, jobject thiz, jlong lc) {
+       return (jlong) linphone_core_get_config((LinphoneCore *)lc);
+}
+
+extern "C" void Java_org_linphone_core_LpConfigImpl_setInt(JNIEnv *env, jobject thiz, jlong lpc,
+               jstring section, jstring key, jint value) {
+        const char *csection = env->GetStringUTFChars(section, NULL);
+        const char *ckey = env->GetStringUTFChars(key, NULL);
+        lp_config_set_int((LpConfig *)lpc, csection, ckey, (int) value);
+        env->ReleaseStringUTFChars(section, csection);
+        env->ReleaseStringUTFChars(key, ckey);
+}
+
index 59530d816196d36cedfb91e79016ebcf29faaffb..12e84bc97955c19cb4a19c93b2e62039e8685fb3 100644 (file)
@@ -237,6 +237,7 @@ static void linphone_gtk_init_liblinphone(const char *config_file,
        vtable.transfer_state_changed=linphone_gtk_transfer_state_changed;
 
        the_core=linphone_core_new(&vtable,config_file,factory_config_file,NULL);
+       //lp_config_set_int(linphone_core_get_config(the_core), "sip", "store_auth_info", 0);
        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);
index d612589fee8dd1a4efeab880b538c65b2af0bca2..08371f5155ede74f78cc0eb2f4520f88660e8fe1 100644 (file)
@@ -876,4 +876,10 @@ public interface LinphoneCore {
         * Enable/Disable the use of inband DTMFs
         */
        void setUseRfc2833ForDtmfs(boolean use);
+
+       /**
+        * @return returns LpConfig object to read/write to the config file: usefull if you wish to extend
+        * the config file with your own sections
+        */
+       LpConfig getConfig();
 }
diff --git a/java/common/org/linphone/core/LpConfig.java b/java/common/org/linphone/core/LpConfig.java
new file mode 100644 (file)
index 0000000..f31e4d5
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+LPConfig.java
+Copyright (C) 2013  Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+package org.linphone.core;
+
+
+/**
+ * The LpConfig object is used to manipulate a configuration file.
+ * 
+ * <pre>
+ * The format of the configuration file is a .ini like format:
+ * - sections are defined in []
+ * - each section contains a sequence of key=value pairs.
+ * 
+ * Example:
+ * [sound]
+ * echocanceler=1
+ * playback_dev=ALSA: Default device
+ *
+ * [video]
+ * enabled=1
+ * </pre>
+ * }
+ * @author Guillaume Beraudo
+ */
+public interface LpConfig {
+
+       /**
+        * Sets an integer config item
+        * @param key 
+        */
+       void setInt(String section, String key, int value);
+}
index d4f7808c67c65ac95aa292525963d65c87355237..02e31f9a1bfa0566fa93036a41dbc1947c774c0d 100644 (file)
@@ -866,4 +866,10 @@ class LinphoneCoreImpl implements LinphoneCore {
        public void setUseRfc2833ForDtmfs(boolean use) {
                setUseRfc2833ForDtmfs(nativePtr, use);
        }
+
+       private native long getConfig(long ptr);
+       public LpConfig getConfig() {
+               long configPtr=getConfig(nativePtr);
+               return new LpConfigImpl(configPtr);
+       }
 }
diff --git a/java/impl/org/linphone/core/LpConfigImpl.java b/java/impl/org/linphone/core/LpConfigImpl.java
new file mode 100644 (file)
index 0000000..1cb705e
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+LPConfigImpl.java
+Copyright (C) 2013  Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+package org.linphone.core;
+
+
+
+class LpConfigImpl implements LpConfig {
+
+       private final long nativePtr;
+       
+       public LpConfigImpl(long ptr) {
+               nativePtr=ptr;
+       }
+
+       private native void setInt(long ptr, String section, String key, int value);
+       public void setInt(String section, String key, int value) {
+               setInt(nativePtr, section, key, value);
+       }
+
+}