diff --git a/src/daemon/rpmostreed-sysroot.c b/src/daemon/rpmostreed-sysroot.c index c133608f..f17aea3f 100644 --- a/src/daemon/rpmostreed-sysroot.c +++ b/src/daemon/rpmostreed-sysroot.c @@ -303,6 +303,10 @@ sysroot_output_cb (RpmOstreeOutputType type, void *data, void *opaque) switch (type) { + case RPMOSTREE_OUTPUT_MESSAGE: + rpmostree_transaction_emit_message (RPMOSTREE_TRANSACTION (transaction), + ((RpmOstreeOutputMessage*)data)->text); + break; case RPMOSTREE_OUTPUT_TASK_BEGIN: rpmostree_transaction_emit_task_begin (RPMOSTREE_TRANSACTION (transaction), ((RpmOstreeOutputTaskBegin*)data)->text); diff --git a/src/libpriv/rpmostree-output.c b/src/libpriv/rpmostree-output.c index d05fe6a5..00ce1d7b 100644 --- a/src/libpriv/rpmostree-output.c +++ b/src/libpriv/rpmostree-output.c @@ -37,6 +37,9 @@ rpmostree_output_default_handler (RpmOstreeOutputType type, { switch (type) { + case RPMOSTREE_OUTPUT_MESSAGE: + g_print ("%s\n", ((RpmOstreeOutputMessage*)data)->text); + break; case RPMOSTREE_OUTPUT_TASK_BEGIN: /* XXX: move to libglnx spinner once it's implemented */ g_print ("%s... ", ((RpmOstreeOutputTaskBegin*)data)->text); @@ -71,36 +74,33 @@ rpmostree_output_set_callback (void (*cb)(RpmOstreeOutputType, void*, void*), active_cb_opaque = opaque; } +#define strdup_vprintf(format) \ + ({ va_list args; va_start (args, format); \ + char *s = g_strdup_vprintf (format, args); \ + va_end (args); s; }) + +void +rpmostree_output_message (const char *format, ...) +{ + g_autofree char *final_msg = strdup_vprintf (format); + RpmOstreeOutputMessage task = { final_msg }; + active_cb (RPMOSTREE_OUTPUT_MESSAGE, &task, active_cb_opaque); +} + void rpmostree_output_task_begin (const char *format, ...) { - g_autofree char *final = NULL; - va_list args; - - va_start (args, format); - final = g_strdup_vprintf (format, args); - va_end (args); - - { - RpmOstreeOutputTaskBegin task = { final }; - active_cb (RPMOSTREE_OUTPUT_TASK_BEGIN, &task, active_cb_opaque); - } + g_autofree char *final_msg = strdup_vprintf (format); + RpmOstreeOutputTaskBegin task = { final_msg }; + active_cb (RPMOSTREE_OUTPUT_TASK_BEGIN, &task, active_cb_opaque); } void rpmostree_output_task_end (const char *format, ...) { - g_autofree char *final = NULL; - va_list args; - - va_start (args, format); - final = g_strdup_vprintf (format, args); - va_end (args); - - { - RpmOstreeOutputTaskEnd task = { final }; - active_cb (RPMOSTREE_OUTPUT_TASK_END, &task, active_cb_opaque); - } + g_autofree char *final_msg = strdup_vprintf (format); + RpmOstreeOutputTaskEnd task = { final_msg }; + active_cb (RPMOSTREE_OUTPUT_TASK_END, &task, active_cb_opaque); } void diff --git a/src/libpriv/rpmostree-output.h b/src/libpriv/rpmostree-output.h index d944a606..d104061f 100644 --- a/src/libpriv/rpmostree-output.h +++ b/src/libpriv/rpmostree-output.h @@ -19,6 +19,7 @@ #pragma once typedef enum { + RPMOSTREE_OUTPUT_MESSAGE, RPMOSTREE_OUTPUT_TASK_BEGIN, RPMOSTREE_OUTPUT_TASK_END, RPMOSTREE_OUTPUT_PERCENT_PROGRESS, @@ -33,12 +34,17 @@ rpmostree_output_set_callback (void (*cb)(RpmOstreeOutputType, void*, void*), vo typedef struct { const char *text; -} RpmOstreeOutputTaskBegin; +} RpmOstreeOutputMessage; + +void +rpmostree_output_message (const char *format, ...) G_GNUC_PRINTF (1,2); + +typedef RpmOstreeOutputMessage RpmOstreeOutputTaskBegin; void rpmostree_output_task_begin (const char *format, ...) G_GNUC_PRINTF (1,2); -typedef RpmOstreeOutputTaskBegin RpmOstreeOutputTaskEnd; +typedef RpmOstreeOutputMessage RpmOstreeOutputTaskEnd; void rpmostree_output_task_end (const char *format, ...) G_GNUC_PRINTF (1,2);