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:
-sections are defined in []
-each section contains a sequence of key=value pairs
-each line starting by a # is a comment
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 Type
Method
Description
`void`
`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.
`void`
`cleanSectionSuite(String section)`
Removes a suite of sections whose name is derived from section argument,
suffixed with _0, _1, _2 etc.
`String`
`dump()`
Dumps the `Config` as INI into a buffer.
`String`
`dumpAsXml()`
Dumps the `Config` as XML into a buffer.
`boolean`
`getBool(String section, String key, boolean defaultValue)`
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.
`String`
`getDefaultString(String section, String key, String defaultValue)`
Retrieves a default configuration item as a string, given its section, key, and
default value.
`float`
`getFloat(String section, String key, float defaultValue)`
Retrieves a configuration item as a float, given its section, key, and default
value.
`int`
`getInt(String section, String key, int defaultValue)`
Retrieves a configuration item as an integer, given its section, key, and
default value.
`int`
`getInt64(String section, String key, int defaultValue)`
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`
`getNativePointer()`
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.
`String`
`getSectionParamString(String section, String key, String defaultValue)`
Retrieves a section parameter item as a string, given its section and key.
`String[]`
`getSectionsNamesList()`
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.
`String`
`getString(String section, String key, String defaultString)`
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.
`Object`
`getUserData()`
Gets the object stored in this object user's data
`int`
`hasEntry(String section, String key)`
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.
`boolean`
`isReadonly()`
Indicates whether the LinphoneConfig object is readonly, in other words it has
no file backend or file is opened without write permission.
`String`
`loadFromXmlFile(String filename)`
Reads a xml config file and fill the `Config` with the read config
dynamic values.
`int`
`loadFromXmlString(String buffer)`
Reads a xml config string and fill the `Config` with the read config
dynamic values.
`Config`
`newFromBuffer(String buffer)`
Instantiates a `Config` object from a user provided buffer.
`Config`
`newWithFactory(String configFilename, String factoryConfigFilename)`
Instantiates a `Config` object from a user config file and a factory
config file.
`int`
`readFile(String filename)`
Reads a user config file and fill the `Config` 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`
`setBool(String section, String key, boolean value)`
Sets a boolean config item.
`void`
`setFloat(String section, String key, float value)`
Sets a float config item.
`void`
`setInt(String section, String key, int value)`
Sets an integer config item.
`void`
`setInt64(String section, String key, int value)`
Sets a 64 bits integer config item.
`void`
`setIntHex(String section, String key, int value)`
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`
`setRange(String section, String key, int minValue, int maxValue)`
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`
`setString(String section, String key, String value)`
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 data
`int`
`sync()`
Writes the config file to disk.
`String`
`toString()`
`void`
`writeRelativeFile(String filename, String data)`
Write a string in a file placed relatively with the Linphone configuration
file.

## Method Details

### isReadonly

boolean isReadonly()
Indicates whether the LinphoneConfig object is readonly, in other words it has
no file backend or file is opened without write permission.

Returns:
  a boolean.

### getSectionsNamesList

String[] getSectionsNamesList()
Returns the list of sections' names in the LinphoneConfig.

Returns:
  A list of strings. A list of char * objects.

### cleanEntry

void cleanEntry(String section, String key)
Removes entries for key,value in a section.

Parameters:
  `section` - the section for which to clean the key entry
  `key` - the key to clean

### cleanSection

void cleanSection(String section)
Removes every pair of key,value in a section and remove the section.

Parameters:
  `section` - the section to clean

### cleanSectionSuite

void cleanSectionSuite(String section)
Removes a suite of sections whose name is derived from section argument,
suffixed with _0, _1, _2 etc.
This is a common representation for configuration objects that can have
multiple instances.

### dump

String dump()
Dumps the `Config` as INI into a buffer.

Returns:
  The buffer that contains the config dump

### dumpAsXml

String dumpAsXml()
Dumps the `Config` as XML into a buffer.

Returns:
  The buffer that contains the XML dump

### getBool

boolean getBool(String section, String key, boolean defaultValue)
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 item
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found
Returns:
  the found value or default_value if not found.

### getDefaultFloat

float getDefaultFloat(String section, String key, float defaultValue)
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 value
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found
Returns:
  the found default value or default_value if not found.

### getDefaultInt

int getDefaultInt(String section, String key, int defaultValue)
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 value
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found
Returns:
  the found default value or default_value if not found.

### getDefaultInt64

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.
The default integer value is returned if the config item isn't found.

Parameters:
  `section` - The section from which to retrieve the default value
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found
Returns:
  the found default value or default_value if not found.

### getDefaultString

String getDefaultString(String section, String key, String defaultValue)
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 value
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found
Returns:
  the found default value or default_value if not found.

### getFloat

float getFloat(String section, String key, float defaultValue)
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 item
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found
Returns:
  the found value or default_value if not found.

### getInt

int getInt(String section, String key, int defaultValue)
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 item
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found
Returns:
  the found value or default_value if not found.

### getInt64

int getInt64(String section, String key, int defaultValue)
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 item
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found
Returns:
  the found value or default_value if not found.

### getKeysNamesList

String[] getKeysNamesList(String section)
Returns the list of keys' names for a section in the LinphoneConfig.

Parameters:
  `section` - The section name
Returns:
  A list of strings. A list of char * objects.

### getOverwriteFlagForEntry

boolean getOverwriteFlagForEntry(String section, String key)
Retrieves the overwrite flag for a config item.

Parameters:
  `section` - The section from which to retrieve the overwrite flag
  `key` - The name of the configuration item to retrieve the overwrite flag
  from.
Returns:
  true if overwrite flag is set, false otherwise.

### getOverwriteFlagForSection

boolean getOverwriteFlagForSection(String section)
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

String getSectionParamString(String section, String key, 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 value
  `key` - The name of the configuration item to retrieve
  `defaultValue` - The default value to return if not found.
Returns:
  the found default value or default_value if not found.

### getSkipFlagForEntry

boolean getSkipFlagForEntry(String section, String key)
Retrieves the skip flag for a config item.

Parameters:
  `section` - The section from which to retrieve the skip flag
  `key` - The name of the configuration item to retrieve the skip flag from
Returns:
  true if skip flag is set, false otherwise.

### getSkipFlagForSection

boolean getSkipFlagForSection(String section)
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

String getString(String section, String key, 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 item
  `key` - The name of the configuration item to retrieve
  `defaultString` - The default value to return if not found.
Returns:
  the found value or the default one if not found.

### getStringList

String[] getStringList(String section, String key, 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 item
  `key` - The name of the configuration item to retrieve
  `defaultList` - The list to return when the key doesn't exist. A list of
  const char * objects.
Returns:
  A list of strings. A list of const char * objects.

### hasEntry

int hasEntry(String section, String key)
Returns if a given section with a given key is present in the configuration.

Parameters:
  `section` - to check if the given entry exists
  `key` - to check if it exists
Returns:
  1 if it exists, 0 otherwise

### hasSection

int hasSection(String section)
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

String loadFromXmlFile(String filename)
Reads a xml config file and fill the `Config` with the read config
dynamic values.

Parameters:
  `filename` - The filename of the config file to read to fill the `Config`

### loadFromXmlString

int loadFromXmlString(String buffer)
Reads a xml config string and fill the `Config` with the read config
dynamic values.

Parameters:
  `buffer` - The string of the config file to fill the `Config`
Returns:
  0 in case of success

### readFile

int readFile(String filename)
Reads a user config file and fill the `Config` with the read config
values.

Parameters:
  `filename` - The filename of the config file to read to fill the `Config`

### relativeFileExists

boolean relativeFileExists(String filename)
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

void setBool(String section, String key, boolean value)
Sets a boolean config item.

Parameters:
  `section` - The section from which to retrieve a configuration item
  `key` - The name of the configuration item to retrieve
  `value` - the value to set

### setFloat

void setFloat(String section, String key, float value)
Sets a float config item.

Parameters:
  `section` - The section from which to retrieve a configuration item
  `key` - The name of the configuration item to retrieve
  `value` - the value to set

### setInt

void setInt(String section, String key, int value)
Sets an integer config item.

Parameters:
  `section` - The section from which to retrieve a configuration item
  `key` - The name of the configuration item to retrieve
  `value` - the value to set

### setInt64

void setInt64(String section, String key, int value)
Sets a 64 bits integer config item.

Parameters:
  `section` - The section from which to retrieve a configuration item
  `key` - The name of the configuration item to retrieve
  `value` - the value to set

### setIntHex

void setIntHex(String section, String key, int value)
Sets an integer config item, but store it as hexadecimal.

Parameters:
  `section` - The section from which to retrieve a configuration item
  `key` - The name of the configuration item to retrieve
  `value` - the value to set

### setOverwriteFlagForEntry

void setOverwriteFlagForEntry(String section, String key, boolean value)
Sets the overwrite flag for a config item (used when dumping config as xml)

Parameters:
  `section` - The section from which to set the overwrite flag
  `key` - The name of the configuration item to set the overwrite flag from
  `value` - The overwrite flag value to set

### setOverwriteFlagForSection

void setOverwriteFlagForSection(String section, boolean value)
Sets the overwrite flag for a config section (used when dumping config as xml)

Parameters:
  `section` - The section from which to set the overwrite flag
  `value` - The overwrite flag value to set

### setRange

void setRange(String section, String key, int minValue, int maxValue)
Sets a range config item.

Parameters:
  `section` - The section from which to retrieve a configuration item
  `key` - The name of the configuration item to retrieve
  `minValue` - the min value to set
  `maxValue` - the max value to set

### setSkipFlagForEntry

void setSkipFlagForEntry(String section, String key, boolean value)
Sets the skip flag for a config item (used when dumping config as xml)

Parameters:
  `section` - The section from which to set the skip flag
  `key` - The name of the configuration item to set the skip flag from
  `value` - The skip flag value to set

### setSkipFlagForSection

void setSkipFlagForSection(String section, boolean value)
Sets the skip flag for a config section (used when dumping config as xml)

Parameters:
  `section` - The section from which to set the skip flag
  `value` - The skip flag value to set

### setString

void setString(String section, String key, String value)
Sets a string config item.

Parameters:
  `section` - The section from which to retrieve a configuration item
  `key` - The name of the configuration item to retrieve
  `value` - The value to set

### setStringList

void setStringList(String section, String key, String[] value)
Sets a string list config item.

Parameters:
  `section` - The name of the section to put the configuration item into
  `key` - The name of the configuration item to set
  `value` - The value to set. A list of const char * objects.

### sync

int sync()
Writes the config file to disk.

Returns:
  0 if successful, -1 otherwise

### writeRelativeFile

void writeRelativeFile(String filename, String data)
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 file
  `data` - String to write

### newFromBuffer

Config newFromBuffer(String buffer)
Instantiates a `Config` 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 the `Config` 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

Config newWithFactory(String configFilename, String factoryConfigFilename)
Instantiates a `Config` 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
  instantiated `Config`
  `factoryConfigFilename` - the filename of the factory config file to read to
  fill the instantiated `Config`
  see: linphone_config_new
Returns:
  a `Config` object
  The user config file is read first to fill the `Config` 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

void setUserData(Object data)
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()

Overrides:
  `toString` in class `Object`