ZifConfig

ZifConfig — A ZifConfig object manages system wide config options

Synopsis

#define             ZIF_CONFIG_ERROR
                    ZifConfig;
                    ZifConfigPrivate;
                    ZifConfigClass;
enum                ZifConfigError;
GQuark              zif_config_error_quark              (void);
ZifConfig *         zif_config_new                      (void);
gboolean            zif_config_set_filename             (ZifConfig *config,
                                                         const gchar *filename,
                                                         GError **error);
gchar *             zif_config_get_string               (ZifConfig *config,
                                                         const gchar *key,
                                                         GError **error);
gboolean            zif_config_get_boolean              (ZifConfig *config,
                                                         const gchar *key,
                                                         GError **error);
guint               zif_config_get_uint                 (ZifConfig *config,
                                                         const gchar *key,
                                                         GError **error);
guint               zif_config_get_time                 (ZifConfig *config,
                                                         const gchar *key,
                                                         GError **error);
gboolean            zif_config_set_local                (ZifConfig *config,
                                                         const gchar *key,
                                                         const gchar *value,
                                                         GError **error);
gboolean            zif_config_reset_default            (ZifConfig *config,
                                                         GError **error);
gchar *             zif_config_expand_substitutions     (ZifConfig *config,
                                                         const gchar *text,
                                                         GError **error);
gchar **            zif_config_get_basearch_array       (ZifConfig *config);

Object Hierarchy

  GObject
   +----ZifConfig

Description

ZifConfig allows settings to be read from a central config file. Some values can be overridden in a running instance.

The values that are overridden can be reset back to the defaults without re-reading the config file.

Different types of data can be read (string, bool, uint, time). Before reading any data, the backing config file has to be set with zif_config_set_filename() and any reads prior to that will fail.

Details

ZIF_CONFIG_ERROR

#define ZIF_CONFIG_ERROR (zif_config_error_quark ())


ZifConfig

typedef struct _ZifConfig ZifConfig;


ZifConfigPrivate

typedef struct _ZifConfigPrivate ZifConfigPrivate;


ZifConfigClass

typedef struct {
	GObjectClass		 parent_class;
} ZifConfigClass;


enum ZifConfigError

typedef enum {
	ZIF_CONFIG_ERROR_FAILED,
	ZIF_CONFIG_ERROR_LAST
} ZifConfigError;


zif_config_error_quark ()

GQuark              zif_config_error_quark              (void);

Returns :

Our personal error quark.

Since 0.1.0


zif_config_new ()

ZifConfig *         zif_config_new                      (void);

Returns :

A new ZifConfig class instance.

Since 0.1.0


zif_config_set_filename ()

gboolean            zif_config_set_filename             (ZifConfig *config,
                                                         const gchar *filename,
                                                         GError **error);

Sets the filename to use as the system wide config file.

config :

the ZifConfig object

filename :

the system wide config file, e.g. "/etc/yum.conf"

error :

a GError which is used on failure, or NULL

Returns :

TRUE for success, FALSE for failure

Since 0.1.0


zif_config_get_string ()

gchar *             zif_config_get_string               (ZifConfig *config,
                                                         const gchar *key,
                                                         GError **error);

Gets a string value from a local setting, falling back to the config file.

config :

the ZifConfig object

key :

the key name to retrieve, e.g. "cachedir"

error :

a GError which is used on failure, or NULL

Returns :

the allocated value, or NULL

Since 0.1.0


zif_config_get_boolean ()

gboolean            zif_config_get_boolean              (ZifConfig *config,
                                                         const gchar *key,
                                                         GError **error);

Gets a boolean value from a local setting, falling back to the config file.

config :

the ZifConfig object

key :

the key name to retrieve, e.g. "keepcache"

error :

a GError which is used on failure, or NULL

Returns :

TRUE or FALSE

Since 0.1.0


zif_config_get_uint ()

guint               zif_config_get_uint                 (ZifConfig *config,
                                                         const gchar *key,
                                                         GError **error);

Gets a unsigned integer value from a local setting, falling back to the config file.

config :

the ZifConfig object

key :

the key name to retrieve, e.g. "keepcache"

error :

a GError which is used on failure, or NULL

Returns :

the data value, or G_MAXUINT for error

Since 0.1.0


zif_config_get_time ()

guint               zif_config_get_time                 (ZifConfig *config,
                                                         const gchar *key,
                                                         GError **error);

Gets a time value from a local setting, falling back to the config file.

config :

the ZifConfig object

key :

the key name to retrieve, e.g. "metadata_expire"

error :

a GError which is used on failure, or NULL

Returns :

the data value, or 0 for an error

Since 0.1.0


zif_config_set_local ()

gboolean            zif_config_set_local                (ZifConfig *config,
                                                         const gchar *key,
                                                         const gchar *value,
                                                         GError **error);

Sets a local value which is used in preference to the config value.

config :

the ZifConfig object

key :

the key name to save, e.g. "keepcache"

value :

the key data to save, e.g. "always"

error :

a GError which is used on failure, or NULL

Returns :

TRUE for success, FALSE for failure

Since 0.1.0


zif_config_reset_default ()

gboolean            zif_config_reset_default            (ZifConfig *config,
                                                         GError **error);

Removes any local settings previously set.

config :

the ZifConfig object

error :

a GError which is used on failure, or NULL

Returns :

TRUE for success, FALSE for failure

Since 0.1.0


zif_config_expand_substitutions ()

gchar *             zif_config_expand_substitutions     (ZifConfig *config,
                                                         const gchar *text,
                                                         GError **error);

Replaces substitutions in text with the actual values of the running system.

config :

the ZifConfig object

text :

string to scan, e.g. "http://fedora/$releasever/$basearch/moo.rpm"

error :

a GError which is used on failure, or NULL

Returns :

A new allocated string or NULL for error, free with g_free()

Since 0.1.0


zif_config_get_basearch_array ()

gchar **            zif_config_get_basearch_array       (ZifConfig *config);

Gets the list of architectures that packages are native on for this machine.

config :

the ZifConfig object

Returns :

A array of strings, do not free, e.g. [ "i386", "i486", "noarch" ]

Since 0.1.0