Config
public class Config : LinphoneObject
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.
-
Declaration
Swift
public static func getSwiftObject(cObject: OpaquePointer) -> Config -
Declaration
Swift
public var getCobject: OpaquePointer? { get } -
Instantiates a
Configobject from a user config file name, group id and a factory config file. The “group id” is the string that identify the “App group” capability of the iOS application. App group gives access to a shared file system where all the configuration files for shared core are stored. Both iOS application and iOS app extension that need shared core must activate the “App group” capability with the SAME “group id” in the project settings. The caller of this constructor owns a reference. linphone_config_unref must be called when this object is no longer needed.See
See also: linphone_config_newDeclaration
Swift
public static func newForSharedCore(appGroupId: String, configFilename: String?, factoryConfigFilename: String?) -> Config?Parameters
appGroupIdused to compute the path of the config file in the file system shared by the shared Cores
configFilenamethe filename of the user config file to read to fill the instantiated
ConfigfactoryConfigFilenamethe filename of the factory config file to read to fill the instantiated
ConfigReturn Value
a
Configobject
The user config file is read first to fill theConfigand 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. -
Instantiates a
Configobject 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.See
See also: newWithFactory()See
See also: linphone_config_newDeclaration
Swift
public static func newFromBuffer(buffer: String) -> Config?Parameters
bufferthe buffer from which the
Configwill be retrieved. We expect the buffer to be null-terminated.Return Value
a
Configobject -
Instantiates a
Configobject 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.See
See also: linphone_config_newDeclaration
Swift
public static func newWithFactory(configFilename: String?, factoryConfigFilename: String?) -> Config?Parameters
configFilenamethe filename of the user config file to read to fill the instantiated
ConfigfactoryConfigFilenamethe filename of the factory config file to read to fill the instantiated
ConfigReturn Value
a
Configobject
The user config file is read first to fill theConfigand 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. -
Returns the list of sections’ names in the LinphoneConfig.
Declaration
Swift
public var sectionsNamesList: [String] { get }Return Value
A list of strings.
-
Removes entries for key,value in a section.
Declaration
Swift
public func cleanEntry(section: String, key: String)Parameters
sectionthe section for which to clean the key entry
keythe key to clean
-
Removes every pair of key,value in a section and remove the section.
Declaration
Swift
public func cleanSection(section: String)Parameters
sectionthe section to clean
-
Dumps the
Configas INI into a buffer.Declaration
Swift
public func dump() -> StringReturn Value
The buffer that contains the config dump
-
Dumps the
Configas XML into a buffer.Declaration
Swift
public func dumpAsXml() -> StringReturn Value
The buffer that contains the XML dump
-
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
Swift
public func getBool(section: String, key: String, defaultValue: Bool) -> BoolParameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found
Return Value
the found value or default_value if not found.
-
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
Swift
public func getDefaultFloat(section: String, key: String, defaultValue: Float) -> FloatParameters
sectionThe section from which to retrieve the default value
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found
Return Value
the found default value or default_value if not found.
-
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
Swift
public func getDefaultInt(section: String, key: String, defaultValue: Int) -> IntParameters
sectionThe section from which to retrieve the default value
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found
Return Value
the found default value or default_value if not found.
-
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
Swift
public func getDefaultInt64(section: String, key: String, defaultValue: Int64) -> Int64Parameters
sectionThe section from which to retrieve the default value
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found
Return Value
the found default value or default_value if not found.
-
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
Swift
public func getDefaultString(section: String, key: String, defaultValue: String) -> StringParameters
sectionThe section from which to retrieve the default value
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found
Return Value
the found default value or default_value if not found.
-
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
Swift
public func getFloat(section: String, key: String, defaultValue: Float) -> FloatParameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found
Return Value
the found value or default_value if not found.
-
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
Swift
public func getInt(section: String, key: String, defaultValue: Int) -> IntParameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found
Return Value
the found value or default_value if not found.
-
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
Swift
public func getInt64(section: String, key: String, defaultValue: Int64) -> Int64Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found
Return Value
the found value or default_value if not found.
-
Returns the list of keys’ names for a section in the LinphoneConfig.
Declaration
Swift
public func getKeysNamesList(section: String) -> [String]Parameters
sectionThe section name
Return Value
A list of strings.
-
Retrieves the overwrite flag for a config item.
Declaration
Swift
public func getOverwriteFlagForEntry(section: String, key: String) -> BoolParameters
sectionThe section from which to retrieve the overwrite flag
keyThe name of the configuration item to retrieve the overwrite flag from.
Return Value
true if overwrite flag is set, false otherwise.
-
Retrieves the overwrite flag for a config section.
Declaration
Swift
public func getOverwriteFlagForSection(section: String) -> BoolParameters
sectionThe section from which to retrieve the overwrite flag
Return Value
true if overwrite flag is set, false otherwise.
-
Retrieves a configuration item as a range, given its section, key, and default min and max values.
Declaration
Swift
public func getRange(section: String, key: String, min: UnsafeMutablePointer<Int32>, max: UnsafeMutablePointer<Int32>, defaultMin: Int, defaultMax: Int) -> BoolParameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
minThe min value found or default_min
maxThe max value found or default_max
defaultMinthe default min value to return if not found
defaultMaxthe default max value to return if not found.
Return Value
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.
-
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
Swift
public func getSectionParamString(section: String, key: String, defaultValue: String?) -> StringParameters
sectionThe section from which to retrieve the default value
keyThe name of the configuration item to retrieve
defaultValueThe default value to return if not found.
Return Value
the found default value or default_value if not found.
-
Retrieves the skip flag for a config item.
Declaration
Swift
public func getSkipFlagForEntry(section: String, key: String) -> BoolParameters
sectionThe section from which to retrieve the skip flag
keyThe name of the configuration item to retrieve the skip flag from
Return Value
true if skip flag is set, false otherwise.
-
Retrieves the skip flag for a config section.
Declaration
Swift
public func getSkipFlagForSection(section: String) -> BoolParameters
sectionThe section from which to retrieve the skip flag
Return Value
true if skip flag is set, false otherwise.
-
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
Swift
public func getString(section: String, key: String, defaultString: String?) -> StringParameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
defaultStringThe default value to return if not found.
Return Value
the found value or the default one if not found.
-
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
Swift
public func getStringList(section: String, key: String, defaultList: [String]?) -> [String]Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
defaultListThe list to return when the key doesn’t exist.
Return Value
A list of strings.
-
Returns if a given section with a given key is present in the configuration.
Declaration
Swift
public func hasEntry(section: String, key: String) -> IntParameters
sectionto check if the given entry exists
keyto check if it exists
Return Value
1 if it exists, 0 otherwise
-
Returns if a given section is present in the configuration.
Declaration
Swift
public func hasSection(section: String) -> IntParameters
sectionthe section to check if exists
Return Value
1 if it exists, 0 otherwise
-
Reads a xml config file and fill the
Configwith the read config dynamic values.Declaration
Swift
public func loadFromXmlFile(filename: String) -> StringParameters
filenameThe filename of the config file to read to fill the
Config -
Reads a xml config string and fill the
Configwith the read config dynamic values.Declaration
Swift
public func loadFromXmlString(buffer: String) throwsParameters
bufferThe string of the config file to fill the
ConfigReturn Value
0 in case of success
-
Reads a user config file and fill the
Configwith the read config values.Declaration
Swift
public func readFile(filename: String) throwsParameters
filenameThe filename of the config file to read to fill the
Config -
Check if given file name exists relatively to the current location.
Declaration
Swift
public func relativeFileExists(filename: String) -> BoolParameters
filenameThe file name to check if exists
Return Value
true if file exists relative to the to the current location
-
Reload the config from the file.
Declaration
Swift
public func reload() -
Sets a boolean config item.
Declaration
Swift
public func setBool(section: String, key: String, value: Bool)Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
valuethe value to set
-
Sets a float config item.
Declaration
Swift
public func setFloat(section: String, key: String, value: Float)Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
valuethe value to set
-
Sets an integer config item.
Declaration
Swift
public func setInt(section: String, key: String, value: Int)Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
valuethe value to set
-
Sets a 64 bits integer config item.
Declaration
Swift
public func setInt64(section: String, key: String, value: Int64)Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
valuethe value to set
-
Sets an integer config item, but store it as hexadecimal.
Declaration
Swift
public func setIntHex(section: String, key: String, value: Int)Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
valuethe value to set
-
Sets the overwrite flag for a config item (used when dumping config as xml)
Declaration
Swift
public func setOverwriteFlagForEntry(section: String, key: String, value: Bool)Parameters
sectionThe section from which to set the overwrite flag
keyThe name of the configuration item to set the overwrite flag from
valueThe overwrite flag value to set
-
Sets the overwrite flag for a config section (used when dumping config as xml)
Declaration
Swift
public func setOverwriteFlagForSection(section: String, value: Bool)Parameters
sectionThe section from which to set the overwrite flag
valueThe overwrite flag value to set
-
Sets a range config item.
Declaration
Swift
public func setRange(section: String, key: String, minValue: Int, maxValue: Int)Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
minValuethe min value to set
maxValuethe max value to set
-
Sets the skip flag for a config item (used when dumping config as xml)
Declaration
Swift
public func setSkipFlagForEntry(section: String, key: String, value: Bool)Parameters
sectionThe section from which to set the skip flag
keyThe name of the configuration item to set the skip flag from
valueThe skip flag value to set
-
Sets the skip flag for a config section (used when dumping config as xml)
Declaration
Swift
public func setSkipFlagForSection(section: String, value: Bool)Parameters
sectionThe section from which to set the skip flag
valueThe skip flag value to set
-
Sets a string config item.
Declaration
Swift
public func setString(section: String, key: String, value: String?)Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
valueThe value to set
-
Sets a string list config item.
Declaration
Swift
public func setStringList(section: String, key: String, value: [String]?)Parameters
sectionThe name of the section to put the configuration item into
keyThe name of the configuration item to set
valueThe value to set.
-
Writes the config file to disk.
Declaration
Swift
public func sync() throwsReturn Value
0 if successful, -1 otherwise
-
Write a string in a file placed relatively with the Linphone configuration file.
Declaration
Swift
public func writeRelativeFile(filename: String, data: String)Parameters
filenameName of the file where to write data. The name is relative to the place of the config file
dataString to write
Config Class Reference