Stellarium 0.15.2
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 = 0);
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 private:
76  //Contains the translated templates loaded from the file "translate_files" in the webroot folder
77  QMap<QByteArray,QString> templateMap;
78 
79  bool usePassword;
80  QString password;
81  QByteArray passwordReply;
82  APIController* apiController;
83  StaticFileController* staticFiles;
84  QMutex templateMutex;
85 
86  static const QByteArray AUTH_REALM;
87 };
88 
89 #endif
The request handler generates a response for each HTTP request.
Contains all the settings for the StaticFileController.
RequestHandler(const StaticFileControllerSettings &settings, QObject *parent=0)
Constructs the request handler.
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 AbstractAPISerice imp...
Delivers static files.
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