kmail Library API Documentation

keyresolver.h

00001 /* -*- c++ -*- 00002 keyresolver.h 00003 00004 This file is part of libkleopatra, the KDE keymanagement library 00005 Copyright (c) 2004 Klarälvdalens Datakonsult AB 00006 00007 Based on kpgp.h 00008 Copyright (C) 2001,2002 the KPGP authors 00009 See file libkdenetwork/AUTHORS.kpgp for details 00010 00011 Libkleopatra is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU General Public License as 00013 published by the Free Software Foundation; either version 2 of the 00014 License, or (at your option) any later version. 00015 00016 Libkleopatra is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 General Public License for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with this program; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 In addition, as a special exception, the copyright holders give 00026 permission to link the code of this program with any edition of 00027 the Qt library by Trolltech AS, Norway (or with modified versions 00028 of Qt that use the same license as Qt), and distribute linked 00029 combinations including the two. You must obey the GNU General 00030 Public License in all respects for all of the code used other than 00031 Qt. If you modify this file, you may extend this exception to 00032 your version of the file, but you are not obligated to do so. If 00033 you do not wish to do so, delete this exception statement from 00034 your version. 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> // for Kpgp::Result 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 } // namespace Kleo 00308 00309 #endif // __KLEO_KEYRESOLVER_H__
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:46 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003