37 #ifndef __KLEO_KEYRESOLVER_H__
38 #define __KLEO_KEYRESOLVER_H__
40 #include <ui/keyapprovaldialog.h>
42 #include <kleo/enum.h>
45 #include <gpgmepp/key.h>
129 KeyResolver(
bool encToSelf,
bool showApproval,
bool oppEncryption,
131 int encrKeyNearExpiryThresholdDays,
132 int signKeyNearExpiryThresholdDays,
133 int encrRootCertNearExpiryThresholdDays,
134 int signRootCertNearExpiryThresholdDays,
135 int encrChainCertNearExpiryThresholdDays,
136 int signChainCertNearExpiryThresholdDays );
140 struct Item :
public KeyApprovalDialog::Item {
142 : KeyApprovalDialog::Item(),
143 signPref( UnknownSigningPreference ),
144 format( AutoFormat ),
146 Item(
const TQString & a,
147 EncryptionPreference e, SigningPreference s,
148 CryptoMessageFormat f )
149 : KeyApprovalDialog::Item( a, std::vector<GpgME::Key>(), e ),
150 signPref( s ), format( f ), needKeys(
true ) {}
151 Item(
const TQString & a,
const std::vector<GpgME::Key> & k,
152 EncryptionPreference e, SigningPreference s,
153 CryptoMessageFormat f )
154 : KeyApprovalDialog::Item( a, k, e ),
155 signPref( s ), format( f ), needKeys(
false ) {}
157 SigningPreference signPref;
158 CryptoMessageFormat format;
203 Kpgp::Result
resolveAllKeys(
bool& signingRequested,
bool& encryptionRequested );
209 std::vector<GpgME::Key>
signingKeys( CryptoMessageFormat f )
const;
213 SplitInfo(
const TQStringList & r ) : recipients( r ) {}
214 SplitInfo(
const TQStringList & r,
const std::vector<GpgME::Key> & k )
215 : recipients( r ), keys( k ) {}
216 TQStringList recipients;
217 std::vector<GpgME::Key> keys;
227 std::vector<Item> getEncryptionItems(
const TQStringList & recipients );
228 std::vector<GpgME::Key> getEncryptionKeys(
const TQString & recipient,
bool quiet )
const;
230 Kpgp::Result showKeyApprovalDialog();
232 bool encryptionPossible()
const;
233 bool signingPossible()
const;
234 Kpgp::Result resolveEncryptionKeys(
bool signingRequested );
235 Kpgp::Result resolveSigningKeysForEncryption();
236 Kpgp::Result resolveSigningKeysForSigningOnly();
237 Kpgp::Result checkKeyNearExpiry(
const GpgME::Key & key,
238 const char * dontAskAgainName,
bool mine,
239 bool sign,
bool ca=
false,
int recurse_limit=100,
240 const GpgME::Key & orig_key=GpgME::Key::null )
const;
241 void collapseAllSplitInfos();
242 void addToAllSplitInfos(
const std::vector<GpgME::Key> & keys,
unsigned int formats );
243 void addKeys(
const std::vector<Item> & items, CryptoMessageFormat f );
244 void addKeys(
const std::vector<Item> & items );
245 TQStringList allRecipients()
const;
246 std::vector<GpgME::Key> signingKeysFor( CryptoMessageFormat f )
const;
247 std::vector<GpgME::Key> encryptToSelfKeysFor( CryptoMessageFormat f )
const;
249 std::vector<GpgME::Key> lookup(
const TQStringList & patterns,
bool secret=
false )
const;
251 bool haveTrustedEncryptionKey(
const TQString & person )
const;
253 std::vector<GpgME::Key> selectKeys(
const TQString & person,
const TQString & msg,
254 const std::vector<GpgME::Key> & selectedKeys=std::vector<GpgME::Key>() )
const;
256 TQStringList keysForAddress(
const TQString & address )
const;
257 void setKeysForAddress(
const TQString & address,
const TQStringList& pgpKeyFingerprints,
const TQStringList& smimeCertFingerprints )
const;
259 bool encryptToSelf()
const {
return mEncryptToSelf; }
260 bool showApprovalDialog()
const {
return mShowApprovalDialog; }
262 int encryptKeyNearExpiryWarningThresholdInDays()
const {
263 return mEncryptKeyNearExpiryWarningThreshold;
265 int signingKeyNearExpiryWarningThresholdInDays()
const {
266 return mSigningKeyNearExpiryWarningThreshold;
269 int encryptRootCertNearExpiryWarningThresholdInDays()
const {
270 return mEncryptRootCertNearExpiryWarningThreshold;
272 int signingRootCertNearExpiryWarningThresholdInDays()
const {
273 return mSigningRootCertNearExpiryWarningThreshold;
276 int encryptChainCertNearExpiryWarningThresholdInDays()
const {
277 return mEncryptChainCertNearExpiryWarningThreshold;
279 int signingChainCertNearExpiryWarningThresholdInDays()
const {
280 return mSigningChainCertNearExpiryWarningThreshold;
283 struct ContactPreferences {
284 ContactPreferences();
285 Kleo::EncryptionPreference encryptionPreference;
286 Kleo::SigningPreference signingPreference;
287 Kleo::CryptoMessageFormat cryptoMessageFormat;
288 TQStringList pgpKeyFingerprints;
289 TQStringList smimeCertFingerprints;
292 ContactPreferences lookupContactPreferences(
const TQString& address )
const;
293 void saveContactPreference(
const TQString& email,
const ContactPreferences& pref )
const;
296 class EncryptionPreferenceCounter;
297 friend class ::Kleo::KeyResolver::EncryptionPreferenceCounter;
298 class SigningPreferenceCounter;
299 friend class ::Kleo::KeyResolver::SigningPreferenceCounter;
305 const bool mShowApprovalDialog : 1;
306 const bool mOpportunisticEncyption : 1;
307 const unsigned int mCryptoMessageFormats;
309 const int mEncryptKeyNearExpiryWarningThreshold;
310 const int mSigningKeyNearExpiryWarningThreshold;
311 const int mEncryptRootCertNearExpiryWarningThreshold;
312 const int mSigningRootCertNearExpiryWarningThreshold;
313 const int mEncryptChainCertNearExpiryWarningThreshold;
314 const int mSigningChainCertNearExpiryWarningThreshold;
A class to resolve signing/encryption keys w.r.t.
std::vector< SplitInfo > encryptionItems(CryptoMessageFormat f) const
std::vector< GpgME::Key > signingKeys(CryptoMessageFormat f) const
void setSecondaryRecipients(const TQStringList &addresses)
Set the list of secondary (BCC) recipient addresses.
Action checkSigningPreferences(bool signingRequested) const
Determine whether to sign or not, depending on the per-recipient signing preferences,...
Kpgp::Result setEncryptToSelfKeys(const TQStringList &fingerprints)
Set the fingerprints of keys to be used for encrypting to self.
Action checkEncryptionPreferences(bool encryptionRequested) const
Determine whether to encrypt or not, depending on the per-recipient encryption preferences,...
Kpgp::Result setSigningKeys(const TQStringList &fingerprints)
Set the fingerprints of keys to be used for signing.
Kpgp::Result resolveAllKeys(bool &signingRequested, bool &encryptionRequested)
Queries the user for missing keys and displays a key approval dialog if needed.
void setPrimaryRecipients(const TQStringList &addresses)
Set the list of primary (To/CC) recipient addresses.