File indexing completed on 2024-12-15 03:45:02
0001 /* 0002 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KUSERFEEDBACK_CONSOLE_RESTCLIENT_H 0008 #define KUSERFEEDBACK_CONSOLE_RESTCLIENT_H 0009 0010 #include "serverinfo.h" 0011 0012 #include <QObject> 0013 0014 class QNetworkAccessManager; 0015 class QNetworkReply; 0016 class QNetworkRequest; 0017 0018 namespace KUserFeedback { 0019 namespace Console { 0020 0021 /** REST communication handling. */ 0022 class RESTClient : public QObject 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit RESTClient(QObject *parent = nullptr); 0027 ~RESTClient() override; 0028 0029 ServerInfo serverInfo() const; 0030 void setServerInfo(const ServerInfo &info); 0031 void setConnected(bool connected); 0032 bool isConnected() const; 0033 0034 QNetworkReply* get(const QString &command); 0035 QNetworkReply* post(const QString &command, const QByteArray &data); 0036 QNetworkReply* put(const QString &command, const QByteArray &data); 0037 QNetworkReply* deleteResource(const QString &command); 0038 0039 QNetworkAccessManager* networkAccessManager() const; 0040 Q_SIGNALS: 0041 void clientConnected(); 0042 void errorMessage(const QString &msg); 0043 0044 private: 0045 QNetworkRequest makeRequest(const QString &command); 0046 void setupMessageHandler(QNetworkReply *reply); 0047 0048 ServerInfo m_serverInfo; 0049 QNetworkAccessManager *m_networkAccessManager; 0050 bool m_isConnected = false; 0051 }; 0052 0053 } 0054 } 0055 0056 #endif // KUSERFEEDBACK_CONSOLE_RESTCLIENT_H