dbus-connection.h

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., 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);
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 
00172 DBusConnection*    dbus_connection_open                         (const char                 *address,
00173                                                                  DBusError                  *error);
00174 DBusConnection*    dbus_connection_open_private                 (const char                 *address,
00175                                                                  DBusError                  *error);
00176 DBusConnection*    dbus_connection_ref                          (DBusConnection             *connection);
00177 void               dbus_connection_unref                        (DBusConnection             *connection);
00178 void               dbus_connection_close                        (DBusConnection             *connection);
00179 dbus_bool_t        dbus_connection_get_is_connected             (DBusConnection             *connection);
00180 dbus_bool_t        dbus_connection_get_is_authenticated         (DBusConnection             *connection);
00181 dbus_bool_t        dbus_connection_get_is_anonymous             (DBusConnection             *connection);
00182 char*              dbus_connection_get_server_id                (DBusConnection             *connection);
00183 void               dbus_connection_set_exit_on_disconnect       (DBusConnection             *connection,
00184                                                                  dbus_bool_t                 exit_on_disconnect);
00185 void               dbus_connection_flush                        (DBusConnection             *connection);
00186 dbus_bool_t        dbus_connection_read_write_dispatch          (DBusConnection             *connection,
00187                                                                  int                         timeout_milliseconds);
00188 dbus_bool_t        dbus_connection_read_write                   (DBusConnection             *connection,
00189                                                                  int                         timeout_milliseconds);
00190 DBusMessage*       dbus_connection_borrow_message               (DBusConnection             *connection);
00191 void               dbus_connection_return_message               (DBusConnection             *connection,
00192                                                                  DBusMessage                *message);
00193 void               dbus_connection_steal_borrowed_message       (DBusConnection             *connection,
00194                                                                  DBusMessage                *message);
00195 DBusMessage*       dbus_connection_pop_message                  (DBusConnection             *connection);
00196 DBusDispatchStatus dbus_connection_get_dispatch_status          (DBusConnection             *connection);
00197 DBusDispatchStatus dbus_connection_dispatch                     (DBusConnection             *connection);
00198 dbus_bool_t        dbus_connection_has_messages_to_send         (DBusConnection *connection);
00199 dbus_bool_t        dbus_connection_send                         (DBusConnection             *connection,
00200                                                                  DBusMessage                *message,
00201                                                                  dbus_uint32_t              *client_serial);
00202 dbus_bool_t        dbus_connection_send_with_reply              (DBusConnection             *connection,
00203                                                                  DBusMessage                *message,
00204                                                                  DBusPendingCall           **pending_return,
00205                                                                  int                         timeout_milliseconds);
00206 DBusMessage *      dbus_connection_send_with_reply_and_block    (DBusConnection             *connection,
00207                                                                  DBusMessage                *message,
00208                                                                  int                         timeout_milliseconds,
00209                                                                  DBusError                  *error);
00210 dbus_bool_t        dbus_connection_set_watch_functions          (DBusConnection             *connection,
00211                                                                  DBusAddWatchFunction        add_function,
00212                                                                  DBusRemoveWatchFunction     remove_function,
00213                                                                  DBusWatchToggledFunction    toggled_function,
00214                                                                  void                       *data,
00215                                                                  DBusFreeFunction            free_data_function);
00216 dbus_bool_t        dbus_connection_set_timeout_functions        (DBusConnection             *connection,
00217                                                                  DBusAddTimeoutFunction      add_function,
00218                                                                  DBusRemoveTimeoutFunction   remove_function,
00219                                                                  DBusTimeoutToggledFunction  toggled_function,
00220                                                                  void                       *data,
00221                                                                  DBusFreeFunction            free_data_function);
00222 void               dbus_connection_set_wakeup_main_function     (DBusConnection             *connection,
00223                                                                  DBusWakeupMainFunction      wakeup_main_function,
00224                                                                  void                       *data,
00225                                                                  DBusFreeFunction            free_data_function);
00226 void               dbus_connection_set_dispatch_status_function (DBusConnection             *connection,
00227                                                                  DBusDispatchStatusFunction  function,
00228                                                                  void                       *data,
00229                                                                  DBusFreeFunction            free_data_function);
00230 dbus_bool_t        dbus_connection_get_unix_user                (DBusConnection             *connection,
00231                                                                  unsigned long              *uid);
00232 dbus_bool_t        dbus_connection_get_unix_process_id          (DBusConnection             *connection,
00233                                                                  unsigned long              *pid);
00234 void               dbus_connection_set_unix_user_function       (DBusConnection             *connection,
00235                                                                  DBusAllowUnixUserFunction   function,
00236                                                                  void                       *data,
00237                                                                  DBusFreeFunction            free_data_function);
00238 dbus_bool_t        dbus_connection_get_windows_user             (DBusConnection             *connection,
00239                                                                  char                      **windows_sid_p); 
00240 void               dbus_connection_set_windows_user_function    (DBusConnection             *connection,
00241                                                                  DBusAllowWindowsUserFunction function,
00242                                                                  void                       *data,
00243                                                                  DBusFreeFunction            free_data_function);
00244 void               dbus_connection_set_allow_anonymous          (DBusConnection             *connection,
00245                                                                  dbus_bool_t                 value);
00246 void               dbus_connection_set_route_peer_messages      (DBusConnection             *connection,
00247                                                                  dbus_bool_t                 value);
00248 
00249 
00250 /* Filters */
00251 
00252 dbus_bool_t dbus_connection_add_filter    (DBusConnection            *connection,
00253                                            DBusHandleMessageFunction  function,
00254                                            void                      *user_data,
00255                                            DBusFreeFunction           free_data_function);
00256 void        dbus_connection_remove_filter (DBusConnection            *connection,
00257                                            DBusHandleMessageFunction  function,
00258                                            void                      *user_data);
00259 
00260 
00261 /* Other */
00262 dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t     *slot_p);
00263 void        dbus_connection_free_data_slot     (dbus_int32_t     *slot_p);
00264 dbus_bool_t dbus_connection_set_data           (DBusConnection   *connection,
00265                                                 dbus_int32_t      slot,
00266                                                 void             *data,
00267                                                 DBusFreeFunction  free_data_func);
00268 void*       dbus_connection_get_data           (DBusConnection   *connection,
00269                                                 dbus_int32_t      slot);
00270 
00271 void        dbus_connection_set_change_sigpipe (dbus_bool_t       will_modify_sigpipe); 
00272 
00273 void dbus_connection_set_max_message_size  (DBusConnection *connection,
00274                                             long            size);
00275 long dbus_connection_get_max_message_size  (DBusConnection *connection);
00276 void dbus_connection_set_max_received_size (DBusConnection *connection,
00277                                             long            size);
00278 long dbus_connection_get_max_received_size (DBusConnection *connection);
00279 long dbus_connection_get_outgoing_size     (DBusConnection *connection);
00280 
00281 DBusPreallocatedSend* dbus_connection_preallocate_send       (DBusConnection       *connection);
00282 void                  dbus_connection_free_preallocated_send (DBusConnection       *connection,
00283                                                               DBusPreallocatedSend *preallocated);
00284 void                  dbus_connection_send_preallocated      (DBusConnection       *connection,
00285                                                               DBusPreallocatedSend *preallocated,
00286                                                               DBusMessage          *message,
00287                                                               dbus_uint32_t        *client_serial);
00288 
00289 
00290 /* Object tree functionality */
00291 
00296 typedef void              (* DBusObjectPathUnregisterFunction) (DBusConnection  *connection,
00297                                                                 void            *user_data);
00303 typedef DBusHandlerResult (* DBusObjectPathMessageFunction)    (DBusConnection  *connection,
00304                                                                 DBusMessage     *message,
00305                                                                 void            *user_data);
00306 
00313 struct DBusObjectPathVTable
00314 {
00315   DBusObjectPathUnregisterFunction   unregister_function; 
00316   DBusObjectPathMessageFunction      message_function; 
00318   void (* dbus_internal_pad1) (void *); 
00319   void (* dbus_internal_pad2) (void *); 
00320   void (* dbus_internal_pad3) (void *); 
00321   void (* dbus_internal_pad4) (void *); 
00322 };
00323 
00324 dbus_bool_t dbus_connection_register_object_path   (DBusConnection              *connection,
00325                                                     const char                  *path,
00326                                                     const DBusObjectPathVTable  *vtable,
00327                                                     void                        *user_data);
00328 dbus_bool_t dbus_connection_register_fallback      (DBusConnection              *connection,
00329                                                     const char                  *path,
00330                                                     const DBusObjectPathVTable  *vtable,
00331                                                     void                        *user_data);
00332 dbus_bool_t dbus_connection_unregister_object_path (DBusConnection              *connection,
00333                                                     const char                  *path);
00334 
00335 dbus_bool_t dbus_connection_get_object_path_data   (DBusConnection              *connection,
00336                                                     const char                  *path,
00337                                                     void                       **data_p);
00338 
00339 dbus_bool_t dbus_connection_list_registered        (DBusConnection              *connection,
00340                                                     const char                  *parent_path,
00341                                                     char                      ***child_entries);
00342 
00343 dbus_bool_t dbus_connection_get_unix_fd            (DBusConnection              *connection,
00344                                                     int                         *fd);
00345 dbus_bool_t dbus_connection_get_socket             (DBusConnection              *connection,
00346                                                     int                         *fd);
00347 
00356 #ifndef DBUS_DISABLE_DEPRECATED
00357 DBUS_DEPRECATED int dbus_watch_get_fd      (DBusWatch        *watch);
00358 #endif
00359 
00360 int          dbus_watch_get_unix_fd (DBusWatch        *watch);
00361 int          dbus_watch_get_socket  (DBusWatch        *watch);
00362 unsigned int dbus_watch_get_flags   (DBusWatch        *watch);
00363 void*        dbus_watch_get_data    (DBusWatch        *watch);
00364 void         dbus_watch_set_data    (DBusWatch        *watch,
00365                                      void             *data,
00366                                      DBusFreeFunction  free_data_function);
00367 dbus_bool_t  dbus_watch_handle      (DBusWatch        *watch,
00368                                      unsigned int      flags);
00369 dbus_bool_t  dbus_watch_get_enabled (DBusWatch        *watch);
00370 
00378 int         dbus_timeout_get_interval (DBusTimeout      *timeout);
00379 void*       dbus_timeout_get_data     (DBusTimeout      *timeout);
00380 void        dbus_timeout_set_data     (DBusTimeout      *timeout,
00381                                        void             *data,
00382                                        DBusFreeFunction  free_data_function);
00383 dbus_bool_t dbus_timeout_handle       (DBusTimeout      *timeout);
00384 dbus_bool_t dbus_timeout_get_enabled  (DBusTimeout      *timeout);
00385 
00388 DBUS_END_DECLS
00389 
00390 #endif /* DBUS_CONNECTION_H */

Generated on Mon Feb 1 19:15:25 2010 for D-Bus by  doxygen 1.4.7