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 
29 using namespace fawkes;
30 
31 class QAAvahiPublisherMain : public SignalHandler
32 {
33 public:
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 
60 private:
61  AvahiThread *at;
62 };
63 
64 int
65 main(int argc, char **argv)
66 {
67  QAAvahiPublisherMain m;
69 
70  m.run();
71 
73 }
74 
75 /// @endcond
fawkes::SignalHandler
Definition: signal.h:45
fawkes::SignalManager::finalize
static void finalize()
Finalize (and free) the SignalManager instance, this does NOT implicitly delete the signal handlers,...
Definition: signal.cpp:106
fawkes::SignalManager::register_handler
static SignalHandler * register_handler(int signum, SignalHandler *handler)
Register a SignalHandler for a signal.
Definition: signal.cpp:123
fawkes::AvahiThread
Definition: avahi_thread.h:53
fawkes::NetworkService
Definition: service.h:43
fawkes