summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo@endlessm.com>2016-05-10 13:58:56 -0700
committerCosimo Cecchi <cosimo@endlessm.com>2019-05-09 09:30:53 -0700
commitf5fe1b501e25ba8ec34c057df0833dcc27b8280a (patch)
tree5627a8b0e4321101fc0396510a1e3f335f65918b /service
parent9c4a4f2baef7c35934a8b05fb61148f0a356940d (diff)
downloaddconf-f5fe1b501e25ba8ec34c057df0833dcc27b8280a.tar.gz
writer: factor out a common method
Factor out a common method to route completion of DBus methods through. Helps: #29
Diffstat (limited to 'service')
-rw-r--r--service/dconf-writer.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/service/dconf-writer.c b/service/dconf-writer.c
index 5fb3467..26f66dd 100644
--- a/service/dconf-writer.c
+++ b/service/dconf-writer.c
@@ -252,6 +252,21 @@ dconf_writer_end (DConfWriter *writer)
return DCONF_WRITER_GET_CLASS (writer)->end (writer);
}
+static void
+dconf_writer_complete_invocation (DConfDBusWriter *dbus_writer,
+ GDBusMethodInvocation *invocation,
+ GVariant *result,
+ GError *error)
+{
+ if (error)
+ {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+ else
+ g_dbus_method_invocation_return_value (invocation, result);
+}
+
static gboolean
dconf_writer_handle_init (DConfDBusWriter *dbus_writer,
GDBusMethodInvocation *invocation)
@@ -264,15 +279,7 @@ dconf_writer_handle_init (DConfDBusWriter *dbus_writer,
if (dconf_writer_begin (writer, &error))
dconf_writer_commit (writer, &error);
- if (error)
- {
- g_dbus_method_invocation_return_gerror (invocation, error);
- g_error_free (error);
- }
-
- else
- g_dbus_method_invocation_return_value (invocation, NULL);
-
+ dconf_writer_complete_invocation (dbus_writer, invocation, NULL, error);
dconf_writer_end (writer);
return TRUE;
@@ -286,7 +293,7 @@ dconf_writer_handle_change (DConfDBusWriter *dbus_writer,
DConfWriter *writer = DCONF_WRITER (dbus_writer);
DConfChangeset *changeset;
GError *error = NULL;
- GVariant *tmp, *args;
+ GVariant *tmp, *args, *result = NULL;
gchar *tag;
dconf_blame_record (invocation);
@@ -316,19 +323,13 @@ dconf_writer_handle_change (DConfDBusWriter *dbus_writer,
}
out:
- dconf_changeset_unref (changeset);
-
- if (error)
- {
- g_dbus_method_invocation_return_gerror (invocation, error);
- g_error_free (error);
- }
-
- else
- g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", tag));
+ if (!error)
+ result = g_variant_new ("(s)", tag);
+ dconf_changeset_unref (changeset);
g_free (tag);
+ dconf_writer_complete_invocation (dbus_writer, invocation, result, error);
dconf_writer_end (writer);
return TRUE;