47 lines
1.4 KiB
C++
Executable File
47 lines
1.4 KiB
C++
Executable File
#include "bookmarkhelper.h"
|
|
#include <QDebug>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
#include <QJsonDocument>
|
|
#include <qeventloop.h>
|
|
#include <qqmlengine.h>
|
|
#include <QNetworkReply>
|
|
|
|
BookmarkHelper::BookmarkHelper() {}
|
|
|
|
void BookmarkHelper::postBookmark(QString uuid, QString name, QString description, qint64 timestamp) {
|
|
QNetworkRequest request;
|
|
|
|
request.setUrl(QUrl("http://localhost:8080/bookmark"));
|
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
|
|
// SSL-Konfiguration ohne Überprüfung des Zertifikats
|
|
QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
|
|
sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
|
|
request.setSslConfiguration(sslConfig);
|
|
|
|
QJsonObject obj;
|
|
|
|
obj["uuid"] = uuid;
|
|
obj["name"] = name;
|
|
obj["description"] = description;
|
|
obj["timestamp"] = timestamp;
|
|
|
|
QJsonDocument jsonDoc(obj);
|
|
QByteArray jsonData = jsonDoc.toJson();
|
|
|
|
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
|
|
|
QNetworkReply *reply = manager->post(request, jsonData);
|
|
|
|
connect(reply, &QNetworkReply::finished, [reply, this] {
|
|
if (reply->error() == QNetworkReply::NoError) {
|
|
QByteArray response = reply->readAll();
|
|
} else {
|
|
qDebug() << "Error sending Replay:" << reply->errorString();
|
|
}
|
|
reply->deleteLater();
|
|
});
|
|
|
|
}
|