1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* main.c main() for message bus
4 * Copyright (C) 2003 Red Hat, Inc.
6 * Licensed under the Academic Free License version 1.2
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "connection.h"
26 #include <dbus/dbus-list.h>
29 server_watch_callback (DBusWatch *watch,
30 unsigned int condition,
33 DBusServer *server = data;
35 dbus_server_handle_watch (server, watch, condition);
39 add_server_watch (DBusWatch *watch,
42 bus_loop_add_watch (watch, server_watch_callback, server,
47 remove_server_watch (DBusWatch *watch,
50 bus_loop_remove_watch (watch, server_watch_callback, server);
54 setup_server (DBusServer *server)
56 dbus_server_set_watch_functions (server,
57 (DBusAddWatchFunction) add_server_watch,
58 (DBusRemoveWatchFunction) remove_server_watch,
64 new_connection_callback (DBusServer *server,
65 DBusConnection *new_connection,
68 if (!bus_connection_setup (new_connection))
69 ; /* we won't have ref'd the connection so it will die */
73 main (int argc, char **argv)
76 DBusResultCode result;
80 _dbus_warn ("Give the server address as an argument\n");
84 server = dbus_server_listen (argv[1], &result);
87 _dbus_warn ("Failed to start server on %s: %s\n",
88 argv[1], dbus_result_to_string (result));
92 setup_server (server);
94 bus_connection_init ();
96 dbus_server_set_new_connection_function (server,
97 new_connection_callback,
100 _dbus_verbose ("We are on D-Bus...\n");
103 dbus_server_disconnect (server);
104 dbus_server_unref (server);