00001
00002 #include "dbus-glib.h"
00003 #include <stdio.h>
00004
00005 int
00006 main (int argc, char **argv)
00007 {
00008 DBusConnection *connection;
00009 DBusMessage *message, *reply;
00010 GMainLoop *loop;
00011 DBusError error;
00012
00013 if (argc < 2)
00014 {
00015 g_printerr ("Give the server address as an argument\n");
00016 return 1;
00017 }
00018
00019 loop = g_main_loop_new (NULL, FALSE);
00020
00021 dbus_error_init (&error);
00022 connection = dbus_connection_open (argv[1], &error);
00023 if (connection == NULL)
00024 {
00025 g_printerr ("Failed to open connection to %s: %s\n", argv[1],
00026 error.message);
00027 dbus_error_free (&error);
00028 return 1;
00029 }
00030
00031 dbus_connection_setup_with_g_main (connection, NULL);
00032
00033 message = dbus_message_new (DBUS_MESSAGE_HELLO,
00034 DBUS_SERVICE_DBUS);
00035
00036 dbus_error_init (&error);
00037 reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
00038 if (reply == NULL)
00039 {
00040 g_printerr ("Error on hello message: %s\n", error.message);
00041 dbus_error_free (&error);
00042 return 1;
00043 }
00044
00045 g_print ("reply name: %s\n", dbus_message_get_name (reply));
00046
00047 g_main_loop_run (loop);
00048
00049 return 0;
00050 }