allow us to get the actions from the console client
This commit is contained in:
parent
7d66c380ed
commit
2d30206e8d
@ -31,6 +31,7 @@
|
||||
#include <pk-debug.h>
|
||||
#include <pk-task-client.h>
|
||||
#include <pk-package-id.h>
|
||||
#include <pk-enum-list.h>
|
||||
|
||||
/**
|
||||
* pk_console_package_cb:
|
||||
@ -138,6 +139,8 @@ pk_console_parse_multiple_commands (PkTaskClient *tclient, GPtrArray *array)
|
||||
const gchar *value = NULL;
|
||||
const gchar *details = NULL;
|
||||
guint remove;
|
||||
PkEnumList *elist;
|
||||
gchar *text;
|
||||
|
||||
mode = g_ptr_array_index (array, 0);
|
||||
if (array->len > 1) {
|
||||
@ -253,6 +256,20 @@ pk_console_parse_multiple_commands (PkTaskClient *tclient, GPtrArray *array)
|
||||
pk_task_client_set_sync (tclient, TRUE);
|
||||
pk_task_client_get_updates (tclient);
|
||||
remove = 2;
|
||||
} else if (strcmp (value, "actions") == 0) {
|
||||
/* get backend actions */
|
||||
text = pk_task_client_get_actions (tclient);
|
||||
|
||||
/* push into a PkEnumList */
|
||||
elist = pk_enum_list_new ();
|
||||
pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
|
||||
pk_enum_list_from_string (elist, text);
|
||||
pk_enum_list_print (elist);
|
||||
|
||||
/* don't leak */
|
||||
g_free (text);
|
||||
g_object_unref (elist);
|
||||
remove = 2;
|
||||
} else {
|
||||
pk_console_usage ("invalid get type");
|
||||
}
|
||||
|
@ -150,6 +150,32 @@ pk_enum_list_to_string (PkEnumList *elist)
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* pk_enum_list_print:
|
||||
**/
|
||||
gboolean
|
||||
pk_enum_list_print (PkEnumList *elist)
|
||||
{
|
||||
guint i;
|
||||
guint value;
|
||||
const gchar *text = NULL;
|
||||
|
||||
if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
|
||||
g_print ("Printing actions:\n");
|
||||
}
|
||||
for (i=0; i<elist->priv->data->len; i++) {
|
||||
value = GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i));
|
||||
if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
|
||||
text = pk_action_enum_to_text (value);
|
||||
} else {
|
||||
pk_error ("unknown type %i (did you use pk_enum_list_set_type?)", elist->priv->type);
|
||||
}
|
||||
g_print ("%s\n", text);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* pk_enum_list_append:
|
||||
**/
|
||||
|
@ -58,11 +58,12 @@ gboolean pk_enum_list_set_type (PkEnumList *elist,
|
||||
PkEnumListType type);
|
||||
gboolean pk_enum_list_from_string (PkEnumList *elist,
|
||||
const gchar *enums);
|
||||
gchar *pk_enum_list_to_string (PkEnumList *alist);
|
||||
gboolean pk_enum_list_contains (PkEnumList *alist,
|
||||
gchar *pk_enum_list_to_string (PkEnumList *elist);
|
||||
gboolean pk_enum_list_contains (PkEnumList *elist,
|
||||
guint value);
|
||||
gboolean pk_enum_list_append (PkEnumList *alist,
|
||||
gboolean pk_enum_list_append (PkEnumList *elist,
|
||||
guint value);
|
||||
gboolean pk_enum_list_print (PkEnumList *elist);
|
||||
gboolean pk_enum_list_append_multiple (PkEnumList *elist,
|
||||
guint value, ...);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user