aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--keylist.cpp45
-rw-r--r--keylist.h7
-rw-r--r--mainwindow.cpp13
-rw-r--r--mainwindow.h3
4 files changed, 67 insertions, 1 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;
+}
diff --git a/keylist.h b/keylist.h
index 471a825..0909291 100644
--- a/keylist.h
+++ b/keylist.h
@@ -24,6 +24,8 @@
#include "gpgcontext.h"
#include "keyimportdetaildialog.h"
+#include <QNetworkAccessManager>
+#include <QtNetwork>
QT_BEGIN_NAMESPACE
class QWidget;
@@ -54,12 +56,17 @@ public:
public slots:
void slotRefresh();
+ void uploadKeyToServer(QByteArray *keys);
private:
void importKeys(QByteArray inBuffer);
GpgME::GpgContext *mCtx;
QTableWidget *mKeyList;
QMenu *popupMenu;
+ QNetworkAccessManager *qnam;
+
+private slots:
+ void uploadFinished();
protected:
void contextMenuEvent(QContextMenuEvent *event);
diff --git a/mainwindow.cpp b/mainwindow.cpp
index eeafbbf..e3b802e 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -60,7 +60,8 @@ MainWindow::MainWindow()
mKeyList->addMenuAction(copyMailAddressToClipboardAct);
mKeyList->addMenuAction(showKeyDetailsAct);
mKeyList->addMenuAction(refreshKeysFromKeyserverAct);
-
+ mKeyList->addMenuAction(uploadKeyToServerAct);
+
restoreSettings();
// open filename if provided as first command line parameter
@@ -363,6 +364,9 @@ void MainWindow::createActions()
refreshKeysFromKeyserverAct->setToolTip(tr("Refresh key from default keyserver"));
connect(refreshKeysFromKeyserverAct, SIGNAL(triggered()), this, SLOT(refreshKeysFromKeyserver()));
+ uploadKeyToServerAct = new QAction(tr("Upload Key(s) To Server"), this);
+ uploadKeyToServerAct->setToolTip(tr("Upload The Selected Keys To Server"));
+ connect(uploadKeyToServerAct, SIGNAL(triggered()), this, SLOT(uploadKeyToServer()));
/* Key-Shortcuts for Tab-Switchung-Action
*/
switchTabUpAct = new QAction(this);
@@ -932,6 +936,13 @@ void MainWindow::refreshKeysFromKeyserver()
}
+void MainWindow::uploadKeyToServer()
+{
+ QByteArray *keyArray = new QByteArray();
+ mCtx->exportKeys(mKeyList->getSelected(), keyArray);
+
+ mKeyList->uploadKeyToServer(keyArray);
+}
void MainWindow::slotFileEncryption()
{
diff --git a/mainwindow.h b/mainwindow.h
index 6feeec6..35aad26 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -109,6 +109,8 @@ private slots:
void refreshKeysFromKeyserver();
+ void uploadKeyToServer();
+
/**
* @details Open find widget.
*/
@@ -333,6 +335,7 @@ private:
QAction *openHelpAct; /** Action to open tutorial */
QAction *showKeyDetailsAct; /** Action to open key-details dialog */
QAction *refreshKeysFromKeyserverAct; /** Action to refresh a key from keyserver */
+ QAction *uploadKeyToServerAct; /** Action to append selected keys to edit */
QAction *startWizardAct; /** Action to open the wizard */
QAction *cutPgpHeaderAct; /** Action for cutting the PGP header */
QAction *addPgpHeaderAct; /** Action for adding the PGP header */