Make WvStreams compile with gcc 4.4.
[wvstreams.git] / include / wvdbusserver.h
blob77a5213cdd74cdb697dbb06a1279d965f7162a1a
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2004-2006 Net Integration Technologies, Inc.
5 * Pathfinder Software:
6 * Copyright (C) 2007, Carillon Information Security Inc.
8 * This library is licensed under the LGPL, please read LICENSE for details.
9 *
10 * This class represents a dbus server, which may have multiple connections
11 * at the same time. It is intended purely for unit testing and debugging
12 * purposes and by no means should be used in production code (use the
13 * dbus daemon for that).
15 */
16 #ifndef __WVDBUSSERVER_H
17 #define __WVDBUSSERVER_H
19 #include "wvlistener.h"
20 #include "wvhashtable.h"
21 #include "wvlog.h"
22 #include "wvistreamlist.h"
23 #include <stdint.h>
25 class WvDBusMsg;
26 class WvDBusConn;
27 DeclareWvList(WvDBusConn);
30 class WvDBusServer : public WvIStreamList
32 WvIStreamList listeners;
33 public:
34 /*
35 * Constructs a new DBus server. You must then call listen() to
36 * actually listen for new connections.
38 WvDBusServer();
40 /**
41 * Not actually defined. Just prevents accidental copying.
43 WvDBusServer(WvDBusServer &c);
45 /**
46 * Shut down this server.
48 virtual ~WvDBusServer();
50 /**
51 * Listen using a given WvListener moniker. Until you do this at least
52 * once, this stream is !isok(). It is okay to call listen() more
53 * than once if you want to listen on more than one port.
55 * For example:
56 * WvDBusServer s;
57 * s.listen("unix:/tmp/foo");
59 void listen(WvStringParm moniker);
61 virtual bool isok() const;
62 virtual int geterr() const;
64 /**
65 * Register a given dbus service name as belonging to a particular
66 * connection.
68 void register_name(WvStringParm name, WvDBusConn *conn);
70 /**
71 * Undo a register_name().
73 void unregister_name(WvStringParm name, WvDBusConn *conn);
75 /**
76 * Forget all name registrations for a particular connection. Also
77 * forget all serial numbers attached to that connection. Mostly useful
78 * when a connection closes.
80 void unregister_conn(WvDBusConn *conn);
82 /**
83 * get the full, final address (identification guid and all) of the server
84 * if there's more than one listener, returns one of them.
86 WvString get_addr();
88 private:
89 WvLog log;
90 WvDBusConnList all_conns;
91 std::map<WvString,WvDBusConn*> name_to_conn;
93 void new_connection_cb(IWvStream *s);
94 void conn_closed(WvStream &s);
96 bool do_server_msg(WvDBusConn &conn, WvDBusMsg &msg);
97 bool do_bridge_msg(WvDBusConn &conn, WvDBusMsg &msg);
98 bool do_broadcast_msg(WvDBusConn &conn, WvDBusMsg &msg);
99 bool do_gaveup_msg(WvDBusConn &conn, WvDBusMsg &msg);
102 #endif // __WVDBUSSERVER_H