diff options
author | Olivier Brunel <jjk@jjacky.com> | 2015-12-06 18:35:37 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-12-15 15:09:28 +1000 |
commit | 132ec4c3b9f761fb76ff9cf567f3723db62d72df (patch) | |
tree | 0738399fbebaf4c7456446fa21110b91c53a9c6a /lib/libalpm/hook.c | |
parent | 3802cab56374b50d4775d9deaf229cdef5cdbe53 (diff) | |
download | pacman-132ec4c3b9f761fb76ff9cf567f3723db62d72df.tar.xz |
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 <jjk@jjacky.com>
Diffstat (limited to 'lib/libalpm/hook.c')
-rw-r--r-- | lib/libalpm/hook.c | 11 |
1 files changed, 9 insertions, 2 deletions
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: |