aboutsummaryrefslogtreecommitdiffstats
path: root/keylist.cpp
diff options
context:
space:
mode:
authorNils Achtergarde <[email protected]>2017-12-30 20:07:21 +0000
committerNils Achtergarde <[email protected]>2017-12-30 20:07:21 +0000
commitab74a3fee1830311b51972969356ab003b7b6eae (patch)
tree0548457a24b4ce361b6ef55062ce62390e559d14 /keylist.cpp
parentrecommit eafa42262813180336ae5e4c4c284d17a4f42e65 (fixed minor cosmetic effects) (diff)
downloadgpg4usb-ab74a3fee1830311b51972969356ab003b7b6eae.tar.gz
gpg4usb-ab74a3fee1830311b51972969356ab003b7b6eae.zip
recommit of ffc7c45fee1bfa046cd2c605a43c9c5d2cf7eb62 (proof of concept for upload key to server)
Diffstat (limited to 'keylist.cpp')
-rw-r--r--keylist.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/keylist.cpp b/keylist.cpp
index c89b4d8..cd01a2e 100644
--- a/keylist.cpp
+++ b/keylist.cpp
@@ -274,3 +274,48 @@ void KeyList::importKeys(QByteArray inBuffer)
GpgImportInformation result = mCtx->importKey(inBuffer);
new KeyImportDetailDialog(mCtx, result, this);
}
+
+void KeyList::uploadKeyToServer(QByteArray *keys)
+{
+ QUrl reqUrl("http://localhost:11371/pks/add");
+ qnam = new QNetworkAccessManager(this);
+
+ QUrl params;
+ keys->replace("\n", "%0D%0A")
+ .replace("(", "%28")
+ .replace(")", "%29")
+ .replace("/", "%2F")
+ .replace(":", "%3A")
+ .replace("+","%2B")
+ .replace(' ', '+');
+
+ params.addEncodedQueryItem("keytext", *keys);
+ QNetworkRequest req(reqUrl);
+
+ req.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
+
+ QNetworkReply *reply = qnam->post(req,params.encodedQuery());
+ connect(reply, SIGNAL(finished()),
+ this, SLOT(uploadFinished()));
+ qDebug() << "REQURL: " << reqUrl;
+ qDebug() << "PARAMS.ENCODED: " << params.toEncoded();
+}
+
+void KeyList::uploadFinished()
+{
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+
+ QByteArray response = reply->readAll();
+ qDebug() << "RESPNOSE: " << response.data();
+ //reply->readAll();
+ qDebug() << "ERROR: " << reply->error();
+ if (reply->error()) {
+ qDebug() << "Error while contacting keyserver!";
+ return;
+ } else {
+ qDebug() << "Success while contacting keyserver!";
+ }
+
+ reply->deleteLater();
+ reply = 0;
+}