summaryrefslogtreecommitdiff
path: root/test/echo-client.c
blob: 5c6ee4254cec9eb9a419ed08f5f53b809cbc1bc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <dbus/dbus.h>
#include <stdio.h>
#include "watch.h"

int
main (int    argc,
      char **argv)
{
  DBusConnection *connection;
  DBusResultCode result;
  DBusMessage *message;
  
  if (argc < 2)
    {
      fprintf (stderr, "Give the server address as an argument\n");
      return 1;
    }
  
  connection = dbus_connection_open (argv[1], &result);
  if (connection == NULL)
    {
      fprintf (stderr, "Failed to open connection to %s: %s\n",
               argv[1], dbus_result_to_string (result));
      return 1;
    }

  setup_connection (connection);

  /* Send a message to get things going */
  message = dbus_message_new ();
  dbus_connection_send_message (connection,
                                message,
                                NULL);
  dbus_message_unref (message);
  
  do_mainloop ();

  dbus_connection_unref (connection);
  
  return 0;
}