[next] telepathy-glib: tp_dbus_daemon_release_name: rewrite using GDBus
Simon McVittie
smcv at kemper.freedesktop.org
Thu Mar 27 08:42:05 PDT 2014
Module: telepathy-glib
Branch: next
Commit: 0ca0b5a7c14264c0829f6a4ea893fea41e7cdcdf
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=0ca0b5a7c14264c0829f6a4ea893fea41e7cdcdf
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Tue Mar 11 18:21:58 2014 +0000
tp_dbus_daemon_release_name: rewrite using GDBus
---
telepathy-glib/dbus-daemon.c | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/telepathy-glib/dbus-daemon.c b/telepathy-glib/dbus-daemon.c
index ac74e5d..111ca80 100644
--- a/telepathy-glib/dbus-daemon.c
+++ b/telepathy-glib/dbus-daemon.c
@@ -607,17 +607,17 @@ tp_dbus_daemon_release_name (TpDBusDaemon *self,
const gchar *well_known_name,
GError **error)
{
- DBusGConnection *gconn;
- DBusConnection *dbc;
- DBusError dbus_error;
- int result;
+ guint32 result;
const GError *invalidated;
+ GVariant *tuple;
g_return_val_if_fail (TP_IS_DBUS_DAEMON (self), FALSE);
g_return_val_if_fail (tp_dbus_check_valid_bus_name (well_known_name,
TP_DBUS_NAME_TYPE_WELL_KNOWN, error), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ DEBUG ("%s", well_known_name);
+
invalidated = tp_proxy_get_invalidated (self);
if (invalidated != NULL)
@@ -625,38 +625,46 @@ tp_dbus_daemon_release_name (TpDBusDaemon *self,
if (error != NULL)
*error = g_error_copy (invalidated);
+ DEBUG ("- not releasing, we have fallen off D-Bus");
+ return FALSE;
+ }
+
+ tuple = g_dbus_connection_call_sync (tp_proxy_get_dbus_connection (self),
+ "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus",
+ "ReleaseName", g_variant_new ("(s)", well_known_name),
+ G_VARIANT_TYPE ("(u)"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
+
+ if (tuple == NULL)
+ {
+ DEBUG ("- D-Bus error");
return FALSE;
}
- gconn = tp_proxy_get_dbus_connection (self);
- dbc = dbus_g_connection_get_connection (gconn);
- dbus_error_init (&dbus_error);
- result = dbus_bus_release_name (dbc, well_known_name, &dbus_error);
+ g_variant_get (tuple, "(u)", &result);
+ g_variant_unref (tuple);
switch (result)
{
case DBUS_RELEASE_NAME_REPLY_RELEASED:
+ DEBUG ("- released");
return TRUE;
case DBUS_RELEASE_NAME_REPLY_NOT_OWNER:
+ DEBUG ("- not ours");
g_set_error (error, TP_ERROR, TP_ERROR_NOT_YOURS,
"Name '%s' owned by another process", well_known_name);
return FALSE;
case DBUS_RELEASE_NAME_REPLY_NON_EXISTENT:
+ DEBUG ("- not owned");
g_set_error (error, TP_ERROR, TP_ERROR_NOT_AVAILABLE,
"Name '%s' not owned", well_known_name);
return FALSE;
- case -1:
- g_set_error (error, TP_ERROR, TP_ERROR_NOT_AVAILABLE,
- "%s: %s", dbus_error.name, dbus_error.message);
- dbus_error_free (&dbus_error);
- return FALSE;
-
default:
+ DEBUG ("- unexpected code %u", result);
g_set_error (error, TP_ERROR, TP_ERROR_NOT_AVAILABLE,
- "ReleaseName('%s') returned %d and I don't know what that means",
+ "ReleaseName('%s') returned %u and I don't know what that means",
well_known_name, result);
return FALSE;
}
More information about the telepathy-commits
mailing list