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-memory.h>
32 #include <dbus/dbus-object.h>
36 typedef struct DBusWatch DBusWatch;
37 typedef struct DBusTimeout DBusTimeout;
38 typedef struct DBusMessageHandler DBusMessageHandler;
39 typedef struct DBusPreallocatedSend DBusPreallocatedSend;
40 typedef struct DBusPendingCall DBusPendingCall;
44 DBUS_WATCH_READABLE = 1 << 0, /**< As in POLLIN */
45 DBUS_WATCH_WRITABLE = 1 << 1, /**< As in POLLOUT */
46 DBUS_WATCH_ERROR = 1 << 2, /**< As in POLLERR (can't watch for this, but
47 * the flag can be passed to dbus_watch_handle()).
49 DBUS_WATCH_HANGUP = 1 << 3 /**< As in POLLHUP (can't watch for it, but
50 * can be present in current state). */
55 DBUS_DISPATCH_DATA_REMAINS, /**< There is more data to potentially convert to messages. */
56 DBUS_DISPATCH_COMPLETE, /**< All currently available data has been processed. */
57 DBUS_DISPATCH_NEED_MEMORY /**< More memory is needed to continue. */
60 typedef dbus_bool_t (* DBusAddWatchFunction) (DBusWatch *watch,
62 typedef void (* DBusWatchToggledFunction) (DBusWatch *watch,
64 typedef void (* DBusRemoveWatchFunction) (DBusWatch *watch,
66 typedef dbus_bool_t (* DBusAddTimeoutFunction) (DBusTimeout *timeout,
68 typedef void (* DBusTimeoutToggledFunction) (DBusTimeout *timeout,
70 typedef void (* DBusRemoveTimeoutFunction) (DBusTimeout *timeout,
72 typedef void (* DBusDispatchStatusFunction) (DBusConnection *connection,
73 DBusDispatchStatus new_status,
75 typedef void (* DBusWakeupMainFunction) (void *data);
76 typedef dbus_bool_t (* DBusAllowUnixUserFunction) (DBusConnection *connection,
80 typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending,
83 DBusConnection* dbus_connection_open (const char *address,
85 void dbus_connection_ref (DBusConnection *connection);
86 void dbus_connection_unref (DBusConnection *connection);
87 void dbus_connection_disconnect (DBusConnection *connection);
88 dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection);
89 dbus_bool_t dbus_connection_get_is_authenticated (DBusConnection *connection);
90 void dbus_connection_flush (DBusConnection *connection);
91 DBusMessage* dbus_connection_borrow_message (DBusConnection *connection);
92 void dbus_connection_return_message (DBusConnection *connection,
93 DBusMessage *message);
94 void dbus_connection_steal_borrowed_message (DBusConnection *connection,
95 DBusMessage *message);
96 DBusMessage* dbus_connection_pop_message (DBusConnection *connection);
97 DBusDispatchStatus dbus_connection_get_dispatch_status (DBusConnection *connection);
98 DBusDispatchStatus dbus_connection_dispatch (DBusConnection *connection);
99 dbus_bool_t dbus_connection_send (DBusConnection *connection,
100 DBusMessage *message,
101 dbus_uint32_t *client_serial);
102 dbus_bool_t dbus_connection_send_with_reply (DBusConnection *connection,
103 DBusMessage *message,
104 DBusPendingCall **pending_return,
105 int timeout_milliseconds);
106 DBusMessage * dbus_connection_send_with_reply_and_block (DBusConnection *connection,
107 DBusMessage *message,
108 int timeout_milliseconds,
110 dbus_bool_t dbus_connection_set_watch_functions (DBusConnection *connection,
111 DBusAddWatchFunction add_function,
112 DBusRemoveWatchFunction remove_function,
113 DBusWatchToggledFunction toggled_function,
115 DBusFreeFunction free_data_function);
116 dbus_bool_t dbus_connection_set_timeout_functions (DBusConnection *connection,
117 DBusAddTimeoutFunction add_function,
118 DBusRemoveTimeoutFunction remove_function,
119 DBusTimeoutToggledFunction toggled_function,
121 DBusFreeFunction free_data_function);
122 void dbus_connection_set_wakeup_main_function (DBusConnection *connection,
123 DBusWakeupMainFunction wakeup_main_function,
125 DBusFreeFunction free_data_function);
126 void dbus_connection_set_dispatch_status_function (DBusConnection *connection,
127 DBusDispatchStatusFunction function,
129 DBusFreeFunction free_data_function);
130 dbus_bool_t dbus_connection_get_unix_user (DBusConnection *connection,
132 void dbus_connection_set_unix_user_function (DBusConnection *connection,
133 DBusAllowUnixUserFunction function,
135 DBusFreeFunction free_data_function);
138 int dbus_watch_get_fd (DBusWatch *watch);
139 unsigned int dbus_watch_get_flags (DBusWatch *watch);
140 void* dbus_watch_get_data (DBusWatch *watch);
141 void dbus_watch_set_data (DBusWatch *watch,
143 DBusFreeFunction free_data_function);
144 dbus_bool_t dbus_watch_handle (DBusWatch *watch,
146 dbus_bool_t dbus_watch_get_enabled (DBusWatch *watch);
148 int dbus_timeout_get_interval (DBusTimeout *timeout);
149 void* dbus_timeout_get_data (DBusTimeout *timeout);
150 void dbus_timeout_set_data (DBusTimeout *timeout,
152 DBusFreeFunction free_data_function);
153 dbus_bool_t dbus_timeout_handle (DBusTimeout *timeout);
154 dbus_bool_t dbus_timeout_get_enabled (DBusTimeout *timeout);
157 dbus_bool_t dbus_connection_add_filter (DBusConnection *connection,
158 DBusMessageHandler *handler);
159 void dbus_connection_remove_filter (DBusConnection *connection,
160 DBusMessageHandler *handler);
163 dbus_bool_t dbus_connection_register_object (DBusConnection *connection,
164 const char **interfaces,
165 const DBusObjectVTable *vtable,
167 DBusObjectID *object_id);
168 void dbus_connection_unregister_object (DBusConnection *connection,
169 const DBusObjectID *object_id);
173 dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t *slot_p);
174 void dbus_connection_free_data_slot (dbus_int32_t *slot_p);
175 dbus_bool_t dbus_connection_set_data (DBusConnection *connection,
178 DBusFreeFunction free_data_func);
179 void* dbus_connection_get_data (DBusConnection *connection,
182 void dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe);
184 void dbus_connection_set_max_message_size (DBusConnection *connection,
186 long dbus_connection_get_max_message_size (DBusConnection *connection);
187 void dbus_connection_set_max_received_size (DBusConnection *connection,
189 long dbus_connection_get_max_received_size (DBusConnection *connection);
190 long dbus_connection_get_outgoing_size (DBusConnection *connection);
192 DBusPreallocatedSend* dbus_connection_preallocate_send (DBusConnection *connection);
193 void dbus_connection_free_preallocated_send (DBusConnection *connection,
194 DBusPreallocatedSend *preallocated);
195 void dbus_connection_send_preallocated (DBusConnection *connection,
196 DBusPreallocatedSend *preallocated,
197 DBusMessage *message,
198 dbus_uint32_t *client_serial);
201 /* Object tree functionality */
203 typedef struct DBusObjectTreeVTable DBusObjectTreeVTable;
205 typedef void (* DBusObjectTreeUnregisterFunction) (DBusConnection *connection,
208 typedef DBusHandlerResult (* DBusObjectTreeMessageFunction) (DBusConnection *connection,
209 DBusMessage *message,
211 typedef dbus_bool_t (* DBusObjectTreeSubdirsFunction) (DBusConnection *connection,
216 typedef dbus_bool_t (* DBusObjectTreeObjectsFunction) (DBusConnection *connection,
218 DBusObjectID **object_ids,
221 typedef dbus_bool_t (* DBusObjectTreeMethodsFunction) (DBusConnection *connection,
223 DBusObjectID **object_ids,
227 struct DBusObjectTreeVTable
229 DBusObjectTreeUnregisterFunction unregister_function;
230 DBusObjectTreeMessageFunction message_function;
231 DBusObjectTreeSubdirsFunction subdirs_function;
232 DBusObjectTreeObjectsFunction objects_function;
233 DBusObjectTreeMethodsFunction methods_function;
235 void (* dbus_internal_pad1) (void *);
236 void (* dbus_internal_pad2) (void *);
237 void (* dbus_internal_pad3) (void *);
238 void (* dbus_internal_pad4) (void *);
241 dbus_bool_t dbus_connection_register_object_tree (DBusConnection *connection,
243 const DBusObjectTreeVTable *vtable,
245 void dbus_connection_unregister_object_tree (DBusConnection *connection,
251 #endif /* DBUS_CONNECTION_H */