From: Guillaume Beraudo Date: Wed, 16 Jan 2013 09:53:39 +0000 (+0100) Subject: Option to store auth_info in linphonerc X-Git-Url: http://sjero.net/git/?p=linphone;a=commitdiff_plain;h=3a9e33feb0f67bf411a417b436a06358ec97f3a6 Option to store auth_info in linphonerc Force value in user application after core creation in order to prevent the passwords to be stored. --- diff --git a/coreapi/authentication.c b/coreapi/authentication.c index 1f7dfa91..4b5d10fa 100644 --- a/coreapi/authentication.c +++ b/coreapi/authentication.c @@ -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){ diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 7871a105..4144c144 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -23,9 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphonecore_utils.h" #include -#ifdef TUNNEL_ENABLED -#include "linphone_tunnel.h" -#endif extern "C" { #include "mediastreamer2/mediastream.h" @@ -34,6 +31,8 @@ extern "C" { #include "private.h" #include +#include "lpconfig.h" + #ifdef ANDROID #include 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); +} + diff --git a/gtk/main.c b/gtk/main.c index 59530d81..12e84bc9 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -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); diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index d612589f..08371f51 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -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 index 00000000..f31e4d52 --- /dev/null +++ b/java/common/org/linphone/core/LpConfig.java @@ -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. + * + *
+ * 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
+ * 
+ * } + * @author Guillaume Beraudo + */ +public interface LpConfig { + + /** + * Sets an integer config item + * @param key + */ + void setInt(String section, String key, int value); +} diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index d4f7808c..02e31f9a 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -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 index 00000000..1cb705ec --- /dev/null +++ b/java/impl/org/linphone/core/LpConfigImpl.java @@ -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); + } + +}