Class 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 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.
Inherited Members
Namespace: Linphone
Assembly: cs.temp.dll.dll
Syntax
public class Config : LinphoneObject
Properties
SectionsNamesList
Returns the list of sections' names in the LinphoneConfig.
Declaration
public IEnumerable<string> SectionsNamesList { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A list of strings. |
Methods
CleanEntry(String, String)
Removes entries for key,value in a section.
Declaration
public void CleanEntry(string section, string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | the section for which to clean the key entry |
System.String | key | the key to clean |
CleanSection(String)
Removes every pair of key,value in a section and remove the section.
Declaration
public void CleanSection(string section)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | the section to clean |
Dump()
Dumps the Config as INI into a buffer.
Declaration
public string Dump()
Returns
Type | Description |
---|---|
System.String | The buffer that contains the config dump |
DumpAsXml()
Dumps the Config as XML into a buffer.
Declaration
public string DumpAsXml()
Returns
Type | Description |
---|---|
System.String | The buffer that contains the XML dump |
GetBool(String, String, Boolean)
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.
Declaration
public bool GetBool(string section, string key, bool defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Boolean | defaultValue | The default value to return if not found |
Returns
Type | Description |
---|---|
System.Boolean | the found value or default_value if not found. |
GetDefaultFloat(String, String, Single)
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.
Declaration
public float GetDefaultFloat(string section, string key, float defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the default value |
System.String | key | The name of the configuration item to retrieve |
System.Single | defaultValue | The default value to return if not found |
Returns
Type | Description |
---|---|
System.Single | the found default value or default_value if not found. |
GetDefaultInt(String, String, Int32)
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.
Declaration
public int GetDefaultInt(string section, string key, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the default value |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | defaultValue | The default value to return if not found |
Returns
Type | Description |
---|---|
System.Int32 | the found default value or default_value if not found. |
GetDefaultInt64(String, String, Int32)
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.
Declaration
public int GetDefaultInt64(string section, string key, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the default value |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | defaultValue | The default value to return if not found |
Returns
Type | Description |
---|---|
System.Int32 | the found default value or default_value if not found. |
GetDefaultString(String, String, String)
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.
Declaration
public string GetDefaultString(string section, string key, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the default value |
System.String | key | The name of the configuration item to retrieve |
System.String | defaultValue | The default value to return if not found |
Returns
Type | Description |
---|---|
System.String | the found default value or default_value if not found. |
GetFloat(String, String, Single)
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.
Declaration
public float GetFloat(string section, string key, float defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Single | defaultValue | The default value to return if not found |
Returns
Type | Description |
---|---|
System.Single | the found value or default_value if not found. |
GetInt(String, String, Int32)
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.
Declaration
public int GetInt(string section, string key, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | defaultValue | The default value to return if not found |
Returns
Type | Description |
---|---|
System.Int32 | the found value or default_value if not found. |
GetInt64(String, String, Int32)
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.
Declaration
public int GetInt64(string section, string key, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | defaultValue | The default value to return if not found |
Returns
Type | Description |
---|---|
System.Int32 | the found value or default_value if not found. |
GetKeysNamesList(String)
Returns the list of keys' names for a section in the LinphoneConfig.
Declaration
public IEnumerable<string> GetKeysNamesList(string section)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section name |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A list of strings. |
GetOverwriteFlagForEntry(String, String)
Retrieves the overwrite flag for a config item.
Declaration
public bool GetOverwriteFlagForEntry(string section, string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the overwrite flag |
System.String | key | The name of the configuration item to retrieve the overwrite flag from. |
Returns
Type | Description |
---|---|
System.Boolean | true if overwrite flag is set, false otherwise. |
GetOverwriteFlagForSection(String)
Retrieves the overwrite flag for a config section.
Declaration
public bool GetOverwriteFlagForSection(string section)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the overwrite flag |
Returns
Type | Description |
---|---|
System.Boolean | true if overwrite flag is set, false otherwise. |
GetRange(String, String, Int32, Int32, Int32, Int32)
Retrieves a configuration item as a range, given its section, key, and default min and max values.
Declaration
public bool GetRange(string section, string key, int min, int max, int defaultMin, int defaultMax)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | min | The min value found or default_min |
System.Int32 | max | The max value found or default_max |
System.Int32 | defaultMin | the default min value to return if not found |
System.Int32 | defaultMax | the default max value to return if not found. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value is successfully parsed as a range, false otherwise. If false is returned, min and max are filled respectively with default_min and default_max values. |
GetSectionParamString(String, String, String)
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.
Declaration
public string GetSectionParamString(string section, string key, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the default value |
System.String | key | The name of the configuration item to retrieve |
System.String | defaultValue | The default value to return if not found. |
Returns
Type | Description |
---|---|
System.String | the found default value or default_value if not found. |
GetSkipFlagForEntry(String, String)
Retrieves the skip flag for a config item.
Declaration
public bool GetSkipFlagForEntry(string section, string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the skip flag |
System.String | key | The name of the configuration item to retrieve the skip flag from |
Returns
Type | Description |
---|---|
System.Boolean | true if skip flag is set, false otherwise. |
GetSkipFlagForSection(String)
Retrieves the skip flag for a config section.
Declaration
public bool GetSkipFlagForSection(string section)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve the skip flag |
Returns
Type | Description |
---|---|
System.Boolean | true if skip flag is set, false otherwise. |
GetString(String, String, String)
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.
Declaration
public string GetString(string section, string key, string defaultString)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.String | defaultString | The default value to return if not found. |
Returns
Type | Description |
---|---|
System.String | the found value or the default one if not found. |
GetStringList(String, String, IEnumerable<String>)
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.
Declaration
public IEnumerable<string> GetStringList(string section, string key, IEnumerable<string> defaultList)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Collections.Generic.IEnumerable<System.String> | defaultList | The list to return when the key doesn't exist. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A list of strings. |
HasEntry(String, String)
Returns if a given section with a given key is present in the configuration.
Declaration
public int HasEntry(string section, string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | to check if the given entry exists |
System.String | key | to check if it exists |
Returns
Type | Description |
---|---|
System.Int32 | 1 if it exists, 0 otherwise |
HasSection(String)
Returns if a given section is present in the configuration.
Declaration
public int HasSection(string section)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | the section to check if exists |
Returns
Type | Description |
---|---|
System.Int32 | 1 if it exists, 0 otherwise |
LoadFromXmlFile(String)
Reads a xml config file and fill the Config with the read config dynamic values.
Declaration
public string LoadFromXmlFile(string filename)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | The filename of the config file to read to fill the Config |
Returns
Type | Description |
---|---|
System.String |
LoadFromXmlString(String)
Reads a xml config string and fill the Config with the read config dynamic values.
Declaration
public void LoadFromXmlString(string buffer)
Parameters
Type | Name | Description |
---|---|---|
System.String | buffer | The string of the config file to fill the Config |
NewFromBuffer(String)
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.
Declaration
public static Config NewFromBuffer(string buffer)
Parameters
Type | Name | Description |
---|---|---|
System.String | buffer | the buffer from which the Config will be retrieved. We expect the buffer to be null-terminated. |
Returns
Type | Description |
---|---|
Config | a Config object |
Remarks
See :
NewWithFactory(String, String)
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.
Declaration
public static Config NewWithFactory(string configFilename, string factoryConfigFilename)
Parameters
Type | Name | Description |
---|---|---|
System.String | configFilename | the filename of the user config file to read to fill the instantiated Config |
System.String | factoryConfigFilename | the filename of the factory config file to read to fill the instantiated Config |
Returns
Type | Description |
---|---|
Config | a Config object |
Remarks
See : linphone_config_new
ReadFile(String)
Reads a user config file and fill the Config with the read config values.
Declaration
public void ReadFile(string filename)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | The filename of the config file to read to fill the Config |
RelativeFileExists(String)
Check if given file name exists relatively to the current location.
Declaration
public bool RelativeFileExists(string filename)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | The file name to check if exists |
Returns
Type | Description |
---|---|
System.Boolean | true if file exists relative to the to the current location |
Reload()
Reload the config from the file.
Declaration
public void Reload()
SetBool(String, String, Boolean)
Sets a boolean config item.
Declaration
public void SetBool(string section, string key, bool val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Boolean | val | the value to set |
SetFloat(String, String, Single)
Sets a float config item.
Declaration
public void SetFloat(string section, string key, float val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Single | val | the value to set |
SetInt(String, String, Int32)
Sets an integer config item.
Declaration
public void SetInt(string section, string key, int val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | val | the value to set |
SetInt64(String, String, Int32)
Sets a 64 bits integer config item.
Declaration
public void SetInt64(string section, string key, int val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | val | the value to set |
SetIntHex(String, String, Int32)
Sets an integer config item, but store it as hexadecimal.
Declaration
public void SetIntHex(string section, string key, int val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | val | the value to set |
SetOverwriteFlagForEntry(String, String, Boolean)
Sets the overwrite flag for a config item (used when dumping config as xml)
Declaration
public void SetOverwriteFlagForEntry(string section, string key, bool val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to set the overwrite flag |
System.String | key | The name of the configuration item to set the overwrite flag from |
System.Boolean | val | The overwrite flag value to set |
SetOverwriteFlagForSection(String, Boolean)
Sets the overwrite flag for a config section (used when dumping config as xml)
Declaration
public void SetOverwriteFlagForSection(string section, bool val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to set the overwrite flag |
System.Boolean | val | The overwrite flag value to set |
SetRange(String, String, Int32, Int32)
Sets a range config item.
Declaration
public void SetRange(string section, string key, int minValue, int maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.Int32 | minValue | the min value to set |
System.Int32 | maxValue | the max value to set |
SetSkipFlagForEntry(String, String, Boolean)
Sets the skip flag for a config item (used when dumping config as xml)
Declaration
public void SetSkipFlagForEntry(string section, string key, bool val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to set the skip flag |
System.String | key | The name of the configuration item to set the skip flag from |
System.Boolean | val | The skip flag value to set |
SetSkipFlagForSection(String, Boolean)
Sets the skip flag for a config section (used when dumping config as xml)
Declaration
public void SetSkipFlagForSection(string section, bool val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to set the skip flag |
System.Boolean | val | The skip flag value to set |
SetString(String, String, String)
Sets a string config item.
Declaration
public void SetString(string section, string key, string val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The section from which to retrieve a configuration item |
System.String | key | The name of the configuration item to retrieve |
System.String | val | The value to set |
SetStringList(String, String, IEnumerable<String>)
Sets a string list config item.
Declaration
public void SetStringList(string section, string key, IEnumerable<string> val)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The name of the section to put the configuration item into |
System.String | key | The name of the configuration item to set |
System.Collections.Generic.IEnumerable<System.String> | val | The value to set. |
Sync()
Writes the config file to disk.
Declaration
public void Sync()
WriteRelativeFile(String, String)
Write a string in a file placed relatively with the Linphone configuration file.
Declaration
public void WriteRelativeFile(string filename, string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | Name of the file where to write data. The name is relative to the place of the config file |
System.String | data | String to write |