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
REST API web processor.
Browse handler to detect other Webview instances on the network.
Static file web processor.
Webview Thread.
virtual void finalize()
Finalize the thread.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void init()
Initialize the thread.
WebviewThread(bool enable_tp)
Constructor.
virtual void loop()
Code to execute in the thread.
Webview user verification.
Definition: user_verifier.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
Thread aspect for network communication.
Definition: network.h:35
Representation of a service announced or found via service discovery (i.e.
Definition: service.h:38
Thread class encapsulation of pthreads.
Definition: thread.h:46
Basic web reply.
Definition: reply.h:34
Web request dispatcher.
Encapsulation of the libmicrohttpd webserver.
Definition: server.h:44
Thread aspect to provide web pages via Webview.
Definition: webview.h:37
Fawkes library namespace.