summaryrefslogtreecommitdiffstats
path: root/glib/test-dbus-glib.c
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@codefactory.se>2003-01-21 09:23:18 +0000
committerAnders Carlsson <andersca@codefactory.se>2003-01-21 09:23:18 +0000
commit4a85d321b4516c6a663e8bdd530ba59018c974df (patch)
tree2a78137703eb302a46b068654c31e8aaf8b8bf56 /glib/test-dbus-glib.c
parent84f2a1ad2f867f9397de449365f80c5c003296fa (diff)
2003-01-21 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-connection.c: (dbus_connection_send_message): Add a new client_serial parameter. (dbus_connection_send_message_with_reply): Remove a @todo since we've implemented the blocking function. (dbus_connection_send_message_with_reply_and_block): New function that sends a message and waits for a reply and then returns the reply. * dbus/dbus-connection.h: Add new functions. * dbus/dbus-errors.c: (dbus_result_to_string): * dbus/dbus-errors.h: Add new DBUS_RESULT. * dbus/dbus-message-internal.h: * dbus/dbus-message.c: (_dbus_message_get_reply_serial), (_dbus_message_set_sender), (dbus_message_write_header), (dbus_message_new_reply), (decode_header_data), (_dbus_message_loader_return_buffer), (_dbus_message_test): * dbus/dbus-message.h: Add new functions that set the reply serial and sender. Also marshal and demarshal them correctly and add test. * dbus/dbus-protocol.h: Add new DBUS_MESSAGE_TYPE_SENDER. * glib/dbus-glib.h: * glib/dbus-gmain.c: (watch_callback), (free_callback_data), (add_watch), (remove_watch), (add_timeout), (remove_timeout), (dbus_connection_hookup_with_g_main): * glib/test-dbus-glib.c: (main): Rewrite to use GIOChannel and remove the GSource crack. * test/echo-client.c: (main): * test/watch.c: (check_messages): Update for changed APIs
Diffstat (limited to 'glib/test-dbus-glib.c')
-rw-r--r--glib/test-dbus-glib.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/glib/test-dbus-glib.c b/glib/test-dbus-glib.c
index cdce2899..ad147e50 100644
--- a/glib/test-dbus-glib.c
+++ b/glib/test-dbus-glib.c
@@ -1,37 +1,14 @@
#include "dbus-glib.h"
#include <stdio.h>
-GMainLoop *loop;
-
-static void
-message_handler (DBusConnection *connection,
- DBusMessage *message, gpointer user_data)
-{
- static int count = 0;
- DBusMessage *reply;
-
- reply = dbus_message_new ("org.freedesktop.DBus.Test", "org.freedesktop.DBus.Test");
- dbus_connection_send_message (connection,
- reply,
- NULL);
- dbus_message_unref (reply);
- count += 1;
-
- if (count > 100)
- {
- printf ("Saw %d messages, exiting\n", count);
- g_main_loop_quit (loop);
- }
-}
-
int
main (int argc, char **argv)
{
- GSource *source;
-
DBusConnection *connection;
DBusResultCode result;
- DBusMessage *message;
+ DBusMessage *message, *reply;
+
+ GMainLoop *loop;
loop = g_main_loop_new (NULL, FALSE);
@@ -43,16 +20,15 @@ main (int argc, char **argv)
return 1;
}
- source = dbus_connection_gsource_new (connection);
- g_source_attach (source, NULL);
- g_source_set_callback (source, (GSourceFunc)message_handler, NULL, NULL);
-
- message = dbus_message_new ("org.freedesktop.DBus.Test", "org.freedesktop.DBus.Test");
- dbus_connection_send_message (connection,
- message,
- NULL);
- dbus_message_unref (message);
-
+ dbus_connection_hookup_with_g_main (connection);
+
+ message = dbus_message_new ("org.freedesktop.DBus", "org.freedesktop.DBus.Hello");
+ dbus_message_append_fields (message,
+ DBUS_TYPE_STRING, "glib-test",
+ 0);
+
+ reply = dbus_connection_send_message_with_reply_and_block (connection, message, -1, &result);
+ g_print ("reply name: %s\n", dbus_message_get_name (reply));
g_main_loop_run (loop);