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 
28 #include <utils/system/signal.h>
29 
30 using namespace fawkes;
31 
32 class QAAvahiPublisherMain : public SignalHandler
33 {
34  public:
35  QAAvahiPublisherMain()
36  {
37  NetworkService *as = new NetworkService("Fawkes QA", "_fawkes._udp", 1910);
38  at = new AvahiThread();
39  at->publish_service(as);
40  delete as;
41  }
42 
43  ~QAAvahiPublisherMain()
44  {
45  delete at;
46  }
47 
48  void handle_signal(int signum)
49  {
50  at->cancel();
51  }
52 
53  void run()
54  {
55  at->start();
56  at->join();
57  }
58 
59  private:
60  AvahiThread *at;
61 
62 };
63 
64 int
65 main(int argc, char **argv)
66 {
67  QAAvahiPublisherMain m;
69 
70  m.run();
71 
73 }
74 
75 /// @endcond
static void finalize()
Finalize (and free) the SignalManager instance, this does NOT implicitly delete the signal handlers...
Definition: signal.cpp:98
Fawkes library namespace.
Interface for signal handling.
Definition: signal.h:35
static SignalHandler * register_handler(int signum, SignalHandler *handler)
Register a SignalHandler for a signal.
Definition: signal.cpp:116
Avahi main thread.
Definition: avahi_thread.h:54
Representation of a service announced or found via service discovery (i.e.
Definition: service.h:37