DexterPluginIConfig

DexterPluginIConfig — Interface to the Libdexter configuration file

Synopsis

#include <dexterplugin.h>

                    DexterPluginIConfig;
struct              DexterPluginIConfigInterface;

gboolean            dexterplugin_iconfig_has_group      (DexterPluginIConfig *iconfig,
                                                         const gchar *group);
gboolean            dexterplugin_iconfig_get_groups     (DexterPluginIConfig *iconfig,
                                                         gchar ***return_groups,
                                                         gsize *length);
gboolean            dexterplugin_iconfig_get_keys       (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         gchar ***return_keys,
                                                         gsize *length,
                                                         GError **error);
gboolean            dexterplugin_iconfig_get_string     (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gchar **return_string,
                                                         GError **error);
gboolean            dexterplugin_iconfig_get_string_list
                                                        (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gchar ***return_strings,
                                                         gsize *length,
                                                         GError **error);
gboolean            dexterplugin_iconfig_get_boolean    (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gboolean *return_boolean,
                                                         GError **error);
gboolean            dexterplugin_iconfig_get_boolean_list
                                                        (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gboolean **return_booleans,
                                                         gsize *length,
                                                         GError **error);
gboolean            dexterplugin_iconfig_get_integer    (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gint *return_integer,
                                                         GError **error);
gboolean            dexterplugin_iconfig_get_integer_list
                                                        (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gint **return_integers,
                                                         gsize *length,
                                                         GError **error);
gboolean            dexterplugin_iconfig_key_error      (DexterPluginIConfig *iconfig,
                                                         GError *error);

Object Hierarchy

  GInterface
   +----DexterPluginIConfig

Prerequisites

DexterPluginIConfig requires GObject.

Description

Plugins can access the configuration file from this interface.

Example demonstrating how plugins can access the configuration file:

#include <dexterplugin.h>

#define MY_SERVICE_UUID "86127315-6de6-43cd-a835-fbd25476390d"

void some_plugin_function ()
{
  gchar *important_key;

  /* Obtain key "Important" in config file section [86127315-6de6-43cd-a835-fbd25476390d]. */
  if (!dexterplugin_iconfig_get_string (DEXTER_ICONFIG, 
                                        MY_SERVICE_UUID, "Important",
                                        &important_key, NULL)) 
  {
      g_warning ("Important key not found");
      ...
  }
  /* use important_key and when done, free it. */
  g_free (important_key);
}

Details

DexterPluginIConfig

typedef struct _DexterPluginIConfig DexterPluginIConfig;

The configuration file interface.


struct DexterPluginIConfigInterface

struct DexterPluginIConfigInterface {
  /* virtual methods */

  gboolean    (*has_group)        (DexterPluginIConfig   *iconfig,
                                   const gchar           *group);

  gboolean    (*get_groups)       (DexterPluginIConfig   *iconfig,
                                   gchar               ***return_groups,
                                   gsize                 *length);

  gboolean    (*get_keys)         (DexterPluginIConfig   *iconfig,
                                   const gchar           *group,
                                   gchar               ***return_keys,
                                   gsize                 *length,
                                   GError               **error);
    
  gboolean    (*get_string)       (DexterPluginIConfig   *iconfig,
                                   const gchar           *group,
                                   const gchar           *key,
                                   gchar                **return_string,
                                   GError               **error);

  gboolean    (*get_string_list)  (DexterPluginIConfig   *iconfig,
                                   const gchar           *group,
                                   const gchar           *key,
                                   gchar               ***return_strings,
                                   gsize                 *length,
                                   GError               **error);

  gboolean    (*get_boolean)      (DexterPluginIConfig   *iconfig,
                                   const gchar           *group,
                                   const gchar           *key,
                                   gboolean              *return_boolean,
                                   GError               **error);

  gboolean    (*get_boolean_list) (DexterPluginIConfig   *iconfig,
                                   const gchar           *group,
                                   const gchar           *key,
                                   gboolean             **return_booleans,
                                   gsize                 *length,
                                   GError               **error);

  gboolean    (*get_integer)      (DexterPluginIConfig   *iconfig,
                                   const gchar           *group,
                                   const gchar           *key,
                                   gint                  *return_integer,
                                   GError               **error);

  gboolean    (*get_integer_list) (DexterPluginIConfig   *iconfig,
                                   const gchar           *group,
                                   const gchar           *key,
                                   gint                 **return_integers,
                                   gsize                 *length,
                                   GError               **error);

  gboolean    (*key_error)        (DexterPluginIConfig   *iconfig,
                                   GError                *error);
};

Definition of the configuration file interface.


dexterplugin_iconfig_has_group ()

gboolean            dexterplugin_iconfig_has_group      (DexterPluginIConfig *iconfig,
                                                         const gchar *group);

Returns whether or not the specified group exists in the config file.

iconfig :

a DexterPluginIConfig.

group :

gchar group name within the config file.

Returns :

gboolean indicating if group is in the config file or not.

dexterplugin_iconfig_get_groups ()

gboolean            dexterplugin_iconfig_get_groups     (DexterPluginIConfig *iconfig,
                                                         gchar ***return_groups,
                                                         gsize *length);

Sets return_groups to a list of all groups in the config file.

Use g_strfreev() to free *return_groups.

iconfig :

a DexterPluginIConfig.

return_groups :

address of a (gchar **) return pointer to hold list of groups.

length :

address of optional gsize to hold number of groups returned, or NULL.

Returns :

gboolean indicating success or failure.

dexterplugin_iconfig_get_keys ()

gboolean            dexterplugin_iconfig_get_keys       (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         gchar ***return_keys,
                                                         gsize *length,
                                                         GError **error);

Sets return_keys to a list of all keys in the config file for the specified group.

Use g_strfreev() to free *return_keys.

iconfig :

a DexterPluginIConfig.

group :

gchar group name within the config file.

return_keys :

address of a (gchar **) return pointer to hold list of keys.

length :

address of optional gsize to hold number of keys returned, or NULL.

error :

return location for optional GError.

Returns :

gboolean indicating success or failure.

dexterplugin_iconfig_get_string ()

gboolean            dexterplugin_iconfig_get_string     (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gchar **return_string,
                                                         GError **error);

Sets return_string to the key value in the config file for the specified group and key.

Use g_free() to free *return_string.

iconfig :

a DexterPluginIConfig.

group :

gchar group name within the config file.

key :

gchar key name within the config file.

return_string :

address of a (gchar *) return pointer to hold key value.

error :

return location for optional GError.

Returns :

gboolean indicating success or failure.

dexterplugin_iconfig_get_string_list ()

gboolean            dexterplugin_iconfig_get_string_list
                                                        (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gchar ***return_strings,
                                                         gsize *length,
                                                         GError **error);

Sets return_strings to a key value list in the config file for the specified group and key.

Use g_strfreev() to free *return_strings.

iconfig :

a DexterPluginIConfig.

group :

gchar group name within the config file.

key :

gchar key name within the config file.

return_strings :

address of a (gchar **) return pointer to hold key value list.

length :

address of optional gsize to hold number of strings returned, or NULL.

error :

return location for optional GError.

Returns :

gboolean indicating success or failure.

dexterplugin_iconfig_get_boolean ()

gboolean            dexterplugin_iconfig_get_boolean    (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gboolean *return_boolean,
                                                         GError **error);

Sets return_boolean to the key value in the config file for the specified group and key.

iconfig :

a DexterPluginIConfig.

group :

gchar group name within the config file.

key :

gchar key name within the config file.

return_boolean :

address of a gboolean to hold key value.

error :

return location for optional GError.

Returns :

gboolean indicating success or failure.

dexterplugin_iconfig_get_boolean_list ()

gboolean            dexterplugin_iconfig_get_boolean_list
                                                        (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gboolean **return_booleans,
                                                         gsize *length,
                                                         GError **error);

Sets return_booleans to a key value list in the config file for the specified group and key.

Use g_free() to free *return_booleans.

iconfig :

a DexterPluginIConfig.

group :

gchar group name within the config file.

key :

gchar key name within the config file.

return_booleans :

address of a (gboolean *) return pointer to hold key value list.

length :

address of optional gsize to hold number of booleans returned, or NULL.

error :

return location for optional GError.

Returns :

gboolean indicating success or failure.

dexterplugin_iconfig_get_integer ()

gboolean            dexterplugin_iconfig_get_integer    (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gint *return_integer,
                                                         GError **error);

Sets return_integer to the key value in the config file for the specified group and key.

iconfig :

a DexterPluginIConfig.

group :

gchar group name within the config file.

key :

gchar key name within the config file.

return_integer :

address of a gint to hold key value.

error :

return location for optional GError.

Returns :

gboolean indicating success or failure.

dexterplugin_iconfig_get_integer_list ()

gboolean            dexterplugin_iconfig_get_integer_list
                                                        (DexterPluginIConfig *iconfig,
                                                         const gchar *group,
                                                         const gchar *key,
                                                         gint **return_integers,
                                                         gsize *length,
                                                         GError **error);

Sets return_integers to a key value list in the config file for the specified group and key.

Use g_free() to free *return_integers.

iconfig :

a DexterPluginIConfig.

group :

gchar group name within the config file.

key :

gchar key name within the config file.

return_integers :

address of a (gint *) return pointer to hold key value list.

length :

address of optional gsize to hold number of integers returned, or NULL.

error :

return location for optional GError.

Returns :

gboolean indicating success or failure.

dexterplugin_iconfig_key_error ()

gboolean            dexterplugin_iconfig_key_error      (DexterPluginIConfig *iconfig,
                                                         GError *error);

Returns whether or not the specified GError is a key error indicating that the group or key was not found.

iconfig :

a DexterPluginIConfig.

error :

a GError from a previous operation.

Returns :

gboolean indicating if the specified GError is a key error.