Fawkes API  Fawkes Development Version
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 #include <aspect/webview.h>
00034 
00035 #include <logging/cache.h>
00036 
00037 namespace fawkes {
00038   class NetworkService;
00039   class WebServer;
00040   class WebRequestDispatcher;
00041 }
00042 
00043 class WebviewStaticRequestProcessor;
00044 class WebviewBlackBoardRequestProcessor;
00045 class WebviewStartPageRequestProcessor;
00046 class WebviewPluginsRequestProcessor;
00047 class WebviewServiceBrowseHandler;
00048 class WebviewFooterGenerator;
00049 class WebviewHeaderGenerator;
00050 class WebviewUserVerifier;
00051 
00052 class WebviewThread
00053 : public fawkes::Thread,
00054   public fawkes::LoggingAspect,
00055   public fawkes::ConfigurableAspect,
00056   public fawkes::BlackBoardAspect,
00057   public fawkes::NetworkAspect,
00058   public fawkes::LoggerAspect,
00059   public fawkes::PluginDirectorAspect,
00060   public fawkes::WebviewAspect
00061 {
00062  public:
00063   WebviewThread();
00064   ~WebviewThread();
00065 
00066   virtual void init();
00067   virtual void finalize();
00068   virtual void loop();
00069 
00070   static const char *STATIC_URL_PREFIX;
00071   static const char *BLACKBOARD_URL_PREFIX;
00072   static const char *PLUGINS_URL_PREFIX;
00073 
00074  private:
00075   void ssl_create(const char *ssl_key_file, const char *ssl_cert_file);
00076 
00077 
00078  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00079  protected: virtual void run() { Thread::run(); }
00080 
00081  private:
00082   fawkes::WebServer                  *__webserver;
00083   fawkes::WebRequestDispatcher       *__dispatcher;
00084 
00085   WebviewStaticRequestProcessor      *__static_processor;
00086   WebviewStartPageRequestProcessor   *__startpage_processor;
00087   WebviewBlackBoardRequestProcessor  *__blackboard_processor;
00088   WebviewPluginsRequestProcessor     *__plugins_processor;
00089   WebviewServiceBrowseHandler        *__service_browse_handler;
00090   WebviewHeaderGenerator             *__header_gen;
00091   WebviewFooterGenerator             *__footer_gen;
00092   WebviewUserVerifier                *__user_verifier;
00093 
00094   unsigned int __cfg_port;
00095   bool         __cfg_use_ssl;
00096   bool         __cfg_ssl_create;
00097   std::string  __cfg_ssl_key;
00098   std::string  __cfg_ssl_cert;
00099   bool         __cfg_use_basic_auth;
00100   std::string  __cfg_basic_auth_realm;
00101 
00102   fawkes::CacheLogger     __cache_logger;
00103   fawkes::NetworkService *__webview_service;
00104 };
00105 
00106 
00107 #endif