Fawkes API  Fawkes Development Version
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-2014 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef __PLUGINS_WEBVIEW_WEBVIEW_THREAD_H_
23 #define __PLUGINS_WEBVIEW_WEBVIEW_THREAD_H_
24 
25 #include <core/threading/thread.h>
26 #include <aspect/logging.h>
27 #include <aspect/configurable.h>
28 #include <aspect/blackboard.h>
29 #include <aspect/network.h>
30 #include <aspect/logger.h>
31 #include <aspect/plugin_director.h>
32 #include <aspect/webview.h>
33 #ifdef HAVE_JPEG
34 # include <aspect/thread_producer.h>
35 #endif
36 #ifdef HAVE_TF
37 # include <aspect/tf.h>
38 #endif
39 
40 #include <logging/cache.h>
41 
42 namespace fawkes {
43  class NetworkService;
44  class WebServer;
45  class WebRequestDispatcher;
46 }
47 
56 #ifdef HAVE_TF
58 #endif
59 #ifdef HAVE_JPEG
61 #endif
62 
64 : public fawkes::Thread,
65  public fawkes::LoggingAspect,
68  public fawkes::NetworkAspect,
69  public fawkes::LoggerAspect,
71 #ifdef HAVE_JPEG
73 #endif
74 #ifdef HAVE_TF
76 #endif
78 {
79  public:
80  WebviewThread();
81  ~WebviewThread();
82 
83  virtual void init();
84  virtual void finalize();
85  virtual void loop();
86 
87  static const char *STATIC_URL_PREFIX;
88  static const char *BLACKBOARD_URL_PREFIX;
89  static const char *PLUGINS_URL_PREFIX;
90  static const char *TF_URL_PREFIX;
91  static const char *IMAGE_URL_PREFIX;
92 
93  private:
94  void ssl_create(const char *ssl_key_file, const char *ssl_cert_file);
95 
96 
97  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
98  protected: virtual void run() { Thread::run(); }
99 
100  private:
101  fawkes::WebServer *__webserver;
102  fawkes::WebRequestDispatcher *__dispatcher;
103 
104  WebviewStaticRequestProcessor *__static_processor;
105  WebviewStartPageRequestProcessor *__startpage_processor;
106  WebviewBlackBoardRequestProcessor *__blackboard_processor;
107  WebviewPluginsRequestProcessor *__plugins_processor;
108 #ifdef HAVE_TF
109  WebviewTfRequestProcessor *__tf_processor;
110 #endif
111 #ifdef HAVE_JPEG
112  WebviewImageRequestProcessor *__image_processor;
113 #endif
114  WebviewServiceBrowseHandler *__service_browse_handler;
115  WebviewHeaderGenerator *__header_gen;
116  WebviewFooterGenerator *__footer_gen;
117  WebviewUserVerifier *__user_verifier;
118 
119  unsigned int __cfg_port;
120  bool __cfg_use_ipv4;
121  bool __cfg_use_ipv6;
122  bool __cfg_use_ssl;
123  bool __cfg_ssl_create;
124  std::string __cfg_ssl_key;
125  std::string __cfg_ssl_cert;
126  std::string __cfg_ssl_cipher_suite;
127  bool __cfg_use_basic_auth;
128  std::string __cfg_basic_auth_realm;
129  std::string __cfg_access_log;
130 
131  fawkes::CacheLogger __cache_logger;
132  fawkes::NetworkService *__webview_service;
133 };
134 
135 
136 #endif
Thread aspect that allows to provide a logger to Fawkes.
Definition: logger.h:36
Web request dispatcher.
Encapsulation of the libmicrohttpd webserver.
Definition: server.h:43
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
static const char * TF_URL_PREFIX
Prefix for the WebTfRequestProcessor.
Image stream web processor.
static const char * STATIC_URL_PREFIX
Prefix for the WebStaticRequestProcessor.
Fawkes library namespace.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Logging Cache.
Definition: cache.h:40
Thread aspect for network communication.
Definition: network.h:37
Thread class encapsulation of pthreads.
Definition: thread.h:42
Transfrom data web request processor.
Definition: tf_processor.h:38
Static file web processor.
Thread aspect to access the PluginManager.
Thread aspect to access the transform system.
Definition: tf.h:42
static const char * IMAGE_URL_PREFIX
Prefix for the WebMJPEGRequestProcessor.
BlackBoard web request processor.
Webview user verification.
Definition: user_verifier.h:33
Thread aspect to log output.
Definition: logging.h:35
static const char * BLACKBOARD_URL_PREFIX
Prefix for the WebBlackBoardRequestProcessor.
Aspect for thread producing threads.
Representation of a service announced or found via service discovery (i.e.
Definition: service.h:37
Thread aspect to access configuration data.
Definition: configurable.h:35
Web request processor for the start page.
static const char * PLUGINS_URL_PREFIX
Prefix for the WebPluginsRequestProcessor.
Webview page footer.
Thread aspect to provide web pages via Webview.
Definition: webview.h:38
Webview Thread.
Browse handler to detect other Webview instances on the network.
Webview page header.
Plugins web request processor.