webview_thread.h

00001
00002 /***************************************************************************
00003  *  webview_thread.h - Thread that handles web interface requests
00004  *
00005  *  Created: Mon Oct 13 17:49:52 2008 (I5 Developer's Day)
00006  *  Copyright  2006-2008  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.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022
00023 #ifndef __PLUGINS_WEBVIEW_WEBVIEW_THREAD_H_
00024 #define __PLUGINS_WEBVIEW_WEBVIEW_THREAD_H_
00025 
00026 #include <core/threading/thread.h>
00027 #include <aspect/logging.h>
00028 #include <aspect/configurable.h>
00029 #include <aspect/blackboard.h>
00030 #include <aspect/network.h>
00031 #include <aspect/logger.h>
00032 #include <aspect/plugin_director.h>
00033
00034 #include <utils/logging/cache.h>
00035
00036 namespace fawkes {
00037   class NetworkService;
00038 }
00039
00040 class WebRequestDispatcher;
00041 class WebStaticRequestProcessor;
00042 class WebBlackBoardRequestProcessor;
00043 class WebStartPageRequestProcessor;
00044 class WebPluginsRequestProcessor;
00045 class WebviewServiceBrowseHandler;
00046
00047 class WebviewThread
00048 : public fawkes::Thread,
00049   public fawkes::LoggingAspect,
00050   public fawkes::ConfigurableAspect,
00051   public fawkes::BlackBoardAspect,
00052   public fawkes::NetworkAspect,
00053   public fawkes::LoggerAspect,
00054   public fawkes::PluginDirectorAspect
00055 {
00056  public:
00057   WebviewThread();
00058   ~WebviewThread();
00059
00060   virtual void init();
00061   virtual void finalize();
00062   virtual void loop();
00063
00064   static const char *STATIC_URL_PREFIX;
00065   static const char *BLACKBOARD_URL_PREFIX;
00066   static const char *PLUGINS_URL_PREFIX;
00067 
00068  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00069  protected: virtual void run() { Thread::run(); }
00070
00071  private:
00072   struct MHD_Daemon    *__daemon;
00073   WebRequestDispatcher *__dispatcher;
00074
00075   WebStaticRequestProcessor      *__static_processor;
00076   WebStartPageRequestProcessor   *__startpage_processor;
00077   WebBlackBoardRequestProcessor  *__blackboard_processor;
00078   WebPluginsRequestProcessor     *__plugins_processor;
00079   WebviewServiceBrowseHandler    *__service_browse_handler;
00080
00081   unsigned int __cfg_port;
00082
00083   fawkes::CacheLogger     __cache_logger;
00084   fawkes::NetworkService *__webview_service;
00085 };
00086
00087
00088 #endif