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 
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);
00140 typedef dbus_bool_t (* DBusAllowUnixUserFunction)  (DBusConnection *connection,
00141                                                     unsigned long   uid,
00142                                                     void           *data);
00147 typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending,
00148                                                 void            *user_data);
00149 
00154 typedef DBusHandlerResult (* DBusHandleMessageFunction) (DBusConnection     *connection,
00155                                                          DBusMessage        *message,
00156                                                          void               *user_data);
00157 
00158 DBusConnection*    dbus_connection_open                         (const char                 *address,
00159                                                                  DBusError                  *error);
00160 DBusConnection*    dbus_connection_open_private                 (const char                 *address,
00161                                                                  DBusError                  *error);
00162 DBusConnection*    dbus_connection_ref                          (DBusConnection             *connection);
00163 void               dbus_connection_unref                        (DBusConnection             *connection);
00164 void               dbus_connection_close                        (DBusConnection             *connection);
00165 dbus_bool_t        dbus_connection_get_is_connected             (DBusConnection             *connection);
00166 dbus_bool_t        dbus_connection_get_is_authenticated         (DBusConnection             *connection);
00167 void               dbus_connection_set_exit_on_disconnect       (DBusConnection             *connection,
00168                                                                  dbus_bool_t                 exit_on_disconnect);
00169 void               dbus_connection_flush                        (DBusConnection             *connection);
00170 dbus_bool_t        dbus_connection_read_write_dispatch          (DBusConnection             *connection,
00171                                                                  int                         timeout_milliseconds);
00172 dbus_bool_t        dbus_connection_read_write                   (DBusConnection             *connection,
00173                                                                  int                         timeout_milliseconds);
00174 DBusMessage*       dbus_connection_borrow_message               (DBusConnection             *connection);
00175 void               dbus_connection_return_message               (DBusConnection             *connection,
00176                                                                  DBusMessage                *message);
00177 void               dbus_connection_steal_borrowed_message       (DBusConnection             *connection,
00178                                                                  DBusMessage                *message);
00179 DBusMessage*       dbus_connection_pop_message                  (DBusConnection             *connection);
00180 DBusDispatchStatus dbus_connection_get_dispatch_status          (DBusConnection             *connection);
00181 DBusDispatchStatus dbus_connection_dispatch                     (DBusConnection             *connection);
00182 dbus_bool_t        dbus_connection_has_messages_to_send         (DBusConnection *connection);
00183 dbus_bool_t        dbus_connection_send                         (DBusConnection             *connection,
00184                                                                  DBusMessage                *message,
00185                                                                  dbus_uint32_t              *client_serial);
00186 dbus_bool_t        dbus_connection_send_with_reply              (DBusConnection             *connection,
00187                                                                  DBusMessage                *message,
00188                                                                  DBusPendingCall           **pending_return,
00189                                                                  int                         timeout_milliseconds);
00190 DBusMessage *      dbus_connection_send_with_reply_and_block    (DBusConnection             *connection,
00191                                                                  DBusMessage                *message,
00192                                                                  int                         timeout_milliseconds,
00193                                                                  DBusError                  *error);
00194 dbus_bool_t        dbus_connection_set_watch_functions          (DBusConnection             *connection,
00195                                                                  DBusAddWatchFunction        add_function,
00196                                                                  DBusRemoveWatchFunction     remove_function,
00197                                                                  DBusWatchToggledFunction    toggled_function,
00198                                                                  void                       *data,
00199                                                                  DBusFreeFunction            free_data_function);
00200 dbus_bool_t        dbus_connection_set_timeout_functions        (DBusConnection             *connection,
00201                                                                  DBusAddTimeoutFunction      add_function,
00202                                                                  DBusRemoveTimeoutFunction   remove_function,
00203                                                                  DBusTimeoutToggledFunction  toggled_function,
00204                                                                  void                       *data,
00205                                                                  DBusFreeFunction            free_data_function);
00206 void               dbus_connection_set_wakeup_main_function     (DBusConnection             *connection,
00207                                                                  DBusWakeupMainFunction      wakeup_main_function,
00208                                                                  void                       *data,
00209                                                                  DBusFreeFunction            free_data_function);
00210 void               dbus_connection_set_dispatch_status_function (DBusConnection             *connection,
00211                                                                  DBusDispatchStatusFunction  function,
00212                                                                  void                       *data,
00213                                                                  DBusFreeFunction            free_data_function);
00214 dbus_bool_t        dbus_connection_get_unix_user                (DBusConnection             *connection,
00215                                                                  unsigned long              *uid);
00216 dbus_bool_t        dbus_connection_get_unix_process_id          (DBusConnection             *connection,
00217                                                                  unsigned long              *pid);
00218 void               dbus_connection_set_unix_user_function       (DBusConnection             *connection,
00219                                                                  DBusAllowUnixUserFunction   function,
00220                                                                  void                       *data,
00221                                                                  DBusFreeFunction            free_data_function);
00222 void               dbus_connection_set_route_peer_messages      (DBusConnection             *connection,
00223                                                                  dbus_bool_t                 value);
00224 
00225 
00226 /* Filters */
00227 
00228 dbus_bool_t dbus_connection_add_filter    (DBusConnection            *connection,
00229                                            DBusHandleMessageFunction  function,
00230                                            void                      *user_data,
00231                                            DBusFreeFunction           free_data_function);
00232 void        dbus_connection_remove_filter (DBusConnection            *connection,
00233                                            DBusHandleMessageFunction  function,
00234                                            void                      *user_data);
00235 
00236 
00237 /* Other */
00238 dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t     *slot_p);
00239 void        dbus_connection_free_data_slot     (dbus_int32_t     *slot_p);
00240 dbus_bool_t dbus_connection_set_data           (DBusConnection   *connection,
00241                                                 dbus_int32_t      slot,
00242                                                 void             *data,
00243                                                 DBusFreeFunction  free_data_func);
00244 void*       dbus_connection_get_data           (DBusConnection   *connection,
00245                                                 dbus_int32_t      slot);
00246 
00247 void        dbus_connection_set_change_sigpipe (dbus_bool_t       will_modify_sigpipe); 
00248 
00249 void dbus_connection_set_max_message_size  (DBusConnection *connection,
00250                                             long            size);
00251 long dbus_connection_get_max_message_size  (DBusConnection *connection);
00252 void dbus_connection_set_max_received_size (DBusConnection *connection,
00253                                             long            size);
00254 long dbus_connection_get_max_received_size (DBusConnection *connection);
00255 long dbus_connection_get_outgoing_size     (DBusConnection *connection);
00256 
00257 DBusPreallocatedSend* dbus_connection_preallocate_send       (DBusConnection       *connection);
00258 void                  dbus_connection_free_preallocated_send (DBusConnection       *connection,
00259                                                               DBusPreallocatedSend *preallocated);
00260 void                  dbus_connection_send_preallocated      (DBusConnection       *connection,
00261                                                               DBusPreallocatedSend *preallocated,
00262                                                               DBusMessage          *message,
00263                                                               dbus_uint32_t        *client_serial);
00264 
00265 
00266 /* Object tree functionality */
00267 
00272 typedef void              (* DBusObjectPathUnregisterFunction) (DBusConnection  *connection,
00273                                                                 void            *user_data);
00279 typedef DBusHandlerResult (* DBusObjectPathMessageFunction)    (DBusConnection  *connection,
00280                                                                 DBusMessage     *message,
00281                                                                 void            *user_data);
00282 
00289 struct DBusObjectPathVTable
00290 {
00291   DBusObjectPathUnregisterFunction   unregister_function; 
00292   DBusObjectPathMessageFunction      message_function; 
00294   void (* dbus_internal_pad1) (void *); 
00295   void (* dbus_internal_pad2) (void *); 
00296   void (* dbus_internal_pad3) (void *); 
00297   void (* dbus_internal_pad4) (void *); 
00298 };
00299 
00300 dbus_bool_t dbus_connection_register_object_path   (DBusConnection              *connection,
00301                                                     const char                  *path,
00302                                                     const DBusObjectPathVTable  *vtable,
00303                                                     void                        *user_data);
00304 dbus_bool_t dbus_connection_register_fallback      (DBusConnection              *connection,
00305                                                     const char                  *path,
00306                                                     const DBusObjectPathVTable  *vtable,
00307                                                     void                        *user_data);
00308 dbus_bool_t dbus_connection_unregister_object_path (DBusConnection              *connection,
00309                                                     const char                  *path);
00310 
00311 dbus_bool_t dbus_connection_get_object_path_data   (DBusConnection              *connection,
00312                                                     const char                  *path,
00313                                                     void                       **data_p);
00314 
00315 dbus_bool_t dbus_connection_list_registered        (DBusConnection              *connection,
00316                                                     const char                  *parent_path,
00317                                                     char                      ***child_entries);
00318 
00319 dbus_bool_t dbus_connection_get_unix_fd            (DBusConnection              *connection,
00320                                                     int                         *fd);
00321 dbus_bool_t dbus_connection_get_socket             (DBusConnection              *connection,
00322                                                     int                         *fd);
00323 
00332 int          dbus_watch_get_fd      (DBusWatch        *watch);
00333 unsigned int dbus_watch_get_flags   (DBusWatch        *watch);
00334 void*        dbus_watch_get_data    (DBusWatch        *watch);
00335 void         dbus_watch_set_data    (DBusWatch        *watch,
00336                                      void             *data,
00337                                      DBusFreeFunction  free_data_function);
00338 dbus_bool_t  dbus_watch_handle      (DBusWatch        *watch,
00339                                      unsigned int      flags);
00340 dbus_bool_t  dbus_watch_get_enabled (DBusWatch        *watch);
00341 
00349 int         dbus_timeout_get_interval (DBusTimeout      *timeout);
00350 void*       dbus_timeout_get_data     (DBusTimeout      *timeout);
00351 void        dbus_timeout_set_data     (DBusTimeout      *timeout,
00352                                        void             *data,
00353                                        DBusFreeFunction  free_data_function);
00354 dbus_bool_t dbus_timeout_handle       (DBusTimeout      *timeout);
00355 dbus_bool_t dbus_timeout_get_enabled  (DBusTimeout      *timeout);
00356 
00359 DBUS_END_DECLS
00360 
00361 #endif /* DBUS_CONNECTION_H */

Generated on Fri Sep 21 18:12:11 2007 for D-Bus by  doxygen 1.5.1