TlmConfig

TlmConfig — tlm configuration information

Synopsis

#include <tlm-config.h>

struct              TlmConfig;
struct              TlmConfigClass;
gboolean            tlm_config_get_boolean              (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gboolean retval);
GHashTable *        tlm_config_get_group                (TlmConfig *self,
                                                         const gchar *group);
gint                tlm_config_get_int                  (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gint retval);
const gchar *       tlm_config_get_string               (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key);
guint               tlm_config_get_uint                 (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         guint retval);
gboolean            tlm_config_has_group                (TlmConfig *self,
                                                         const gchar *group);
gboolean            tlm_config_has_key                  (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key);
TlmConfig *         tlm_config_new                      ();
void                tlm_config_reload                   (TlmConfig *self);
void                tlm_config_set_boolean              (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gboolean value);
void                tlm_config_set_int                  (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gint value);
void                tlm_config_set_string               (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         const gchar *value);
void                tlm_config_set_uint                 (TlmConfig *self,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         guint value);

Object Hierarchy

  GObject
   +----TlmConfig

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:

  • TLM_CONF_FILE environment variable

  • g_get_user_config_dir() + "tlm.conf"

  • each of g_get_system_config_dirs() + "tlm.conf"

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

Details

struct TlmConfig

struct TlmConfig;

Opaque structure for the object.


struct TlmConfigClass

struct TlmConfigClass {
    GObjectClass parent_class;
};

Opaque structure for the class.

GObjectClass parent_class;

parent class object

tlm_config_get_boolean ()

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

Get a boolean configuration value.

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_get_group ()

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

Retrives the configuration in given group as GHashTable

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_get_int ()

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

Get an integer configuration value.

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_get_string ()

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

Get a string configuration value.

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 or cannot be converted to the integer, NULL is returned.

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.

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_has_group ()

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

Checks if any configuration available for group.

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.

self :

an instance of TlmConfig. [transfer none]

group :

the group name

key :

the key name

Returns :

TRUE, if found, FALSE otherwise.

tlm_config_new ()

TlmConfig *         tlm_config_new                      ();

Create a TlmConfig object.

Returns :

an instance of TlmConfig.

tlm_config_reload ()

void                tlm_config_reload                   (TlmConfig *self);

Reloads the configuration.

self :

an instance of TlmConfig. [transfer none]

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.

self :

an instance of TlmConfig. [transfer none]

group :

the group name

key :

the key name

value :

the value

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.

self :

an instance of TlmConfig. [transfer none]

group :

the group name

key :

the key name

value :

the value

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.

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

self :

an instance of TlmConfig. [transfer none]

group :

the group name. [transfer none]

key :

the key name

value :

the value