mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-30 09:49:26 +00:00
Reworked lpconfig global default values section to have one default value for each section + use proxy default value when creating proxy config
This commit is contained in:
parent
2c0e4947cc
commit
cac1551acd
7 changed files with 111 additions and 30 deletions
|
|
@ -1417,6 +1417,11 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandat
|
|||
linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
|
||||
}
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createProxyConfig(JNIEnv* env, jobject thiz, jlong lc) {
|
||||
LinphoneProxyConfig* proxy = linphone_core_create_proxy_config((LinphoneCore *)lc);
|
||||
return (jlong) proxy;
|
||||
}
|
||||
|
||||
//ProxyConfig
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
|
||||
|
|
|
|||
|
|
@ -461,3 +461,37 @@ void lp_config_clean_section(LpConfig *lpconfig, const char *section){
|
|||
int lp_config_needs_commit(const LpConfig *lpconfig){
|
||||
return lpconfig->modified>0;
|
||||
}
|
||||
|
||||
static const char *DEFAULT_VALUES_SUFFIX = "_default_values";
|
||||
|
||||
int lp_config_get_default_int(const LpConfig *lpconfig, const char *section, const char *key, int default_value) {
|
||||
char default_section[MAX_LEN];
|
||||
strcpy(default_section, section);
|
||||
strcat(default_section, DEFAULT_VALUES_SUFFIX);
|
||||
|
||||
return lp_config_get_int(lpconfig, default_section, key, default_value);
|
||||
}
|
||||
|
||||
int64_t lp_config_get_default_int64(const LpConfig *lpconfig, const char *section, const char *key, int64_t default_value) {
|
||||
char default_section[MAX_LEN];
|
||||
strcpy(default_section, section);
|
||||
strcat(default_section, DEFAULT_VALUES_SUFFIX);
|
||||
|
||||
return lp_config_get_int64(lpconfig, default_section, key, default_value);
|
||||
}
|
||||
|
||||
float lp_config_get_default_float(const LpConfig *lpconfig, const char *section, const char *key, float default_value) {
|
||||
char default_section[MAX_LEN];
|
||||
strcpy(default_section, section);
|
||||
strcat(default_section, DEFAULT_VALUES_SUFFIX);
|
||||
|
||||
return lp_config_get_float(lpconfig, default_section, key, default_value);
|
||||
}
|
||||
|
||||
const char* lp_config_get_default_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value) {
|
||||
char default_section[MAX_LEN];
|
||||
strcpy(default_section, section);
|
||||
strcat(default_section, DEFAULT_VALUES_SUFFIX);
|
||||
|
||||
return lp_config_get_string(lpconfig, default_section, key, default_value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,20 +55,6 @@ typedef struct _LpConfig LpConfig;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define LP_CONFIG_DEFAULT_STRING(config, name, default) \
|
||||
(config) ? (lp_config_get_string(config, "default_values", name, default)) : (default)
|
||||
|
||||
#define LP_CONFIG_DEFAULT_INT(config, name, default) \
|
||||
(config) ? (lp_config_get_int(config, "default_values", name, default)) : (default)
|
||||
|
||||
#define LP_CONFIG_DEFAULT_INT64(config, name, default) \
|
||||
(config) ? (lp_config_get_int64(config, "default_values", name, default)) : (default)
|
||||
|
||||
#define LP_CONFIG_DEFAULT_FLOAT(config, name, default) \
|
||||
(config) ? (lp_config_get_float(config, "default_values", name, default)) : (default)
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a LpConfig object from a user config file.
|
||||
*
|
||||
|
|
@ -220,7 +206,40 @@ void lp_config_for_each_entry(const LpConfig *lpconfig, const char *section, voi
|
|||
|
||||
/*tells whether uncommited (with lp_config_sync()) modifications exist*/
|
||||
int lp_config_needs_commit(const LpConfig *lpconfig);
|
||||
|
||||
LINPHONE_PUBLIC void lp_config_destroy(LpConfig *cfg);
|
||||
|
||||
/**
|
||||
* Retrieves a default configuration item as an integer, given its section, key, and default value.
|
||||
*
|
||||
* @ingroup misc
|
||||
* The default integer value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC int lp_config_get_default_int(const LpConfig *lpconfig, const char *section, const char *key, int default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a default configuration item as a 64 bit integer, given its section, key, and default value.
|
||||
*
|
||||
* @ingroup misc
|
||||
* The default integer value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC int64_t lp_config_get_default_int64(const LpConfig *lpconfig, const char *section, const char *key, int64_t default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a default configuration item as a float, given its section, key, and default value.
|
||||
*
|
||||
* @ingroup misc
|
||||
* The default float value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC float lp_config_get_default_float(const LpConfig *lpconfig, const char *section, const char *key, float default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a default configuration item as a string, given its section, key, and default value.
|
||||
*
|
||||
* @ingroup misc
|
||||
* The default value string is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC const char* lp_config_get_default_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,15 +41,25 @@ void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){
|
|||
lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy(lc,NULL));
|
||||
}
|
||||
|
||||
static void linphone_proxy_config_init(LinphoneCore* lc,LinphoneProxyConfig *obj){
|
||||
const char *dial_prefix;
|
||||
memset(obj,0,sizeof(LinphoneProxyConfig));
|
||||
obj->magic=linphone_proxy_config_magic;
|
||||
obj->expires=LP_CONFIG_DEFAULT_INT((lc?lc->config:NULL),"reg_expires",3600);
|
||||
dial_prefix=LP_CONFIG_DEFAULT_STRING((lc?lc->config:NULL),"dial_prefix",NULL);
|
||||
if (dial_prefix) obj->dial_prefix=ms_strdup(dial_prefix);
|
||||
obj->dial_escape_plus=LP_CONFIG_DEFAULT_INT((lc?lc->config:NULL),"dial_escape_plus",0);
|
||||
obj->privacy=LP_CONFIG_DEFAULT_INT((lc?lc->config:NULL),"privacy",LinphonePrivacyDefault);
|
||||
static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *obj) {
|
||||
const char *dial_prefix = lc ? lp_config_get_default_string(lc->config,"proxy","dial_prefix",NULL) : NULL;
|
||||
const char *identity = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_identity", NULL) : NULL;
|
||||
const char *proxy = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_proxy", NULL) : NULL;
|
||||
const char *route = lc ? lp_config_get_default_string(lc->config, "proxy", "reg_route", NULL) : NULL;
|
||||
const char *contact_params = lc ? lp_config_get_default_string(lc->config, "proxy", "contact_parameters", NULL) : NULL;
|
||||
const char *contact_uri_params = lc ? lp_config_get_default_string(lc->config, "proxy", "contact_uri_parameters", NULL) : NULL;
|
||||
|
||||
memset(obj, 0, sizeof(LinphoneProxyConfig));
|
||||
obj->magic = linphone_proxy_config_magic;
|
||||
obj->expires = lc ? lp_config_get_default_int(lc->config, "proxy", "reg_expires", 3600) : 3600;
|
||||
obj->dial_prefix = dial_prefix ? ms_strdup(dial_prefix) : NULL;
|
||||
obj->dial_escape_plus = lc ? lp_config_get_default_int(lc->config, "proxy", "dial_escape_plus", 0) : 0;
|
||||
obj->privacy = lc ? lp_config_get_default_int(lc->config, "proxy", "privacy", LinphonePrivacyDefault) : LinphonePrivacyDefault;
|
||||
obj->reg_identity = identity ? ms_strdup(identity) : NULL;
|
||||
obj->reg_proxy = proxy ? ms_strdup(proxy) : NULL;
|
||||
obj->reg_route = route ? ms_strdup(route) : NULL;
|
||||
obj->contact_params = contact_params ? ms_strdup(contact_params) : NULL;
|
||||
obj->contact_uri_params = contact_uri_params ? ms_strdup(contact_uri_params) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -64,6 +74,7 @@ static void linphone_proxy_config_init(LinphoneCore* lc,LinphoneProxyConfig *obj
|
|||
LinphoneProxyConfig *linphone_proxy_config_new() {
|
||||
return linphone_core_create_proxy_config(NULL);
|
||||
}
|
||||
|
||||
LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc) {
|
||||
LinphoneProxyConfig *obj=NULL;
|
||||
obj=ms_new(LinphoneProxyConfig,1);
|
||||
|
|
@ -71,8 +82,6 @@ LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc) {
|
|||
return obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Destroys a proxy config.
|
||||
*
|
||||
|
|
@ -1091,19 +1100,19 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config
|
|||
|
||||
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_expires(cfg,lp_config_get_int(config,key,"reg_expires",lp_config_get_default_int(config,"proxy","reg_expires",600)));
|
||||
linphone_proxy_config_enableregister(cfg,lp_config_get_int(config,key,"reg_sendregister",0));
|
||||
|
||||
linphone_proxy_config_enable_publish(cfg,lp_config_get_int(config,key,"publish",0));
|
||||
|
||||
linphone_proxy_config_set_dial_escape_plus(cfg,lp_config_get_int(config,key,"dial_escape_plus",LP_CONFIG_DEFAULT_INT(config,"dial_escape_plus",0)));
|
||||
linphone_proxy_config_set_dial_prefix(cfg,lp_config_get_string(config,key,"dial_prefix",LP_CONFIG_DEFAULT_STRING(config,"dial_prefix",NULL)));
|
||||
linphone_proxy_config_set_dial_escape_plus(cfg,lp_config_get_int(config,key,"dial_escape_plus",lp_config_get_default_int(config,"proxy","dial_escape_plus",0)));
|
||||
linphone_proxy_config_set_dial_prefix(cfg,lp_config_get_string(config,key,"dial_prefix",lp_config_get_default_string(config,"proxy","dial_prefix",NULL)));
|
||||
|
||||
tmp=lp_config_get_string(config,key,"type",NULL);
|
||||
if (tmp!=NULL && strlen(tmp)>0)
|
||||
linphone_proxy_config_set_sip_setup(cfg,tmp);
|
||||
|
||||
linphone_proxy_config_set_privacy(cfg,lp_config_get_int(config,key,"privacy",LP_CONFIG_DEFAULT_INT(config,"privacy",LinphonePrivacyDefault)));
|
||||
linphone_proxy_config_set_privacy(cfg,lp_config_get_int(config,key,"privacy",lp_config_get_default_int(config,"proxy","privacy",LinphonePrivacyDefault)));
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1518,4 +1518,10 @@ public interface LinphoneCore {
|
|||
* @return true if successful, false otherwise.
|
||||
*/
|
||||
public boolean acceptEarlyMediaWithParams(LinphoneCall call, LinphoneCallParams params);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public LinphoneProxyConfig createProxyConfig();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ abstract public class LinphoneCoreFactory {
|
|||
abstract public LinphoneAddress createLinphoneAddress(String address) throws LinphoneCoreException;
|
||||
abstract public LpConfig createLpConfig(String file);
|
||||
|
||||
abstract public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException;
|
||||
abstract public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException;
|
||||
|
||||
/**
|
||||
* Enable verbose traces
|
||||
* @param enable
|
||||
|
|
@ -96,12 +97,14 @@ abstract public class LinphoneCoreFactory {
|
|||
abstract public void setDebugMode(boolean enable, String tag);
|
||||
|
||||
abstract public void setLogHandler(LinphoneLogHandler handler);
|
||||
|
||||
/**
|
||||
* Create a LinphoneFriend, similar to {@link #createLinphoneFriend()} + {@link LinphoneFriend#setAddress(LinphoneAddress)}
|
||||
* @param friendUri a buddy address, must be a sip uri like sip:joe@sip.linphone.org
|
||||
* @return a new LinphoneFriend with address initialized
|
||||
*/
|
||||
abstract public LinphoneFriend createLinphoneFriend(String friendUri);
|
||||
|
||||
/**
|
||||
* Create a new LinphoneFriend
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native void setChatDatabasePath(long nativePtr, String path);
|
||||
private native long[] getChatRooms(long nativePtr);
|
||||
private native int migrateToMultiTransport(long nativePtr);
|
||||
private native long createProxyConfig(long nativePtr);
|
||||
|
||||
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig, File factoryConfig, Object userdata) throws IOException {
|
||||
mListener = listener;
|
||||
|
|
@ -1129,4 +1130,8 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
long ptrParams = params != null ? ((LinphoneCallParamsImpl) params).nativePtr : 0;
|
||||
return acceptEarlyMediaWithParams(nativePtr, getCallPtr(call), ptrParams);
|
||||
}
|
||||
@Override
|
||||
public LinphoneProxyConfig createProxyConfig() {
|
||||
return new LinphoneProxyConfigImpl(createProxyConfig(nativePtr));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue