From 132ec4c3b9f761fb76ff9cf567f3723db62d72df Mon Sep 17 00:00:00 2001 From: Olivier Brunel Date: Sun, 6 Dec 2015 18:35:37 +0100 Subject: Add events ALPM_EVENT_HOOK_{START,DONE} Add events to let frontends know when hooks are being processed (and when it's done), as that might be useful to update the UI. Signed-off-by: Olivier Brunel --- lib/libalpm/hook.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/libalpm/hook.c') diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c index ee7ad9d2..9f73ecc6 100644 --- a/lib/libalpm/hook.c +++ b/lib/libalpm/hook.c @@ -52,7 +52,7 @@ struct _alpm_hook_t { alpm_list_t *depends; char **cmd; alpm_list_t *matches; - enum _alpm_hook_when_t when; + alpm_hook_when_t when; int abort_on_fail, needs_targets; }; @@ -608,8 +608,9 @@ static int _alpm_hook_run_hook(alpm_handle_t *handle, struct _alpm_hook_t *hook) } } -int _alpm_hook_run(alpm_handle_t *handle, enum _alpm_hook_when_t when) +int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when) { + alpm_event_hook_t event = { .when = when }; alpm_list_t *i, *hooks = NULL, *hooks_triggered = NULL; const char *suffix = ".hook"; size_t suflen = strlen(suffix); @@ -717,6 +718,9 @@ int _alpm_hook_run(alpm_handle_t *handle, enum _alpm_hook_when_t when) } if(hooks_triggered != NULL) { + event.type = ALPM_EVENT_HOOK_START; + EVENT(handle, &event); + for(i = hooks_triggered; i; i = i->next) { struct _alpm_hook_t *hook = i->data; _alpm_log(handle, ALPM_LOG_DEBUG, "running hook %s\n", hook->name); @@ -726,6 +730,9 @@ int _alpm_hook_run(alpm_handle_t *handle, enum _alpm_hook_when_t when) } alpm_list_free(hooks_triggered); + + event.type = ALPM_EVENT_HOOK_DONE; + EVENT(handle, &event); } cleanup: -- cgit v1.2.3-54-g00ecf