Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+46
@@ -0,0 +1,46 @@
|
||||
#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();
|
||||
});
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user