16 #include "messagecomposer_export.h"
17 #include <Libkleo/Enum>
18 #include <Libkleo/KeyApprovalDialog>
20 #include <gpgme++/key.h>
24 #include <QStringList>
25 #include <QSharedPointer>
29 class NearExpiryChecker;
35 enum Result { Failure = 0, Ok = 1, Canceled = 2 };
120 struct ContactPreferences {
121 ContactPreferences();
122 Kleo::EncryptionPreference encryptionPreference;
123 Kleo::SigningPreference signingPreference;
124 Kleo::CryptoMessageFormat cryptoMessageFormat;
129 struct Item :
public KeyApprovalDialog::Item {
131 : KeyApprovalDialog::Item()
132 , signPref(UnknownSigningPreference)
138 Item(
const QString &a, EncryptionPreference e, SigningPreference s, CryptoMessageFormat f)
139 : KeyApprovalDialog::Item(a, std::vector<GpgME::Key>(), e)
146 Item(
const QString &a,
const std::vector<GpgME::Key> &k, EncryptionPreference e, SigningPreference s, CryptoMessageFormat f)
147 : KeyApprovalDialog::Item(a, k, e)
154 SigningPreference signPref;
155 CryptoMessageFormat format;
164 Q_REQUIRED_RESULT Kleo::Result setEncryptToSelfKeys(
const QStringList &fingerprints);
169 Q_REQUIRED_RESULT Kleo::Result setSigningKeys(
const QStringList &fingerprints);
174 void setPrimaryRecipients(
const QStringList &addresses);
179 void setSecondaryRecipients(
const QStringList &addresses);
186 Q_REQUIRED_RESULT
Action checkSigningPreferences(
bool signingRequested)
const;
192 Q_REQUIRED_RESULT
Action checkEncryptionPreferences(
bool encryptionRequested)
const;
198 Q_REQUIRED_RESULT Kleo::Result resolveAllKeys(
bool &signingRequested,
bool &encryptionRequested);
204 Q_REQUIRED_RESULT std::vector<GpgME::Key> signingKeys(CryptoMessageFormat f)
const;
207 SplitInfo() =
default;
214 SplitInfo(
const QStringList &r,
const std::vector<GpgME::Key> &k)
221 std::vector<GpgME::Key> keys;
227 Q_REQUIRED_RESULT std::vector<SplitInfo> encryptionItems(CryptoMessageFormat f)
const;
229 std::vector<GpgME::Key> encryptToSelfKeysFor(CryptoMessageFormat f)
const;
233 void setAutocryptEnabled(
bool autocryptEnabled);
235 std::map<QByteArray, QString> useAutocrypt()
const;
241 void setAkonadiLookupEnabled(
bool akonadiLookupEnabled);
245 std::vector<Item> getEncryptionItems(
const QStringList &recipients);
246 std::vector<GpgME::Key> getEncryptionKeys(
const QString &recipient,
bool quiet)
const;
248 Kleo::Result showKeyApprovalDialog(
bool &finalySendUnencrypted);
250 bool encryptionPossible()
const;
251 bool signingPossible()
const;
252 Kleo::Result resolveEncryptionKeys(
bool signingRequested,
bool &finalySendUnencrypted);
253 Kleo::Result resolveSigningKeysForEncryption();
254 Kleo::Result resolveSigningKeysForSigningOnly();
255 void collapseAllSplitInfos();
256 void addToAllSplitInfos(
const std::vector<GpgME::Key> &keys,
unsigned int formats);
257 void addKeys(
const std::vector<Item> &items, CryptoMessageFormat f);
258 void addKeys(
const std::vector<Item> &items);
260 std::vector<GpgME::Key> signingKeysFor(CryptoMessageFormat f)
const;
262 std::vector<GpgME::Key> lookup(
const QStringList &patterns,
bool secret =
false)
const;
264 std::vector<GpgME::Key>
265 selectKeys(
const QString &person,
const QString &msg,
const std::vector<GpgME::Key> &selectedKeys = std::vector<GpgME::Key>())
const;
270 bool encryptToSelf()
const;
271 bool showApprovalDialog()
const;
273 ContactPreferences lookupContactPreferences(
const QString &address)
const;
274 void saveContactPreference(
const QString &email,
const ContactPreferences &pref)
const;
277 class EncryptionPreferenceCounter;
278 friend class ::Kleo::KeyResolver::EncryptionPreferenceCounter;
279 class SigningPreferenceCounter;
280 friend class ::Kleo::KeyResolver::SigningPreferenceCounter;
282 struct KeyResolverPrivate;
283 std::unique_ptr<KeyResolverPrivate>
const d;
286 const bool mShowApprovalDialog : 1;
287 const bool mOpportunisticEncyption : 1;
288 const unsigned int mCryptoMessageFormats;