Package org.linphone.core
Interface Config
public interface Config
This object is used to manipulate a configuration file.
The format of the configuration file is a .ini like format:
Various types can be used: strings and lists of strings, integers, floats,
booleans (written as 0 or 1) and range of integers.
Usually a
(where configuration changes through API calls will be saved) and one named
'factory' which is read-only and overwrites any setting that may exists in the
default one.
It is also possible to use only one (either default or factory) or even none.
The format of the configuration file is a .ini like format:
Various types can be used: strings and lists of strings, integers, floats,
booleans (written as 0 or 1) and range of integers.
Usually a
Core
is initialized using two Config
, one default(where configuration changes through API calls will be saved) and one named
'factory' which is read-only and overwrites any setting that may exists in the
default one.
It is also possible to use only one (either default or factory) or even none.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanEntry
(String section, String key) Removes entries for key,value in a section.void
cleanSection
(String section) Removes every pair of key,value in a section and remove the section.dump()
Dumps theConfig
as INI into a buffer.Dumps theConfig
as XML into a buffer.boolean
Retrieves a configuration item as a boolean, given its section, key, and
default value.float
getDefaultFloat
(String section, String key, float defaultValue) Retrieves a default configuration item as a float, given its section, key, and
default value.int
getDefaultInt
(String section, String key, int defaultValue) Retrieves a default configuration item as an integer, given its section, key,
and default value.int
getDefaultInt64
(String section, String key, int defaultValue) Retrieves a default configuration item as a 64 bit integer, given its section,
key, and default value.getDefaultString
(String section, String key, String defaultValue) Retrieves a default configuration item as a string, given its section, key, and
default value.float
Retrieves a configuration item as a float, given its section, key, and default
value.int
Retrieves a configuration item as an integer, given its section, key, and
default value.int
Retrieves a configuration item as a 64 bit integer, given its section, key, and
default value.String[]
getKeysNamesList
(String section) Returns the list of keys' names for a section in the LinphoneConfig.long
Gets the native pointer used by this class to make native method calls.boolean
getOverwriteFlagForEntry
(String section, String key) Retrieves the overwrite flag for a config item.boolean
getOverwriteFlagForSection
(String section) Retrieves the overwrite flag for a config section.getSectionParamString
(String section, String key, String defaultValue) Retrieves a section parameter item as a string, given its section and key.String[]
Returns the list of sections' names in the LinphoneConfig.boolean
getSkipFlagForEntry
(String section, String key) Retrieves the skip flag for a config item.boolean
getSkipFlagForSection
(String section) Retrieves the skip flag for a config section.Retrieves a configuration item as a string, given its section, key, and default
value.String[]
getStringList
(String section, String key, String[] defaultList) Retrieves a configuration item as a list of strings, given its section, key,
and default value.Gets the object stored in this object user's dataint
Returns if a given section with a given key is present in the configuration.int
hasSection
(String section) Returns if a given section is present in the configuration.loadFromXmlFile
(String filename) Reads a xml config file and fill theConfig
with the read config
dynamic values.int
loadFromXmlString
(String buffer) Reads a xml config string and fill theConfig
with the read config
dynamic values.newFromBuffer
(String buffer) Instantiates aConfig
object from a user provided buffer.newWithFactory
(String configFilename, String factoryConfigFilename) Instantiates aConfig
object from a user config file and a factory
config file.int
Reads a user config file and fill theConfig
with the read config
values.boolean
relativeFileExists
(String filename) Check if given file name exists relatively to the current location.void
reload()
Reload the config from the file.void
Sets a boolean config item.void
Sets a float config item.void
Sets an integer config item.void
Sets a 64 bits integer config item.void
Sets an integer config item, but store it as hexadecimal.void
setOverwriteFlagForEntry
(String section, String key, boolean value) Sets the overwrite flag for a config item (used when dumping config as xml)
void
setOverwriteFlagForSection
(String section, boolean value) Sets the overwrite flag for a config section (used when dumping config as xml)
void
Sets a range config item.void
setSkipFlagForEntry
(String section, String key, boolean value) Sets the skip flag for a config item (used when dumping config as xml)
void
setSkipFlagForSection
(String section, boolean value) Sets the skip flag for a config section (used when dumping config as xml)
void
Sets a string config item.void
setStringList
(String section, String key, String[] value) Sets a string list config item.void
setUserData
(Object data) Sets the object to store in this object user's dataint
sync()
Writes the config file to disk.toString()
void
writeRelativeFile
(String filename, String data) Write a string in a file placed relatively with the Linphone configuration
file.
-
Method Details
-
getSectionsNamesList
Returns the list of sections' names in the LinphoneConfig.
- Returns:
- A list of strings.
-
cleanEntry
Removes entries for key,value in a section.
- Parameters:
section
- the section for which to clean the key entrykey
- the key to clean
-
cleanSection
Removes every pair of key,value in a section and remove the section.
- Parameters:
section
- the section to clean
-
dump
- Returns:
- The buffer that contains the config dump
-
dumpAsXml
- Returns:
- The buffer that contains the XML dump
-
getBool
Retrieves a configuration item as a boolean, given its section, key, and
default value.
The default boolean value is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found- Returns:
- the found value or default_value if not found.
-
getDefaultFloat
Retrieves a default configuration item as a float, given its section, key, and
default value.
The default float value is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve the default valuekey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found- Returns:
- the found default value or default_value if not found.
-
getDefaultInt
Retrieves a default configuration item as an integer, given its section, key,
and default value.
The default integer value is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve the default valuekey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found- Returns:
- the found default value or default_value if not found.
-
getDefaultInt64
Retrieves a default configuration item as a 64 bit integer, given its section,
key, and default value.
The default integer value is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve the default valuekey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found- Returns:
- the found default value or default_value if not found.
-
getDefaultString
Retrieves a default configuration item as a string, given its section, key, and
default value.
The default value string is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve the default valuekey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found- Returns:
- the found default value or default_value if not found.
-
getFloat
Retrieves a configuration item as a float, given its section, key, and default
value.
The default float value is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found- Returns:
- the found value or default_value if not found.
-
getInt
Retrieves a configuration item as an integer, given its section, key, and
default value.
The default integer value is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found- Returns:
- the found value or default_value if not found.
-
getInt64
Retrieves a configuration item as a 64 bit integer, given its section, key, and
default value.
The default integer value is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found- Returns:
- the found value or default_value if not found.
-
getKeysNamesList
Returns the list of keys' names for a section in the LinphoneConfig.
- Parameters:
section
- The section name- Returns:
- A list of strings.
-
getOverwriteFlagForEntry
Retrieves the overwrite flag for a config item.
- Parameters:
section
- The section from which to retrieve the overwrite flagkey
- The name of the configuration item to retrieve the overwrite flag
from.- Returns:
- true if overwrite flag is set, false otherwise.
-
getOverwriteFlagForSection
Retrieves the overwrite flag for a config section.
- Parameters:
section
- The section from which to retrieve the overwrite flag- Returns:
- true if overwrite flag is set, false otherwise.
-
getSectionParamString
@Nullable String getSectionParamString(@NonNull String section, @NonNull String key, @Nullable String defaultValue) Retrieves a section parameter item as a string, given its section and key.
The default value string is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve the default valuekey
- The name of the configuration item to retrievedefaultValue
- The default value to return if not found.- Returns:
- the found default value or default_value if not found.
-
getSkipFlagForEntry
Retrieves the skip flag for a config item.
- Parameters:
section
- The section from which to retrieve the skip flagkey
- The name of the configuration item to retrieve the skip flag from- Returns:
- true if skip flag is set, false otherwise.
-
getSkipFlagForSection
Retrieves the skip flag for a config section.
- Parameters:
section
- The section from which to retrieve the skip flag- Returns:
- true if skip flag is set, false otherwise.
-
getString
@Nullable String getString(@NonNull String section, @NonNull String key, @Nullable String defaultString) Retrieves a configuration item as a string, given its section, key, and default
value.
The default value string is returned if the config item isn't found.- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievedefaultString
- The default value to return if not found.- Returns:
- the found value or the default one if not found.
-
getStringList
@NonNull String[] getStringList(@NonNull String section, @NonNull String key, @Nullable String[] defaultList) Retrieves a configuration item as a list of strings, given its section, key,
and default value.
The default value is returned if the config item is not found.- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievedefaultList
- The list to return when the key doesn't exist.- Returns:
- A list of strings.
-
hasEntry
Returns if a given section with a given key is present in the configuration.
- Parameters:
section
- to check if the given entry existskey
- to check if it exists- Returns:
- 1 if it exists, 0 otherwise
-
hasSection
Returns if a given section is present in the configuration.
- Parameters:
section
- the section to check if exists- Returns:
- 1 if it exists, 0 otherwise
-
loadFromXmlFile
- Parameters:
filename
- The filename of the config file to read to fill theConfig
-
loadFromXmlString
- Parameters:
buffer
- The string of the config file to fill theConfig
- Returns:
- 0 in case of success
-
readFile
- Parameters:
filename
- The filename of the config file to read to fill theConfig
-
relativeFileExists
Check if given file name exists relatively to the current location.
- Parameters:
filename
- The file name to check if exists- Returns:
- true if file exists relative to the to the current location
-
reload
void reload()Reload the config from the file.
-
setBool
Sets a boolean config item.
- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievevalue
- the value to set
-
setFloat
Sets a float config item.
- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievevalue
- the value to set
-
setInt
Sets an integer config item.
- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievevalue
- the value to set
-
setInt64
Sets a 64 bits integer config item.
- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievevalue
- the value to set
-
setIntHex
Sets an integer config item, but store it as hexadecimal.
- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievevalue
- the value to set
-
setOverwriteFlagForEntry
Sets the overwrite flag for a config item (used when dumping config as xml)
- Parameters:
section
- The section from which to set the overwrite flagkey
- The name of the configuration item to set the overwrite flag fromvalue
- The overwrite flag value to set
-
setOverwriteFlagForSection
Sets the overwrite flag for a config section (used when dumping config as xml)
- Parameters:
section
- The section from which to set the overwrite flagvalue
- The overwrite flag value to set
-
setRange
Sets a range config item.
- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrieveminValue
- the min value to setmaxValue
- the max value to set
-
setSkipFlagForEntry
Sets the skip flag for a config item (used when dumping config as xml)
- Parameters:
section
- The section from which to set the skip flagkey
- The name of the configuration item to set the skip flag fromvalue
- The skip flag value to set
-
setSkipFlagForSection
Sets the skip flag for a config section (used when dumping config as xml)
- Parameters:
section
- The section from which to set the skip flagvalue
- The skip flag value to set
-
setString
Sets a string config item.
- Parameters:
section
- The section from which to retrieve a configuration itemkey
- The name of the configuration item to retrievevalue
- The value to set
-
setStringList
Sets a string list config item.
- Parameters:
section
- The name of the section to put the configuration item intokey
- The name of the configuration item to setvalue
- The value to set.
-
sync
int sync()Writes the config file to disk.
- Returns:
- 0 if successful, -1 otherwise
-
writeRelativeFile
Write a string in a file placed relatively with the Linphone configuration
file.
- Parameters:
filename
- Name of the file where to write data. The name is relative to
the place of the config filedata
- String to write
-
newFromBuffer
Instantiates aConfig
object from a user provided buffer.
The caller of this constructor owns a reference. linphone_config_unref must be
called when this object is no longer needed.- Parameters:
buffer
- the buffer from which theConfig
will be retrieved. We
expect the buffer to be null-terminated.
see:newWithFactory(java.lang.String, java.lang.String)
see: linphone_config_new- Returns:
- a
Config
object
-
newWithFactory
@Nullable Config newWithFactory(@Nullable String configFilename, @Nullable String factoryConfigFilename) Instantiates aConfig
object from a user config file and a factory
config file.
The caller of this constructor owns a reference. linphone_config_unref must be
called when this object is no longer needed.- Parameters:
configFilename
- the filename of the user config file to read to fill the
instantiatedConfig
factoryConfigFilename
- the filename of the factory config file to read to
fill the instantiatedConfig
see: linphone_config_new- Returns:
- a
Config
object
The user config file is read first to fill theConfig
and then the
factory config file is read. Therefore the configuration parameters defined in
the user config file will be overwritten by the parameters defined in the
factory config file.
-
setUserData
Sets the object to store in this object user's data- Parameters:
data
- the object to store
-
getUserData
Object getUserData()Gets the object stored in this object user's data- Returns:
- the object store if any, null otherwise
-
getNativePointer
long getNativePointer()Gets the native pointer used by this class to make native method calls.- Returns:
- the nativer pointer, as long
-
toString
String toString()
-