Fawkes API Fawkes Development Version
qa_avahi_publisher.cpp
1
2/***************************************************************************
3 * qa_avahi_publisher.cpp - QA for AvahiServicePublisher
4 *
5 * Generated: Tue Nov 07 18:41:46 2006
6 * Copyright 2006 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24/// @cond QA
25
26#include <netcomm/dns-sd/avahi_thread.h>
27#include <utils/system/signal.h>
28
29using namespace fawkes;
30
31class QAAvahiPublisherMain : public SignalHandler
32{
33public:
34 QAAvahiPublisherMain()
35 {
36 NetworkService *as = new NetworkService("Fawkes QA", "_fawkes._udp", 1910);
37 at = new AvahiThread();
38 at->publish_service(as);
39 delete as;
40 }
41
42 ~QAAvahiPublisherMain()
43 {
44 delete at;
45 }
46
47 void
48 handle_signal(int signum)
49 {
50 at->cancel();
51 }
52
53 void
54 run()
55 {
56 at->start();
57 at->join();
58 }
59
60private:
61 AvahiThread *at;
62};
63
64int
65main(int argc, char **argv)
66{
67 QAAvahiPublisherMain m;
68 SignalManager::register_handler(SIGINT, &m);
69
70 m.run();
71
72 SignalManager::finalize();
73}
74
75/// @endcond
Avahi main thread.
Definition: avahi_thread.h:55
Representation of a service announced or found via service discovery (i.e.
Definition: service.h:38
Interface for signal handling.
Definition: signal.h:36
Fawkes library namespace.