Stellarium  0.90.0
RequestHandler.hpp
1 /*
2  * Stellarium Remote Control plugin
3  * Copyright (C) 2015 Florian Schaukowitsch
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef REQUESTHANDLER_HPP_
21 #define REQUESTHANDLER_HPP_
22 
25 
26 class APIController;
28 
33 {
34  Q_OBJECT
35 public:
40  RequestHandler(const StaticFileControllerSettings& settings, QObject* parent = Q_NULLPTR);
42  virtual ~RequestHandler();
43 
45  void update(double deltaTime);
46 
59  virtual void service(HttpRequest& request, HttpResponse& response);
60 
61 public slots:
65  void setUsePassword(bool v);
68  bool getUsePassword() { return usePassword; }
70  void setPassword(const QString& pw);
71 
72 private slots:
73  void refreshTemplates();
74 
75  void addExtensionServices(QObjectList services);
76 
77 private:
78  //Contains the translated templates loaded from the file "translate_files" in the webroot folder
79  QMap<QByteArray,QString> templateMap;
80 
81  bool usePassword;
82  QString password;
83  QByteArray passwordReply;
84  APIController* apiController;
85  StaticFileController* staticFiles;
86  QMutex templateMutex;
87 
88  static const QByteArray AUTH_REALM;
89 };
90 
91 #endif
The request handler generates a response for each HTTP request.
Contains all the settings for the StaticFileController.
void setPassword(const QString &pw)
This is the main request handler for the remote control plugin, receiving and dispatching the HTTP re...
void setUsePassword(bool v)
Sets wether a password set with setPassword() is required by all requests.
virtual ~RequestHandler()
The internal APIController, and all registered services are deleted.
This object represents a single HTTP request.
Definition: httprequest.h:36
bool getUsePassword()
Returns if a password is required to access the remote control.
virtual void service(HttpRequest &request, HttpResponse &response)
Receives the HttpRequest from the HttpListener.
This class handles the API-specific requests and dispatches them to the correct RemoteControlServiceI...
Delivers static files.
RequestHandler(const StaticFileControllerSettings &settings, QObject *parent=Q_NULLPTR)
Constructs the request handler.
void update(double deltaTime)
Called in the main thread each frame, only passed on to APIController::update.
This object represents a HTTP response, used to return something to the web client.
Definition: httpresponse.h:35