00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
#ifndef __KLEO_KEYRESOLVER_H__
00038
#define __KLEO_KEYRESOLVER_H__
00039
00040
#include <ui/keyapprovaldialog.h>
00041
00042
#include <kleo/enum.h>
00043
00044
#include <kpgp.h>
00045
#include <gpgmepp/key.h>
00046
00047
#include <vector>
00048
00049
class QStringList;
00050
00051
namespace Kleo {
00052
00053
00127 class KeyResolver {
00128
public:
00129
KeyResolver(
bool encToSelf,
bool showApproval,
bool oppEncryption,
00130
unsigned int format,
00131
int encrKeyNearExpiryThresholdDays,
00132
int signKeyNearExpiryThresholdDays,
00133
int encrRootCertNearExpiryThresholdDays,
00134
int signRootCertNearExpiryThresholdDays,
00135
int encrChainCertNearExpiryThresholdDays,
00136
int signChainCertNearExpiryThresholdDays );
00137
00138 ~
KeyResolver();
00139
00140
struct Item :
public KeyApprovalDialog::Item {
00141 Item() : KeyApprovalDialog::Item() {}
00142 Item(
const QString & a,
const std::vector<GpgME::Key> & k,
00143 EncryptionPreference e, SigningPreference s,
00144 CryptoMessageFormat f )
00145 : KeyApprovalDialog::Item( a, k, e ),
00146 signPref( s ), format( f ) {}
00147
00148 SigningPreference signPref;
00149 CryptoMessageFormat format;
00150 };
00151
00152
00158 Kpgp::Result setEncryptToSelfKeys(
const QStringList & fingerprints );
00163 Kpgp::Result setSigningKeys(
const QStringList & fingerprints );
00168
void setPrimaryRecipients(
const QStringList & addresses );
00173
void setSecondaryRecipients(
const QStringList & addresses );
00174
00175
00181 Action checkSigningPreferences(
bool signingRequested )
const;
00187 Action checkEncryptionPreferences(
bool encryptionRequested )
const;
00188
00193 Kpgp::Result resolveAllKeys(
bool signingRequested,
bool encryptionRequested );
00194
00199 std::vector<GpgME::Key> signingKeys( CryptoMessageFormat f )
const;
00200
00201
struct SplitInfo {
00202 SplitInfo() {}
00203 SplitInfo(
const QStringList & r ) : recipients( r ) {}
00204 SplitInfo(
const QStringList & r,
const std::vector<GpgME::Key> & k )
00205 : recipients( r ), keys( k ) {}
00206
QStringList recipients;
00207 std::vector<GpgME::Key> keys;
00208 };
00213 std::vector<SplitInfo> encryptionItems( CryptoMessageFormat f )
const;
00214
00215
private:
00216
void dump()
const;
00217 std::vector<Item> getEncryptionItems(
const QStringList & recipients );
00218 std::vector<GpgME::Key> getEncryptionKeys(
const QString & recipient,
bool quiet )
const;
00219
00220 Kpgp::Result showKeyApprovalDialog();
00221
00222
bool encryptionPossible()
const;
00223
bool signingPossible()
const;
00224 Kpgp::Result resolveEncryptionKeys(
bool signingRequested );
00225 Kpgp::Result resolveSigningKeysForEncryption();
00226 Kpgp::Result resolveSigningKeysForSigningOnly();
00227 Kpgp::Result checkKeyNearExpiry(
const GpgME::Key & key,
00228
const char * dontAskAgainName,
bool mine,
00229
bool sign,
bool ca=
false,
int recurse_limit=100,
00230
const GpgME::Key & orig_key=GpgME::Key::null )
const;
00231
void collapseAllSplitInfos();
00232
void addToAllSplitInfos(
const std::vector<GpgME::Key> & keys,
unsigned int formats );
00233
void addKeys(
const std::vector<Item> & items, CryptoMessageFormat f );
00234
void addKeys(
const std::vector<Item> & items );
00235
QStringList allRecipients()
const;
00236 std::vector<GpgME::Key> signingKeysFor( CryptoMessageFormat f )
const;
00237 std::vector<GpgME::Key> encryptToSelfKeysFor( CryptoMessageFormat f )
const;
00238
00239 std::vector<GpgME::Key> lookup(
const QStringList & patterns,
bool secret=
false )
const;
00240
00241
bool haveTrustedEncryptionKey(
const QString & person )
const;
00242
00243 std::vector<GpgME::Key> selectKeys(
const QString & person,
const QString & msg,
00244
const std::vector<GpgME::Key> & selectedKeys=std::vector<GpgME::Key>() )
const;
00245
00246
QStringList keysForAddress(
const QString & address )
const;
00247
void setKeysForAddress(
const QString & address,
const QStringList& pgpKeyFingerprints,
const QStringList& smimeCertFingerprints )
const;
00248
00249
bool encryptToSelf()
const {
return mEncryptToSelf; }
00250
bool showApprovalDialog()
const {
return mShowApprovalDialog; }
00251
00252
int encryptKeyNearExpiryWarningThresholdInDays()
const {
00253
return mEncryptKeyNearExpiryWarningThreshold;
00254 }
00255
int signingKeyNearExpiryWarningThresholdInDays()
const {
00256
return mSigningKeyNearExpiryWarningThreshold;
00257 }
00258
00259
int encryptRootCertNearExpiryWarningThresholdInDays()
const {
00260
return mEncryptRootCertNearExpiryWarningThreshold;
00261 }
00262
int signingRootCertNearExpiryWarningThresholdInDays()
const {
00263
return mSigningRootCertNearExpiryWarningThreshold;
00264 }
00265
00266
int encryptChainCertNearExpiryWarningThresholdInDays()
const {
00267
return mEncryptChainCertNearExpiryWarningThreshold;
00268 }
00269
int signingChainCertNearExpiryWarningThresholdInDays()
const {
00270
return mSigningChainCertNearExpiryWarningThreshold;
00271 }
00272
00273
struct ContactPreferences {
00274 ContactPreferences();
00275 Kleo::EncryptionPreference encryptionPreference;
00276 Kleo::SigningPreference signingPreference;
00277 Kleo::CryptoMessageFormat cryptoMessageFormat;
00278
QStringList pgpKeyFingerprints;
00279
QStringList smimeCertFingerprints;
00280 };
00281
00282 ContactPreferences& lookupContactPreferences(
const QString& address )
const;
00283
void saveContactPreference(
const QString& email,
const ContactPreferences& pref )
const;
00284
00285
private:
00286
class EncryptionPreferenceCounter;
00287
friend class EncryptionPreferenceCounter;
00288
class SigningPreferenceCounter;
00289
friend class SigningPreferenceCounter;
00290
00291
class Private;
00292 Private * d;
00293
00294
bool mEncryptToSelf;
00295
const bool mShowApprovalDialog : 1;
00296
const bool mOpportunisticEncyption : 1;
00297
const unsigned int mCryptoMessageFormats;
00298
00299
const int mEncryptKeyNearExpiryWarningThreshold;
00300
const int mSigningKeyNearExpiryWarningThreshold;
00301
const int mEncryptRootCertNearExpiryWarningThreshold;
00302
const int mSigningRootCertNearExpiryWarningThreshold;
00303
const int mEncryptChainCertNearExpiryWarningThreshold;
00304
const int mSigningChainCertNearExpiryWarningThreshold;
00305 };
00306
00307 }
00308
00309
#endif // __KLEO_KEYRESOLVER_H__