16#include "messagecomposer_export.h"
17#include <Libkleo/Enum>
18#include <Libkleo/KeyApprovalDialog>
20#include <gpgme++/key.h>
24#include <QSharedPointer>
29class ContactPreference;
114class MESSAGECOMPOSER_EXPORT KeyResolver
117 KeyResolver(
bool encToSelf,
bool showApproval,
bool oppEncryption,
unsigned int format,
const std::shared_ptr<Kleo::ExpiryChecker> &expiryChecker);
121 struct Item :
public KeyApprovalDialog::Item {
123 : KeyApprovalDialog::
Item()
124 , signPref(UnknownSigningPreference)
130 Item(
const QString &a, EncryptionPreference e, SigningPreference s, CryptoMessageFormat f)
131 : KeyApprovalDialog::
Item(a, std::vector<GpgME::Key>(), e)
138 Item(
const QString &a,
const std::vector<GpgME::Key> &k, EncryptionPreference e, SigningPreference s, CryptoMessageFormat f)
139 : KeyApprovalDialog::
Item(a, k, e)
146 SigningPreference signPref;
147 CryptoMessageFormat format;
156 [[nodiscard]] Kleo::Result setEncryptToSelfKeys(
const QStringList &fingerprints);
161 [[nodiscard]] Kleo::Result setSigningKeys(
const QStringList &fingerprints);
166 void setPrimaryRecipients(
const QStringList &addresses);
171 void setSecondaryRecipients(
const QStringList &addresses);
178 [[nodiscard]]
Action checkSigningPreferences(
bool signingRequested)
const;
184 [[nodiscard]]
Action checkEncryptionPreferences(
bool encryptionRequested)
const;
190 [[nodiscard]] Kleo::Result resolveAllKeys(
bool &signingRequested,
bool &encryptionRequested);
196 [[nodiscard]] std::vector<GpgME::Key> signingKeys(CryptoMessageFormat f)
const;
199 SplitInfo() =
default;
206 SplitInfo(
const QStringList &r,
const std::vector<GpgME::Key> &k)
213 std::vector<GpgME::Key> keys;
219 [[nodiscard]] std::vector<SplitInfo> encryptionItems(CryptoMessageFormat f)
const;
221 [[nodiscard]] std::vector<GpgME::Key> encryptToSelfKeysFor(CryptoMessageFormat f)
const;
225 void setAutocryptEnabled(
bool autocryptEnabled);
227 [[nodiscard]] std::map<QByteArray, QString> useAutocrypt()
const;
233 void setAkonadiLookupEnabled(
bool akonadiLookupEnabled);
240 void setContactPreferences(
const QString &address,
const MessageComposer::ContactPreference &preference);
244 [[nodiscard]] std::vector<Item> getEncryptionItems(
const QStringList &recipients);
245 [[nodiscard]] std::vector<GpgME::Key> getEncryptionKeys(
const QString &recipient,
bool quiet)
const;
247 [[nodiscard]] Kleo::Result showKeyApprovalDialog(
bool &finalySendUnencrypted);
249 [[nodiscard]]
bool encryptionPossible()
const;
250 [[nodiscard]]
bool signingPossible()
const;
251 [[nodiscard]] Kleo::Result resolveEncryptionKeys(
bool signingRequested,
bool &finalySendUnencrypted);
252 [[nodiscard]] Kleo::Result resolveSigningKeysForEncryption();
253 [[nodiscard]] Kleo::Result resolveSigningKeysForSigningOnly();
254 void collapseAllSplitInfos();
255 void addToAllSplitInfos(
const std::vector<GpgME::Key> &keys,
unsigned int formats);
256 void addKeys(
const std::vector<Item> &items, CryptoMessageFormat f);
257 void addKeys(
const std::vector<Item> &items);
259 [[nodiscard]] std::vector<GpgME::Key> signingKeysFor(CryptoMessageFormat f)
const;
261 [[nodiscard]] std::vector<GpgME::Key> lookup(
const QStringList &patterns,
bool secret =
false)
const;
263 [[nodiscard]] std::vector<GpgME::Key>
264 selectKeys(
const QString &person,
const QString &msg,
const std::vector<GpgME::Key> &selectedKeys = std::vector<GpgME::Key>())
const;
269 [[nodiscard]]
bool encryptToSelf()
const;
270 [[nodiscard]]
bool showApprovalDialog()
const;
272 [[nodiscard]] MessageComposer::ContactPreference lookupContactPreferences(
const QString &address)
const;
273 void saveContactPreference(
const QString &email,
const MessageComposer::ContactPreference &pref)
const;
276 class EncryptionPreferenceCounter;
277 friend class ::Kleo::KeyResolver::EncryptionPreferenceCounter;
278 class SigningPreferenceCounter;
279 friend class ::Kleo::KeyResolver::SigningPreferenceCounter;
281 struct KeyResolverPrivate;
282 std::unique_ptr<KeyResolverPrivate>
const d;
285 const bool mShowApprovalDialog : 1;
286 const bool mOpportunisticEncyption : 1;
287 const unsigned int mCryptoMessageFormats;
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...