D-Bus
1.4.16
|
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 00002 /* dbus-connection.h DBusConnection object 00003 * 00004 * Copyright (C) 2002, 2003 Red Hat Inc. 00005 * 00006 * Licensed under the Academic Free License version 2.1 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 */ 00023 #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) 00024 #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents." 00025 #endif 00026 00027 #ifndef DBUS_CONNECTION_H 00028 #define DBUS_CONNECTION_H 00029 00030 #include <dbus/dbus-errors.h> 00031 #include <dbus/dbus-memory.h> 00032 #include <dbus/dbus-message.h> 00033 #include <dbus/dbus-shared.h> 00034 00035 DBUS_BEGIN_DECLS 00036 00042 /* documented in dbus-watch.c */ 00043 typedef struct DBusWatch DBusWatch; 00044 /* documented in dbus-timeout.c */ 00045 typedef struct DBusTimeout DBusTimeout; 00047 typedef struct DBusPreallocatedSend DBusPreallocatedSend; 00049 typedef struct DBusPendingCall DBusPendingCall; 00051 typedef struct DBusConnection DBusConnection; 00053 typedef struct DBusObjectPathVTable DBusObjectPathVTable; 00054 00058 typedef enum 00059 { 00060 DBUS_WATCH_READABLE = 1 << 0, 00061 DBUS_WATCH_WRITABLE = 1 << 1, 00062 DBUS_WATCH_ERROR = 1 << 2, 00067 DBUS_WATCH_HANGUP = 1 << 3 00072 } DBusWatchFlags; 00073 00078 typedef enum 00079 { 00080 DBUS_DISPATCH_DATA_REMAINS, 00081 DBUS_DISPATCH_COMPLETE, 00082 DBUS_DISPATCH_NEED_MEMORY 00083 } DBusDispatchStatus; 00084 00090 typedef dbus_bool_t (* DBusAddWatchFunction) (DBusWatch *watch, 00091 void *data); 00096 typedef void (* DBusWatchToggledFunction) (DBusWatch *watch, 00097 void *data); 00102 typedef void (* DBusRemoveWatchFunction) (DBusWatch *watch, 00103 void *data); 00109 typedef dbus_bool_t (* DBusAddTimeoutFunction) (DBusTimeout *timeout, 00110 void *data); 00116 typedef void (* DBusTimeoutToggledFunction) (DBusTimeout *timeout, 00117 void *data); 00122 typedef void (* DBusRemoveTimeoutFunction) (DBusTimeout *timeout, 00123 void *data); 00127 typedef void (* DBusDispatchStatusFunction) (DBusConnection *connection, 00128 DBusDispatchStatus new_status, 00129 void *data); 00134 typedef void (* DBusWakeupMainFunction) (void *data); 00135 00142 typedef dbus_bool_t (* DBusAllowUnixUserFunction) (DBusConnection *connection, 00143 unsigned long uid, 00144 void *data); 00145 00152 typedef dbus_bool_t (* DBusAllowWindowsUserFunction) (DBusConnection *connection, 00153 const char *user_sid, 00154 void *data); 00155 00156 00161 typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending, 00162 void *user_data); 00163 00168 typedef DBusHandlerResult (* DBusHandleMessageFunction) (DBusConnection *connection, 00169 DBusMessage *message, 00170 void *user_data); 00171 DBUS_EXPORT 00172 DBusConnection* dbus_connection_open (const char *address, 00173 DBusError *error); 00174 DBUS_EXPORT 00175 DBusConnection* dbus_connection_open_private (const char *address, 00176 DBusError *error); 00177 DBUS_EXPORT 00178 DBusConnection* dbus_connection_ref (DBusConnection *connection); 00179 DBUS_EXPORT 00180 void dbus_connection_unref (DBusConnection *connection); 00181 DBUS_EXPORT 00182 void dbus_connection_close (DBusConnection *connection); 00183 DBUS_EXPORT 00184 dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection); 00185 DBUS_EXPORT 00186 dbus_bool_t dbus_connection_get_is_authenticated (DBusConnection *connection); 00187 DBUS_EXPORT 00188 dbus_bool_t dbus_connection_get_is_anonymous (DBusConnection *connection); 00189 DBUS_EXPORT 00190 char* dbus_connection_get_server_id (DBusConnection *connection); 00191 DBUS_EXPORT 00192 dbus_bool_t dbus_connection_can_send_type (DBusConnection *connection, 00193 int type); 00194 00195 DBUS_EXPORT 00196 void dbus_connection_set_exit_on_disconnect (DBusConnection *connection, 00197 dbus_bool_t exit_on_disconnect); 00198 DBUS_EXPORT 00199 void dbus_connection_flush (DBusConnection *connection); 00200 DBUS_EXPORT 00201 dbus_bool_t dbus_connection_read_write_dispatch (DBusConnection *connection, 00202 int timeout_milliseconds); 00203 DBUS_EXPORT 00204 dbus_bool_t dbus_connection_read_write (DBusConnection *connection, 00205 int timeout_milliseconds); 00206 DBUS_EXPORT 00207 DBusMessage* dbus_connection_borrow_message (DBusConnection *connection); 00208 DBUS_EXPORT 00209 void dbus_connection_return_message (DBusConnection *connection, 00210 DBusMessage *message); 00211 DBUS_EXPORT 00212 void dbus_connection_steal_borrowed_message (DBusConnection *connection, 00213 DBusMessage *message); 00214 DBUS_EXPORT 00215 DBusMessage* dbus_connection_pop_message (DBusConnection *connection); 00216 DBUS_EXPORT 00217 DBusDispatchStatus dbus_connection_get_dispatch_status (DBusConnection *connection); 00218 DBUS_EXPORT 00219 DBusDispatchStatus dbus_connection_dispatch (DBusConnection *connection); 00220 DBUS_EXPORT 00221 dbus_bool_t dbus_connection_has_messages_to_send (DBusConnection *connection); 00222 DBUS_EXPORT 00223 dbus_bool_t dbus_connection_send (DBusConnection *connection, 00224 DBusMessage *message, 00225 dbus_uint32_t *client_serial); 00226 DBUS_EXPORT 00227 dbus_bool_t dbus_connection_send_with_reply (DBusConnection *connection, 00228 DBusMessage *message, 00229 DBusPendingCall **pending_return, 00230 int timeout_milliseconds); 00231 DBUS_EXPORT 00232 DBusMessage * dbus_connection_send_with_reply_and_block (DBusConnection *connection, 00233 DBusMessage *message, 00234 int timeout_milliseconds, 00235 DBusError *error); 00236 DBUS_EXPORT 00237 dbus_bool_t dbus_connection_set_watch_functions (DBusConnection *connection, 00238 DBusAddWatchFunction add_function, 00239 DBusRemoveWatchFunction remove_function, 00240 DBusWatchToggledFunction toggled_function, 00241 void *data, 00242 DBusFreeFunction free_data_function); 00243 DBUS_EXPORT 00244 dbus_bool_t dbus_connection_set_timeout_functions (DBusConnection *connection, 00245 DBusAddTimeoutFunction add_function, 00246 DBusRemoveTimeoutFunction remove_function, 00247 DBusTimeoutToggledFunction toggled_function, 00248 void *data, 00249 DBusFreeFunction free_data_function); 00250 DBUS_EXPORT 00251 void dbus_connection_set_wakeup_main_function (DBusConnection *connection, 00252 DBusWakeupMainFunction wakeup_main_function, 00253 void *data, 00254 DBusFreeFunction free_data_function); 00255 DBUS_EXPORT 00256 void dbus_connection_set_dispatch_status_function (DBusConnection *connection, 00257 DBusDispatchStatusFunction function, 00258 void *data, 00259 DBusFreeFunction free_data_function); 00260 DBUS_EXPORT 00261 dbus_bool_t dbus_connection_get_unix_user (DBusConnection *connection, 00262 unsigned long *uid); 00263 DBUS_EXPORT 00264 dbus_bool_t dbus_connection_get_unix_process_id (DBusConnection *connection, 00265 unsigned long *pid); 00266 DBUS_EXPORT 00267 dbus_bool_t dbus_connection_get_adt_audit_session_data (DBusConnection *connection, 00268 void **data, 00269 dbus_int32_t *data_size); 00270 DBUS_EXPORT 00271 void dbus_connection_set_unix_user_function (DBusConnection *connection, 00272 DBusAllowUnixUserFunction function, 00273 void *data, 00274 DBusFreeFunction free_data_function); 00275 DBUS_EXPORT 00276 dbus_bool_t dbus_connection_get_windows_user (DBusConnection *connection, 00277 char **windows_sid_p); 00278 DBUS_EXPORT 00279 void dbus_connection_set_windows_user_function (DBusConnection *connection, 00280 DBusAllowWindowsUserFunction function, 00281 void *data, 00282 DBusFreeFunction free_data_function); 00283 DBUS_EXPORT 00284 void dbus_connection_set_allow_anonymous (DBusConnection *connection, 00285 dbus_bool_t value); 00286 DBUS_EXPORT 00287 void dbus_connection_set_route_peer_messages (DBusConnection *connection, 00288 dbus_bool_t value); 00289 00290 00291 /* Filters */ 00292 00293 DBUS_EXPORT 00294 dbus_bool_t dbus_connection_add_filter (DBusConnection *connection, 00295 DBusHandleMessageFunction function, 00296 void *user_data, 00297 DBusFreeFunction free_data_function); 00298 DBUS_EXPORT 00299 void dbus_connection_remove_filter (DBusConnection *connection, 00300 DBusHandleMessageFunction function, 00301 void *user_data); 00302 00303 00304 /* Other */ 00305 DBUS_EXPORT 00306 dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t *slot_p); 00307 DBUS_EXPORT 00308 void dbus_connection_free_data_slot (dbus_int32_t *slot_p); 00309 DBUS_EXPORT 00310 dbus_bool_t dbus_connection_set_data (DBusConnection *connection, 00311 dbus_int32_t slot, 00312 void *data, 00313 DBusFreeFunction free_data_func); 00314 DBUS_EXPORT 00315 void* dbus_connection_get_data (DBusConnection *connection, 00316 dbus_int32_t slot); 00317 00318 DBUS_EXPORT 00319 void dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe); 00320 00321 DBUS_EXPORT 00322 void dbus_connection_set_max_message_size (DBusConnection *connection, 00323 long size); 00324 DBUS_EXPORT 00325 long dbus_connection_get_max_message_size (DBusConnection *connection); 00326 DBUS_EXPORT 00327 void dbus_connection_set_max_received_size (DBusConnection *connection, 00328 long size); 00329 DBUS_EXPORT 00330 long dbus_connection_get_max_received_size (DBusConnection *connection); 00331 00332 DBUS_EXPORT 00333 void dbus_connection_set_max_message_unix_fds (DBusConnection *connection, 00334 long n); 00335 DBUS_EXPORT 00336 long dbus_connection_get_max_message_unix_fds (DBusConnection *connection); 00337 DBUS_EXPORT 00338 void dbus_connection_set_max_received_unix_fds(DBusConnection *connection, 00339 long n); 00340 DBUS_EXPORT 00341 long dbus_connection_get_max_received_unix_fds(DBusConnection *connection); 00342 00343 DBUS_EXPORT 00344 long dbus_connection_get_outgoing_size (DBusConnection *connection); 00345 DBUS_EXPORT 00346 long dbus_connection_get_outgoing_unix_fds (DBusConnection *connection); 00347 00348 DBUS_EXPORT 00349 DBusPreallocatedSend* dbus_connection_preallocate_send (DBusConnection *connection); 00350 DBUS_EXPORT 00351 void dbus_connection_free_preallocated_send (DBusConnection *connection, 00352 DBusPreallocatedSend *preallocated); 00353 DBUS_EXPORT 00354 void dbus_connection_send_preallocated (DBusConnection *connection, 00355 DBusPreallocatedSend *preallocated, 00356 DBusMessage *message, 00357 dbus_uint32_t *client_serial); 00358 00359 00360 /* Object tree functionality */ 00361 00366 typedef void (* DBusObjectPathUnregisterFunction) (DBusConnection *connection, 00367 void *user_data); 00373 typedef DBusHandlerResult (* DBusObjectPathMessageFunction) (DBusConnection *connection, 00374 DBusMessage *message, 00375 void *user_data); 00376 00383 struct DBusObjectPathVTable 00384 { 00385 DBusObjectPathUnregisterFunction unregister_function; 00386 DBusObjectPathMessageFunction message_function; 00388 void (* dbus_internal_pad1) (void *); 00389 void (* dbus_internal_pad2) (void *); 00390 void (* dbus_internal_pad3) (void *); 00391 void (* dbus_internal_pad4) (void *); 00392 }; 00393 00394 DBUS_EXPORT 00395 dbus_bool_t dbus_connection_try_register_object_path (DBusConnection *connection, 00396 const char *path, 00397 const DBusObjectPathVTable *vtable, 00398 void *user_data, 00399 DBusError *error); 00400 00401 DBUS_EXPORT 00402 dbus_bool_t dbus_connection_register_object_path (DBusConnection *connection, 00403 const char *path, 00404 const DBusObjectPathVTable *vtable, 00405 void *user_data); 00406 00407 DBUS_EXPORT 00408 dbus_bool_t dbus_connection_try_register_fallback (DBusConnection *connection, 00409 const char *path, 00410 const DBusObjectPathVTable *vtable, 00411 void *user_data, 00412 DBusError *error); 00413 00414 DBUS_EXPORT 00415 dbus_bool_t dbus_connection_register_fallback (DBusConnection *connection, 00416 const char *path, 00417 const DBusObjectPathVTable *vtable, 00418 void *user_data); 00419 DBUS_EXPORT 00420 dbus_bool_t dbus_connection_unregister_object_path (DBusConnection *connection, 00421 const char *path); 00422 00423 DBUS_EXPORT 00424 dbus_bool_t dbus_connection_get_object_path_data (DBusConnection *connection, 00425 const char *path, 00426 void **data_p); 00427 00428 DBUS_EXPORT 00429 dbus_bool_t dbus_connection_list_registered (DBusConnection *connection, 00430 const char *parent_path, 00431 char ***child_entries); 00432 00433 DBUS_EXPORT 00434 dbus_bool_t dbus_connection_get_unix_fd (DBusConnection *connection, 00435 int *fd); 00436 DBUS_EXPORT 00437 dbus_bool_t dbus_connection_get_socket (DBusConnection *connection, 00438 int *fd); 00439 00448 #ifndef DBUS_DISABLE_DEPRECATED 00449 DBUS_EXPORT 00450 DBUS_DEPRECATED int dbus_watch_get_fd (DBusWatch *watch); 00451 #endif 00452 00453 DBUS_EXPORT 00454 int dbus_watch_get_unix_fd (DBusWatch *watch); 00455 DBUS_EXPORT 00456 int dbus_watch_get_socket (DBusWatch *watch); 00457 DBUS_EXPORT 00458 unsigned int dbus_watch_get_flags (DBusWatch *watch); 00459 DBUS_EXPORT 00460 void* dbus_watch_get_data (DBusWatch *watch); 00461 DBUS_EXPORT 00462 void dbus_watch_set_data (DBusWatch *watch, 00463 void *data, 00464 DBusFreeFunction free_data_function); 00465 DBUS_EXPORT 00466 dbus_bool_t dbus_watch_handle (DBusWatch *watch, 00467 unsigned int flags); 00468 DBUS_EXPORT 00469 dbus_bool_t dbus_watch_get_enabled (DBusWatch *watch); 00470 00478 DBUS_EXPORT 00479 int dbus_timeout_get_interval (DBusTimeout *timeout); 00480 DBUS_EXPORT 00481 void* dbus_timeout_get_data (DBusTimeout *timeout); 00482 DBUS_EXPORT 00483 void dbus_timeout_set_data (DBusTimeout *timeout, 00484 void *data, 00485 DBusFreeFunction free_data_function); 00486 DBUS_EXPORT 00487 dbus_bool_t dbus_timeout_handle (DBusTimeout *timeout); 00488 DBUS_EXPORT 00489 dbus_bool_t dbus_timeout_get_enabled (DBusTimeout *timeout); 00490 00493 DBUS_END_DECLS 00494 00495 #endif /* DBUS_CONNECTION_H */