## ZifHistory ZifHistory — Discover details about past transactions |

## Synopsis

    #define             ZIF_HISTORY_ERROR
    struct              ZifHistory;
    struct              ZifHistoryClass;
    enum                ZifHistoryError;
    gboolean            zif_history_add_entry               (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             ZifTransactionReason reason,
                                                             guint uid,
                                                             const gchar *command_line,
                                                             GError **error);
    GQuark              zif_history_error_quark             (void);
    gchar *             zif_history_get_cmdline             (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             GError **error);
    GPtrArray *         zif_history_get_packages            (ZifHistory *history,
                                                             gint64 timestamp,
                                                             GError **error);
    ZifTransactionReason zif_history_get_reason             (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             GError **error);
    gchar *             zif_history_get_repo                (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             GError **error);
    gchar *             zif_history_get_repo_newest         (ZifHistory *history,
                                                             ZifPackage *package,
                                                             GError **error);
    GArray *            zif_history_get_transactions_for_package
                                                            (ZifHistory *history,
                                                             ZifPackage *package,
                                                             GError **error);
    guint               zif_history_get_uid                 (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             GError **error);
    gboolean            zif_history_import                  (ZifHistory *history,
                                                             ZifDb *db,
                                                             GError **error);
    GArray *            zif_history_list_transactions       (ZifHistory *history,
                                                             GError **error);
    ZifHistory *        zif_history_new                     (void);
    gboolean            zif_history_set_repo_for_store      (ZifHistory *history,
                                                             ZifStore *store,
                                                             GError **error);

## Object Hierarchy

      GObject
       +----ZifHistory

## Description

ZifHistory allows the user to see past transaction details to see what was installed, upgraded and the reasons why.

## Details

### ZIF_HISTORY_ERROR

    #define ZIF_HISTORY_ERROR		(zif_history_error_quark ())

### struct ZifHistory

    struct ZifHistory;

### struct ZifHistoryClass

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

### enum ZifHistoryError

    typedef enum {
    	ZIF_HISTORY_ERROR_FAILED,
    	ZIF_HISTORY_ERROR_FAILED_TO_OPEN,
    	ZIF_HISTORY_ERROR_LAST
    } ZifHistoryError;

`ZIF_HISTORY_ERROR_FAILED` |
`ZIF_HISTORY_ERROR_FAILED_TO_OPEN` |
`ZIF_HISTORY_ERROR_LAST` |

### zif_history_add_entry ()

    gboolean            zif_history_add_entry               (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             ZifTransactionReason reason,
                                                             guint uid,
                                                             const gchar *command_line,
                                                             GError **error);

Adds an entry into the zif history store

`history` : | A ZifHistory
`package` : | A ZifPackage
`timestamp` : | A timestamp
`reason` : | A `ZifTransactionReason`
`error` : | A GError, or `NULL`
Returns : | `TRUE` on success

Since 0.2.4

### zif_history_error_quark ()

    GQuark              zif_history_error_quark             (void);

Returns : | An error quark.

Since 0.2.4

### zif_history_get_cmdline ()

    gchar *             zif_history_get_cmdline             (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             GError **error);

Gets the command line used to process the specified package for the given timestamp.

`history` : | A ZifHistory
`package` : | A ZifPackage
`timestamp` : | A timestamp
`error` : | A GError, or `NULL`
Returns : | The command line, or `NULL` for error

Since 0.2.4

### zif_history_get_packages ()

    GPtrArray *         zif_history_get_packages            (ZifHistory *history,
                                                             gint64 timestamp,
                                                             GError **error);

Return all the packages that were modified on a specified timestamp.

`history` : | A ZifHistory
`timestamp` : | A timestamp
`error` : | A GError, or `NULL`
Returns : | A GPtrArray of ZifPackage's with the specified timestamp. [element-type ZifPackage][transfer container]

Since 0.2.4

### zif_history_get_reason ()

    ZifTransactionReason zif_history_get_reason             (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             GError **error);

Gets the transaction reason for the specified package and the given timestamp.

`history` : | A ZifHistory
`package` : | A ZifPackage
`timestamp` : | A timestamp
`error` : | A GError, or `NULL`
Returns : | The `ZifTransactionReason`, or `ZIF_TRANSACTION_REASON_INVALID` for error

Since 0.2.4

### zif_history_get_repo ()

    gchar *             zif_history_get_repo                (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             GError **error);

Gets the source store id for the specified package for the given timestamp.

`history` : | A ZifHistory
`package` : | A ZifPackage
`timestamp` : | A timestamp
`error` : | A GError, or `NULL`
Returns : | The store ID, or `NULL` for error

Since 0.2.4

### zif_history_get_repo_newest ()

    gchar *             zif_history_get_repo_newest         (ZifHistory *history,
                                                             ZifPackage *package,
                                                             GError **error);

Gets the source repository for a specific package. Note: this will return the repo for the most recently installed version of the package.

`history` : | A ZifHistory
`package` : | A ZifPackage
`error` : | A GError, or `NULL`
Returns : | The remote store ID for the installed package, or `NULL`

Since 0.2.4

### zif_history_get_transactions_for_package ()

    GArray *            zif_history_get_transactions_for_package
                                                            (ZifHistory *history,
                                                             ZifPackage *package,
                                                             GError **error);

Returns an array of transaction timestamps. Each timestamp may correspond to a number of modified packages.

`history` : | A ZifHistory
`package` : | A ZifPackage
`error` : | A GError, or `NULL`
Returns : | an GArray of gint64. [element-type gint64][transfer container]

Since 0.2.6

### zif_history_get_uid ()

    guint               zif_history_get_uid                 (ZifHistory *history,
                                                             ZifPackage *package,
                                                             gint64 timestamp,
                                                             GError **error);

Gets the user id for the specified package for the given timestamp.

`history` : | A ZifHistory
`package` : | A ZifPackage
`timestamp` : | A timestamp
`error` : | A GError, or `NULL`
Returns : | A UID, or `G_MAXUINT` for error

Since 0.2.4

### zif_history_import ()

    gboolean            zif_history_import                  (ZifHistory *history,
                                                             ZifDb *db,
                                                             GError **error);

Imports a legacy yumdb database into the zif history store

`history` : | A ZifHistory
`db` : | A ZifDb
`error` : | A GError, or `NULL`
Returns : | `TRUE` on success

Since 0.2.4

### zif_history_list_transactions ()

    GArray *            zif_history_list_transactions       (ZifHistory *history,
                                                             GError **error);

Returns an array of transaction timestamps. Each timestamp may correspond to a number of modified packages.

`history` : | A ZifHistory
`error` : | A GError, or `NULL`
Returns : | an GArray of gint64. [element-type gint64][transfer container]

Since 0.2.4

### zif_history_new ()

    ZifHistory *        zif_history_new                     (void);

Returns : | A new ZifHistory instance.

Since 0.2.4

### zif_history_set_repo_for_store ()

    gboolean            zif_history_set_repo_for_store      (ZifHistory *history,
                                                             ZifStore *store,
                                                             GError **error);

Sets all the repo_id values for every package in the store. This is much quicker than calling `zif_history_get_repo_newest()` for each package as only one SQL statement is prepared.

`history` : | A ZifHistory
`store` : | A ZifStore
`error` : | A GError, or `NULL`
Returns : | `TRUE` on success

Since 0.2.4