ZifPackage

ZifPackage — Generic object to represent an installed or remote package.

Synopsis

#define             ZIF_PACKAGE_ERROR
                    ZifPackage;
                    ZifPackagePrivate;
                    ZifPackageClass;
enum                ZifPackageEnsureType;
enum                ZifPackageError;
GQuark              zif_package_error_quark             (void);
ZifPackage *        zif_package_new                     (void);
const gchar *       zif_package_get_id                  (ZifPackage *package);
const gchar *       zif_package_get_name                (ZifPackage *package);
const gchar *       zif_package_get_summary             (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
const gchar *       zif_package_get_description         (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
const gchar *       zif_package_get_license             (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
const gchar *       zif_package_get_url                 (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
const gchar *       zif_package_get_filename            (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
const gchar *       zif_package_get_category            (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
const gchar *       zif_package_get_group               (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
guint64             zif_package_get_size                (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
GPtrArray *         zif_package_get_files               (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
GPtrArray *         zif_package_get_requires            (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
GPtrArray *         zif_package_get_provides            (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
void                zif_package_set_installed           (ZifPackage *package,
                                                         gboolean installed);
gboolean            zif_package_set_id                  (ZifPackage *package,
                                                         const gchar *package_id,
                                                         GError **error);
void                zif_package_set_summary             (ZifPackage *package,
                                                         ZifString *summary);
void                zif_package_set_description         (ZifPackage *package,
                                                         ZifString *description);
void                zif_package_set_license             (ZifPackage *package,
                                                         ZifString *license);
void                zif_package_set_url                 (ZifPackage *package,
                                                         ZifString *url);
void                zif_package_set_location_href       (ZifPackage *package,
                                                         ZifString *location_href);
void                zif_package_set_category            (ZifPackage *package,
                                                         ZifString *category);
void                zif_package_set_group               (ZifPackage *package,
                                                         ZifString *group);
void                zif_package_set_size                (ZifPackage *package,
                                                         guint64 size);
void                zif_package_set_files               (ZifPackage *package,
                                                         GPtrArray *files);
void                zif_package_set_requires            (ZifPackage *package,
                                                         GPtrArray *requires);
void                zif_package_set_provides            (ZifPackage *package,
                                                         GPtrArray *provides);
gboolean            zif_package_download                (ZifPackage *package,
                                                         const gchar *directory,
                                                         ZifState *state,
                                                         GError **error);
ZifUpdate *         zif_package_get_update_detail       (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);
const gchar *       zif_package_get_package_id          (ZifPackage *package);
void                zif_package_print                   (ZifPackage *package);
gboolean            zif_package_is_devel                (ZifPackage *package);
gboolean            zif_package_is_gui                  (ZifPackage *package);
gboolean            zif_package_is_installed            (ZifPackage *package);
gboolean            zif_package_is_free                 (ZifPackage *package);
gboolean            zif_package_is_native               (ZifPackage *package);
gint                zif_package_compare                 (ZifPackage *a,
                                                         ZifPackage *b);
ZifPackage *        zif_package_array_get_newest        (GPtrArray *array,
                                                         GError **error);
gboolean            zif_package_array_filter_newest     (GPtrArray *packages);
const gchar *       zif_package_ensure_type_to_string   (ZifPackageEnsureType type);

Object Hierarchy

  GObject
   +----ZifPackage
         +----ZifPackageLocal
         +----ZifPackageRemote

Description

This object is subclassed by ZifPackageLocal and ZifPackageRemote.

Details

ZIF_PACKAGE_ERROR

#define ZIF_PACKAGE_ERROR		(zif_package_error_quark ())


ZifPackage

typedef struct _ZifPackage ZifPackage;


ZifPackagePrivate

typedef struct _ZifPackagePrivate ZifPackagePrivate;


ZifPackageClass

typedef struct {
	GObjectClass parent_class;

	/* vtable */
	gboolean	 (*ensure_data)			(ZifPackage *package,
							 ZifPackageEnsureType type,
							 ZifState *state,
							 GError		**error);
} ZifPackageClass;


enum ZifPackageEnsureType

typedef enum {
	ZIF_PACKAGE_ENSURE_TYPE_FILES,
	ZIF_PACKAGE_ENSURE_TYPE_SUMMARY,
	ZIF_PACKAGE_ENSURE_TYPE_LICENCE,
	ZIF_PACKAGE_ENSURE_TYPE_DESCRIPTION,
	ZIF_PACKAGE_ENSURE_TYPE_URL,
	ZIF_PACKAGE_ENSURE_TYPE_SIZE,
	ZIF_PACKAGE_ENSURE_TYPE_GROUP,
	ZIF_PACKAGE_ENSURE_TYPE_CATEGORY,
	ZIF_PACKAGE_ENSURE_TYPE_REQUIRES,
	ZIF_PACKAGE_ENSURE_TYPE_PROVIDES,
	ZIF_PACKAGE_ENSURE_TYPE_CONFLICTS,
	ZIF_PACKAGE_ENSURE_TYPE_OBSOLETES,
	ZIF_PACKAGE_ENSURE_TYPE_LAST
} ZifPackageEnsureType;


enum ZifPackageError

typedef enum {
	ZIF_PACKAGE_ERROR_FAILED,
	ZIF_PACKAGE_ERROR_LAST
} ZifPackageError;


zif_package_error_quark ()

GQuark              zif_package_error_quark             (void);

Returns :

Our personal error quark.

Since 0.1.0


zif_package_new ()

ZifPackage *        zif_package_new                     (void);

Returns :

A new ZifPackage class instance.

Since 0.1.0


zif_package_get_id ()

const gchar *       zif_package_get_id                  (ZifPackage *package);

Gets the id uniquely identifying the package in all repos.

package :

the ZifPackage object

Returns :

the PackageId representing the package.

Since 0.1.0


zif_package_get_name ()

const gchar *       zif_package_get_name                (ZifPackage *package);

Gets the package name.

package :

the ZifPackage object

Returns :

the package name.

Since 0.1.0


zif_package_get_summary ()

const gchar *       zif_package_get_summary             (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the package summary.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the const string or NULL

Since 0.1.0


zif_package_get_description ()

const gchar *       zif_package_get_description         (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the package description.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the const string or NULL

Since 0.1.0


zif_package_get_license ()

const gchar *       zif_package_get_license             (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the package licence.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the const string or NULL

Since 0.1.0


zif_package_get_url ()

const gchar *       zif_package_get_url                 (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the homepage URL for the package.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the const string or NULL

Since 0.1.0


zif_package_get_filename ()

const gchar *       zif_package_get_filename            (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the remote filename for the package, e.g. Packages/net-snmp-5.4.2-3.fc10.i386.rpm

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the const string or NULL

Since 0.1.0


zif_package_get_category ()

const gchar *       zif_package_get_category            (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the category the packag is in.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the const string or NULL

Since 0.1.0


zif_package_get_group ()

const gchar *       zif_package_get_group               (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the package group.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the group name string

Since 0.1.0


zif_package_get_size ()

guint64             zif_package_get_size                (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the size of the package. This is the installed size for installed packages, and the download size for remote packages.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the package size, or 0 for failure

Since 0.1.0


zif_package_get_files ()

GPtrArray *         zif_package_get_files               (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the file list for the package.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the reference counted GPtrArray, use g_ptr_array_unref() when done

Since 0.1.0


zif_package_get_requires ()

GPtrArray *         zif_package_get_requires            (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets all the package requires.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the reference counted GPtrArray, use g_ptr_array_unref() when done

Since 0.1.0


zif_package_get_provides ()

GPtrArray *         zif_package_get_provides            (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Get all the package provides.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

the reference counted GPtrArray, use g_ptr_array_unref() when done

Since 0.1.0


zif_package_set_installed ()

void                zif_package_set_installed           (ZifPackage *package,
                                                         gboolean installed);

Sets the package installed status.

package :

the ZifPackage object

installed :

If the package is installed

Since 0.1.0


zif_package_set_id ()

gboolean            zif_package_set_id                  (ZifPackage *package,
                                                         const gchar *package_id,
                                                         GError **error);

Sets the unique id for the package.

package :

the ZifPackage object

package_id :

A PackageId defining the object

error :

Returns :

TRUE for success, FALSE for failure

Since 0.1.0


zif_package_set_summary ()

void                zif_package_set_summary             (ZifPackage *package,
                                                         ZifString *summary);

Sets the package summary.

package :

the ZifPackage object

summary :

the package summary

Since 0.1.0


zif_package_set_description ()

void                zif_package_set_description         (ZifPackage *package,
                                                         ZifString *description);

Sets the package description.

package :

the ZifPackage object

description :

the package description

Since 0.1.0


zif_package_set_license ()

void                zif_package_set_license             (ZifPackage *package,
                                                         ZifString *license);

Sets the package license.

package :

the ZifPackage object

license :

license

Since 0.1.0


zif_package_set_url ()

void                zif_package_set_url                 (ZifPackage *package,
                                                         ZifString *url);

Sets the project homepage URL.

package :

the ZifPackage object

url :

The package homepage URL

Since 0.1.0


zif_package_set_location_href ()

void                zif_package_set_location_href       (ZifPackage *package,
                                                         ZifString *location_href);

Sets the remote download location.

package :

the ZifPackage object

location_href :

the remote download filename

Since 0.1.0


zif_package_set_category ()

void                zif_package_set_category            (ZifPackage *package,
                                                         ZifString *category);

Sets the package category.

package :

the ZifPackage object

category :

category

Since 0.1.0


zif_package_set_group ()

void                zif_package_set_group               (ZifPackage *package,
                                                         ZifString *group);

Sets the package group.

package :

the ZifPackage object

group :

the package group

Since 0.1.0


zif_package_set_size ()

void                zif_package_set_size                (ZifPackage *package,
                                                         guint64 size);

Sets the package size in bytes.

package :

the ZifPackage object

size :

the package size in bytes

Since 0.1.0


zif_package_set_files ()

void                zif_package_set_files               (ZifPackage *package,
                                                         GPtrArray *files);

Sets the package file list.

package :

the ZifPackage object

files :

the package filelist

Since 0.1.0


zif_package_set_requires ()

void                zif_package_set_requires            (ZifPackage *package,
                                                         GPtrArray *requires);

Sets the package requires.

package :

the ZifPackage object

requires :

the package requires

Since 0.1.0


zif_package_set_provides ()

void                zif_package_set_provides            (ZifPackage *package,
                                                         GPtrArray *provides);

Sets the package provides

package :

the ZifPackage object

provides :

the package provides

Since 0.1.0


zif_package_download ()

gboolean            zif_package_download                (ZifPackage *package,
                                                         const gchar *directory,
                                                         ZifState *state,
                                                         GError **error);

Downloads a package.

package :

the ZifPackage object

directory :

the local directory to save to

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

TRUE for success, FALSE for failure

Since 0.1.0


zif_package_get_update_detail ()

ZifUpdate *         zif_package_get_update_detail       (ZifPackage *package,
                                                         ZifState *state,
                                                         GError **error);

Gets the update detail for a package.

package :

the ZifPackage object

state :

a ZifState to use for progress reporting

error :

a GError which is used on failure, or NULL

Returns :

a ZifUpdate, or NULL for failure

Since 0.1.0


zif_package_get_package_id ()

const gchar *       zif_package_get_package_id          (ZifPackage *package);

Gets the id (as text) uniquely identifying the package in all repos.

package :

the ZifPackage object

Returns :

The package-id representing the package.

Since 0.1.0


zif_package_print ()

void                zif_package_print                   (ZifPackage *package);

Prints details about a package to STDOUT.

package :

the ZifPackage object

Since 0.1.0


zif_package_is_devel ()

gboolean            zif_package_is_devel                (ZifPackage *package);

Finds out if a package is a development package.

package :

the ZifPackage object

Returns :

TRUE or FALSE

Since 0.1.0


zif_package_is_gui ()

gboolean            zif_package_is_gui                  (ZifPackage *package);

Finds out if a package is a GUI package.

package :

the ZifPackage object

Returns :

TRUE or FALSE

Since 0.1.0


zif_package_is_installed ()

gboolean            zif_package_is_installed            (ZifPackage *package);

Finds out if a package is installed.

package :

the ZifPackage object

Returns :

TRUE or FALSE

Since 0.1.0


zif_package_is_free ()

gboolean            zif_package_is_free                 (ZifPackage *package);

Check the string license_text for free licenses, indicated by their short names as documented at http://fedoraproject.org/wiki/Licensing

Licenses can be grouped by " or " to indicate that the package can be redistributed under any of the licenses in the group. For instance: GPLv2+ or Artistic or FooLicense.

Also, if a license ends with "+", the "+" is removed before comparing it to the list of valid licenses. So if license "FooLicense" is free, then "FooLicense+" is considered free.

Groups of licenses can be grouped with " and " to indicate that parts of the package are distributed under one group of licenses, while other parts of the package are distributed under another group. Groups may be wrapped in parenthesis. For instance: (GPLv2+ or Artistic) and (GPL+ or Artistic) and FooLicense.

At least one license in each group must be free for the package to be considered Free Software. If the license_text is empty, the package is considered non-free.

package :

the ZifPackage object

Returns :

TRUE or FALSE

Since 0.1.0


zif_package_is_native ()

gboolean            zif_package_is_native               (ZifPackage *package);

Finds out if a package is the native architecture for the system.

package :

the ZifPackage object

Returns :

TRUE or FALSE

Since 0.1.0


zif_package_compare ()

gint                zif_package_compare                 (ZifPackage *a,
                                                         ZifPackage *b);

Compares one package versions against each other.

a :

the first package to compare

b :

the second package to compare

Returns :

1 for a>b, 0 for a==b, -1 for b>a, or G_MAXINT for error

Since 0.1.0


zif_package_array_get_newest ()

ZifPackage *        zif_package_array_get_newest        (GPtrArray *array,
                                                         GError **error);

Returns the newest package from a list.

array :

array of ZifPackage's

error :

a GError which is used on failure, or NULL

Returns :

a single ZifPackage, or NULL in the case of an error. Use g_object_unref() when done.

Since 0.1.0


zif_package_array_filter_newest ()

gboolean            zif_package_array_filter_newest     (GPtrArray *packages);

Filters the list so that only the newest version of a package remains.

packages :

array of ZifPackage's

Returns :

TRUE if the array was modified

Since 0.1.0


zif_package_ensure_type_to_string ()

const gchar *       zif_package_ensure_type_to_string   (ZifPackageEnsureType type);

Gets the string representation of a ZifPackageEnsureType

type :

the ZifPackageEnsureType enumerated value

Returns :

The ZifPackageEnsureType represented as a string