]> git.ipfire.org Git - pakfire.git/commitdiff
progress: Set a default start action
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 1 Oct 2023 12:29:03 +0000 (12:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 1 Oct 2023 12:29:03 +0000 (12:29 +0000)
If some application is not using the progress feature, at least we have
a log message about what is happening...

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/progress.c

index 648f9d051704d126a11237bf2bf6c6b38d357b9e..a3c6b64b5cba18501cf4192d383ffd32f24e315f 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <time.h>
 
+#include <pakfire/logging.h>
 #include <pakfire/pakfire.h>
 #include <pakfire/private.h>
 #include <pakfire/progress.h>
@@ -76,6 +77,18 @@ static void pakfire_progress_free(struct pakfire_progress* p) {
        free(p);
 }
 
+static int pakfire_progress_default_start_callback(struct pakfire* pakfire,
+               struct pakfire_progress* p, void* data, unsigned long int value) {
+       // Fetch the title
+       const char* title = pakfire_progress_get_title(p);
+
+       // Log the title
+       if (title)
+               INFO(pakfire, "%s\n", title);
+
+       return 0;
+}
+
 int pakfire_progress_create(struct pakfire_progress** progress,
                struct pakfire* pakfire, int flags) {
        struct pakfire_progress* p = NULL;
@@ -98,7 +111,8 @@ int pakfire_progress_create(struct pakfire_progress** progress,
        // Initialize status
        p->status = PAKFIRE_PROGRESS_INIT;
 
-       // XXX Create a couple of default callbacks
+       // Configure some default callbacks
+       p->callbacks.start = pakfire_progress_default_start_callback;
 
        // Call setup
        if (!pakfire_progress_has_flag(p, PAKFIRE_PROGRESS_NO_PROGRESS)) {