diff options
Diffstat (limited to 'src/m_key_server_sync')
| -rw-r--r-- | src/m_key_server_sync/KeyServerList.cpp | 3 | ||||
| -rw-r--r-- | src/m_key_server_sync/KeyServerProbe.cpp | 4 | ||||
| -rw-r--r-- | src/m_key_server_sync/KeyServerSyncModule.cpp | 26 | ||||
| -rw-r--r-- | src/m_key_server_sync/PKSInterface.cpp | 11 | ||||
| -rw-r--r-- | src/m_key_server_sync/SearchKeyDialog.cpp | 5 | ||||
| -rw-r--r-- | src/m_key_server_sync/VKSInterface.cpp | 15 | ||||
| -rw-r--r-- | src/m_key_server_sync/module.json | 5 |
7 files changed, 33 insertions, 36 deletions
diff --git a/src/m_key_server_sync/KeyServerList.cpp b/src/m_key_server_sync/KeyServerList.cpp index 349de86..bbb9f7f 100644 --- a/src/m_key_server_sync/KeyServerList.cpp +++ b/src/m_key_server_sync/KeyServerList.cpp @@ -52,7 +52,8 @@ constexpr auto kOpenPGPServer = "https://keys.openpgp.org"; Q_GLOBAL_STATIC(QMutex, settings_mutex) auto GlobalSettings() -> QSettings* { - return qobject_cast<QSettings*>(static_cast<QObject*>(GFUIGlobalSettings())); + return qobject_cast<QSettings*>( + static_cast<QObject*>(GFStorageSettingsRoot(GFModuleSdkContext()))); } /** diff --git a/src/m_key_server_sync/KeyServerProbe.cpp b/src/m_key_server_sync/KeyServerProbe.cpp index f93ac76..4124a6a 100644 --- a/src/m_key_server_sync/KeyServerProbe.cpp +++ b/src/m_key_server_sync/KeyServerProbe.cpp @@ -28,8 +28,6 @@ #include "KeyServerProbe.h" -#include <GFSDKExtra.h> - #include <QCoreApplication> #include <QJsonDocument> #include <QNetworkAccessManager> @@ -201,7 +199,7 @@ void KeyServerProber::send(const QString& url, bool is_hkp) { QNetworkRequest request{QUrl(target)}; request.setHeader(QNetworkRequest::UserAgentHeader, - QString::fromUtf8(GFHttpRequestUserAgent())); + QString::fromUtf8(GFAppUserAgent(GFModuleSdkContext()))); request.setTransferTimeout(kProbeTimeoutMs); request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy); diff --git a/src/m_key_server_sync/KeyServerSyncModule.cpp b/src/m_key_server_sync/KeyServerSyncModule.cpp index a07eade..e4a81b0 100644 --- a/src/m_key_server_sync/KeyServerSyncModule.cpp +++ b/src/m_key_server_sync/KeyServerSyncModule.cpp @@ -151,9 +151,10 @@ auto OnActivate() -> GFResult { QStringList{GC_TR("keyserver"), GC_TR("key server"), GC_TR("hkp"), GC_TR("vks"), GC_TR("publish"), GC_TR("search")} .join('\n'); - GFUIRegisterSettingsPage( - kSettingsPageId, "keys_engines", GC_TR("Key Servers"), - (keywords).toUtf8().constData(), KeyServerSettingsPageFactory, nullptr); + gf::sdk::RegisterSettingsPage(GFModuleSdkContext(), kSettingsPageId, + "keys_engines", GC_TR("Key Servers"), + keywords.toUtf8().constData(), + KeyServerSettingsPageFactory, nullptr); return GFResult::Ok(); } @@ -162,11 +163,9 @@ namespace { auto UploadKeyToServer(QWidget* parent, int channel, const QString& key_id) -> int { - char* key_data = nullptr; - int size = 0; - auto ret = GFGpgExportKey(channel, (key_id).toUtf8().constData(), 1, - &key_data, &size); - if (ret != 0 || key_data == nullptr || size <= 0) { + const auto exported = + gf::sdk::ExportKey(GFModuleSdkContext(), channel, key_id, true); + if (exported.isEmpty()) { QMessageBox::critical( parent, QCoreApplication::translate("GTrC", "Key Upload Failed"), QCoreApplication::translate( @@ -177,9 +176,7 @@ auto UploadKeyToServer(QWidget* parent, int channel, const QString& key_id) return -1; } - // UnStrDup takes ownership of key_data and frees it; key_data must not be - // used afterwards. - auto key_text = UDUP(key_data); + const auto key_text = QString::fromUtf8(exported); const auto route = KeyServerList::SyncRoute(); const auto server = route.url; @@ -295,9 +292,8 @@ auto UpdateKeyFromKeyServer(QWidget* parent, int channel, const QString& fpr) FetchKey( route, fpr, true, [parent, channel](const QString& key_data) { - auto data = key_data.toUtf8(); - GFGpgImportKeys(channel, parent, data.constData(), - static_cast<int>(data.size())); + gf::sdk::ImportKeys(GFModuleSdkContext(), channel, parent, + key_data.toUtf8()); }, [parent, fpr, host](const QString& error, const QString& data) { Q_UNUSED(data); @@ -575,7 +571,7 @@ auto OnRequestSearchPublicKeyByFingerprint(const GFEvent& event) auto OnDeactivate() -> GFResult { // The registry holds a function pointer into this shared object; leaving it // behind would crash the next time the Settings dialog is built. - GFUIUnregisterSettingsPage(kSettingsPageId); + GFUIUnregisterSettingsPage(GFModuleSdkContext(), kSettingsPageId); return GFResult::Ok(); } diff --git a/src/m_key_server_sync/PKSInterface.cpp b/src/m_key_server_sync/PKSInterface.cpp index 9d1b6fa..7cc119d 100644 --- a/src/m_key_server_sync/PKSInterface.cpp +++ b/src/m_key_server_sync/PKSInterface.cpp @@ -28,8 +28,6 @@ #include "PKSInterface.h" -#include <GFSDKExtra.h> - #include "GFModule.h" namespace { @@ -201,7 +199,8 @@ auto PKSInterface::Search(const QString& url, const QString& type, auto request = QNetworkRequest(url_from_remote); // set timeout and user agent - request.setHeader(QNetworkRequest::UserAgentHeader, GFHttpRequestUserAgent()); + request.setHeader(QNetworkRequest::UserAgentHeader, + GFAppUserAgent(GFModuleSdkContext())); request.setTransferTimeout(15000); // 15 seconds reply_ = manager_->get(request); @@ -238,7 +237,8 @@ void PKSInterface::LookupKeyById(const QString& url, const QString& keyid) { url + "/pks/lookup?search=0x" + handle + "&op=get&options=mr"; auto request = QNetworkRequest(url_from_remote); - request.setHeader(QNetworkRequest::UserAgentHeader, GFHttpRequestUserAgent()); + request.setHeader(QNetworkRequest::UserAgentHeader, + GFAppUserAgent(GFModuleSdkContext())); request.setTransferTimeout(15000); auto* reply = manager_->get(request); @@ -279,7 +279,8 @@ void PKSInterface::UploadKey(const QString& url, const QByteArray& key_data) { data.replace(" ", "+"); QNetworkRequest request(req_url); - request.setHeader(QNetworkRequest::UserAgentHeader, GFHttpRequestUserAgent()); + request.setHeader(QNetworkRequest::UserAgentHeader, + GFAppUserAgent(GFModuleSdkContext())); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); diff --git a/src/m_key_server_sync/SearchKeyDialog.cpp b/src/m_key_server_sync/SearchKeyDialog.cpp index 5d790d5..3017d2b 100644 --- a/src/m_key_server_sync/SearchKeyDialog.cpp +++ b/src/m_key_server_sync/SearchKeyDialog.cpp @@ -369,12 +369,11 @@ void SearchKeyDialog::slot_lookup_finished_pks( FLOG_DEBUG("importing key data of size %1, data: %2", key_data.size(), QString::fromUtf8(key_data)); - auto channel = GFGpgCurrentGpgContextChannel(); + auto channel = GFGpgCurrentChannel(GFModuleSdkContext()); if (channel < 0) { slot_set_error_message(tr("No GPG context is available.")); return; } - GFGpgImportKeys(channel, this, key_data.data(), - static_cast<int>(key_data.size())); + gf::sdk::ImportKeys(GFModuleSdkContext(), channel, this, key_data); } diff --git a/src/m_key_server_sync/VKSInterface.cpp b/src/m_key_server_sync/VKSInterface.cpp index 86fad2e..006729c 100644 --- a/src/m_key_server_sync/VKSInterface.cpp +++ b/src/m_key_server_sync/VKSInterface.cpp @@ -28,8 +28,6 @@ #include "VKSInterface.h" -#include <GFSDKExtra.h> - #include <QByteArray> #include <QDebug> #include <QJsonArray> @@ -52,7 +50,7 @@ constexpr int kTransferTimeoutMs = 15000; auto VKSInterface::make_request(const QUrl& url) -> QNetworkRequest { QNetworkRequest request(url); request.setHeader(QNetworkRequest::UserAgentHeader, - QString::fromUtf8(GFHttpRequestUserAgent())); + QString::fromUtf8(GFAppUserAgent(GFModuleSdkContext()))); request.setTransferTimeout(kTransferTimeoutMs); return request; } @@ -71,7 +69,8 @@ void VKSInterface::GetByFingerprint(const QString& fingerprint) { // two of them can hold different versions of the same key. cache_key_ = QString("module:key-server-sync:key-data:%1:fpr:%2") .arg(QUrl(target_key_server_).host(), fingerprint); - auto value = UDUP(GFCacheGet((cache_key_).toUtf8().constData())); + auto value = gf::sdk::CacheText(GFModuleSdkContext(), GF_STORE_SESSION, + (cache_key_).toUtf8().constData()); if (!value.isEmpty()) { emit SignalKeyRetrieved(value); return; @@ -87,7 +86,8 @@ void VKSInterface::GetByKeyId(const QString& key_id) { // search cache by first cache_key_ = QString("module:key-server-sync:key-data:%1:id:%2") .arg(QUrl(target_key_server_).host(), key_id); - auto value = UDUP(GFCacheGet((cache_key_).toUtf8().constData())); + auto value = gf::sdk::CacheText(GFModuleSdkContext(), GF_STORE_SESSION, + (cache_key_).toUtf8().constData()); if (!value.isEmpty()) { emit SignalKeyRetrieved(value); return; @@ -156,8 +156,9 @@ void VKSInterface::on_reply_finished(QNetworkReply* reply) { if (url.path().contains("/vks/v1/by-fingerprint") || url.path().contains("/vks/v1/by-keyid") || url.path().contains("/vks/v1/by-email")) { - GFCacheSaveWithTTL((cache_key_).toUtf8().constData(), - (QString(response_data)).toUtf8().constData(), 300); + gf::sdk::SetCacheText(GFModuleSdkContext(), GF_STORE_SESSION, + (cache_key_).toUtf8().constData(), + (QString(response_data)).toUtf8().constData(), 300); emit SignalKeyRetrieved(QString(response_data)); } else if (url.path().contains("/vks/v1/upload")) { if (json_response.isObject()) { diff --git a/src/m_key_server_sync/module.json b/src/m_key_server_sync/module.json index 624eece..e6163c0 100644 --- a/src/m_key_server_sync/module.json +++ b/src/m_key_server_sync/module.json @@ -7,8 +7,9 @@ "author": "Saturneric", "capabilities": [ "gpg", - "ui", - "network" + "network", + "storage", + "ui" ], "events": [ "KEY_PAIR_OPERA_MENU_CREATED", |
