diff --git a/icons.qrc b/icons.qrc new file mode 100644 index 00000000..9de097c3 --- /dev/null +++ b/icons.qrc @@ -0,0 +1,14 @@ + + + icons/guh-logo.svg + icons/guh-logo-8x8.png + icons/guh-logo-16x16.png + icons/guh-logo-22x22.png + icons/guh-logo-32x32.png + icons/guh-logo-48x48.png + icons/guh-logo-64x64.png + icons/guh-logo-128x128.png + icons/guh-logo-256x256.png + icons/guh-logo-512x512.png + + diff --git a/icons/guh-logo-128x128.png b/icons/guh-logo-128x128.png new file mode 100644 index 00000000..14305711 Binary files /dev/null and b/icons/guh-logo-128x128.png differ diff --git a/icons/guh-logo-16x16.png b/icons/guh-logo-16x16.png new file mode 100644 index 00000000..9e9be80d Binary files /dev/null and b/icons/guh-logo-16x16.png differ diff --git a/icons/guh-logo-22x22.png b/icons/guh-logo-22x22.png new file mode 100644 index 00000000..a907cb51 Binary files /dev/null and b/icons/guh-logo-22x22.png differ diff --git a/icons/guh-logo-256x256.png b/icons/guh-logo-256x256.png new file mode 100644 index 00000000..8aa39bf7 Binary files /dev/null and b/icons/guh-logo-256x256.png differ diff --git a/icons/guh-logo-32x32.png b/icons/guh-logo-32x32.png new file mode 100644 index 00000000..72b68065 Binary files /dev/null and b/icons/guh-logo-32x32.png differ diff --git a/icons/guh-logo-48x48.png b/icons/guh-logo-48x48.png new file mode 100644 index 00000000..858a6534 Binary files /dev/null and b/icons/guh-logo-48x48.png differ diff --git a/icons/guh-logo-512x512.png b/icons/guh-logo-512x512.png new file mode 100644 index 00000000..46a7cc63 Binary files /dev/null and b/icons/guh-logo-512x512.png differ diff --git a/icons/guh-logo-64x64.png b/icons/guh-logo-64x64.png new file mode 100644 index 00000000..2b865ecd Binary files /dev/null and b/icons/guh-logo-64x64.png differ diff --git a/icons/guh-logo-8x8.png b/icons/guh-logo-8x8.png new file mode 100644 index 00000000..60daa23e Binary files /dev/null and b/icons/guh-logo-8x8.png differ diff --git a/icons/guh-logo.svg b/icons/guh-logo.svg new file mode 100644 index 00000000..17065d0b --- /dev/null +++ b/icons/guh-logo.svg @@ -0,0 +1,602 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/server.pri b/server/server.pri index 9a0faf07..b2a6fd55 100644 --- a/server/server.pri +++ b/server/server.pri @@ -5,6 +5,7 @@ contains(DEFINES, WEBSOCKET){ HEADERS += $$top_srcdir/server/websocketserver.h } +RESOURCES += $$top_srcdir/icons.qrc SOURCES += $$top_srcdir/server/guhcore.cpp \ $$top_srcdir/server/tcpserver.cpp \ diff --git a/server/webserver.cpp b/server/webserver.cpp index cc93b681..2d0a62b5 100644 --- a/server/webserver.cpp +++ b/server/webserver.cpp @@ -195,6 +195,28 @@ QString WebServer::fileName(const QString &query) return m_webinterfaceDir.path() + fileName; } +HttpReply *WebServer::processIconRequest(const QString &fileName) +{ + if (!fileName.endsWith(".png")) + return RestResource::createErrorReply(HttpReply::NotFound); + + QByteArray imageData; + + QImage image(":" + fileName); + QBuffer buffer(&imageData); + buffer.open(QIODevice::WriteOnly); + image.save(&buffer, "png"); + + if (!imageData.isEmpty()) { + HttpReply *reply = RestResource::createSuccessReply(); + reply->setHeader(HttpReply::ContentTypeHeader, "image/png"); + reply->setPayload(imageData); + return reply; + } + + return RestResource::createErrorReply(HttpReply::NotFound); +} + void WebServer::incomingConnection(qintptr socketDescriptor) { if (!m_enabled) @@ -332,6 +354,15 @@ void WebServer::readClient() return; } + // check icon call + if (request.url().path().startsWith("/icons/") && request.method() == HttpRequest::Get) { + HttpReply *reply = processIconRequest(request.url().path()); + reply->setClientId(clientId); + sendHttpReply(reply); + reply->deleteLater(); + return; + } + // request for a file... if (request.method() == HttpRequest::Get) { // check if the webinterface dir does exist, otherwise a filerequest is not relevant diff --git a/server/webserver.h b/server/webserver.h index c84f3cad..56ee4948 100644 --- a/server/webserver.h +++ b/server/webserver.h @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -89,6 +91,8 @@ private: bool verifyFile(QSslSocket *socket, const QString &fileName); QString fileName(const QString &query); + HttpReply *processIconRequest(const QString &fileName); + protected: void incomingConnection(qintptr socketDescriptor) override;