ZifGroups

ZifGroups — A ZifGroups class handles category to group mapping

Synopsis

#define             ZIF_GROUPS_ERROR
                    ZifGroups;
                    ZifGroupsPrivate;
                    ZifGroupsClass;
enum                ZifGroupsError;
GQuark              zif_groups_error_quark              (void);
ZifGroups *         zif_groups_new                      (void);
gboolean            zif_groups_set_mapping_file         (ZifGroups *groups,
                                                         const gchar *mapping_file,
                                                         GError **error);
gboolean            zif_groups_load                     (ZifGroups *groups,
                                                         GError **error);
GPtrArray *         zif_groups_get_groups               (ZifGroups *groups,
                                                         GError **error);
GPtrArray *         zif_groups_get_categories           (ZifGroups *groups,
                                                         GError **error);
const gchar *       zif_groups_get_group_for_cat        (ZifGroups *groups,
                                                         const gchar *cat,
                                                         GError **error);

Object Hierarchy

  GObject
   +----ZifGroups

Description

In Zif, we have a few groups that are enumerated, and categories that are not enumerated and are custom to the vendor. The mapping from categories to groups (and vice versa) is done with a mapping file which has to be set using zif_groups_set_mapping_file() before any queries are done.

In zif parlance, a group is a single string, e.g. "education" and a category is two strings, a parent and chld that are joined with a delimiter, e.g. "apps;education".

Details

ZIF_GROUPS_ERROR

#define ZIF_GROUPS_ERROR (zif_groups_error_quark ())


ZifGroups

typedef struct _ZifGroups ZifGroups;


ZifGroupsPrivate

typedef struct _ZifGroupsPrivate ZifGroupsPrivate;

Private ZifGroups data


ZifGroupsClass

typedef struct {
	GObjectClass		 parent_class;
} ZifGroupsClass;


enum ZifGroupsError

typedef enum {
	ZIF_GROUPS_ERROR_FAILED,
	ZIF_GROUPS_ERROR_LAST
} ZifGroupsError;


zif_groups_error_quark ()

GQuark              zif_groups_error_quark              (void);

Returns :

Our personal error quark.

Since 0.1.0


zif_groups_new ()

ZifGroups *         zif_groups_new                      (void);

Returns :

A new ZifGroups class instance.

Since 0.1.0


zif_groups_set_mapping_file ()

gboolean            zif_groups_set_mapping_file         (ZifGroups *groups,
                                                         const gchar *mapping_file,
                                                         GError **error);

This sets up the file that is used to map categories to group enums.

groups :

the ZifGroups object

mapping_file :

mapping file from categories to groups

error :

a GError which is used on failure, or NULL

Returns :

TRUE for success, FALSE for failure

Since 0.1.0


zif_groups_load ()

gboolean            zif_groups_load                     (ZifGroups *groups,
                                                         GError **error);

Loads the mapping file from disk into memory.

groups :

the ZifGroups object

error :

a GError which is used on failure, or NULL

Returns :

TRUE for success, FALSE for failure

Since 0.1.0


zif_groups_get_groups ()

GPtrArray *         zif_groups_get_groups               (ZifGroups *groups,
                                                         GError **error);

Gets the groups supported by the packaging system.

groups :

the ZifGroups object

error :

a GError which is used on failure, or NULL

Returns :

A GPtrArray of the string groups that are supported, free with g_ptr_array_unref()

Since 0.1.0


zif_groups_get_categories ()

GPtrArray *         zif_groups_get_categories           (ZifGroups *groups,
                                                         GError **error);

Gets the categories supported by the packaging system.

groups :

the ZifGroups object

error :

a GError which is used on failure, or NULL

Returns :

category list as an array of strings, free with g_ptr_array_unref()

Since 0.1.0


zif_groups_get_group_for_cat ()

const gchar *       zif_groups_get_group_for_cat        (ZifGroups *groups,
                                                         const gchar *cat,
                                                         GError **error);

Returns the group enumerated type for the category.

groups :

the ZifGroups object

cat :

the category name, e.g. "games/action"

error :

a GError which is used on failure, or NULL

Returns :

the specific group name or NULL

Since 0.1.0