diff options
author | Ted Gould <ted@gould.cx> | 2010-12-08 10:23:33 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-12-08 10:23:33 -0600 |
commit | 76196aa5c6bab4a47d4ed2238bfda9142c5c6ce4 (patch) | |
tree | ecebec1e2e180131595eac26a4eeeb493625c768 /tests/test-glib-proxy-server.c | |
parent | cc7b24b14152407bbaec45924da989bb8692a2c2 (diff) | |
parent | 1a73825600508b5d7f027641b05a682a8ac81f5e (diff) | |
download | libdbusmenu-76196aa5c6bab4a47d4ed2238bfda9142c5c6ce4.tar.gz libdbusmenu-76196aa5c6bab4a47d4ed2238bfda9142c5c6ce4.tar.bz2 libdbusmenu-76196aa5c6bab4a47d4ed2238bfda9142c5c6ce4.zip |
Switching from dbus-glib to GDBus
Diffstat (limited to 'tests/test-glib-proxy-server.c')
-rw-r--r-- | tests/test-glib-proxy-server.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/tests/test-glib-proxy-server.c b/tests/test-glib-proxy-server.c index f32b426..a5dfd4e 100644 --- a/tests/test-glib-proxy-server.c +++ b/tests/test-glib-proxy-server.c @@ -20,11 +20,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <glib.h> - -#include <dbus/dbus.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> -#include <dbus/dbus-glib-bindings.h> +#include <gio/gio.h> #include <libdbusmenu-glib/menuitem.h> #include <libdbusmenu-glib/server.h> @@ -104,31 +100,36 @@ layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) return; } -int -main (int argc, char ** argv) +static void +on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) { - g_type_init(); - - GError * error = NULL; - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - - g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(connection))); + server = dbusmenu_server_new("/org/test"); + layout_change(NULL, 0, NULL); - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - guint nameret = 0; + return; +} - if (!org_freedesktop_DBus_request_name(bus_proxy, "test.proxy.server", 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } +static void +name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) +{ + g_error("Unable to get name '%s' on DBus", name); + g_main_loop_quit(mainloop); + return; +} - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } +int +main (int argc, char ** argv) +{ + g_type_init(); - server = dbusmenu_server_new("/org/test"); - layout_change(NULL, 0, NULL); + g_bus_own_name(G_BUS_TYPE_SESSION, + "test.proxy.server", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus, + NULL, + name_lost, + NULL, + NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); |