hyperion.ng
WebServer.h
1 #ifndef WEBSERVER_H
2 #define WEBSERVER_H
3 
4 #include <QObject>
5 #include <QString>
6 #include <QJsonDocument>
7 
8 // hyperion / utils
9 #include <utils/Logger.h>
10 
11 // settings
12 #include <utils/settings.h>
13 
15 class StaticFileServing;
16 class QtHttpServer;
17 
18 class WebServer : public QObject {
19  Q_OBJECT
20 
21 public:
22  WebServer (const QJsonDocument& config, QObject * parent = 0);
23 
24  virtual ~WebServer (void);
25 
26  void start();
27  void stop();
28 
29  quint16 getPort() { return _port; };
30 
32  bool isInited() { return _inited; };
33 
37  void setSSDPDescription(const QString & desc);
38 
39 signals:
44  void stateChange(const bool newState);
45 
49  void portChanged(const quint16& port);
50 
51 public slots:
55  void initServer();
56 
57  void onServerStopped (void);
58  void onServerStarted (quint16 port);
59  void onServerError (QString msg);
60 
66  void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
67 
68 private:
69  QJsonDocument _config;
70  Logger* _log;
71  QString _baseUrl;
72  quint16 _port;
73  StaticFileServing* _staticFileServing;
74  QtHttpServer* _server;
75  bool _inited = false;
76 
77  const QString WEBSERVER_DEFAULT_PATH = ":/webconfig";
78  const quint16 WEBSERVER_DEFAULT_PORT = 8090;
79 
80  BonjourServiceRegister * _serviceRegister = nullptr;
81 };
82 
83 #endif // WEBSERVER_H
Definition: Logger.h:32
void setSSDPDescription(const QString &desc)
Set a new description, if empty the description is NotFound for clients.
Definition: WebServer.cpp:124
void initServer()
Init server after thread start.
Definition: WebServer.cpp:28
void portChanged(const quint16 &port)
Emits whenever the port changes (doesn&#39;t compare prev <> now)
Definition: bonjourserviceregister.h:43
bool isInited()
check if server has been inited
Definition: WebServer.h:32
void stateChange(const bool newState)
whenever server is started or stopped (to sync with SSDPHandler)
Definition: QtHttpServer.h:37
Definition: WebServer.h:18
Definition: StaticFileServing.h:14
void handleSettingsUpdate(const settings::type &type, const QJsonDocument &config)
Handle settings update from Hyperion Settingsmanager emit or this constructor.
Definition: WebServer.cpp:75