WvStreams
wvdbusserver.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 2004-2006 Net Integration Technologies, Inc.
4  *
5  * Pathfinder Software:
6  * Copyright (C) 2007, Carillon Information Security Inc.
7  *
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).
14  *
15  */
16 #ifndef __WVDBUSSERVER_H
17 #define __WVDBUSSERVER_H
18 
19 #include "wvlistener.h"
20 #include "wvhashtable.h"
21 #include "wvlog.h"
22 #include "wvistreamlist.h"
23 #include <stdint.h>
24 
25 class WvDBusMsg;
26 class WvDBusConn;
27 DeclareWvList(WvDBusConn);
28 
29 
31 {
32  WvIStreamList listeners;
33 public:
34  /*
35  * Constructs a new DBus server. You must then call listen() to
36  * actually listen for new connections.
37  */
38  WvDBusServer();
39 
44 
48  virtual ~WvDBusServer();
49 
59  void listen(WvStringParm moniker);
60 
61  virtual bool isok() const;
62  virtual int geterr() const;
63 
68  void register_name(WvStringParm name, WvDBusConn *conn);
69 
73  void unregister_name(WvStringParm name, WvDBusConn *conn);
74 
80  void unregister_conn(WvDBusConn *conn);
81 
87 
88 private:
89  WvLog log;
90  WvDBusConnList all_conns;
91  std::map<WvString,WvDBusConn*> name_to_conn;
92 
93  void new_connection_cb(IWvStream *s);
94  void conn_closed(WvStream &s);
95 
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);
100 };
101 
102 #endif // __WVDBUSSERVER_H
WvDBusServer::isok
virtual bool isok() const
return true if the stream is actually usable right now
Definition: wvdbusserver.cc:139
WvDBusServer::unregister_conn
void unregister_conn(WvDBusConn *conn)
Forget all name registrations for a particular connection.
Definition: wvdbusserver.cc:182
WvDBusServer::register_name
void register_name(WvStringParm name, WvDBusConn *conn)
Register a given dbus service name as belonging to a particular connection.
Definition: wvdbusserver.cc:169
IWvStream
Definition: iwvstream.h:24
WvDBusServer
Definition: wvdbusserver.h:30
WvDBusServer::unregister_name
void unregister_name(WvStringParm name, WvDBusConn *conn)
Undo a register_name().
Definition: wvdbusserver.cc:175
WvDBusServer::listen
void listen(WvStringParm moniker)
Listen using a given WvListener moniker.
Definition: wvdbusserver.cc:126
WvDBusMsg
Definition: wvdbusmsg.h:28
WvDBusServer::~WvDBusServer
virtual ~WvDBusServer()
Shut down this server.
Definition: wvdbusserver.cc:119
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvLog
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition: wvlog.h:56
WvStream
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:24
WvDBusServer::get_addr
WvString get_addr()
get the full, final address (identification guid and all) of the server if there's more than one list...
Definition: wvdbusserver.cc:158
WvDBusServer::geterr
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
Definition: wvdbusserver.cc:152
WvIStreamList
WvStreamList holds a list of WvStream objects – and its select() and callback() functions know how to...
Definition: wvistreamlist.h:20
WvDBusConn
Definition: wvdbusconn.h:65