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.

  • Undocumented

    Declaration

    Swift

    public static func getSwiftObject(cObject: OpaquePointer) -> Config
  • Undocumented

    Declaration

    Swift

    public var getCobject: OpaquePointer? { get }
  • Instantiates a Config object 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_new

    Declaration

    Swift

    public static func newForSharedCore(appGroupId: String, configFilename: String?, factoryConfigFilename: String?) -> Config?

    Parameters

    appGroupId

    used to compute the path of the config file in the file system shared by the shared Cores

    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

    Return Value

    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.

  • 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.

    See

    See also: newWithFactory()

    See

    See also: linphone_config_new

    Declaration

    Swift

    public static func newFromBuffer(buffer: String) -> Config?

    Parameters

    buffer

    the buffer from which the Config will be retrieved. We expect the buffer to be null-terminated.

    Return Value

    a Config object

  • 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.

    See

    See also: linphone_config_new

    Declaration

    Swift

    public static func newWithFactory(configFilename: String?, factoryConfigFilename: String?) -> Config?

    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

    Return Value

    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.

  • 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

    section

    the section for which to clean the key entry

    key

    the key to clean

  • Removes every pair of key,value in a section and remove the section.

    Declaration

    Swift

    public func cleanSection(section: String)

    Parameters

    section

    the section to clean

  • Dumps the Config as INI into a buffer.

    Declaration

    Swift

    public func dump() -> String

    Return Value

    The buffer that contains the config dump

  • Dumps the Config as XML into a buffer.

    Declaration

    Swift

    public func dumpAsXml() -> String

    Return 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) -> Bool

    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

    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) -> Float

    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

    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) -> Int

    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

    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) -> Int64

    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

    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) -> String

    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

    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) -> Float

    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

    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) -> Int

    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

    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) -> Int64

    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

    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

    section

    The 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) -> Bool

    Parameters

    section

    The section from which to retrieve the overwrite flag

    key

    The 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) -> Bool

    Parameters

    section

    The 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) -> Bool

    Parameters

    section

    The section from which to retrieve a configuration item

    key

    The name of the configuration item to retrieve

    min

    The min value found or default_min

    max

    The max value found or default_max

    defaultMin

    the default min value to return if not found

    defaultMax

    the 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?) -> String

    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.

    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) -> Bool

    Parameters

    section

    The section from which to retrieve the skip flag

    key

    The 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) -> Bool

    Parameters

    section

    The 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?) -> String

    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.

    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

    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.

    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) -> Int

    Parameters

    section

    to check if the given entry exists

    key

    to 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) -> Int

    Parameters

    section

    the section to check if exists

    Return Value

    1 if it exists, 0 otherwise

  • Reads a xml config file and fill the Config with the read config dynamic values.

    Declaration

    Swift

    public func loadFromXmlFile(filename: String) -> String

    Parameters

    filename

    The filename of the config file to read to fill the Config

  • Reads a xml config string and fill the Config with the read config dynamic values.

    Declaration

    Swift

    public func loadFromXmlString(buffer: String) throws

    Parameters

    buffer

    The string of the config file to fill the Config

    Return Value

    0 in case of success

  • Reads a user config file and fill the Config with the read config values.

    Declaration

    Swift

    public func readFile(filename: String) throws

    Parameters

    filename

    The 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) -> Bool

    Parameters

    filename

    The 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

    section

    The section from which to retrieve a configuration item

    key

    The name of the configuration item to retrieve

    value

    the value to set

  • Sets a float config item.

    Declaration

    Swift

    public func setFloat(section: String, key: String, value: Float)

    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

  • Sets an integer config item.

    Declaration

    Swift

    public func setInt(section: String, key: String, value: Int)

    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

  • Sets a 64 bits integer config item.

    Declaration

    Swift

    public func setInt64(section: String, key: String, value: Int64)

    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

  • Sets an integer config item, but store it as hexadecimal.

    Declaration

    Swift

    public func setIntHex(section: String, key: String, value: Int)

    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

  • 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

    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

  • Sets the overwrite flag for a config section (used when dumping config as xml)

    Declaration

    Swift

    public func setOverwriteFlagForSection(section: String, value: Bool)

    Parameters

    section

    The section from which to set the overwrite flag

    value

    The overwrite flag value to set

  • Sets a range config item.

    Declaration

    Swift

    public func setRange(section: String, key: String, minValue: Int, maxValue: Int)

    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

  • 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

    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

  • Sets the skip flag for a config section (used when dumping config as xml)

    Declaration

    Swift

    public func setSkipFlagForSection(section: String, value: Bool)

    Parameters

    section

    The section from which to set the skip flag

    value

    The skip flag value to set

  • Sets a string config item.

    Declaration

    Swift

    public func setString(section: String, key: String, value: String?)

    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

  • Sets a string list config item.

    Declaration

    Swift

    public func setStringList(section: String, key: String, value: [String]?)

    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.

  • Writes the config file to disk.

    Declaration

    Swift

    public func sync() throws

    Return 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

    filename

    Name of the file where to write data. The name is relative to the place of the config file

    data

    String to write