From: Lukasz Skalski Date: Mon, 11 May 2015 15:11:42 +0000 (+0000) Subject: [kdbus] Use new API insted of direct call to org.freedesktop.DBus X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fglib.git;a=commitdiff_plain;h=763a93621a361c3b81005502ee4d404b723034f8 [kdbus] Use new API insted of direct call to org.freedesktop.DBus --- diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c index 95ca329..46d649b 100644 --- a/gio/gapplicationimpl-dbus.c +++ b/gio/gapplicationimpl-dbus.c @@ -346,7 +346,6 @@ g_application_impl_attempt_primary (GApplicationImpl *impl, NULL /* set_property */ }; GApplicationClass *app_class = G_APPLICATION_GET_CLASS (impl->app); - GVariant *reply; guint32 rval; if (org_gtk_Application == NULL) @@ -425,17 +424,11 @@ g_application_impl_attempt_primary (GApplicationImpl *impl, * 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); @@ -479,10 +472,7 @@ g_application_impl_stop_primary (GApplicationImpl *impl) 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; } } diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c index f17a579..09ee399 100644 --- a/gio/gdbus-tool.c +++ b/gio/gdbus-tool.c @@ -265,10 +265,9 @@ static void 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; @@ -276,52 +275,32 @@ print_names (GDBusConnection *c, 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); diff --git a/gio/gdbusnamewatching.c b/gio/gdbusnamewatching.c index feb09dd..2b2735f 100644 --- a/gio/gdbusnamewatching.c +++ b/gio/gdbusnamewatching.c @@ -475,18 +475,21 @@ has_connection (Client *client) 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 {