sl@0: /* -*- mode: C; c-file-style: "gnu" -*- */ sl@0: /* dbus-connection.h DBusConnection object sl@0: * sl@0: * Copyright (C) 2002, 2003 Red Hat Inc. sl@0: * Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * Licensed under the Academic Free License version 2.1 sl@0: * sl@0: * This program is free software; you can redistribute it and/or modify sl@0: * it under the terms of the GNU General Public License as published by sl@0: * the Free Software Foundation; either version 2 of the License, or sl@0: * (at your option) any later version. sl@0: * sl@0: * This program is distributed in the hope that it will be useful, sl@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of sl@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the sl@0: * GNU General Public License for more details. sl@0: * sl@0: * You should have received a copy of the GNU General Public License sl@0: * along with this program; if not, write to the Free Software sl@0: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA sl@0: * sl@0: */ sl@0: #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) sl@0: #error "Only can be included directly, this file may disappear or change contents." sl@0: #endif sl@0: sl@0: #ifndef DBUS_CONNECTION_H sl@0: #define DBUS_CONNECTION_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: DBUS_BEGIN_DECLS sl@0: sl@0: /** sl@0: * @addtogroup DBusConnection sl@0: * @{ sl@0: */ sl@0: sl@0: /* documented in dbus-watch.c */ sl@0: typedef struct DBusWatch DBusWatch; sl@0: /* documented in dbus-timeout.c */ sl@0: typedef struct DBusTimeout DBusTimeout; sl@0: /** Opaque type representing preallocated resources so a message can be sent without further memory allocation. */ sl@0: typedef struct DBusPreallocatedSend DBusPreallocatedSend; sl@0: /** Opaque type representing a method call that has not yet received a reply. */ sl@0: typedef struct DBusPendingCall DBusPendingCall; sl@0: /** Opaque type representing a connection to a remote application and associated incoming/outgoing message queues. */ sl@0: typedef struct DBusConnection DBusConnection; sl@0: /** Set of functions that must be implemented to handle messages sent to a particular object path. */ sl@0: typedef struct DBusObjectPathVTable DBusObjectPathVTable; sl@0: sl@0: /** sl@0: * Indicates the status of a #DBusWatch. sl@0: */ sl@0: typedef enum sl@0: { sl@0: DBUS_WATCH_READABLE = 1 << 0, /**< As in POLLIN */ sl@0: DBUS_WATCH_WRITABLE = 1 << 1, /**< As in POLLOUT */ sl@0: DBUS_WATCH_ERROR = 1 << 2, /**< As in POLLERR (can't watch for sl@0: * this, but can be present in sl@0: * current state passed to sl@0: * dbus_watch_handle()). sl@0: */ sl@0: DBUS_WATCH_HANGUP = 1 << 3 /**< As in POLLHUP (can't watch for sl@0: * it, but can be present in current sl@0: * state passed to sl@0: * dbus_watch_handle()). sl@0: */ sl@0: } DBusWatchFlags; sl@0: sl@0: /** sl@0: * Indicates the status of incoming data on a #DBusConnection. This determines whether sl@0: * dbus_connection_dispatch() needs to be called. sl@0: */ sl@0: typedef enum sl@0: { sl@0: DBUS_DISPATCH_DATA_REMAINS, /**< There is more data to potentially convert to messages. */ sl@0: DBUS_DISPATCH_COMPLETE, /**< All currently available data has been processed. */ sl@0: DBUS_DISPATCH_NEED_MEMORY /**< More memory is needed to continue. */ sl@0: } DBusDispatchStatus; sl@0: sl@0: /** Called when libdbus needs a new watch to be monitored by the main sl@0: * loop. Returns #FALSE if it lacks enough memory to add the sl@0: * watch. Set by dbus_connection_set_watch_functions() or sl@0: * dbus_server_set_watch_functions(). sl@0: */ sl@0: typedef dbus_bool_t (* DBusAddWatchFunction) (DBusWatch *watch, sl@0: void *data); sl@0: /** Called when dbus_watch_get_enabled() may return a different value sl@0: * than it did before. Set by dbus_connection_set_watch_functions() sl@0: * or dbus_server_set_watch_functions(). sl@0: */ sl@0: typedef void (* DBusWatchToggledFunction) (DBusWatch *watch, sl@0: void *data); sl@0: /** Called when libdbus no longer needs a watch to be monitored by the sl@0: * main loop. Set by dbus_connection_set_watch_functions() or sl@0: * dbus_server_set_watch_functions(). sl@0: */ sl@0: typedef void (* DBusRemoveWatchFunction) (DBusWatch *watch, sl@0: void *data); sl@0: /** Called when libdbus needs a new timeout to be monitored by the main sl@0: * loop. Returns #FALSE if it lacks enough memory to add the sl@0: * watch. Set by dbus_connection_set_timeout_functions() or sl@0: * dbus_server_set_timeout_functions(). sl@0: */ sl@0: typedef dbus_bool_t (* DBusAddTimeoutFunction) (DBusTimeout *timeout, sl@0: void *data); sl@0: /** Called when dbus_timeout_get_enabled() may return a different sl@0: * value than it did before. sl@0: * Set by dbus_connection_set_timeout_functions() or sl@0: * dbus_server_set_timeout_functions(). sl@0: */ sl@0: typedef void (* DBusTimeoutToggledFunction) (DBusTimeout *timeout, sl@0: void *data); sl@0: /** Called when libdbus no longer needs a timeout to be monitored by the sl@0: * main loop. Set by dbus_connection_set_timeout_functions() or sl@0: * dbus_server_set_timeout_functions(). sl@0: */ sl@0: typedef void (* DBusRemoveTimeoutFunction) (DBusTimeout *timeout, sl@0: void *data); sl@0: /** Called when the return value of dbus_connection_get_dispatch_status() sl@0: * may have changed. Set with dbus_connection_set_dispatch_status_function(). sl@0: */ sl@0: typedef void (* DBusDispatchStatusFunction) (DBusConnection *connection, sl@0: DBusDispatchStatus new_status, sl@0: void *data); sl@0: /** sl@0: * Called when the main loop's thread should be notified that there's now work sl@0: * to do. Set with dbus_connection_set_wakeup_main_function(). sl@0: */ sl@0: typedef void (* DBusWakeupMainFunction) (void *data); sl@0: /** sl@0: * Called during authentication on UNIX systems to check whether the given sl@0: * user ID is allowed to connect. Never called on Windows. Set with sl@0: * dbus_connection_set_unix_user_function(). sl@0: */ sl@0: typedef dbus_bool_t (* DBusAllowUnixUserFunction) (DBusConnection *connection, sl@0: unsigned long uid, sl@0: void *data); sl@0: /** sl@0: * Called when a pending call now has a reply available. Set with sl@0: * dbus_pending_call_set_notify(). sl@0: */ sl@0: typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending, sl@0: void *user_data); sl@0: sl@0: /** sl@0: * Called when a message needs to be handled. The result indicates whether or sl@0: * not more handlers should be run. Set with dbus_connection_add_filter(). sl@0: */ sl@0: typedef DBusHandlerResult (* DBusHandleMessageFunction) (DBusConnection *connection, sl@0: DBusMessage *message, sl@0: void *user_data); sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusConnection* dbus_connection_open (const char *address, sl@0: DBusError *error); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusConnection* dbus_connection_open_private (const char *address, sl@0: DBusError *error); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusConnection* dbus_connection_ref (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_unref (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_close (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_get_is_authenticated (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_set_exit_on_disconnect (DBusConnection *connection, sl@0: dbus_bool_t exit_on_disconnect); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_flush (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_read_write_dispatch (DBusConnection *connection, sl@0: int timeout_milliseconds); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_read_write (DBusConnection *connection, sl@0: int timeout_milliseconds); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusMessage* dbus_connection_borrow_message (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_return_message (DBusConnection *connection, sl@0: DBusMessage *message); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_steal_borrowed_message (DBusConnection *connection, sl@0: DBusMessage *message); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusMessage* dbus_connection_pop_message (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusDispatchStatus dbus_connection_get_dispatch_status (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusDispatchStatus dbus_connection_dispatch (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_has_messages_to_send (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_send (DBusConnection *connection, sl@0: DBusMessage *message, sl@0: dbus_uint32_t *client_serial); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_send_with_reply (DBusConnection *connection, sl@0: DBusMessage *message, sl@0: DBusPendingCall **pending_return, sl@0: int timeout_milliseconds); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusMessage * dbus_connection_send_with_reply_and_block (DBusConnection *connection, sl@0: DBusMessage *message, sl@0: int timeout_milliseconds, sl@0: DBusError *error); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_set_watch_functions (DBusConnection *connection, sl@0: DBusAddWatchFunction add_function, sl@0: DBusRemoveWatchFunction remove_function, sl@0: DBusWatchToggledFunction toggled_function, sl@0: void *data, sl@0: DBusFreeFunction free_data_function); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_set_timeout_functions (DBusConnection *connection, sl@0: DBusAddTimeoutFunction add_function, sl@0: DBusRemoveTimeoutFunction remove_function, sl@0: DBusTimeoutToggledFunction toggled_function, sl@0: void *data, sl@0: DBusFreeFunction free_data_function); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_set_wakeup_main_function (DBusConnection *connection, sl@0: DBusWakeupMainFunction wakeup_main_function, sl@0: void *data, sl@0: DBusFreeFunction free_data_function); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_set_dispatch_status_function (DBusConnection *connection, sl@0: DBusDispatchStatusFunction function, sl@0: void *data, sl@0: DBusFreeFunction free_data_function); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_get_unix_user (DBusConnection *connection, sl@0: unsigned long *uid); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_get_unix_process_id (DBusConnection *connection, sl@0: unsigned long *pid); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_set_unix_user_function (DBusConnection *connection, sl@0: DBusAllowUnixUserFunction function, sl@0: void *data, sl@0: DBusFreeFunction free_data_function); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_set_route_peer_messages (DBusConnection *connection, sl@0: dbus_bool_t value); sl@0: sl@0: sl@0: /* Filters */ sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_add_filter (DBusConnection *connection, sl@0: DBusHandleMessageFunction function, sl@0: void *user_data, sl@0: DBusFreeFunction free_data_function); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_remove_filter (DBusConnection *connection, sl@0: DBusHandleMessageFunction function, sl@0: void *user_data); sl@0: sl@0: sl@0: /* Other */ sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t *slot_p); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_free_data_slot (dbus_int32_t *slot_p); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_set_data (DBusConnection *connection, sl@0: dbus_int32_t slot, sl@0: void *data, sl@0: DBusFreeFunction free_data_func); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void* dbus_connection_get_data (DBusConnection *connection, sl@0: dbus_int32_t slot); sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe); sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_set_max_message_size (DBusConnection *connection, sl@0: long size); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: long dbus_connection_get_max_message_size (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_set_max_received_size (DBusConnection *connection, sl@0: long size); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: long dbus_connection_get_max_received_size (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: long dbus_connection_get_outgoing_size (DBusConnection *connection); sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: DBusPreallocatedSend* dbus_connection_preallocate_send (DBusConnection *connection); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_free_preallocated_send (DBusConnection *connection, sl@0: DBusPreallocatedSend *preallocated); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_connection_send_preallocated (DBusConnection *connection, sl@0: DBusPreallocatedSend *preallocated, sl@0: DBusMessage *message, sl@0: dbus_uint32_t *client_serial); sl@0: sl@0: sl@0: /* Object tree functionality */ sl@0: sl@0: /** sl@0: * Called when a #DBusObjectPathVTable is unregistered (or its connection is freed). sl@0: * Found in #DBusObjectPathVTable. sl@0: */ sl@0: typedef void (* DBusObjectPathUnregisterFunction) (DBusConnection *connection, sl@0: void *user_data); sl@0: /** sl@0: * Called when a message is sent to a registered object path. Found in sl@0: * #DBusObjectPathVTable which is registered with dbus_connection_register_object_path() sl@0: * or dbus_connection_register_fallback(). sl@0: */ sl@0: typedef DBusHandlerResult (* DBusObjectPathMessageFunction) (DBusConnection *connection, sl@0: DBusMessage *message, sl@0: void *user_data); sl@0: sl@0: /** sl@0: * Virtual table that must be implemented to handle a portion of the sl@0: * object path hierarchy. Attach the vtable to a particular path using sl@0: * dbus_connection_register_object_path() or sl@0: * dbus_connection_register_fallback(). sl@0: */ sl@0: struct DBusObjectPathVTable sl@0: { sl@0: DBusObjectPathUnregisterFunction unregister_function; /**< Function to unregister this handler */ sl@0: DBusObjectPathMessageFunction message_function; /**< Function to handle messages */ sl@0: sl@0: void (* dbus_internal_pad1) (void *); /**< Reserved for future expansion */ sl@0: void (* dbus_internal_pad2) (void *); /**< Reserved for future expansion */ sl@0: void (* dbus_internal_pad3) (void *); /**< Reserved for future expansion */ sl@0: void (* dbus_internal_pad4) (void *); /**< Reserved for future expansion */ sl@0: }; sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_register_object_path (DBusConnection *connection, sl@0: const char *path, sl@0: const DBusObjectPathVTable *vtable, sl@0: void *user_data); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_register_fallback (DBusConnection *connection, sl@0: const char *path, sl@0: const DBusObjectPathVTable *vtable, sl@0: void *user_data); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_unregister_object_path (DBusConnection *connection, sl@0: const char *path); sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_get_object_path_data (DBusConnection *connection, sl@0: const char *path, sl@0: void **data_p); sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_list_registered (DBusConnection *connection, sl@0: const char *parent_path, sl@0: char ***child_entries); sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_get_unix_fd (DBusConnection *connection, sl@0: int *fd); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_connection_get_socket (DBusConnection *connection, sl@0: int *fd); sl@0: sl@0: /** @} */ sl@0: sl@0: sl@0: /** sl@0: * @addtogroup DBusWatch sl@0: * @{ sl@0: */ sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: int dbus_watch_get_fd (DBusWatch *watch); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: unsigned int dbus_watch_get_flags (DBusWatch *watch); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void* dbus_watch_get_data (DBusWatch *watch); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_watch_set_data (DBusWatch *watch, sl@0: void *data, sl@0: DBusFreeFunction free_data_function); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_watch_handle (DBusWatch *watch, sl@0: unsigned int flags); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_watch_get_enabled (DBusWatch *watch); sl@0: sl@0: /** @} */ sl@0: sl@0: /** sl@0: * @addtogroup DBusTimeout sl@0: * @{ sl@0: */ sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: int dbus_timeout_get_interval (DBusTimeout *timeout); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void* dbus_timeout_get_data (DBusTimeout *timeout); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: void dbus_timeout_set_data (DBusTimeout *timeout, sl@0: void *data, sl@0: DBusFreeFunction free_data_function); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_timeout_handle (DBusTimeout *timeout); sl@0: #ifdef __SYMBIAN32__ sl@0: IMPORT_C sl@0: #endif sl@0: dbus_bool_t dbus_timeout_get_enabled (DBusTimeout *timeout); sl@0: sl@0: /** @} */ sl@0: sl@0: DBUS_END_DECLS sl@0: sl@0: #endif /* DBUS_CONNECTION_H */