output: add support for messages
This is already supported by the D-Bus API, though not in our output wrapper. Closes: #919 Approved by: cgwalters
This commit is contained in:
parent
da2c4ea8ca
commit
7b774cee7e
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user