configure.ac: if neither boost nor tr1 is available, die right away.
[wvstreams.git] / dbus / tests / wvdbusd.cc
blob63621026b2f13381f3e8028a1a8b792e346a9f50
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"
10 static WvX509Mgr *cert = NULL;
13 class WvDBusDaemon : public WvStreamsDaemon
15 public:
16 WvDBusDaemon() :
17 WvStreamsDaemon("WvDBusDaemon", WVPACKAGE_VERSION,
18 wv::bind(&WvDBusDaemon::cb, this)),
19 log("WvDBusDaemon", WvLog::Debug), configfile("wvdbus.ini")
21 args.add_option('c', "config", "Specify path to configuration file",
22 "FILENAME", configfile);
23 args.add_required_arg("MONIKER", true);
26 virtual ~WvDBusDaemon()
28 WVRELEASE(cert);
31 void cb()
33 log("WvDBusDaemon starting.\n");
34 conf.mount(WvString("ini:%s", configfile));
36 if (!cert && conf["cert"].exists() && conf["privrsa"].exists())
38 cert = new WvX509Mgr;
39 cert->decode(WvX509::CertPEM, *conf["cert"]);
40 cert->decode(WvRSAKey::RsaPEM, *conf["privrsa"]);
42 if (!cert->test())
44 log("Certificate found in ini file, but failed to load!\n");
45 WVRELEASE(cert);
47 else
48 log("Certificate found in ini file, and loaded!\n");
51 WvDBusServer *s = new WvDBusServer;
52 WvStringList::Iter i(extra_args());
53 for (i.rewind(); i.next(); )
54 s->listen(*i);
55 add_die_stream(s, true, "DBus Server");
58 private:
59 WvLog log;
60 UniConfRoot conf;
61 WvString configfile;
65 static IWvStream *dbus_serv_creator(WvStringParm s, IObject *obj)
67 return new WvSSLStream(IWvStream::create(s, obj), cert, 0, true);
70 static WvMoniker<IWvStream> sreg("sslserv", dbus_serv_creator, true);
73 int main(int argc, char *argv[])
75 return WvDBusDaemon().run(argc, argv);