WvStreams
wvdbusd.cc
1#include "wvdbusserver.h"
2#include "wvstreamsdaemon.h"
3#include "wvautoconf.h"
4#include "wvx509mgr.h"
5#include "wvsslstream.h"
6#include "wvmoniker.h"
7#include "uniconfroot.h"
8
9
10static WvX509Mgr *cert = NULL;
11
12
13class WvDBusDaemon : public WvStreamsDaemon
14{
15public:
16 WvDBusDaemon() :
17 WvStreamsDaemon("WvDBusDaemon", WVPACKAGE_VERSION,
18 wv::bind(&WvDBusDaemon::cb, this)),
19 log("WvDBusDaemon", WvLog::Debug), configfile("wvdbus.ini")
20 {
21 args.add_option('c', "config", "Specify path to configuration file",
22 "FILENAME", configfile);
23 args.add_required_arg("MONIKER", true);
24 }
25
26 virtual ~WvDBusDaemon()
27 {
28 WVRELEASE(cert);
29 }
30
31 void cb()
32 {
33 log("WvDBusDaemon starting.\n");
34 conf.mount(WvString("ini:%s", configfile));
35
36 if (!cert && conf["cert"].exists() && conf["privrsa"].exists())
37 {
38 cert = new WvX509Mgr;
39 cert->decode(WvX509::CertPEM, *conf["cert"]);
40 cert->decode(WvRSAKey::RsaPEM, *conf["privrsa"]);
41
42 if (!cert->test())
43 {
44 log("Certificate found in ini file, but failed to load!\n");
45 WVRELEASE(cert);
46 }
47 else
48 log("Certificate found in ini file, and loaded!\n");
49 }
50
52 WvStringList::Iter i(extra_args());
53 for (i.rewind(); i.next(); )
54 s->listen(*i);
55 add_die_stream(s, true, "DBus Server");
56 }
57
58private:
59 WvLog log;
60 UniConfRoot conf;
61 WvString configfile;
62};
63
64
65static IWvStream *dbus_serv_creator(WvStringParm s, IObject *obj)
66{
67 return new WvSSLStream(IWvStream::create(s, obj), cert, 0, true);
68}
69
70static WvMoniker<IWvStream> sreg("sslserv", dbus_serv_creator, true);
71
72
73int main(int argc, char *argv[])
74{
75 return WvDBusDaemon().run(argc, argv);
76}
The basic interface which is included by all other XPLC interfaces and objects.
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...
void listen(WvStringParm moniker)
Listen using a given WvListener moniker.
const WvStringList & extra_args() const
Remaining args.
int run(const char *argv0)
Run the daemon with no argument processing. Returns exit status.
Definition wvdaemon.cc:119
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
SSL Stream, handles SSLv2, SSLv3, and TLS Methods - If you want it to be a server,...
WvStreamsDaemon(WvStringParm name, WvStringParm version, WvDaemonCallback cb)
void add_die_stream(IWvStream *istream, bool auto_free, const char *id)
WvString is an implementation of a simple and efficient printable-string class.
virtual void decode(const WvX509::DumpMode mode, WvStringParm encoded)
Load the information from the format requested by mode into the class - this overwrites the certifica...
Definition wvx509mgr.cc:664