summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/alpm.h16
-rw-r--r--lib/libalpm/sync.c9
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index b129ff9b..5fc9c0d2 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -322,6 +322,15 @@ typedef enum _alpm_event_type_t {
ALPM_EVENT_RETRIEVE_DONE,
/** Not all files were successfully downloaded from a repository. */
ALPM_EVENT_RETRIEVE_FAILED,
+ /** A file will be downloaded from a repository; See alpm_event_pkgdownload_t
+ * for arguments */
+ ALPM_EVENT_PKGDOWNLOAD_START,
+ /** A file was downloaded from a repository; See alpm_event_pkgdownload_t
+ * for arguments */
+ ALPM_EVENT_PKGDOWNLOAD_DONE,
+ /** A file failed to be downloaded from a repository; See
+ * alpm_event_pkgdownload_t for arguments */
+ ALPM_EVENT_PKGDOWNLOAD_FAILED,
/** Disk space usage will be computed for a package. */
ALPM_EVENT_DISKSPACE_START,
/** Disk space usage was computed for a package. */
@@ -426,6 +435,13 @@ typedef struct _alpm_event_log_t {
va_list args;
} alpm_event_log_t;
+typedef struct _alpm_event_pkgdownload_t {
+ /** Type of event. */
+ alpm_event_type_t type;
+ /** Name of the file */
+ const char *file;
+} alpm_event_pkgdownload_t;
+
/** Event callback. */
typedef void (*alpm_cb_event)(alpm_event_t *);
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 68c33243..96db50a3 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -897,11 +897,16 @@ static int find_dl_candidates(alpm_db_t *repo, alpm_list_t **files, alpm_list_t
static int download_single_file(alpm_handle_t *handle, struct dload_payload *payload,
const char *cachedir)
{
+ alpm_event_pkgdownload_t event = {
+ .type = ALPM_EVENT_PKGDOWNLOAD_START,
+ .file = payload->remote_name
+ };
const alpm_list_t *server;
payload->handle = handle;
payload->allow_resume = 1;
+ EVENT(handle, &event);
for(server = payload->servers; server; server = server->next) {
const char *server_url = server->data;
size_t len;
@@ -912,6 +917,8 @@ static int download_single_file(alpm_handle_t *handle, struct dload_payload *pay
snprintf(payload->fileurl, len, "%s/%s", server_url, payload->remote_name);
if(_alpm_download(payload, cachedir, NULL, NULL) != -1) {
+ event.type = ALPM_EVENT_PKGDOWNLOAD_DONE;
+ EVENT(handle, &event);
return 0;
}
@@ -919,6 +926,8 @@ static int download_single_file(alpm_handle_t *handle, struct dload_payload *pay
payload->unlink_on_fail = 0;
}
+ event.type = ALPM_EVENT_PKGDOWNLOAD_FAILED;
+ EVENT(handle, &event);
return -1;
}