NULL /* set_property */
};
GApplicationClass *app_class = G_APPLICATION_GET_CLASS (impl->app);
- GVariant *reply;
guint32 rval;
if (org_gtk_Application == NULL)
* in the case that we can't do that.
*/
/* DBUS_NAME_FLAG_DO_NOT_QUEUE: 0x4 */
- reply = g_dbus_connection_call_sync (impl->session_bus, "org.freedesktop.DBus", "/org/freedesktop/DBus",
- "org.freedesktop.DBus", "RequestName",
- g_variant_new ("(su)", impl->bus_name, 0x4), G_VARIANT_TYPE ("(u)"),
- 0, -1, cancellable, error);
+ rval = g_dbus_request_name (impl->session_bus, impl->bus_name, G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE, error);
- if (reply == NULL)
+ if (rval == G_BUS_REQUEST_NAME_FLAGS_ERROR)
return FALSE;
- g_variant_get (reply, "(u)", &rval);
- g_variant_unref (reply);
-
/* DBUS_REQUEST_NAME_REPLY_EXISTS: 3 */
impl->primary = (rval != 3);
if (impl->primary && impl->bus_name)
{
- g_dbus_connection_call (impl->session_bus, "org.freedesktop.DBus",
- "/org/freedesktop/DBus", "org.freedesktop.DBus",
- "ReleaseName", g_variant_new ("(s)", impl->bus_name),
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+ g_dbus_release_name (impl->session_bus, impl->bus_name, NULL);
impl->primary = FALSE;
}
}
print_names (GDBusConnection *c,
gboolean include_unique_names)
{
- GVariant *result;
+ gchar **list_names;
GError *error;
- GVariantIter *iter;
- gchar *str;
+ guint cnt;
GHashTable *name_set;
GList *keys;
GList *l;
name_set = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
error = NULL;
- result = g_dbus_connection_call_sync (c,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus",
- "ListNames",
- NULL,
- G_VARIANT_TYPE ("(as)"),
- G_DBUS_CALL_FLAGS_NONE,
- 3000, /* 3 secs */
- NULL,
- &error);
- if (result == NULL)
+ cnt = 0;
+ list_names = g_dbus_get_list_names (c, &error);
+ if (list_names == NULL)
{
g_printerr (_("Error: %s\n"), error->message);
g_error_free (error);
goto out;
}
- g_variant_get (result, "(as)", &iter);
- while (g_variant_iter_loop (iter, "s", &str))
- g_hash_table_insert (name_set, g_strdup (str), NULL);
- g_variant_iter_free (iter);
- g_variant_unref (result);
+
+ while (list_names[cnt])
+ g_hash_table_insert (name_set, g_strdup (list_names[cnt++]), NULL);
+ g_strfreev(list_names);
error = NULL;
- result = g_dbus_connection_call_sync (c,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus",
- "ListActivatableNames",
- NULL,
- G_VARIANT_TYPE ("(as)"),
- G_DBUS_CALL_FLAGS_NONE,
- 3000, /* 3 secs */
- NULL,
- &error);
- if (result == NULL)
+ cnt = 0;
+ list_names = g_dbus_get_list_activatable_names (c, &error);
+ if (list_names == NULL)
{
g_printerr (_("Error: %s\n"), error->message);
g_error_free (error);
goto out;
}
- g_variant_get (result, "(as)", &iter);
- while (g_variant_iter_loop (iter, "s", &str))
- g_hash_table_insert (name_set, g_strdup (str), NULL);
- g_variant_iter_free (iter);
- g_variant_unref (result);
+
+ while (list_names[cnt])
+ g_hash_table_insert (name_set, g_strdup (list_names[cnt++]), NULL);
+ g_strfreev(list_names);
keys = g_hash_table_get_keys (name_set);
keys = g_list_sort (keys, (GCompareFunc) g_strcmp0);
if (client->flags & G_BUS_NAME_WATCHER_FLAGS_AUTO_START)
{
- g_dbus_connection_call (client->connection,
- "org.freedesktop.DBus", /* bus name */
- "/org/freedesktop/DBus", /* object path */
- "org.freedesktop.DBus", /* interface name */
- "StartServiceByName", /* method name */
- g_variant_new ("(su)", client->name, 0),
- G_VARIANT_TYPE ("(u)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- (GAsyncReadyCallback) start_service_by_name_cb,
- client_ref (client));
+ if (_g_dbus_connection_is_kdbus (client->connection))
+ g_error ("TODO: Implement StartServiceByName\n");
+ else
+ g_dbus_connection_call (client->connection,
+ "org.freedesktop.DBus", /* bus name */
+ "/org/freedesktop/DBus", /* object path */
+ "org.freedesktop.DBus", /* interface name */
+ "StartServiceByName", /* method name */
+ g_variant_new ("(su)", client->name, 0),
+ G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback) start_service_by_name_cb,
+ client_ref (client));
}
else
{