Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
webview_thread.h
1 
2 /***************************************************************************
3  * webview_thread.h - Thread that handles web interface requests
4  *
5  * Created: Mon Oct 13 17:49:52 2008 (I5 Developer's Day)
6  * Copyright 2006-2008 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.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_WEBVIEW_WEBVIEW_THREAD_H_
24 #define __PLUGINS_WEBVIEW_WEBVIEW_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/logging.h>
28 #include <aspect/configurable.h>
29 #include <aspect/blackboard.h>
30 #include <aspect/network.h>
31 #include <aspect/logger.h>
32 #include <aspect/plugin_director.h>
33 #include <aspect/webview.h>
34 
35 #include <logging/cache.h>
36 
37 namespace fawkes {
38  class NetworkService;
39  class WebServer;
40  class WebRequestDispatcher;
41 }
42 
51 
53 : public fawkes::Thread,
54  public fawkes::LoggingAspect,
57  public fawkes::NetworkAspect,
58  public fawkes::LoggerAspect,
61 {
62  public:
63  WebviewThread();
64  ~WebviewThread();
65 
66  virtual void init();
67  virtual void finalize();
68  virtual void loop();
69 
70  static const char *STATIC_URL_PREFIX;
71  static const char *BLACKBOARD_URL_PREFIX;
72  static const char *PLUGINS_URL_PREFIX;
73 
74  private:
75  void ssl_create(const char *ssl_key_file, const char *ssl_cert_file);
76 
77 
78  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
79  protected: virtual void run() { Thread::run(); }
80 
81  private:
82  fawkes::WebServer *__webserver;
83  fawkes::WebRequestDispatcher *__dispatcher;
84 
85  WebviewStaticRequestProcessor *__static_processor;
86  WebviewStartPageRequestProcessor *__startpage_processor;
87  WebviewBlackBoardRequestProcessor *__blackboard_processor;
88  WebviewPluginsRequestProcessor *__plugins_processor;
89  WebviewServiceBrowseHandler *__service_browse_handler;
90  WebviewHeaderGenerator *__header_gen;
91  WebviewFooterGenerator *__footer_gen;
92  WebviewUserVerifier *__user_verifier;
93 
94  unsigned int __cfg_port;
95  bool __cfg_use_ssl;
96  bool __cfg_ssl_create;
97  std::string __cfg_ssl_key;
98  std::string __cfg_ssl_cert;
99  bool __cfg_use_basic_auth;
100  std::string __cfg_basic_auth_realm;
101 
102  fawkes::CacheLogger __cache_logger;
103  fawkes::NetworkService *__webview_service;
104 };
105 
106 
107 #endif