Main Page | Modules | Data Structures | Directories | File List | Data Fields | Related Pages

dbus-server-protected.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* dbus-server-protected.h Used by subclasses of DBusServer object (internal to D-BUS implementation)
00003  *
00004  * Copyright (C) 2002  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 #ifndef DBUS_SERVER_PROTECTED_H
00024 #define DBUS_SERVER_PROTECTED_H
00025 
00026 #include <config.h>
00027 #include <dbus/dbus-internals.h>
00028 #include <dbus/dbus-server.h>
00029 #include <dbus/dbus-timeout.h>
00030 #include <dbus/dbus-watch.h>
00031 #include <dbus/dbus-resources.h>
00032 #include <dbus/dbus-dataslot.h>
00033 
00034 DBUS_BEGIN_DECLS
00035 
00036 typedef struct DBusServerVTable DBusServerVTable;
00037 
00041 struct DBusServerVTable
00042 {
00043   void        (* finalize)      (DBusServer *server);
00046   void        (* disconnect)    (DBusServer *server);
00048 };
00049 
00053 struct DBusServer
00054 {
00055   DBusAtomic refcount;                        
00056   const DBusServerVTable *vtable;             
00057   DBusMutex *mutex;                           
00058   DBusWatchList *watches;                     
00059   DBusTimeoutList *timeouts;                  
00061   char *address;                              
00063   int max_connections;                        
00065   DBusDataSlotList slot_list;   
00067   DBusNewConnectionFunction  new_connection_function;
00069   void *new_connection_data;
00071   DBusFreeFunction new_connection_free_data_function;
00076   char **auth_mechanisms; 
00078   unsigned int disconnected : 1;              
00080 #ifndef DBUS_DISABLE_CHECKS
00081   unsigned int have_server_lock : 1; 
00082 #endif
00083 };
00084 
00085 dbus_bool_t _dbus_server_init_base      (DBusServer             *server,
00086                                          const DBusServerVTable *vtable,
00087                                          const DBusString       *address);
00088 void        _dbus_server_finalize_base  (DBusServer             *server);
00089 dbus_bool_t _dbus_server_add_watch      (DBusServer             *server,
00090                                          DBusWatch              *watch);
00091 void        _dbus_server_remove_watch   (DBusServer             *server,
00092                                          DBusWatch              *watch);
00093 void        _dbus_server_toggle_watch   (DBusServer             *server,
00094                                          DBusWatch              *watch,
00095                                          dbus_bool_t             enabled);
00096 dbus_bool_t _dbus_server_add_timeout    (DBusServer             *server,
00097                                          DBusTimeout            *timeout);
00098 void        _dbus_server_remove_timeout (DBusServer             *server,
00099                                          DBusTimeout            *timeout);
00100 void        _dbus_server_toggle_timeout (DBusServer             *server,
00101                                          DBusTimeout            *timeout,
00102                                          dbus_bool_t             enabled);
00103 
00104 void        _dbus_server_ref_unlocked   (DBusServer             *server);
00105 
00106 #ifdef DBUS_DISABLE_CHECKS
00107 #define TOOK_LOCK_CHECK(server)
00108 #define RELEASING_LOCK_CHECK(server)
00109 #define HAVE_LOCK_CHECK(server)
00110 #else
00111 #define TOOK_LOCK_CHECK(server) do {                \
00112     _dbus_assert (!(server)->have_server_lock); \
00113     (server)->have_server_lock = TRUE;          \
00114   } while (0)
00115 #define RELEASING_LOCK_CHECK(server) do {            \
00116     _dbus_assert ((server)->have_server_lock);   \
00117     (server)->have_server_lock = FALSE;          \
00118   } while (0)
00119 #define HAVE_LOCK_CHECK(server)        _dbus_assert ((server)->have_server_lock)
00120 /* A "DO_NOT_HAVE_LOCK_CHECK" is impossible since we need the lock to check the flag */
00121 #endif
00122 
00123 #define TRACE_LOCKS 0
00124 
00125 #define SERVER_LOCK(server)   do {                                              \
00126     if (TRACE_LOCKS) { _dbus_verbose ("  LOCK: %s\n", _DBUS_FUNCTION_NAME); }   \
00127     dbus_mutex_lock ((server)->mutex);                                          \
00128     TOOK_LOCK_CHECK (server);                                                   \
00129   } while (0)
00130 
00131 #define SERVER_UNLOCK(server) do {                                                      \
00132     if (TRACE_LOCKS) { _dbus_verbose ("  UNLOCK: %s\n", _DBUS_FUNCTION_NAME);  }        \
00133     RELEASING_LOCK_CHECK (server);                                                      \
00134     dbus_mutex_unlock ((server)->mutex);                                                \
00135   } while (0)
00136 
00137 DBUS_END_DECLS
00138 
00139 #endif /* DBUS_SERVER_PROTECTED_H */

Generated on Tue Dec 20 14:16:42 2005 for D-BUS by  doxygen 1.4.2