Skip to content

Commit

Permalink
Merge pull request #58 from jluebbe/api-description
Browse files Browse the repository at this point in the history
Add slot description and improve dbus API
  • Loading branch information
jluebbe committed Jul 5, 2016
2 parents d12cf6f + 0c51c73 commit 2f37240
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
2 changes: 2 additions & 0 deletions include/config_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ typedef enum {
typedef struct _RaucSlot {
/** name of the slot. A glib intern string. */
const gchar *name;
/** user-friendly description of the slot. A glib intern string. */
gchar *description;
/** slot class the slot belongs to. A glib intern string. */
const gchar *sclass;
/** device this slot uses */
Expand Down
5 changes: 5 additions & 0 deletions src/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ G_DEFINE_QUARK(r-config-error-quark, r_config_error)
static void free_slot(gpointer value) {
RaucSlot *slot = (RaucSlot*)value;

g_clear_pointer(&slot->description, g_free);
g_clear_pointer(&slot->device, g_free);
g_clear_pointer(&slot->type, g_free);
g_clear_pointer(&slot->bootname, g_free);
Expand Down Expand Up @@ -154,6 +155,10 @@ gboolean load_config(const gchar *filename, RaucConfig **config, GError **error)
slot->name = g_intern_string(value);
g_free(value);

slot->description = g_key_file_get_string(key_file, groups[i], "description", NULL);
if (!slot->description)
slot->description = g_strdup("");

slot->sclass = g_intern_string(groupsplit[1]);

value = resolve_path(filename,
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ static gboolean status_start(int argc, char **argv)
}
g_print(" %s: class=%s, device=%s, type=%s, bootname=%s\n",
name, slot->sclass, slot->device, slot->type, slot->bootname);
g_print(" state=%s", state);
g_print(" state=%s, description=%s", state, slot->description);
if (slot->parent)
g_print(", parent=%s", slot->parent->name);
else
Expand Down
7 changes: 1 addition & 6 deletions src/rauc-installer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

<property name="Operation" type="s" access="read"/>
<property name="LastError" type="s" access="read"/>

<signal name="ProgressUpdated">
<arg name="percentage" type="i"/>
<arg name="description" type="s"/>
<arg name="nesting_depth" type="i"/>
</signal>
<property name="ProgressUpdated" type="(isi)" access="read"/>

<signal name="Completed">
<arg name="result" type="i"/>
Expand Down
12 changes: 10 additions & 2 deletions src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,16 @@ static void send_progress_callback(gint percentage,
const gchar *message,
gint nesting_depth) {

r_installer_emit_progress_updated(r_installer, percentage, message,
nesting_depth);
GVariant **progress_update;
GVariant *progress_update_tuple;

progress_update = g_new(GVariant*, 3);
progress_update[0] = g_variant_new_int32(percentage);
progress_update[1] = g_variant_new_string(message);
progress_update[2] = g_variant_new_int32(nesting_depth);

progress_update_tuple = g_variant_new_tuple(progress_update, 3);
r_installer_set_progress_updated(r_installer, progress_update_tuple);
}

static void r_on_bus_acquired(GDBusConnection *connection,
Expand Down
10 changes: 10 additions & 0 deletions test/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,32 @@ mountprefix=/mnt/myrauc/\n\
path=/etc/rauc/keyring/\n\
\n\
[slot.rescue.0]\n\
description=Rescue partition\n\
device=/dev/mtd4\n\
type=raw\n\
bootname=factory0\n\
readonly=true\n\
\n\
[slot.rootfs.0]\n\
description=Root filesystem partition 0\n\
device=/dev/sda0\n\
type=ext4\n\
bootname=system0\n\
\n\
[slot.rootfs.1]\n\
description=Root filesystem partition 1\n\
device=/dev/sda1\n\
type=ext4\n\
bootname=system1\n\
\n\
[slot.appfs.0]\n\
description=Application filesystem partition 0\n\
device=/dev/sda2\n\
type=ext4\n\
parent=rootfs.0\n\
\n\
[slot.appfs.1]\n\
description=Application filesystem partition 1\n\
device=/dev/sda3\n\
type=ext4\n\
parent=rootfs.1\n";
Expand All @@ -85,6 +90,7 @@ parent=rootfs.1\n";

slot = g_hash_table_lookup(config->slots, "rescue.0");
g_assert_cmpstr(slot->name, ==, "rescue.0");
g_assert_cmpstr(slot->description, ==, "Rescue partition");
g_assert_cmpstr(slot->device, ==, "/dev/mtd4");
g_assert_cmpstr(slot->bootname, ==, "factory0");
g_assert_cmpstr(slot->type, ==, "raw");
Expand All @@ -94,6 +100,7 @@ parent=rootfs.1\n";

slot = g_hash_table_lookup(config->slots, "rootfs.0");
g_assert_cmpstr(slot->name, ==, "rootfs.0");
g_assert_cmpstr(slot->description, ==, "Root filesystem partition 0");
g_assert_cmpstr(slot->device, ==, "/dev/sda0");
g_assert_cmpstr(slot->bootname, ==, "system0");
g_assert_cmpstr(slot->type, ==, "ext4");
Expand All @@ -103,6 +110,7 @@ parent=rootfs.1\n";

slot = g_hash_table_lookup(config->slots, "rootfs.1");
g_assert_cmpstr(slot->name, ==, "rootfs.1");
g_assert_cmpstr(slot->description, ==, "Root filesystem partition 1");
g_assert_cmpstr(slot->device, ==, "/dev/sda1");
g_assert_cmpstr(slot->bootname, ==, "system1");
g_assert_cmpstr(slot->type, ==, "ext4");
Expand All @@ -112,6 +120,7 @@ parent=rootfs.1\n";

slot = g_hash_table_lookup(config->slots, "appfs.0");
g_assert_cmpstr(slot->name, ==, "appfs.0");
g_assert_cmpstr(slot->description, ==, "Application filesystem partition 0");
g_assert_cmpstr(slot->device, ==, "/dev/sda2");
g_assert_null(slot->bootname);
g_assert_cmpstr(slot->type, ==, "ext4");
Expand All @@ -121,6 +130,7 @@ parent=rootfs.1\n";

slot = g_hash_table_lookup(config->slots, "appfs.1");
g_assert_cmpstr(slot->name, ==, "appfs.1");
g_assert_cmpstr(slot->description, ==, "Application filesystem partition 1");
g_assert_cmpstr(slot->device, ==, "/dev/sda3");
g_assert_null(slot->bootname);
g_assert_cmpstr(slot->type, ==, "ext4");
Expand Down

0 comments on commit 2f37240

Please sign in to comment.