ZifGroups

ZifGroups — Category to group mapping

Synopsis

#define             ZIF_GROUPS_ERROR
struct              ZifGroups;
struct              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,
                                                         ZifState *state,
                                                         GError **error);
GPtrArray *         zif_groups_get_groups               (ZifGroups *groups,
                                                         ZifState *state,
                                                         GError **error);
GPtrArray *         zif_groups_get_categories           (ZifGroups *groups,
                                                         ZifState *state,
                                                         GError **error);
GPtrArray *         zif_groups_get_cats_for_group       (ZifGroups *groups,
                                                         const gchar *group_enum,
                                                         ZifState *state,
                                                         GError **error);
const gchar *       zif_groups_get_group_for_cat        (ZifGroups *groups,
                                                         const gchar *cat,
                                                         ZifState *state,
                                                         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 ())


struct ZifGroups

struct ZifGroups;


struct ZifGroupsClass

struct ZifGroupsClass {
	GObjectClass		 parent_class;
	/* Padding for future expansion */
	void (*_zif_reserved1) (void);
	void (*_zif_reserved2) (void);
	void (*_zif_reserved3) (void);
	void (*_zif_reserved4) (void);
};


enum ZifGroupsError

typedef enum {
	ZIF_GROUPS_ERROR_FAILED,
	ZIF_GROUPS_ERROR_LAST
} ZifGroupsError;

ZIF_GROUPS_ERROR_FAILED

ZIF_GROUPS_ERROR_LAST


zif_groups_error_quark ()

GQuark              zif_groups_error_quark              (void);

Returns :

An error quark.

Since 0.1.0


zif_groups_new ()

ZifGroups *         zif_groups_new                      (void);

Returns :

A new ZifGroups 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 :

A ZifGroups

mapping_file :

Mapping filename from categories to groups

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.0


zif_groups_load ()

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

Loads the mapping file from disk into memory.

groups :

A ZifGroups

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.3.1


zif_groups_get_groups ()

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

Gets the groups supported by the packaging system.

groups :

A ZifGroups

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

An array of the string groups that are supported. [element-type utf8][transfer container]

Since 0.3.1


zif_groups_get_categories ()

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

Gets the categories supported by the packaging system.

groups :

A ZifGroups

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

An array of category list as strings. [element-type utf8][transfer container]

Since 0.3.1


zif_groups_get_cats_for_group ()

GPtrArray *         zif_groups_get_cats_for_group       (ZifGroups *groups,
                                                         const gchar *group_enum,
                                                         ZifState *state,
                                                         GError **error);

Gets all the categories that map to to this group enumeration.

groups :

A ZifGroups

group_enum :

A group enumeration, e.g. "education"

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

An array of category list as strings. [element-type utf8][transfer container]

Since 0.3.1


zif_groups_get_group_for_cat ()

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

Returns the group enumerated type for the category.

groups :

A ZifGroups

cat :

Category name, e.g. "games/action"

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

A specific group name or NULL

Since 0.3.1