Changeset View
Changeset View
Standalone View
Standalone View
src/utils/gnupg-helper.cpp
Show All 34 Lines | |||||
35 | #include <config-kleopatra.h> | 35 | #include <config-kleopatra.h> | ||
36 | 36 | | |||
37 | #include "gnupg-helper.h" | 37 | #include "gnupg-helper.h" | ||
38 | 38 | | |||
39 | #include "utils/hex.h" | 39 | #include "utils/hex.h" | ||
40 | 40 | | |||
41 | #include <gpgme++/engineinfo.h> | 41 | #include <gpgme++/engineinfo.h> | ||
42 | #include <gpgme++/error.h> | 42 | #include <gpgme++/error.h> | ||
43 | #include <gpgme++/key.h> | ||||
43 | 44 | | |||
44 | #include <QGpgME/Protocol> | 45 | #include <QGpgME/Protocol> | ||
45 | #include <QGpgME/CryptoConfig> | 46 | #include <QGpgME/CryptoConfig> | ||
46 | 47 | | |||
47 | #include "kleopatra_debug.h" | 48 | #include "kleopatra_debug.h" | ||
48 | 49 | | |||
49 | #include <QDir> | 50 | #include <QDir> | ||
50 | #include <QFile> | 51 | #include <QFile> | ||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 267 | { | |||
270 | } | 271 | } | ||
271 | const QGpgME::CryptoConfig *const config = QGpgME::cryptoConfig(); | 272 | const QGpgME::CryptoConfig *const config = QGpgME::cryptoConfig(); | ||
272 | if (!config) { | 273 | if (!config) { | ||
273 | return false; | 274 | return false; | ||
274 | } | 275 | } | ||
275 | const QGpgME::CryptoConfigEntry *const entry = config->entry(QStringLiteral("gpg"), QStringLiteral("Keyserver"), QStringLiteral("keyserver")); | 276 | const QGpgME::CryptoConfigEntry *const entry = config->entry(QStringLiteral("gpg"), QStringLiteral("Keyserver"), QStringLiteral("keyserver")); | ||
276 | return entry && !entry->stringValue().isEmpty(); | 277 | return entry && !entry->stringValue().isEmpty(); | ||
277 | } | 278 | } | ||
279 | | ||||
280 | bool Kleo::gpgComplianceP(const char *mode) | ||||
justusw: So this duplicates functionality from libkleo, which is bad, but a) I did not know where to put… | |||||
281 | { | ||||
282 | auto conf = QGpgME::cryptoConfig(); | ||||
283 | return (conf->entry(QStringLiteral("gpg"), | ||||
284 | QStringLiteral("Configuration"), | ||||
285 | QStringLiteral("compliance"))->stringValue() | ||||
286 | == QString(mode)); | ||||
287 | } | ||||
288 | | ||||
289 | enum GpgME::UserID::Validity Kleo::keyValidity(const GpgME::Key &key) | ||||
justusw: Likewise. | |||||
290 | { | ||||
291 | enum UserID::Validity validity = UserID::Validity::Unknown; | ||||
292 | | ||||
293 | for (const auto &uid: key.userIDs()) | ||||
294 | if (validity == UserID::Validity::Unknown | ||||
295 | || validity > uid.validity()) | ||||
296 | validity = uid.validity(); | ||||
297 | | ||||
298 | return validity; | ||||
299 | } |
So this duplicates functionality from libkleo, which is bad, but a) I did not know where to put it exactly in libkleo (see the other diff), and b) frankly, I like my predicate better because it is easier to use (avoids the QStringLiteral("de-vs") in the expression.