aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-11-16 17:16:45 -0600
committerTed Gould <ted@gould.cx>2010-11-16 17:16:45 -0600
commitb0a7118fc4581f07b42c25ce02bda01fd1604097 (patch)
tree1befed53a9819b90dcfeb6006ba046d05fcfaaac
parentb856f7cd47db470f4369aa28ad87dc1925bf68a5 (diff)
downloadlibdbusmenu-b0a7118fc4581f07b42c25ce02bda01fd1604097.tar.gz
libdbusmenu-b0a7118fc4581f07b42c25ce02bda01fd1604097.tar.bz2
libdbusmenu-b0a7118fc4581f07b42c25ce02bda01fd1604097.zip
Chaning to get dbus names via GDBus
-rw-r--r--tests/test-glib-simple-items.c3
-rw-r--r--tests/test-glib-submenu-server.c53
-rw-r--r--tests/test-gtk-label-server.c52
-rw-r--r--tests/test-gtk-reorder-server.c55
-rw-r--r--tests/test-gtk-shortcut-server.c53
5 files changed, 110 insertions, 106 deletions
diff --git a/tests/test-glib-simple-items.c b/tests/test-glib-simple-items.c
index 5b9f538..3ea5480 100644
--- a/tests/test-glib-simple-items.c
+++ b/tests/test-glib-simple-items.c
@@ -1,6 +1,3 @@
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-glib/menuitem.h>
diff --git a/tests/test-glib-submenu-server.c b/tests/test-glib-submenu-server.c
index 68f7004..73362c1 100644
--- a/tests/test-glib-submenu-server.c
+++ b/tests/test-glib-submenu-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/server.h>
#include <libdbusmenu-glib/menuitem.h>
@@ -72,33 +68,38 @@ timer_func (gpointer data)
return TRUE;
}
-int
-main (int argc, char ** argv)
+static void
+on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data)
{
- GError * error = NULL;
-
- g_type_init();
-
- 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(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
+ server = dbusmenu_server_new("/org/test");
- DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- guint nameret = 0;
+ timer_func(NULL);
+ g_timeout_add(2500, timer_func, NULL);
- if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) {
- g_error("Unable to call to request name");
- return 1;
- }
+ return;
+}
- if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- g_error("Unable to get 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;
+}
- server = dbusmenu_server_new("/org/test");
+int
+main (int argc, char ** argv)
+{
+ g_type_init();
- timer_func(NULL);
- g_timeout_add(2500, timer_func, NULL);
+ g_bus_own_name(G_BUS_TYPE_SESSION,
+ "org.dbusmenu.test",
+ 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);
diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c
index 32572fc..ddf8fcf 100644
--- a/tests/test-gtk-label-server.c
+++ b/tests/test-gtk-label-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>
@@ -53,6 +49,25 @@ timer_func (gpointer data)
return TRUE;
}
+static void
+on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data)
+{
+ server = dbusmenu_server_new("/org/test");
+
+ timer_func(NULL);
+ g_timeout_add_seconds(5, timer_func, NULL);
+
+ return;
+}
+
+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;
+}
+
int
main (int argc, char ** argv)
{
@@ -73,26 +88,15 @@ main (int argc, char ** argv)
root_array = json_node_get_array(root_node);
g_debug("%d layouts in test description '%s'", json_array_get_length(root_array), argv[1]);
- 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(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
- DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- guint nameret = 0;
-
- if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) {
- g_error("Unable to call to request name");
- return 1;
- }
-
- if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- g_error("Unable to get name");
- return 1;
- }
-
- server = dbusmenu_server_new("/org/test");
-
- timer_func(NULL);
- g_timeout_add_seconds(5, timer_func, NULL);
+ g_bus_own_name(G_BUS_TYPE_SESSION,
+ "glib.label.test",
+ 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);
diff --git a/tests/test-gtk-reorder-server.c b/tests/test-gtk-reorder-server.c
index eee9bb8..44209f1 100644
--- a/tests/test-gtk-reorder-server.c
+++ b/tests/test-gtk-reorder-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>
@@ -73,29 +69,9 @@ timer_func (gpointer data)
return TRUE;
}
-int
-main (int argc, char ** argv)
+static void
+on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data)
{
- GError * error = NULL;
-
- g_type_init();
-
- 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(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
-
- DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- guint nameret = 0;
-
- if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) {
- g_error("Unable to call to request name");
- return 1;
- }
-
- if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- g_error("Unable to get name");
- return 1;
- }
-
server = dbusmenu_server_new("/org/test");
root = dbusmenu_menuitem_new();
dbusmenu_server_set_root(server, root);
@@ -109,6 +85,31 @@ main (int argc, char ** argv)
timer_func(NULL);
g_timeout_add_seconds(5, timer_func, NULL);
+ return;
+}
+
+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;
+}
+
+int
+main (int argc, char ** argv)
+{
+ g_type_init();
+
+ g_bus_own_name(G_BUS_TYPE_SESSION,
+ "glib.label.test",
+ 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);
diff --git a/tests/test-gtk-shortcut-server.c b/tests/test-gtk-shortcut-server.c
index 3b703a1..b205d03 100644
--- a/tests/test-gtk-shortcut-server.c
+++ b/tests/test-gtk-shortcut-server.c
@@ -20,13 +20,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib.h>
+#include <gio/gio.h>
#include <gdk/gdkkeysyms.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib-bindings.h>
-
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-gtk/menuitem.h>
@@ -61,33 +57,38 @@ build_menu (void)
return;
}
-int
-main (int argc, char ** argv)
+static void
+on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data)
{
- GError * error = NULL;
-
- g_type_init();
-
- 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(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
+ server = dbusmenu_server_new("/org/test");
+ build_menu();
- DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- guint nameret = 0;
+ g_timeout_add_seconds(10, timer_func, NULL);
- if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) {
- g_error("Unable to call to request name");
- return 1;
- }
+ return;
+}
- if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- g_error("Unable to get 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;
+}
- server = dbusmenu_server_new("/org/test");
- build_menu();
+int
+main (int argc, char ** argv)
+{
+ g_type_init();
- g_timeout_add_seconds(10, timer_func, NULL);
+ g_bus_own_name(G_BUS_TYPE_SESSION,
+ "glib.label.test",
+ 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);