dbus-connection.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 
00037 typedef struct DBusWatch DBusWatch;
00038 typedef struct DBusTimeout DBusTimeout;
00039 typedef struct DBusPreallocatedSend DBusPreallocatedSend;
00040 typedef struct DBusPendingCall DBusPendingCall;
00041 typedef struct DBusConnection DBusConnection;
00042 typedef struct DBusObjectPathVTable DBusObjectPathVTable;
00043 
00044 typedef enum
00045 {
00046   DBUS_WATCH_READABLE = 1 << 0, 
00047   DBUS_WATCH_WRITABLE = 1 << 1, 
00048   DBUS_WATCH_ERROR    = 1 << 2, 
00051   DBUS_WATCH_HANGUP   = 1 << 3  
00053 } DBusWatchFlags;
00054 
00055 typedef enum
00056 {
00057   DBUS_DISPATCH_DATA_REMAINS,  
00058   DBUS_DISPATCH_COMPLETE,      
00059   DBUS_DISPATCH_NEED_MEMORY    
00060 } DBusDispatchStatus;
00061 
00062 typedef dbus_bool_t (* DBusAddWatchFunction)       (DBusWatch      *watch,
00063                                                     void           *data);
00064 typedef void        (* DBusWatchToggledFunction)   (DBusWatch      *watch,
00065                                                     void           *data);
00066 typedef void        (* DBusRemoveWatchFunction)    (DBusWatch      *watch,
00067                                                     void           *data);
00068 typedef dbus_bool_t (* DBusAddTimeoutFunction)     (DBusTimeout    *timeout,
00069                                                     void           *data);
00070 typedef void        (* DBusTimeoutToggledFunction) (DBusTimeout    *timeout,
00071                                                     void           *data);
00072 typedef void        (* DBusRemoveTimeoutFunction)  (DBusTimeout    *timeout,
00073                                                     void           *data);
00074 typedef void        (* DBusDispatchStatusFunction) (DBusConnection *connection,
00075                                                     DBusDispatchStatus new_status,
00076                                                     void           *data);
00077 typedef void        (* DBusWakeupMainFunction)     (void           *data);
00078 typedef dbus_bool_t (* DBusAllowUnixUserFunction)  (DBusConnection *connection,
00079                                                     unsigned long   uid,
00080                                                     void           *data);
00081 
00082 typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending,
00083                                                 void            *user_data);
00084 
00085 
00086 typedef DBusHandlerResult (* DBusHandleMessageFunction) (DBusConnection     *connection,
00087                                                          DBusMessage        *message,
00088                                                          void               *user_data);
00089 
00090 DBusConnection*    dbus_connection_open                         (const char                 *address,
00091                                                                  DBusError                  *error);
00092 DBusConnection*    dbus_connection_open_private                 (const char                 *address,
00093                                                                  DBusError                  *error);
00094 DBusConnection*    dbus_connection_ref                          (DBusConnection             *connection);
00095 void               dbus_connection_unref                        (DBusConnection             *connection);
00096 void               dbus_connection_close                        (DBusConnection             *connection);
00097 void               dbus_connection_disconnect                   (DBusConnection             *connection);
00098 dbus_bool_t        dbus_connection_get_is_connected             (DBusConnection             *connection);
00099 dbus_bool_t        dbus_connection_get_is_authenticated         (DBusConnection             *connection);
00100 void               dbus_connection_set_exit_on_disconnect       (DBusConnection             *connection,
00101                                                                  dbus_bool_t                 exit_on_disconnect);
00102 void               dbus_connection_flush                        (DBusConnection             *connection);
00103 dbus_bool_t        dbus_connection_read_write_dispatch          (DBusConnection             *connection,
00104                                                                  int                         timeout_milliseconds);
00105 dbus_bool_t        dbus_connection_read_write                   (DBusConnection             *connection,
00106                                                                  int                         timeout_milliseconds);
00107 DBusMessage*       dbus_connection_borrow_message               (DBusConnection             *connection);
00108 void               dbus_connection_return_message               (DBusConnection             *connection,
00109                                                                  DBusMessage                *message);
00110 void               dbus_connection_steal_borrowed_message       (DBusConnection             *connection,
00111                                                                  DBusMessage                *message);
00112 DBusMessage*       dbus_connection_pop_message                  (DBusConnection             *connection);
00113 DBusDispatchStatus dbus_connection_get_dispatch_status          (DBusConnection             *connection);
00114 DBusDispatchStatus dbus_connection_dispatch                     (DBusConnection             *connection);
00115 dbus_bool_t        dbus_connection_has_messages_to_send         (DBusConnection *connection);
00116 dbus_bool_t        dbus_connection_send                         (DBusConnection             *connection,
00117                                                                  DBusMessage                *message,
00118                                                                  dbus_uint32_t              *client_serial);
00119 dbus_bool_t        dbus_connection_send_with_reply              (DBusConnection             *connection,
00120                                                                  DBusMessage                *message,
00121                                                                  DBusPendingCall           **pending_return,
00122                                                                  int                         timeout_milliseconds);
00123 DBusMessage *      dbus_connection_send_with_reply_and_block    (DBusConnection             *connection,
00124                                                                  DBusMessage                *message,
00125                                                                  int                         timeout_milliseconds,
00126                                                                  DBusError                  *error);
00127 dbus_bool_t        dbus_connection_set_watch_functions          (DBusConnection             *connection,
00128                                                                  DBusAddWatchFunction        add_function,
00129                                                                  DBusRemoveWatchFunction     remove_function,
00130                                                                  DBusWatchToggledFunction    toggled_function,
00131                                                                  void                       *data,
00132                                                                  DBusFreeFunction            free_data_function);
00133 dbus_bool_t        dbus_connection_set_timeout_functions        (DBusConnection             *connection,
00134                                                                  DBusAddTimeoutFunction      add_function,
00135                                                                  DBusRemoveTimeoutFunction   remove_function,
00136                                                                  DBusTimeoutToggledFunction  toggled_function,
00137                                                                  void                       *data,
00138                                                                  DBusFreeFunction            free_data_function);
00139 void               dbus_connection_set_wakeup_main_function     (DBusConnection             *connection,
00140                                                                  DBusWakeupMainFunction      wakeup_main_function,
00141                                                                  void                       *data,
00142                                                                  DBusFreeFunction            free_data_function);
00143 void               dbus_connection_set_dispatch_status_function (DBusConnection             *connection,
00144                                                                  DBusDispatchStatusFunction  function,
00145                                                                  void                       *data,
00146                                                                  DBusFreeFunction            free_data_function);
00147 dbus_bool_t        dbus_connection_get_unix_user                (DBusConnection             *connection,
00148                                                                  unsigned long              *uid);
00149 dbus_bool_t        dbus_connection_get_unix_process_id          (DBusConnection             *connection,
00150                                                                  unsigned long              *pid);
00151 void               dbus_connection_set_unix_user_function       (DBusConnection             *connection,
00152                                                                  DBusAllowUnixUserFunction   function,
00153                                                                  void                       *data,
00154                                                                  DBusFreeFunction            free_data_function);
00155 
00156 
00157 int          dbus_watch_get_fd      (DBusWatch        *watch);
00158 unsigned int dbus_watch_get_flags   (DBusWatch        *watch);
00159 void*        dbus_watch_get_data    (DBusWatch        *watch);
00160 void         dbus_watch_set_data    (DBusWatch        *watch,
00161                                      void             *data,
00162                                      DBusFreeFunction  free_data_function);
00163 dbus_bool_t  dbus_watch_handle      (DBusWatch        *watch,
00164                                      unsigned int      flags);
00165 dbus_bool_t  dbus_watch_get_enabled (DBusWatch        *watch);
00166 
00167 int         dbus_timeout_get_interval (DBusTimeout      *timeout);
00168 void*       dbus_timeout_get_data     (DBusTimeout      *timeout);
00169 void        dbus_timeout_set_data     (DBusTimeout      *timeout,
00170                                        void             *data,
00171                                        DBusFreeFunction  free_data_function);
00172 dbus_bool_t dbus_timeout_handle       (DBusTimeout      *timeout);
00173 dbus_bool_t dbus_timeout_get_enabled  (DBusTimeout      *timeout);
00174 
00175 /* Filters */
00176 
00177 dbus_bool_t dbus_connection_add_filter    (DBusConnection            *connection,
00178                                            DBusHandleMessageFunction  function,
00179                                            void                      *user_data,
00180                                            DBusFreeFunction           free_data_function);
00181 void        dbus_connection_remove_filter (DBusConnection            *connection,
00182                                            DBusHandleMessageFunction  function,
00183                                            void                      *user_data);
00184 
00185 
00186 /* Other */
00187 dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t     *slot_p);
00188 void        dbus_connection_free_data_slot     (dbus_int32_t     *slot_p);
00189 dbus_bool_t dbus_connection_set_data           (DBusConnection   *connection,
00190                                                 dbus_int32_t      slot,
00191                                                 void             *data,
00192                                                 DBusFreeFunction  free_data_func);
00193 void*       dbus_connection_get_data           (DBusConnection   *connection,
00194                                                 dbus_int32_t      slot);
00195 
00196 void        dbus_connection_set_change_sigpipe (dbus_bool_t       will_modify_sigpipe); 
00197 
00198 void dbus_connection_set_max_message_size  (DBusConnection *connection,
00199                                             long            size);
00200 long dbus_connection_get_max_message_size  (DBusConnection *connection);
00201 void dbus_connection_set_max_received_size (DBusConnection *connection,
00202                                             long            size);
00203 long dbus_connection_get_max_received_size (DBusConnection *connection);
00204 long dbus_connection_get_outgoing_size     (DBusConnection *connection);
00205 
00206 DBusPreallocatedSend* dbus_connection_preallocate_send       (DBusConnection       *connection);
00207 void                  dbus_connection_free_preallocated_send (DBusConnection       *connection,
00208                                                               DBusPreallocatedSend *preallocated);
00209 void                  dbus_connection_send_preallocated      (DBusConnection       *connection,
00210                                                               DBusPreallocatedSend *preallocated,
00211                                                               DBusMessage          *message,
00212                                                               dbus_uint32_t        *client_serial);
00213 
00214 
00215 /* Object tree functionality */
00216 
00217 typedef void              (* DBusObjectPathUnregisterFunction) (DBusConnection  *connection,
00218                                                                 void            *user_data);
00219 typedef DBusHandlerResult (* DBusObjectPathMessageFunction)    (DBusConnection  *connection,
00220                                                                 DBusMessage     *message,
00221                                                                 void            *user_data);
00222 
00227 struct DBusObjectPathVTable
00228 {
00229   DBusObjectPathUnregisterFunction   unregister_function; 
00230   DBusObjectPathMessageFunction      message_function; 
00232   void (* dbus_internal_pad1) (void *); 
00233   void (* dbus_internal_pad2) (void *); 
00234   void (* dbus_internal_pad3) (void *); 
00235   void (* dbus_internal_pad4) (void *); 
00236 };
00237 
00238 dbus_bool_t dbus_connection_register_object_path   (DBusConnection              *connection,
00239                                                     const char                  *path,
00240                                                     const DBusObjectPathVTable  *vtable,
00241                                                     void                        *user_data);
00242 dbus_bool_t dbus_connection_register_fallback      (DBusConnection              *connection,
00243                                                     const char                  *path,
00244                                                     const DBusObjectPathVTable  *vtable,
00245                                                     void                        *user_data);
00246 dbus_bool_t dbus_connection_unregister_object_path (DBusConnection              *connection,
00247                                                     const char                  *path);
00248 
00249 dbus_bool_t dbus_connection_get_object_path_data   (DBusConnection              *connection,
00250                                                     const char                  *path,
00251                                                     void                       **data_p);
00252 
00253 dbus_bool_t dbus_connection_list_registered        (DBusConnection              *connection,
00254                                                     const char                  *parent_path,
00255                                                     char                      ***child_entries);
00256 
00257 dbus_bool_t dbus_connection_get_unix_fd            (DBusConnection              *connection,
00258                                                     int                         *fd);
00259 
00260 DBUS_END_DECLS
00261 
00262 #endif /* DBUS_CONNECTION_H */

Generated on Tue Jul 7 15:13:58 2009 for D-BUS by  doxygen 1.4.6