aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/thread
diff options
context:
space:
mode:
authorSaturn&Eric <[email protected]>2022-07-23 14:54:51 +0000
committerGitHub <[email protected]>2022-07-23 14:54:51 +0000
commitb244320b2d228189767aa6d59febceb6b64527fb (patch)
tree179d34e2a3e84231fad72c4bbe9f74673d0b74d0 /src/ui/thread
parentMerge pull request #68 from saturneric/develop-2.0.8 (diff)
parentfeat(project): add rpm package support (diff)
downloadGpgFrontend-2.0.9.tar.gz
GpgFrontend-2.0.9.zip
Merge pull request #70 from saturneric/dev/2.0.8/saturnericv2.0.9
Develop 2.0.9.1
Diffstat (limited to 'src/ui/thread')
-rw-r--r--src/ui/thread/KeyServerImportTask.cpp64
-rw-r--r--src/ui/thread/KeyServerImportTask.h80
-rw-r--r--src/ui/thread/KeyServerSearchTask.cpp59
-rw-r--r--src/ui/thread/KeyServerSearchTask.h76
-rw-r--r--src/ui/thread/ListedKeyServerTestTask.h4
5 files changed, 279 insertions, 4 deletions
diff --git a/src/ui/thread/KeyServerImportTask.cpp b/src/ui/thread/KeyServerImportTask.cpp
new file mode 100644
index 00000000..bf3e1822
--- /dev/null
+++ b/src/ui/thread/KeyServerImportTask.cpp
@@ -0,0 +1,64 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#include "ui/thread/KeyServerImportTask.h"
+
+#include <vector>
+
+GpgFrontend::UI::KeyServerImportTask::KeyServerImportTask(
+ std::string keyserver_url, std::vector<std::string> keyids)
+ : keyserver_url_(std::move(keyserver_url)),
+ keyids_(std::move(keyids)),
+ manager_(new QNetworkAccessManager(this)) {}
+
+void GpgFrontend::UI::KeyServerImportTask::run() {
+ SetFinishAfterRun(false);
+
+ QUrl keyserver_url = QUrl(keyserver_url_.c_str());
+ for (const auto& key_id : keyids_) {
+ QUrl req_url(keyserver_url.scheme() + "://" + keyserver_url.host() +
+ "/pks/lookup?op=get&search=0x" + key_id.c_str() +
+ "&options=mr");
+
+ reply_ = manager_->get(QNetworkRequest(req_url));
+
+ connect(reply_, &QNetworkReply::finished, this,
+ &KeyServerImportTask::dealing_reply_from_server);
+ }
+}
+
+void GpgFrontend::UI::KeyServerImportTask::dealing_reply_from_server() {
+ QByteArray buffer;
+ QNetworkReply::NetworkError network_reply = reply_->error();
+ if (network_reply == QNetworkReply::NoError) {
+ buffer = reply_->readAll();
+ }
+ emit SignalKeyServerImportResult(network_reply, buffer);
+
+ if (result_count_++ == keyids_.size() - 1) {
+ emit SignalTaskFinished();
+ }
+} \ No newline at end of file
diff --git a/src/ui/thread/KeyServerImportTask.h b/src/ui/thread/KeyServerImportTask.h
new file mode 100644
index 00000000..7d3b66c6
--- /dev/null
+++ b/src/ui/thread/KeyServerImportTask.h
@@ -0,0 +1,80 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef GPGFRONTEND_KEYSERVERIMPORTTASK_H
+#define GPGFRONTEND_KEYSERVERIMPORTTASK_H
+
+#include "GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+class KeyServerImportTask : public Thread::Task {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Key Server Search Task object
+ *
+ * @param keyserver_url
+ * @param search_string
+ */
+ KeyServerImportTask(std::string keyserver_url,
+ std::vector<std::string> keyid);
+
+ signals:
+
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void SignalKeyServerImportResult(QNetworkReply::NetworkError reply,
+ QByteArray buffer);
+
+ protected:
+ /**
+ * @brief
+ *
+ */
+ void run() override;
+
+ private slots:
+
+ /**
+ * @brief
+ *
+ */
+ void dealing_reply_from_server();
+
+ private:
+ std::string keyserver_url_; ///<
+ std::vector<std::string> keyids_; ///<
+ int result_count_ = 0;
+
+ QNetworkAccessManager *manager_; ///<
+ QNetworkReply *reply_; ///<
+};
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_KEYSERVERIMPORTTASK_H \ No newline at end of file
diff --git a/src/ui/thread/KeyServerSearchTask.cpp b/src/ui/thread/KeyServerSearchTask.cpp
new file mode 100644
index 00000000..0090e79d
--- /dev/null
+++ b/src/ui/thread/KeyServerSearchTask.cpp
@@ -0,0 +1,59 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#include "ui/thread/KeyServerSearchTask.h"
+
+#include <utility>
+
+GpgFrontend::UI::KeyServerSearchTask::KeyServerSearchTask(
+ std::string keyserver_url, std::string search_string)
+ : keyserver_url_(std::move(keyserver_url)),
+ search_string_(std::move(search_string)),
+ manager_(new QNetworkAccessManager(this)) {}
+
+void GpgFrontend::UI::KeyServerSearchTask::run() {
+ SetFinishAfterRun(false);
+
+ QUrl url_from_remote =
+ QString::fromStdString(keyserver_url_) +
+ "/pks/lookup?search=" + QString::fromStdString(search_string_) +
+ "&op=index&options=mr";
+
+ reply_ = manager_->get(QNetworkRequest(url_from_remote));
+
+ connect(reply_, &QNetworkReply::finished, this,
+ &KeyServerSearchTask::dealing_reply_from_server);
+}
+
+void GpgFrontend::UI::KeyServerSearchTask::dealing_reply_from_server() {
+ QByteArray buffer;
+ QNetworkReply::NetworkError network_reply = reply_->error();
+ if (network_reply == QNetworkReply::NoError) {
+ buffer = reply_->readAll();
+ }
+ emit SignalKeyServerSearchResult(network_reply, buffer);
+ emit SignalTaskFinished();
+}
diff --git a/src/ui/thread/KeyServerSearchTask.h b/src/ui/thread/KeyServerSearchTask.h
new file mode 100644
index 00000000..3333e949
--- /dev/null
+++ b/src/ui/thread/KeyServerSearchTask.h
@@ -0,0 +1,76 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef GPGFRONTEND_KEYSERVERSEARCHTASK_H
+#define GPGFRONTEND_KEYSERVERSEARCHTASK_H
+
+#include "GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+class KeyServerSearchTask : public Thread::Task {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Key Server Search Task object
+ *
+ * @param keyserver_url
+ * @param search_string
+ */
+ KeyServerSearchTask(std::string keyserver_url, std::string search_string);
+
+ signals:
+
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void SignalKeyServerSearchResult(QNetworkReply::NetworkError reply,
+ QByteArray buffer);
+
+ protected:
+ /**
+ * @brief
+ *
+ */
+ void run() override;
+
+ private slots:
+
+ void dealing_reply_from_server();
+
+ private:
+ std::string keyserver_url_; ///<
+ std::string search_string_; ///<
+
+ QNetworkAccessManager *manager_; ///<
+ QNetworkReply *reply_; ///<
+};
+
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_KEYSERVERSEARCHTASK_H \ No newline at end of file
diff --git a/src/ui/thread/ListedKeyServerTestTask.h b/src/ui/thread/ListedKeyServerTestTask.h
index 8edaccb0..aa1bac5e 100644
--- a/src/ui/thread/ListedKeyServerTestTask.h
+++ b/src/ui/thread/ListedKeyServerTestTask.h
@@ -27,11 +27,7 @@
#ifndef GPGFRONTEND_LISTEDKEYSERVERTESTTHREAD_H
#define GPGFRONTEND_LISTEDKEYSERVERTESTTHREAD_H
-#include <vector>
-
#include "GpgFrontendUI.h"
-#include "core/thread/Task.h"
-
namespace GpgFrontend::UI {
/**