1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00
joplin/QtClient/JoplinQtClient/webapi.h
Laurent Cozic a409f994cd api sync
2016-12-27 21:25:07 +01:00

56 lines
1.5 KiB
C++
Executable File

#ifndef WEBAPI_H
#define WEBAPI_H
#include <stable.h>
namespace jop {
class WebApi : public QObject {
Q_OBJECT
public:
struct QueuedRequest {
QNetworkAccessManager::Operation method;
QString path;
QUrlQuery query;
QUrlQuery data;
QNetworkReply* reply;
QNetworkRequest* request;
QString tag;
};
WebApi(const QString& baseUrl);
QString baseUrl() const;
void execRequest(QNetworkAccessManager::Operation method, const QString& path,const QUrlQuery& query = QUrlQuery(), const QUrlQuery& data = QUrlQuery(), const QString& tag = "");
void post(const QString& path,const QUrlQuery& query = QUrlQuery(), const QUrlQuery& data = QUrlQuery(), const QString& tag = "");
void get(const QString& path,const QUrlQuery& query = QUrlQuery(), const QUrlQuery& data = QUrlQuery(), const QString& tag = "");
void put(const QString& path,const QUrlQuery& query = QUrlQuery(), const QUrlQuery& data = QUrlQuery(), const QString& tag = "");
//void patch(const QString& path,const QUrlQuery& query = QUrlQuery(), const QUrlQuery& data = QUrlQuery(), const QString& tag = "");
void setSessionId(const QString& v);
private:
QString baseUrl_;
QList<QueuedRequest> queuedRequests_;
QList<QueuedRequest> inProgressRequests_;
void processQueue();
QString sessionId_;
QNetworkAccessManager manager_;
public slots:
void request_finished(QNetworkReply* reply);
void request_error(QNetworkReply::NetworkError e);
signals:
void requestDone(const QJsonObject& response, const QString& tag);
};
}
#endif // WEBAPI_H