#ifndef WEBSERVERNOTIFY_H #define WEBSERVERNOTIFY_H #include #include #include #include #include #include #include #include #include #include struct Notification { QString nickname; QString url; QString content; QString soundURL; QString blockColor; QString borderColor; int borderSize; int duration; QString titleColor; QString titleFamily; int titleSize; QString contentColor; QString contentFamily; int contentSize; qint64 timestamp; // Новое поле для цвета фона страницы QString pageBackgroundColor; Notification() : borderSize(2), duration(10), titleSize(16), contentSize(14), timestamp(0), pageBackgroundColor("transparent") // По умолчанию прозрачный {} }; class HttpServer : public QObject { Q_OBJECT public: explicit HttpServer(QObject *parent = nullptr); ~HttpServer(); bool start(quint16 port); void stop(); quint16 port() const; void addNotification(const Notification ¬ification); void clearNotifications(); signals: void serverStarted(bool success); private slots: void onNewConnection(); void readClient(); void discardClient(); private: QTcpServer *m_server; QList m_clients; QList m_notifications; QString m_pageBackgroundColor; // Цвет фона страницы void processRequest(QTcpSocket *socket, const QString &request); void sendResponse(QTcpSocket *socket, const QString &contentType, const QString &content, int statusCode = 200); void sendHtmlPage(QTcpSocket *socket); void sendJSONMessages(QTcpSocket *socket); void serveStaticFile(QTcpSocket *socket, const QString &filePath); QString getMimeType(const QString &filePath); QString generateHTML(); QString generateJSON(); void cleanOldMessages(); }; #endif // WEBSERVERNOTIFY_H