summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/dload.c
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2021-04-25 20:03:54 +0200
committerAllan McRae <allan@archlinux.org>2021-05-01 04:08:14 +0200
commite7fa35baa22bf6710a904815456d3ff679005fc7 (patch)
treec988537bbc720da5fce7de30c39e73f6e67a16a0 /lib/libalpm/dload.c
parent523c393e9e6175e632d355c9440abb0be164a362 (diff)
downloadpacman-e7fa35baa22bf6710a904815456d3ff679005fc7.tar.gz
pacman-e7fa35baa22bf6710a904815456d3ff679005fc7.tar.xz
add front-end provided context to callbacks
Our callbacks require front-ends to maintain state in order to provide reasonable output. The new download callback in particular requires much more complex state information to be saved. Without the ability to provide context, state must be saved globally, which may not be possible for all front-ends. Scripting language bindings in particular have no way to register per-handle callbacks without some form of context. Implements: FS#12721 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Diffstat (limited to 'lib/libalpm/dload.c')
-rw-r--r--lib/libalpm/dload.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index a4c42f8d..70ec318a 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -209,7 +209,8 @@ static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow,
* download_size (nor included in the total download size callback) */
cb_data.total = dltotal;
cb_data.downloaded = dlnow;
- payload->handle->dlcb(payload->remote_name, ALPM_DOWNLOAD_PROGRESS, &cb_data);
+ payload->handle->dlcb(payload->handle->dlcb_ctx,
+ payload->remote_name, ALPM_DOWNLOAD_PROGRESS, &cb_data);
payload->prevprogress = current_size;
return 0;
@@ -672,7 +673,7 @@ cleanup:
alpm_download_event_completed_t cb_data = {0};
cb_data.total = bytes_dl;
cb_data.result = ret;
- handle->dlcb(payload->remote_name, ALPM_DOWNLOAD_COMPLETED, &cb_data);
+ handle->dlcb(handle->dlcb_ctx, payload->remote_name, ALPM_DOWNLOAD_COMPLETED, &cb_data);
}
curl_multi_remove_handle(curlm, curl);
@@ -806,7 +807,7 @@ static int curl_download_internal(alpm_handle_t *handle,
if(curl_add_payload(handle, curlm, payload, localpath) == 0) {
if(handle->dlcb && !payload->signature) {
alpm_download_event_init_t cb_data = {.optional = payload->errors_ok};
- handle->dlcb(payload->remote_name, ALPM_DOWNLOAD_INIT, &cb_data);
+ handle->dlcb(handle->dlcb_ctx, payload->remote_name, ALPM_DOWNLOAD_INIT, &cb_data);
}
payloads = payloads->next;
@@ -877,7 +878,7 @@ int _alpm_download(alpm_handle_t *handle,
int success = 0;
if(payload->fileurl) {
- if (handle->fetchcb(payload->fileurl, localpath, payload->force) != -1) {
+ if (handle->fetchcb(handle->fetchcb_ctx, payload->fileurl, localpath, payload->force) != -1) {
success = 1;
break;
}
@@ -891,7 +892,7 @@ int _alpm_download(alpm_handle_t *handle,
MALLOC(fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(fileurl, len, "%s/%s", server, payload->filepath);
- ret = handle->fetchcb(fileurl, localpath, payload->force);
+ ret = handle->fetchcb(handle->fetchcb_ctx, fileurl, localpath, payload->force);
free(fileurl);
if (ret != -1) {