11#include <QQmlParserStatus>
13#include "shelfmodel.h"
15#ifdef HYELICHT_BUILD_ONBOARD
18class QHttpServerRequest;
19class QHttpServerResponder;
41class HttpServer :
public QObject,
public QQmlParserStatus
44 Q_INTERFACES(QQmlParserStatus)
93 explicit
HttpServer(QObject *parent =
nullptr);
205 void updateHandler();
209#ifdef HYELICHT_BUILD_ONBOARD
210 std::function<void(
const QHttpServerRequest &, QHttpServerResponder &)> propHandler(
const char *prop);
211 std::function<void(
const QHttpServerRequest &, QHttpServerResponder &)> modelRowHandler(
const char *prop,
212 const int index,
const int role);
213 void propToJSon(QHttpServerResponder &responder,
const QHttpHeaders &headers,
214 const QObject *obj,
const char *name);
215 void jsonToProp(
const QHttpServerRequest &request, QHttpServerResponder &responder,
216 const QHttpHeaders &headers, QObject *obj,
const char *name);
218 QJsonObject rowToJson(
const QModelIndex &modelIndex);
219 QHash<int, QVariant> jsonToModelRole(
const QJsonDocument &document,
220 const QString &roleName);
224 QString m_listenAddress;
227#ifdef HYELICHT_BUILD_ONBOARD
228 QPointer<QTcpServer> m_tcpServer;
229 QPointer<QHttpServer> m_httpServer;
232 QPointer<ShelfModel> m_model;
HTTP REST API binding and server for ShelfModel.
Definition httpserver.h:42
void componentComplete() override
Implements the QQmlParserStatus interface.
Definition httpserver.cpp:129
void setModel(ShelfModel *model)
Set the ShelfModel instance this server provides a HTTP REST API binding for.
Definition httpserver.cpp:100
void modelChanged()
The ShelfModel instance this server provides a HTTP REST API binding for has changed.
void classBegin() override
Implements the QQmlParserStatus interface.
Definition httpserver.cpp:124
void listenAddressChanged() const
The listen address for the server has changed.
void setListenAddress(const QString &listenAddress)
Set the listen address for the server.
Definition httpserver.cpp:64
void portChanged() const
The port the server listens on has changed.
QString listenAddress
Listen address for the server.
Definition httpserver.h:65
bool enabled
Toggle the server on or off.
Definition httpserver.h:55
int port
Port the server listens on.
Definition httpserver.h:75
void setEnabled(bool enabled)
Turn the server on or off.
Definition httpserver.cpp:46
void setPort(int port)
Set the port the server listens on.
Definition httpserver.cpp:82
ShelfModel * model
ShelfModel instance this server provides a HTTP REST API binding for.
Definition httpserver.h:86
void enabledChanged() const
The server has turned on or off.
Data model and business logic specific to the Hyelicht shelf.
Definition shelfmodel.h:48