Free memory with dbus_free instead of free. Account for NULL signatures.
[dbus-cxx-async.git] / src / connection_p.h
blobeebf41f7957132f80722770fc19bda73c1ea81b4
1 /*
3 * D-Bus++ - C++ bindings for D-Bus
5 * Copyright (C) 2005-2009 Paolo Durante <shackan@gmail.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef __DBUSXX_CONNECTION_P_H
26 #define __DBUSXX_CONNECTION_P_H
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
32 #include <dbus-c++/connection.h>
33 #include <dbus-c++/server.h>
34 #include <dbus-c++/dispatcher.h>
35 #include <dbus-c++/refptr_impl.h>
37 #include <dbus/dbus.h>
39 #include <string>
40 #include <map>
42 namespace DBus {
44 // Forward Declaration
45 class DispatcherCache;
47 class ConnectionPMap : private std::map<DBusConnection *, RefPtrI<Connection::Private> >, public Synchronized
49 public:
51 typedef RefPtrI<Connection::Private> Ref;
52 typedef std::map<DBusConnection *, Ref> Base;
54 ~ConnectionPMap()
56 Guard g(this);
58 while (!empty()) Base::erase(begin());
61 Ref& get(DBusConnection *c)
63 Guard g(this);
65 return Base::operator [](c);
68 void remove(DBusConnection *c)
70 Guard g(this);
72 Base::erase(c);
76 struct DBUSXXAPILOCAL Connection::Private : public CallbackTarget
78 RefPtrI<DispatcherCache> dispCache;
79 DBusConnection *conn;
80 bool priv;
82 std::vector<std::string> names;
84 Dispatcher *dispatcher;
85 bool do_dispatch();
87 MessageSlot disconn_filter;
88 bool disconn_filter_function(const Message &);
90 Server::Private *server;
91 void detach_server();
93 Private(DBusConnection *, bool, Dispatcher *, Server::Private * = NULL);
95 ~Private();
97 void init();
99 DBusDispatchStatus dispatch_status();
100 bool has_something_to_dispatch();
102 static void dispatch_status_stub(DBusConnection *, DBusDispatchStatus, void *);
104 static DBusHandlerResult message_filter_stub(DBusConnection *, DBusMessage *, void *);
107 } /* namespace DBus */
109 #endif//__DBUSXX_CONNECTION_P_H