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-2018 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 <aspect/configurable.h>
26 #include <aspect/logging.h>
27 #include <aspect/network.h>
28 #include <aspect/webview.h>
29 #include <core/threading/thread.h>
30 #include <logging/cache.h>
31 
32 namespace fawkes {
33 class NetworkService;
34 class WebServer;
35 class WebRequestDispatcher;
36 class WebReply;
37 } // namespace fawkes
38 
43 
45  public fawkes::LoggingAspect,
47  public fawkes::NetworkAspect,
49 {
50 public:
51  WebviewThread(bool enable_tp);
52  ~WebviewThread();
53 
54  virtual void init();
55  virtual void finalize();
56  virtual void loop();
57 
58 private:
59  void tls_create(const char *tls_key_file, const char *tls_cert_file);
60  fawkes::WebReply *produce_404();
61 
62  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
63 protected:
64  virtual void
65  run()
66  {
67  Thread::run();
68  }
69 
70 private:
71  fawkes::WebServer * webserver_;
72  fawkes::WebRequestDispatcher *dispatcher_;
73 
74  WebviewStaticRequestProcessor *static_processor_;
75  WebviewRESTRequestProcessor * rest_processor_;
76  WebviewServiceBrowseHandler * service_browse_handler_;
77  WebviewUserVerifier * user_verifier_;
78 
79  unsigned int cfg_port_;
80  bool cfg_use_ipv4_;
81  bool cfg_use_ipv6_;
82  bool cfg_use_tls_;
83  bool cfg_tls_create_;
84  std::string cfg_tls_key_;
85  std::string cfg_tls_cert_;
86  std::string cfg_tls_cipher_suite_;
87  bool cfg_use_basic_auth_;
88  std::string cfg_basic_auth_realm_;
89  std::string cfg_access_log_;
90  bool cfg_use_thread_pool_;
91  unsigned int cfg_num_threads_;
92  std::vector<std::string> cfg_explicit_404_;
93 
94  fawkes::NetworkService *webview_service_;
95 };
96 
97 #endif
WebviewThread::finalize
virtual void finalize()
Finalize the thread.
Definition: webview_thread.cpp:259
WebviewUserVerifier
Definition: user_verifier.h:33
fawkes::WebServer
Definition: server.h:43
WebviewThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: webview_thread.h:65
fawkes::WebRequestDispatcher
Definition: request_dispatcher.h:51
WebviewRESTRequestProcessor
Definition: rest_processor.h:37
fawkes::NetworkService
Definition: service.h:43
fawkes
fawkes::LoggingAspect
Definition: logging.h:38
WebviewThread::loop
virtual void loop()
Code to execute in the thread.
Definition: webview_thread.cpp:286
WebviewThread::init
virtual void init()
Initialize the thread.
Definition: webview_thread.cpp:68
WebviewThread
Definition: webview_thread.h:44
fawkes::WebviewAspect
Definition: webview.h:42
fawkes::Thread
Definition: thread.h:45
WebviewStaticRequestProcessor
Definition: static_processor.h:37
fawkes::ConfigurableAspect
Definition: configurable.h:38
WebviewThread::WebviewThread
WebviewThread(bool enable_tp)
Constructor.
Definition: webview_thread.cpp:54
fawkes::WebReply
Definition: reply.h:39
WebviewServiceBrowseHandler
Definition: service_browse_handler.h:36
fawkes::NetworkAspect
Definition: network.h:40