ZifStore

## ZifStore ZifStore — Collection of packages |

## Synopsis

    #define             ZIF_STORE_ERROR
    #define             ZIF_STORE_RESOLVE_FLAG_USE_ALL
    struct              ZifStore;
    struct              ZifStoreClass;
    enum                ZifStoreError;
    enum                ZifStoreResolveFlags;
    gboolean            zif_store_add_package               (ZifStore *store,
                                                             ZifPackage *package,
                                                             GError **error);
    gboolean            zif_store_add_packages              (ZifStore *store,
                                                             GPtrArray *array,
                                                             GError **error);
    gboolean            zif_store_clean                     (ZifStore *store,
                                                             ZifState *state,
                                                             GError **error);
    GQuark              zif_store_error_quark               (void);
    ZifPackage *        zif_store_find_package              (ZifStore *store,
                                                             const gchar *package_id,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_get_categories            (ZifStore *store,
                                                             ZifState *state,
                                                             GError **error);
    gboolean            zif_store_get_enabled               (ZifStore *store);
    const gchar *       zif_store_get_id                    (ZifStore *store);
    GPtrArray *         zif_store_get_packages              (ZifStore *store,
                                                             ZifState *state,
                                                             GError **error);
    guint               zif_store_get_size                  (ZifStore *store);
    gboolean            zif_store_load                      (ZifStore *store,
                                                             ZifState *state,
                                                             GError **error);
    ZifStore *          zif_store_new                       (void);
    void                zif_store_print                     (ZifStore *store);
    gboolean            zif_store_refresh                   (ZifStore *store,
                                                             gboolean force,
                                                             ZifState *state,
                                                             GError **error);
    gboolean            zif_store_remove_package            (ZifStore *store,
                                                             ZifPackage *package,
                                                             GError **error);
    gboolean            zif_store_remove_packages           (ZifStore *store,
                                                             GPtrArray *array,
                                                             GError **error);
    GPtrArray *         zif_store_resolve                   (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_resolve_full              (ZifStore *store,
                                                             gchar **search,
                                                             ZifStoreResolveFlags flags,
                                                             ZifState *state,
                                                             GError **error);
    ZifPackage *        zif_store_resolve_package           (ZifStore *store,
                                                             ZifPackage *package,
                                                             ZifStoreResolveFlags flags,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_search_category           (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_search_details            (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_search_file               (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_search_group              (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_search_name               (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);
    void                zif_store_set_enabled               (ZifStore *store,
                                                             gboolean enabled);
    gboolean            zif_store_unload                    (ZifStore *store,
                                                             GError **error);
    GPtrArray *         zif_store_what_conflicts            (ZifStore *store,
                                                             GPtrArray *depends,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_what_obsoletes            (ZifStore *store,
                                                             GPtrArray *depends,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_what_provides             (ZifStore *store,
                                                             GPtrArray *depends,
                                                             ZifState *state,
                                                             GError **error);
    GPtrArray *         zif_store_what_requires             (ZifStore *store,
                                                             GPtrArray *depends,
                                                             ZifState *state,
                                                             GError **error);

## Object Hierarchy

      GObject
       +----ZifStore
             +----ZifStoreDirectory
             +----ZifStoreLocal
             +----ZifStoreMeta
             +----ZifStoreRemote
             +----ZifStoreRhn

## Properties

      "enabled"                  gboolean              : Read / Write
      "loaded"                   gboolean              : Read / Write

## Description

ZifStoreLocal, ZifStoreRemote and ZifStoreMeta all implement ZifStore.

## Details

### ZIF_STORE_ERROR

    #define ZIF_STORE_ERROR		(zif_store_error_quark ())

### ZIF_STORE_RESOLVE_FLAG_USE_ALL

    #define             ZIF_STORE_RESOLVE_FLAG_USE_ALL

### struct ZifStore

    struct ZifStore;

### struct ZifStoreClass

    struct ZifStoreClass {
    	GObjectClass parent_class;
    	/* vtable */
    	gboolean	 (*load)		(ZifStore		*store,
    						 ZifState		*state,
    						 GError			**error);
    	gboolean	 (*clean)		(ZifStore		*store,
    						 ZifState		*state,
    						 GError			**error);
    	gboolean	 (*refresh)		(ZifStore		*store,
    						 gboolean		 force,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*search_name)		(ZifStore		*store,
    						 gchar			**search,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*search_category) (ZifStore		*store,
    						 gchar			**search,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*search_details) (ZifStore		*store,
    						 gchar			**search,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*search_group) (ZifStore		*store,
    						 gchar			**search,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*search_file)		(ZifStore		*store,
    						 gchar			**search,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*resolve)		(ZifStore		*store,
    						 gchar			**search,
    						 ZifStoreResolveFlags	 flags,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*what_provides) (ZifStore		*store,
    						 GPtrArray		*depends,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*what_requires) (ZifStore		*store,
    						 GPtrArray		*depends,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*what_obsoletes) (ZifStore		*store,
    						 GPtrArray		*depends,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*what_conflicts) (ZifStore		*store,
    						 GPtrArray		*depends,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*get_packages) (ZifStore		*store,
    						 ZifState		*state,
    						 GError			**error);
    	ZifPackage *(*find_package) (ZifStore		*store,
    						 const gchar		*package_id,
    						 ZifState		*state,
    						 GError			**error);
    	GPtrArray *(*get_categories) (ZifStore		*store,
    						 ZifState		*state,
    						 GError			**error);
    	const gchar *(*get_id)		(ZifStore		*store);
    	void		 (*print)		(ZifStore		*store);

    	/* Padding for future expansion */
    	void (*_zif_reserved1) (void);
    	void (*_zif_reserved2) (void);
    	void (*_zif_reserved3) (void);
    	void (*_zif_reserved4) (void);
    };

### enum ZifStoreError

    typedef enum {
    	ZIF_STORE_ERROR_FAILED,
    	ZIF_STORE_ERROR_FAILED_AS_OFFLINE,
    	ZIF_STORE_ERROR_FAILED_TO_FIND,
    	ZIF_STORE_ERROR_FAILED_TO_DOWNLOAD,
    	ZIF_STORE_ERROR_ARRAY_IS_EMPTY,
    	ZIF_STORE_ERROR_NO_SUPPORT,
    	ZIF_STORE_ERROR_NOT_LOCKED,
    	ZIF_STORE_ERROR_MULTIPLE_MATCHES,
    	ZIF_STORE_ERROR_RECOVERABLE,
    	ZIF_STORE_ERROR_NO_RELEASEVER,
    	ZIF_STORE_ERROR_NOT_ENABLED,
    	ZIF_STORE_ERROR_LAST
    } ZifStoreError;

`ZIF_STORE_ERROR_FAILED` |
`ZIF_STORE_ERROR_FAILED_AS_OFFLINE` |
`ZIF_STORE_ERROR_FAILED_TO_FIND` |
`ZIF_STORE_ERROR_FAILED_TO_DOWNLOAD` |
`ZIF_STORE_ERROR_ARRAY_IS_EMPTY` |
`ZIF_STORE_ERROR_NO_SUPPORT` |
`ZIF_STORE_ERROR_NOT_LOCKED` |
`ZIF_STORE_ERROR_MULTIPLE_MATCHES` |
`ZIF_STORE_ERROR_RECOVERABLE` |
`ZIF_STORE_ERROR_NO_RELEASEVER` |
`ZIF_STORE_ERROR_NOT_ENABLED` |
`ZIF_STORE_ERROR_LAST` |

### enum ZifStoreResolveFlags

    typedef enum {
    	ZIF_STORE_RESOLVE_FLAG_USE_NAME			= 1<<0,
    	ZIF_STORE_RESOLVE_FLAG_USE_NAME_ARCH		= 1<<1,
    	ZIF_STORE_RESOLVE_FLAG_USE_NAME_VERSION		= 1<<2,
    	ZIF_STORE_RESOLVE_FLAG_USE_NAME_VERSION_ARCH = 1<<3,
    	ZIF_STORE_RESOLVE_FLAG_PREFER_NATIVE		= 1<<4,
    	ZIF_STORE_RESOLVE_FLAG_USE_GLOB			= 1<<5,
    	ZIF_STORE_RESOLVE_FLAG_USE_REGEX		= 1<<6,
    } ZifStoreResolveFlags;

`ZIF_STORE_RESOLVE_FLAG_USE_NAME` |
`ZIF_STORE_RESOLVE_FLAG_USE_NAME_ARCH` |
`ZIF_STORE_RESOLVE_FLAG_USE_NAME_VERSION` |
`ZIF_STORE_RESOLVE_FLAG_USE_NAME_VERSION_ARCH` |
`ZIF_STORE_RESOLVE_FLAG_PREFER_NATIVE` |
`ZIF_STORE_RESOLVE_FLAG_USE_GLOB` |
`ZIF_STORE_RESOLVE_FLAG_USE_REGEX` |

### zif_store_add_package ()

    gboolean            zif_store_add_package               (ZifStore *store,
                                                             ZifPackage *package,
                                                             GError **error);

Adds a package to the store.

`store` : | A ZifStore
`package` : | A ZifPackage
`error` : | A GError, or `NULL`
Returns : | `TRUE` for success, `FALSE` otherwise

Since 0.1.6

### zif_store_add_packages ()

    gboolean            zif_store_add_packages              (ZifStore *store,
                                                             GPtrArray *array,
                                                             GError **error);

Adds an array of packages to the store.

`store` : | A ZifStore
`array` : | Array of ZifPackage's
`error` : | A GError, or `NULL`
Returns : | `TRUE` for success, `FALSE` otherwise

Since 0.1.6

### zif_store_clean ()

    gboolean            zif_store_clean                     (ZifStore *store,
                                                             ZifState *state,
                                                             GError **error);

Cleans the ZifStore objects by deleting cache.

`store` : | A ZifStore
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | `TRUE` for success, `FALSE` otherwise

Since 0.1.0

### zif_store_error_quark ()

    GQuark              zif_store_error_quark               (void);

Returns : | An error quark.

Since 0.1.0

### zif_store_find_package ()

    ZifPackage *        zif_store_find_package              (ZifStore *store,
                                                             const gchar *package_id,
                                                             ZifState *state,
                                                             GError **error);

Find a single package in the ZifStore.

`store` : | A ZifStore
`package_id` : | A package ID which defines the package
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | A single ZifPackage or `NULL`. Use g_object_unref when `done()`. [transfer full]

Since 0.1.0

### zif_store_get_categories ()

    GPtrArray *         zif_store_get_categories            (ZifStore *store,
                                                             ZifState *state,
                                                             GError **error);

Return a list of custom categories.

`store` : | A ZifStore
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifCategory's. [element-type ZifCategory][transfer container]

Since 0.1.0

### zif_store_get_enabled ()

    gboolean            zif_store_get_enabled               (ZifStore *store);

Gets if the store is enabled at runtime.

`store` : | A ZifStore

Since 0.2.2

### zif_store_get_id ()

    const gchar *       zif_store_get_id                    (ZifStore *store);

Gets the id for the object.

`store` : | A ZifStore
Returns : | A text ID, or `NULL`

Since 0.1.0

### zif_store_get_packages ()

    GPtrArray *         zif_store_get_packages              (ZifStore *store,
                                                             ZifState *state,
                                                             GError **error);

Return all packages in the ZifStore's.

`store` : | A ZifStore
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.0

### zif_store_get_size ()

    guint               zif_store_get_size                  (ZifStore *store);

Gets the number of packages in the store.

`store` : | A ZifStore
Returns : | the number of packages

Since 0.2.5

### zif_store_load ()

    gboolean            zif_store_load                      (ZifStore *store,
                                                             ZifState *state,
                                                             GError **error);

Loads the ZifStore object.

`store` : | A ZifStore
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | `TRUE` for success, `FALSE` otherwise

Since 0.1.0

### zif_store_new ()

    ZifStore *          zif_store_new                       (void);

Returns : | A new ZifStore instance.

Since 0.1.0

### zif_store_print ()

    void                zif_store_print                     (ZifStore *store);

Prints all the objects in the store.

`store` : | A ZifStore

Since 0.1.0

### zif_store_refresh ()

    gboolean            zif_store_refresh                   (ZifStore *store,
                                                             gboolean force,
                                                             ZifState *state,
                                                             GError **error);

refresh the ZifStore objects by downloading new data if required.

`store` : | A ZifStore
`force` : | If the data should be re-downloaded if it's still valid
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | `TRUE` for success, `FALSE` otherwise

Since 0.1.0

### zif_store_remove_package ()

    gboolean            zif_store_remove_package            (ZifStore *store,
                                                             ZifPackage *package,
                                                             GError **error);

Removes a package from the store.

`store` : | A ZifStore
`package` : | A ZifPackage
`error` : | A GError, or `NULL`
Returns : | `TRUE` for success, `FALSE` otherwise

Since 0.1.6

### zif_store_remove_packages ()

    gboolean            zif_store_remove_packages           (ZifStore *store,
                                                             GPtrArray *array,
                                                             GError **error);

Removes an array of packages from the store.

`store` : | A ZifStore
`array` : | Array of ZifPackage's
`error` : | A GError, or `NULL`
Returns : | `TRUE` for success, `FALSE` otherwise

Since 0.1.6

### zif_store_resolve ()

    GPtrArray *         zif_store_resolve                   (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);

Finds packages matching the package name exactly.

`store` : | A ZifStore
`search` : | The search terms, e.g. "gnome-power-manager". [array zero-terminated=1][element-type utf8]
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.0

### zif_store_resolve_full ()

    GPtrArray *         zif_store_resolve_full              (ZifStore *store,
                                                             gchar **search,
                                                             ZifStoreResolveFlags flags,
                                                             ZifState *state,
                                                             GError **error);

Finds packages matching the package name exactly.

If `ZIF_STORE_RESOLVE_FLAG_PREFER_NATIVE` is specified in the `flags` bitmask and the `search` terms do not include architecture suffixes (e.g. ".i686") then the store is first searched using the machine native arch. If no native packages are found, then the store is searched again, this time matching any package regardless of architecture.

`store` : | A ZifStore
`search` : | The search terms, e.g. "gnome-power-manager.i386". [array zero-terminated=1][element-type utf8]
`flags` : | A bitfield of `ZifStoreResolveFlags`, e.g. `ZIF_STORE_RESOLVE_FLAG_USE_NAME_ARCH`
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.2.4

### zif_store_resolve_package ()

    ZifPackage *        zif_store_resolve_package           (ZifStore *store,
                                                             ZifPackage *package,
                                                             ZifStoreResolveFlags flags,
                                                             ZifState *state,
                                                             GError **error);

Finds a package matching in the store. Note, this uses the ->resolve interface, rather than the ->find_package interface. This allows the user to match on any of the specified `flags`.

This function may be useful if you want to convert a ZifPackage to a ZifPackageRemote or ZifPackageLocal. An error will be returned if more than one item matches in the store.

`store` : | A ZifStore
`package` : | A ZifPackage
`flags` : | A bitfield of `ZifStoreResolveFlags`, e.g. `ZIF_STORE_RESOLVE_FLAG_USE_NAME_ARCH`
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | A ZifPackage, or NULL for an error. [transfer full]

Since 0.2.7

### zif_store_search_category ()

    GPtrArray *         zif_store_search_category           (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);

Return packages in a specific category.

`store` : | A ZifStore
`search` : | The search terms, e.g. "gnome/games". [array zero-terminated=1][element-type utf8]
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.0

### zif_store_search_details ()

    GPtrArray *         zif_store_search_details            (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);

Find packages that match some detail about the package.

`store` : | A ZifStore
`search` : | The search terms, e.g. "trouble". [array zero-terminated=1][element-type utf8]
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.0

### zif_store_search_file ()

    GPtrArray *         zif_store_search_file               (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);

Find packages that provide the specified file.

`store` : | A ZifStore
`search` : | The search terms, e.g. "/usr/bin/gnome-power-manager". [array zero-terminated=1][element-type utf8]
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.0

### zif_store_search_group ()

    GPtrArray *         zif_store_search_group              (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);

Find packages that belong in a specific group.

`store` : | A ZifStore
`search` : | The search terms, e.g. "games". [array zero-terminated=1][element-type utf8]
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.0

### zif_store_search_name ()

    GPtrArray *         zif_store_search_name               (ZifStore *store,
                                                             gchar **search,
                                                             ZifState *state,
                                                             GError **error);

Find packages that match the package name in some part.

`store` : | A ZifStore
`search` : | The search terms, e.g. "power". [array zero-terminated=1][element-type utf8]
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.0

### zif_store_set_enabled ()

    void                zif_store_set_enabled               (ZifStore *store,
                                                             gboolean enabled);

Sets the store runtime enabled state.

NOTE: this will not change results if the store has already been referenced, but will stop the store showing up in the results from `zif_repos_get_stores_enabled()`.

`store` : | A ZifStore
`enabled` : | The new value

Since 0.2.2

### zif_store_unload ()

    gboolean            zif_store_unload                    (ZifStore *store,
                                                             GError **error);

Unloads the ZifStore object.

`store` : | A ZifStore
`error` : | A GError, or `NULL`
Returns : | `TRUE` for success, `FALSE` otherwise

Since 0.1.6

### zif_store_what_conflicts ()

    GPtrArray *         zif_store_what_conflicts            (ZifStore *store,
                                                             GPtrArray *depends,
                                                             ZifState *state,
                                                             GError **error);

Find packages that conflict a specific string.

`store` : | A ZifStore
`depends` : | An array of ZifDepend's to search for
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.3

### zif_store_what_obsoletes ()

    GPtrArray *         zif_store_what_obsoletes            (ZifStore *store,
                                                             GPtrArray *depends,
                                                             ZifState *state,
                                                             GError **error);

Find packages that obsolete a specific string.

`store` : | A ZifStore
`depends` : | An array of ZifDepend's to search for
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.3

### zif_store_what_provides ()

    GPtrArray *         zif_store_what_provides             (ZifStore *store,
                                                             GPtrArray *depends,
                                                             ZifState *state,
                                                             GError **error);

Find packages that provide a specific string.

`store` : | A ZifStore
`depends` : | An array of ZifDepend's to search for
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.3

### zif_store_what_requires ()

    GPtrArray *         zif_store_what_requires             (ZifStore *store,
                                                             GPtrArray *depends,
                                                             ZifState *state,
                                                             GError **error);

Find packages that provide a specific string.

`store` : | A ZifStore
`depends` : | An array of ZifDepend's to search for
`state` : | A ZifState to use for progress reporting
`error` : | A GError, or `NULL`
Returns : | An array of ZifPackage's. [element-type ZifPackage][transfer container]

Since 0.1.3

## Property Details

### The `"enabled"` property

      "enabled"                  gboolean              : Read / Write

Default value: FALSE

Since 0.3.3

### The `"loaded"` property

      "loaded"                   gboolean              : Read / Write

Default value: FALSE

Since 0.2.3