1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-connection.h DBusConnection object
4 * Copyright (C) 2002 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
23 #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
24 #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
27 #ifndef DBUS_CONNECTION_H
28 #define DBUS_CONNECTION_H
30 #include <dbus/dbus-errors.h>
31 #include <dbus/dbus-message.h>
32 #include <dbus/dbus-memory.h>
36 typedef struct DBusConnection DBusConnection;
37 typedef struct DBusWatch DBusWatch;
38 typedef struct DBusTimeout DBusTimeout;
39 typedef struct DBusMessageHandler DBusMessageHandler;
43 DBUS_HANDLER_RESULT_REMOVE_MESSAGE, /**< Remove this message, no further processing. */
44 DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS /**< Run any additional handlers that are interested in this message. */
49 DBUS_WATCH_READABLE = 1 << 0, /**< As in POLLIN */
50 DBUS_WATCH_WRITABLE = 1 << 1, /**< As in POLLOUT */
51 DBUS_WATCH_ERROR = 1 << 2, /**< As in POLLERR (can't watch for this, but
52 * the flag can be passed to dbus_connection_handle_watch()).
54 DBUS_WATCH_HANGUP = 1 << 3 /**< As in POLLHUP (can't watch for it, but
55 * can be present in current state). */
58 typedef void (* DBusAddWatchFunction) (DBusWatch *watch,
61 typedef void (* DBusRemoveWatchFunction) (DBusWatch *watch,
64 typedef void (* DBusAddTimeoutFunction) (DBusTimeout *timeout,
66 typedef void (* DBusRemoveTimeoutFunction) (DBusTimeout *timeout,
69 typedef void (* DBusDisconnectFunction) (DBusConnection *connection,
72 DBusConnection* dbus_connection_open (const char *address,
73 DBusResultCode *result);
74 void dbus_connection_ref (DBusConnection *connection);
75 void dbus_connection_unref (DBusConnection *connection);
76 void dbus_connection_disconnect (DBusConnection *connection);
77 dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection);
78 dbus_bool_t dbus_connection_get_is_authenticated (DBusConnection *connection);
79 void dbus_connection_flush (DBusConnection *connection);
80 int dbus_connection_get_n_messages (DBusConnection *connection);
81 DBusMessage* dbus_connection_peek_message (DBusConnection *connection);
82 DBusMessage* dbus_connection_pop_message (DBusConnection *connection);
83 dbus_bool_t dbus_connection_dispatch_message (DBusConnection *connection);
85 dbus_bool_t dbus_connection_send_message (DBusConnection *connection,
87 DBusResultCode *result);
88 dbus_bool_t dbus_connection_send_message_with_reply (DBusConnection *connection,
90 DBusMessageHandler *reply_handler,
91 int timeout_milliseconds,
92 DBusResultCode *result);
94 void dbus_connection_set_disconnect_function (DBusConnection *connection,
95 DBusDisconnectFunction function,
97 DBusFreeFunction free_data_function);
98 void dbus_connection_set_watch_functions (DBusConnection *connection,
99 DBusAddWatchFunction add_function,
100 DBusRemoveWatchFunction remove_function,
102 DBusFreeFunction free_data_function);
103 void dbus_connection_set_timeout_functions (DBusConnection *connection,
104 DBusAddTimeoutFunction add_function,
105 DBusRemoveTimeoutFunction remove_function,
107 DBusFreeFunction free_data_function);
108 void dbus_connection_handle_watch (DBusConnection *connection,
110 unsigned int condition);
114 int dbus_watch_get_fd (DBusWatch *watch);
115 unsigned int dbus_watch_get_flags (DBusWatch *watch);
116 void* dbus_watch_get_data (DBusWatch *watch);
117 void dbus_watch_set_data (DBusWatch *watch,
119 DBusFreeFunction free_data_function);
121 int dbus_timeout_get_interval (DBusTimeout *timeout);
122 void* dbus_timeout_get_data (DBusTimeout *timeout);
123 void dbus_timeout_set_data (DBusTimeout *timeout,
125 DBusFreeFunction free_data_function);
126 void dbus_timeout_handle (DBusTimeout *timeout);
130 dbus_bool_t dbus_connection_add_filter (DBusConnection *connection,
131 DBusMessageHandler *handler);
132 void dbus_connection_remove_filter (DBusConnection *connection,
133 DBusMessageHandler *handler);
135 dbus_bool_t dbus_connection_register_handler (DBusConnection *connection,
136 DBusMessageHandler *handler,
137 const char **messages_to_handle,
139 void dbus_connection_unregister_handler (DBusConnection *connection,
140 DBusMessageHandler *handler,
141 const char **messages_to_handle,
145 int dbus_connection_allocate_data_slot (void);
146 void dbus_connection_free_data_slot (int slot);
147 dbus_bool_t dbus_connection_set_data (DBusConnection *connection,
150 DBusFreeFunction free_data_func);
151 void* dbus_connection_get_data (DBusConnection *connection,
154 void dbus_connection_set_max_message_size (DBusConnection *connection,
156 long dbus_connection_get_max_message_size (DBusConnection *connection);
157 void dbus_connection_set_max_live_messages_size (DBusConnection *connection,
159 long dbus_connection_get_max_live_messages_size (DBusConnection *connection);
164 #endif /* DBUS_CONNECTION_H */