PkPackageSack

## PkPackageSack PkPackageSack — A sack of packages that can be manipulated |

## Synopsis

    #define             PK_PACKAGE_SACK_TYPE_ERROR
    struct              PkPackageSack;
    struct              PkPackageSackClass;
    enum                PkPackageSackSortType;
    PkPackageSack *     pk_package_sack_new                 (void);
    void                pk_package_sack_test                (gpointer user_data);
    gboolean            (*PkPackageSackFilterFunc)          (PkPackage *package,
                                                             gpointer user_data);
    void                pk_package_sack_clear               (PkPackageSack *sack);
    gchar **            pk_package_sack_get_ids             (PkPackageSack *sack);
    guint               pk_package_sack_get_size            (PkPackageSack *sack);
    GPtrArray *         pk_package_sack_get_array           (PkPackageSack *sack);
    void                pk_package_sack_sort                (PkPackageSack *sack,
                                                             PkPackageSackSortType type);
    gboolean            pk_package_sack_add_package         (PkPackageSack *sack,
                                                             PkPackage *package);
    gboolean            pk_package_sack_add_package_by_id   (PkPackageSack *sack,
                                                             const gchar *package_id,
                                                             GError **error);
    gboolean            pk_package_sack_add_packages_from_file
                                                            (PkPackageSack *sack,
                                                             GFile *file,
                                                             GError **error);
    gboolean            pk_package_sack_to_file             (PkPackageSack *sack,
                                                             GFile *file,
                                                             GError **error);
    gboolean            pk_package_sack_remove_package      (PkPackageSack *sack,
                                                             PkPackage *package);
    gboolean            pk_package_sack_remove_package_by_id
                                                            (PkPackageSack *sack,
                                                             const gchar *package_id);
    gboolean            pk_package_sack_remove_by_filter    (PkPackageSack *sack,
                                                             PkPackageSackFilterFunc filter_cb,
                                                             gpointer user_data);
    PkPackage *         pk_package_sack_find_by_id          (PkPackageSack *sack,
                                                             const gchar *package_id);
    PkPackageSack *     pk_package_sack_filter_by_info      (PkPackageSack *sack,
                                                             PkInfoEnum info);
    PkPackageSack *     pk_package_sack_filter              (PkPackageSack *sack,
                                                             PkPackageSackFilterFunc filter_cb,
                                                             gpointer user_data);
    guint64             pk_package_sack_get_total_bytes     (PkPackageSack *sack);
    gboolean            pk_package_sack_merge_generic_finish
                                                            (PkPackageSack *sack,
                                                             GAsyncResult *res,
                                                             GError **error);
    void                pk_package_sack_resolve_async       (PkPackageSack *sack,
                                                             GCancellable *cancellable,
                                                             PkProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    void                pk_package_sack_get_details_async   (PkPackageSack *sack,
                                                             GCancellable *cancellable,
                                                             PkProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    void                pk_package_sack_get_update_detail_async
                                                            (PkPackageSack *sack,
                                                             GCancellable *cancellable,
                                                             PkProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
                        PkPackageSackResults;

## Object Hierarchy

      GObject
       +----PkPackageSack

      GEnum
       +----PkPackageSackSortType

## Description

A package sack is a set of packages that can have operations done on them in parallel. This might be adding summary text for bare package ID's, or to add package or update details.

## Details

### PK_PACKAGE_SACK_TYPE_ERROR

    #define PK_PACKAGE_SACK_TYPE_ERROR (pk_package_sack_error_get_type ())

### struct PkPackageSack

    struct PkPackageSack;

### struct PkPackageSackClass

    struct PkPackageSackClass {
    	GObjectClass parent_class;

    	/* signals */
    	void		(* changed)			(PkPackageSack *sack);
    	/* padding for future expansion */
    	void (*_pk_reserved1) (void);
    	void (*_pk_reserved2) (void);
    	void (*_pk_reserved3) (void);
    	void (*_pk_reserved4) (void);
    	void (*_pk_reserved5) (void);
    };

### enum PkPackageSackSortType

    typedef enum {
    	PK_PACKAGE_SACK_SORT_TYPE_NAME,
    	PK_PACKAGE_SACK_SORT_TYPE_INFO,
    	PK_PACKAGE_SACK_SORT_TYPE_PACKAGE_ID,
    	PK_PACKAGE_SACK_SORT_TYPE_SUMMARY,
    	PK_PACKAGE_SACK_SORT_TYPE_LAST
    } PkPackageSackSortType;

`PK_PACKAGE_SACK_SORT_TYPE_NAME` |
`PK_PACKAGE_SACK_SORT_TYPE_INFO` |
`PK_PACKAGE_SACK_SORT_TYPE_PACKAGE_ID` |
`PK_PACKAGE_SACK_SORT_TYPE_SUMMARY` |
`PK_PACKAGE_SACK_SORT_TYPE_LAST` |

### pk_package_sack_new ()

    PkPackageSack *     pk_package_sack_new                 (void);

Returns : | a new PkPackageSack object.

Since 0.5.2

### pk_package_sack_test ()

    void                pk_package_sack_test                (gpointer user_data);

### PkPackageSackFilterFunc ()

    gboolean            (*PkPackageSackFilterFunc)          (PkPackage *package,
                                                             gpointer user_data);

### pk_package_sack_clear ()

    void                pk_package_sack_clear               (PkPackageSack *sack);

Empty all the packages from the sack

`sack` : | a valid PkPackageSack instance

Since 0.5.2

### pk_package_sack_get_ids ()

    gchar **            pk_package_sack_get_ids             (PkPackageSack *sack);

Returns all the Package IDs in the sack

`sack` : | a valid PkPackageSack instance
Returns : | the number of packages in the sack, free with `g_strfreev()`. [transfer full]

Since 0.5.3

### pk_package_sack_get_size ()

    guint               pk_package_sack_get_size            (PkPackageSack *sack);

Gets the number of packages in the sack

`sack` : | a valid PkPackageSack instance
Returns : | the number of packages in the sack

Since 0.5.2

### pk_package_sack_get_array ()

    GPtrArray *         pk_package_sack_get_array           (PkPackageSack *sack);

Gets the package array from the sack

`sack` : | a valid PkPackageSack instance
Returns : | A GPtrArray, free with `g_ptr_array_unref()`. [element-type PkPackage][transfer container]

Since 0.6.1

### pk_package_sack_sort ()

    void                pk_package_sack_sort                (PkPackageSack *sack,
                                                             PkPackageSackSortType type);

### pk_package_sack_add_package ()

    gboolean            pk_package_sack_add_package         (PkPackageSack *sack,
                                                             PkPackage *package);

Adds a package to the sack.

`sack` : | a valid PkPackageSack instance
`package` : | a valid PkPackage instance
Returns : | `TRUE` if the package was added to the sack

Since 0.5.2

### pk_package_sack_add_package_by_id ()

    gboolean            pk_package_sack_add_package_by_id   (PkPackageSack *sack,
                                                             const gchar *package_id,
                                                             GError **error);

Adds a package reference to the sack.

`sack` : | a valid PkPackageSack instance
`package_id` : | a package_id descriptor
`error` : | a `GError` to put the error code and message in, or `NULL`
Returns : | `TRUE` if the package was added to the sack

Since 0.5.2

### pk_package_sack_add_packages_from_file ()

    gboolean            pk_package_sack_add_packages_from_file
                                                            (PkPackageSack *sack,
                                                             GFile *file,
                                                             GError **error);

Write the contents of a PkPackageSack to a package-list file.

`sack` : | a valid PkPackageSack instance
`file` : | a valid package-list file
`error` : | a `GError` to put the error code and message in, or `NULL`
Returns : | `TRUE` if there were no errors.

Since 0.8.6

### pk_package_sack_to_file ()

    gboolean            pk_package_sack_to_file             (PkPackageSack *sack,
                                                             GFile *file,
                                                             GError **error);

### pk_package_sack_remove_package ()

    gboolean            pk_package_sack_remove_package      (PkPackageSack *sack,
                                                             PkPackage *package);

Removes a package reference from the sack. The pointers have to match exactly.

`sack` : | a valid PkPackageSack instance
`package` : | a valid PkPackage instance
Returns : | `TRUE` if the package was removed from the sack

Since 0.5.2

### pk_package_sack_remove_package_by_id ()

    gboolean            pk_package_sack_remove_package_by_id
                                                            (PkPackageSack *sack,
                                                             const gchar *package_id);

Removes a package reference from the sack. As soon as one package is removed the search is stopped.

`sack` : | a valid PkPackageSack instance
`package_id` : | a package_id descriptor
Returns : | `TRUE` if the package was removed from the sack

Since 0.5.2

### pk_package_sack_remove_by_filter ()

    gboolean            pk_package_sack_remove_by_filter    (PkPackageSack *sack,
                                                             PkPackageSackFilterFunc filter_cb,
                                                             gpointer user_data);

Removes from the package sack any packages that return `FALSE` from the filter function.

`sack` : | a valid PkPackageSack instance
`filter_cb` : | a PkPackageSackFilterFunc, which returns `TRUE` for the PkPackage's to retain. [scope call]
`user_data` : | user data to pass to `filter_cb`
Returns : | `TRUE` if a package was removed from the sack

Since 0.6.3

### pk_package_sack_find_by_id ()

    PkPackage *         pk_package_sack_find_by_id          (PkPackageSack *sack,
                                                             const gchar *package_id);

Finds a package in a sack from reference. As soon as one package is found the search is stopped.

`sack` : | a valid PkPackageSack instance
`package_id` : | a package_id descriptor
Returns : | the PkPackage object, or `NULL` if unfound. Free with `g_object_unref()`. [transfer full]

Since 0.5.2

### pk_package_sack_filter_by_info ()

    PkPackageSack *     pk_package_sack_filter_by_info      (PkPackageSack *sack,
                                                             PkInfoEnum info);

Returns a new package sack which only matches packages that match the specified info enum value.

`sack` : | a valid PkPackageSack instance
`info` : | a `PkInfoEnum` value to match
Returns : | a new PkPackageSack, free with `g_object_unref()`. [transfer full]

Since 0.6.2

### pk_package_sack_filter ()

    PkPackageSack *     pk_package_sack_filter              (PkPackageSack *sack,
                                                             PkPackageSackFilterFunc filter_cb,
                                                             gpointer user_data);

Returns a new package sack which only matches packages that return `TRUE` from the filter function.

`sack` : | a valid PkPackageSack instance
`filter_cb` : | a PkPackageSackFilterFunc, which returns `TRUE` for the PkPackage's to add. [scope call]
`user_data` : | user data to pass to `filter_cb`
Returns : | a new PkPackageSack, free with `g_object_unref()`. [transfer full]

Since 0.6.3

### pk_package_sack_get_total_bytes ()

    guint64             pk_package_sack_get_total_bytes     (PkPackageSack *sack);

Gets the total size of the package sack in bytes.

`sack` : | a valid PkPackageSack instance
Returns : | the size in bytes

Since 0.5.2

### pk_package_sack_merge_generic_finish ()

    gboolean            pk_package_sack_merge_generic_finish
                                                            (PkPackageSack *sack,
                                                             GAsyncResult *res,
                                                             GError **error);

Gets the result from the asynchronous function.

`sack` : | a valid PkPackageSack instance
`res` : | the GAsyncResult
`error` : | A GError or `NULL`
Returns : | `TRUE` for success

Since 0.5.2

### pk_package_sack_resolve_async ()

    void                pk_package_sack_resolve_async       (PkPackageSack *sack,
                                                             GCancellable *cancellable,
                                                             PkProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Merges in details about packages using resolve.

`sack` : | a valid PkPackageSack instance
`cancellable` : | a GCancellable or `NULL`
`progress_callback` : | the function to run when the progress changes. [scope call]
`progress_user_data` : | data to pass to `progress_callback`
`callback` : | the function to run on completion
`user_data` : | the data to pass to `callback`

Since 0.5.2

### pk_package_sack_get_details_async ()

    void                pk_package_sack_get_details_async   (PkPackageSack *sack,
                                                             GCancellable *cancellable,
                                                             PkProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Merges in details about packages.

`sack` : | a valid PkPackageSack instance
`cancellable` : | a GCancellable or `NULL`
`progress_callback` : | the function to run when the progress changes. [scope call]
`progress_user_data` : | data to pass to `progress_callback`
`callback` : | the function to run on completion
`user_data` : | the data to pass to `callback`

### pk_package_sack_get_update_detail_async ()

    void                pk_package_sack_get_update_detail_async
                                                            (PkPackageSack *sack,
                                                             GCancellable *cancellable,
                                                             PkProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Merges in update details about packages.

`sack` : | a valid PkPackageSack instance
`cancellable` : | a GCancellable or `NULL`
`progress_callback` : | the function to run when the progress changes. [scope call]
`progress_user_data` : | data to pass to `progress_callback`
`callback` : | the function to run on completion
`user_data` : | the data to pass to `callback`

Since 0.5.2

### PkPackageSackResults

    typedef struct _PkPackageSackResults PkPackageSackResults;