qa_avahi_publisher.cpp

00001 
00002 /***************************************************************************
00003  *  qa_avahi_publisher.cpp - QA for AvahiServicePublisher
00004  *
00005  *  Generated: Tue Nov 07 18:41:46 2006
00006  *  Copyright  2006  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 /// @cond QA
00025 
00026 #include <netcomm/dns-sd/avahi_thread.h>
00027 
00028 #include <utils/system/signal.h>
00029 
00030 using namespace fawkes;
00031 
00032 class QAAvahiPublisherMain : public SignalHandler
00033 {
00034  public:
00035   QAAvahiPublisherMain()
00036   {
00037     NetworkService *as = new NetworkService("Fawkes QA", "_fawkes._udp", 1910);
00038     at = new AvahiThread();
00039     at->publish_service(as);
00040     delete as;
00041   }
00042 
00043   ~QAAvahiPublisherMain()
00044   {
00045     delete at;
00046   }
00047 
00048   void handle_signal(int signum)
00049   {
00050     at->cancel();
00051   }
00052 
00053   void run()
00054   {
00055     at->start();
00056     at->join();
00057   }
00058 
00059  private:
00060   AvahiThread *at;
00061 
00062 };
00063 
00064 int
00065 main(int argc, char **argv)
00066 {
00067   QAAvahiPublisherMain m;
00068   SignalManager::register_handler(SIGINT, &m);
00069 
00070   m.run();
00071 
00072   SignalManager::finalize();
00073 }
00074 
00075 /// @endcond

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1