TlmConfig

TlmConfig — tlm configuration information

Functions

Object Hierarchy

    GObject
    ╰── TlmConfig

Includes

#include <tlm-config.h>

Description

TlmConfig holds configuration information as a set of keys and values (integer or strings). The key names are defined in

General config keys.

Note that authentication and account plugins may use plugin-specific configuration keys; see plugins' documentation for specifics.

The configuration is retrieved from the tlm configuration file. See below for where the file is searched for.

Usage

Following code snippet demonstrates how to create and use config object:


TlmConfig* config = tlm_config_new ();
const gchar *str = tlm_config_get_string (config,
 TLM_CONFIG_GENERAL, TLM_CONFIG_GENERAL_PAM_SERVICE, 0);
g_object_unref(config);

Where the configuration file is searched for

If tlm has been compiled with --enable-debug, then these locations are used, in decreasing order of priority:

Otherwise, the config file location is determined at compilation time as $(sysconfdir) + "tlm.conf"

Example configuration file

See example configuration file here:

tlm configuration file

Functions

tlm_config_new ()

TlmConfig *
tlm_config_new ();

Create a TlmConfig object.

Returns

an instance of TlmConfig.


tlm_config_get_int ()

gint
tlm_config_get_int (TlmConfig *self,
                    const gchar *group,
                    const gchar *key,
                    gint retval);

Get an integer configuration value.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name

 

key

the key name

 

retval

value to be returned in case key is not found

 

Returns

the value corresponding to the key as an integer. If the key does not exist or cannot be converted to the integer, retval is returned.


tlm_config_set_int ()

void
tlm_config_set_int (TlmConfig *self,
                    const gchar *group,
                    const gchar *key,
                    gint value);

Sets the configuration value to the provided integer.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name

 

key

the key name

 

value

the value

 

tlm_config_get_uint ()

guint
tlm_config_get_uint (TlmConfig *self,
                     const gchar *group,
                     const gchar *key,
                     guint retval);

Get an unsigned integer configuration value.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name.

[transfer none]

key

the key name.

[transfer none]

retval

value to be returned in case key is not found

 

Returns

the value corresponding to the key as an unsigned integer. If the key does not exist or cannot be converted to the integer, retval is returned.


tlm_config_set_uint ()

void
tlm_config_set_uint (TlmConfig *self,
                     const gchar *group,
                     const gchar *key,
                     guint value);

Sets the configuration value to the provided unsigned integer.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name.

[transfer none]

key

the key name

 

value

the value

 

tlm_config_get_string ()

const gchar *
tlm_config_get_string (TlmConfig *self,
                       const gchar *group,
                       const gchar *key);

Get a string configuration value.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name, NULL refers to General.

[transfer none]

key

the key name.

[transfer none]

Returns

the value corresponding to the key as an string. If the key does not exist, NULL is returned.


tlm_config_get_string_default ()

const gchar *
tlm_config_get_string_default (TlmConfig *self,
                               const gchar *group,
                               const gchar *key,
                               const gchar *value);

Get a string configuration value.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name, NULL refers to General.

[transfer none]

key

the key name.

[transfer none]

value

default value.

[transfer none]

Returns

the value corresponding to the key as an string. If the key does not exist, given default value is returned.


tlm_config_set_string ()

void
tlm_config_set_string (TlmConfig *self,
                       const gchar *group,
                       const gchar *key,
                       const gchar *value);

Sets the configuration value to the provided string.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name.

[transfer none]

key

the key name.

[transfer none]

value

the value.

[transfer none]

tlm_config_get_boolean ()

gboolean
tlm_config_get_boolean (TlmConfig *self,
                        const gchar *group,
                        const gchar *key,
                        gboolean retval);

Get a boolean configuration value.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name.

[transfer none]

key

the key name.

[transfer none]

retval

value to be returned in case key is not found

 

Returns

the value corresponding to the key as boolean. If the key does not exist or cannot be converted to boolean, retval is returned.


tlm_config_set_boolean ()

void
tlm_config_set_boolean (TlmConfig *self,
                        const gchar *group,
                        const gchar *key,
                        gboolean value);

Sets the configuration value to the provided value.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name

 

key

the key name

 

value

the value

 

tlm_config_has_group ()

gboolean
tlm_config_has_group (TlmConfig *self,
                      const gchar *group);

Checks if any configuration available for group.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name

 

Returns

TRUE if found, FALSE otherwise.


tlm_config_has_key ()

gboolean
tlm_config_has_key (TlmConfig *self,
                    const gchar *group,
                    const gchar *key);

Checks if key is in given group.

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name

 

key

the key name

 

Returns

TRUE, if found, FALSE otherwise.


tlm_config_get_group ()

GHashTable *
tlm_config_get_group (TlmConfig *self,
                      const gchar *group);

Retrives the configuration in given group as GHashTable

Parameters

self

an instance of TlmConfig.

[transfer none]

group

the group name

 

Returns

the key, value paired dictionary if found, NULL otherwise.

[transfer none]


tlm_config_reload ()

void
tlm_config_reload (TlmConfig *self);

Reloads the configuration.

Parameters

self

an instance of TlmConfig.

[transfer none]

Types and Values