ZifDownload

ZifDownload — Download packages

Synopsis

#define             ZIF_DOWNLOAD_ERROR
struct              ZifDownload;
struct              ZifDownloadClass;
enum                ZifDownloadError;
GQuark              zif_download_error_quark            (void);
ZifDownload *       zif_download_new                    (void);
gboolean            zif_download_set_proxy              (ZifDownload *download,
                                                         const gchar *http_proxy,
                                                         GError **error);
gboolean            zif_download_file                   (ZifDownload *download,
                                                         const gchar *uri,
                                                         const gchar *filename,
                                                         ZifState *state,
                                                         GError **error);
gboolean            zif_download_file_full              (ZifDownload *download,
                                                         const gchar *uri,
                                                         const gchar *filename,
                                                         guint64 size,
                                                         const gchar *content_types,
                                                         GChecksumType checksum_type,
                                                         const gchar *checksum,
                                                         ZifState *state,
                                                         GError **error);
gboolean            zif_download_location_add_uri       (ZifDownload *download,
                                                         const gchar *uri,
                                                         GError **error);
gboolean            zif_download_location_add_array     (ZifDownload *download,
                                                         GPtrArray *array,
                                                         GError **error);
gboolean            zif_download_location_remove_uri    (ZifDownload *download,
                                                         const gchar *uri,
                                                         GError **error);
gboolean            zif_download_location               (ZifDownload *download,
                                                         const gchar *location,
                                                         const gchar *filename,
                                                         ZifState *state,
                                                         GError **error);
gboolean            zif_download_location_full          (ZifDownload *download,
                                                         const gchar *location,
                                                         const gchar *filename,
                                                         guint64 size,
                                                         const gchar *content_types,
                                                         GChecksumType checksum_type,
                                                         const gchar *checksum,
                                                         ZifState *state,
                                                         GError **error);
guint               zif_download_location_get_size      (ZifDownload *download);
void                zif_download_location_clear         (ZifDownload *download);

Object Hierarchy

  GObject
   +----ZifDownload

Description

This object is a simple wrapper around libsoup that handles mirrorlists, timeouts and retries.

Details

ZIF_DOWNLOAD_ERROR

#define ZIF_DOWNLOAD_ERROR		(zif_download_error_quark ())


struct ZifDownload

struct ZifDownload;


struct ZifDownloadClass

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


enum ZifDownloadError

typedef enum {
	ZIF_DOWNLOAD_ERROR_FAILED,
	ZIF_DOWNLOAD_ERROR_PERMISSION_DENIED,
	ZIF_DOWNLOAD_ERROR_CANCELLED,
	ZIF_DOWNLOAD_ERROR_NO_SPACE,
	ZIF_DOWNLOAD_ERROR_WRONG_STATUS,
	ZIF_DOWNLOAD_ERROR_WRONG_CONTENT_TYPE,
	ZIF_DOWNLOAD_ERROR_WRONG_SIZE,
	ZIF_DOWNLOAD_ERROR_WRONG_CHECKSUM,
	ZIF_DOWNLOAD_ERROR_NO_LOCATIONS,
	ZIF_DOWNLOAD_ERROR_LAST
} ZifDownloadError;

ZIF_DOWNLOAD_ERROR_FAILED

ZIF_DOWNLOAD_ERROR_PERMISSION_DENIED

ZIF_DOWNLOAD_ERROR_CANCELLED

ZIF_DOWNLOAD_ERROR_NO_SPACE

ZIF_DOWNLOAD_ERROR_WRONG_STATUS

ZIF_DOWNLOAD_ERROR_WRONG_CONTENT_TYPE

ZIF_DOWNLOAD_ERROR_WRONG_SIZE

ZIF_DOWNLOAD_ERROR_WRONG_CHECKSUM

ZIF_DOWNLOAD_ERROR_NO_LOCATIONS

ZIF_DOWNLOAD_ERROR_LAST


zif_download_error_quark ()

GQuark              zif_download_error_quark            (void);

Returns :

An error quark.

Since 0.1.0


zif_download_new ()

ZifDownload *       zif_download_new                    (void);

Returns :

A new download instance.

Since 0.1.0


zif_download_set_proxy ()

gboolean            zif_download_set_proxy              (ZifDownload *download,
                                                         const gchar *http_proxy,
                                                         GError **error);

Sets the proxy used for downloading files.

Do not use this method any more. Instead use: zif_config_set_string(config, "http_proxy", "value", error)

download :

A ZifDownload

http_proxy :

HTTP proxy, e.g. "http://10.0.0.1:8080"

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.0


zif_download_file ()

gboolean            zif_download_file                   (ZifDownload *download,
                                                         const gchar *uri,
                                                         const gchar *filename,
                                                         ZifState *state,
                                                         GError **error);

Downloads a file either from a remote site, or copying the file from the local filesystem.

This function will return with an error if the downloaded file has zero size.

download :

A ZifDownload

uri :

A full remote URI

filename :

A local filename to save to

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.0


zif_download_file_full ()

gboolean            zif_download_file_full              (ZifDownload *download,
                                                         const gchar *uri,
                                                         const gchar *filename,
                                                         guint64 size,
                                                         const gchar *content_types,
                                                         GChecksumType checksum_type,
                                                         const gchar *checksum,
                                                         ZifState *state,
                                                         GError **error);

Downloads a file either from a remote site, or copying the file from the local filesystem, and then verifying it against what we are expecting.

download :

A ZifDownload

uri :

A full remote URI.

filename :

Local filename to save to

size :

Expected size in bytes, or 0

content_types :

Comma delimited expected content types of the file, or NULL

checksum_type :

Checksum type, e.g. G_CHECKSUM_SHA256, or 0

checksum :

Expected checksum of the file, or NULL

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.2.1


zif_download_location_add_uri ()

gboolean            zif_download_location_add_uri       (ZifDownload *download,
                                                         const gchar *uri,
                                                         GError **error);

Adds a URI to be used when using zif_download_location_full().

download :

A ZifDownload

uri :

Full mirror URI, e.g. "http://dave.com/pub/"

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.3


zif_download_location_add_array ()

gboolean            zif_download_location_add_array     (ZifDownload *download,
                                                         GPtrArray *array,
                                                         GError **error);

Adds an array of URIs to be used when using zif_download_location_full().

download :

A ZifDownload

array :

Array of URI strings to add

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.3


zif_download_location_remove_uri ()

gboolean            zif_download_location_remove_uri    (ZifDownload *download,
                                                         const gchar *uri,
                                                         GError **error);

Removes a URI from the pool used to download files.

download :

A ZifDownload

uri :

URI to remove

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.3


zif_download_location ()

gboolean            zif_download_location               (ZifDownload *download,
                                                         const gchar *location,
                                                         const gchar *filename,
                                                         ZifState *state,
                                                         GError **error);

Downloads a file using a pool of download servers.

download :

A ZifDownload

location :

Location to add on to the end of the pool URIs

filename :

Local filename to save to

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.3


zif_download_location_full ()

gboolean            zif_download_location_full          (ZifDownload *download,
                                                         const gchar *location,
                                                         const gchar *filename,
                                                         guint64 size,
                                                         const gchar *content_types,
                                                         GChecksumType checksum_type,
                                                         const gchar *checksum,
                                                         ZifState *state,
                                                         GError **error);

Downloads a file using a pool of download servers, and then verifying it against what we are expecting.

download :

A ZifDownload

location :

Location to add on to the end of the pool URIs

filename :

Local filename to save to

size :

Expected size in bytes, or 0

content_types :

Comma delimited expected content types of the file, or NULL

checksum_type :

Checksum type, e.g. G_CHECKSUM_SHA256, or 0

checksum :

Expected checksum of the file, or NULL

state :

A ZifState to use for progress reporting

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.3


zif_download_location_get_size ()

guint               zif_download_location_get_size      (ZifDownload *download);

Gets the number of active mirrors we can use.

download :

A ZifDownload

Returns :

A number or active URIs

Since 0.1.3


zif_download_location_clear ()

void                zif_download_location_clear         (ZifDownload *download);

Clears the list of active mirrors.

download :

A ZifDownload

Since 0.1.3