• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

keyresolver.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  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 "libkleo/ui/keyapprovaldialog.h"
00041 #include "kleo/enum.h"
00042 
00043 #include <libkpgp/kpgp.h> // for Kpgp::Result
00044 #include <gpgme++/key.h>
00045 
00046 #include <vector>
00047 
00048 class QStringList;
00049 
00050 namespace Kleo {
00051 
00052 
00126   class KeyResolver {
00127   public:
00128     KeyResolver( bool encToSelf, bool showApproval, bool oppEncryption,
00129          unsigned int format,
00130          int encrKeyNearExpiryThresholdDays,
00131          int signKeyNearExpiryThresholdDays,
00132          int encrRootCertNearExpiryThresholdDays,
00133          int signRootCertNearExpiryThresholdDays,
00134          int encrChainCertNearExpiryThresholdDays,
00135          int signChainCertNearExpiryThresholdDays );
00136 
00137     ~KeyResolver();
00138 
00139     struct Item : public KeyApprovalDialog::Item {
00140       Item()
00141     : KeyApprovalDialog::Item(),
00142       signPref( UnknownSigningPreference ),
00143       format( AutoFormat ),
00144       needKeys( true ) {}
00145       Item( const QString & a,
00146         EncryptionPreference e, SigningPreference s,
00147         CryptoMessageFormat f )
00148     : KeyApprovalDialog::Item( a, std::vector<GpgME::Key>(), e ),
00149       signPref( s ), format( f ), needKeys( true ) {}
00150       Item( const QString & a, const std::vector<GpgME::Key> & k,
00151         EncryptionPreference e, SigningPreference s,
00152         CryptoMessageFormat f )
00153     : KeyApprovalDialog::Item( a, k, e ),
00154       signPref( s ), format( f ), needKeys( false ) {}
00155 
00156       SigningPreference signPref;
00157       CryptoMessageFormat format;
00158       bool needKeys;
00159     };
00160 
00161 
00167     Kpgp::Result setEncryptToSelfKeys( const QStringList & fingerprints );
00172     Kpgp::Result setSigningKeys( const QStringList & fingerprints );
00177     void setPrimaryRecipients( const QStringList & addresses );
00182     void setSecondaryRecipients( const QStringList & addresses );
00183 
00184 
00190     Action checkSigningPreferences( bool signingRequested ) const;
00196     Action checkEncryptionPreferences( bool encryptionRequested ) const;
00197 
00202     Kpgp::Result resolveAllKeys( bool& signingRequested, bool& encryptionRequested );
00203 
00208     std::vector<GpgME::Key> signingKeys( CryptoMessageFormat f ) const;
00209 
00210     struct SplitInfo {
00211       SplitInfo() {}
00212       SplitInfo( const QStringList & r ) : recipients( r ) {}
00213       SplitInfo( const QStringList & r, const std::vector<GpgME::Key> & k )
00214     : recipients( r ), keys( k ) {}
00215       QStringList recipients;
00216       std::vector<GpgME::Key> keys;
00217     };
00222     std::vector<SplitInfo> encryptionItems( CryptoMessageFormat f ) const;
00223 
00224   private:
00225     void dump() const;
00226     std::vector<Item> getEncryptionItems( const QStringList & recipients );
00227     std::vector<GpgME::Key> getEncryptionKeys( const QString & recipient, bool quiet ) const;
00228 
00229     Kpgp::Result showKeyApprovalDialog();
00230 
00231     bool encryptionPossible() const;
00232     bool signingPossible() const;
00233     Kpgp::Result resolveEncryptionKeys( bool signingRequested );
00234     Kpgp::Result resolveSigningKeysForEncryption();
00235     Kpgp::Result resolveSigningKeysForSigningOnly();
00236     Kpgp::Result checkKeyNearExpiry( const GpgME::Key & key,
00237                      const char * dontAskAgainName, bool mine,
00238                      bool sign, bool ca=false, int recurse_limit=100,
00239                      const GpgME::Key & orig_key=GpgME::Key::null ) const;
00240     void collapseAllSplitInfos();
00241     void addToAllSplitInfos( const std::vector<GpgME::Key> & keys, unsigned int formats );
00242     void addKeys( const std::vector<Item> & items, CryptoMessageFormat f );
00243     void addKeys( const std::vector<Item> & items );
00244     QStringList allRecipients() const;
00245     std::vector<GpgME::Key> signingKeysFor( CryptoMessageFormat f ) const;
00246     std::vector<GpgME::Key> encryptToSelfKeysFor( CryptoMessageFormat f ) const;
00247 
00248     std::vector<GpgME::Key> lookup( const QStringList & patterns, bool secret=false ) const;
00249 
00250     bool haveTrustedEncryptionKey( const QString & person ) const;
00251 
00252     std::vector<GpgME::Key> selectKeys( const QString & person, const QString & msg,
00253                     const std::vector<GpgME::Key> & selectedKeys=std::vector<GpgME::Key>() ) const;
00254 
00255     QStringList keysForAddress( const QString & address ) const;
00256     void setKeysForAddress( const QString & address, const QStringList& pgpKeyFingerprints, const QStringList& smimeCertFingerprints ) const;
00257 
00258     bool encryptToSelf() const { return mEncryptToSelf; }
00259     bool showApprovalDialog() const { return mShowApprovalDialog; }
00260 
00261     int encryptKeyNearExpiryWarningThresholdInDays() const {
00262       return mEncryptKeyNearExpiryWarningThreshold;
00263     }
00264     int signingKeyNearExpiryWarningThresholdInDays() const {
00265       return mSigningKeyNearExpiryWarningThreshold;
00266     }
00267 
00268     int encryptRootCertNearExpiryWarningThresholdInDays() const {
00269       return mEncryptRootCertNearExpiryWarningThreshold;
00270     }
00271     int signingRootCertNearExpiryWarningThresholdInDays() const {
00272       return mSigningRootCertNearExpiryWarningThreshold;
00273     }
00274 
00275     int encryptChainCertNearExpiryWarningThresholdInDays() const {
00276       return mEncryptChainCertNearExpiryWarningThreshold;
00277     }
00278     int signingChainCertNearExpiryWarningThresholdInDays() const {
00279       return mSigningChainCertNearExpiryWarningThreshold;
00280     }
00281 
00282     struct ContactPreferences {
00283       ContactPreferences();
00284       Kleo::EncryptionPreference encryptionPreference;
00285       Kleo::SigningPreference signingPreference;
00286       Kleo::CryptoMessageFormat cryptoMessageFormat;
00287       QStringList pgpKeyFingerprints;
00288       QStringList smimeCertFingerprints;
00289     };
00290 
00291     ContactPreferences lookupContactPreferences( const QString& address ) const;
00292     void saveContactPreference( const QString& email, const ContactPreferences& pref ) const;
00293 
00294   private:
00295     class EncryptionPreferenceCounter;
00296     friend class ::Kleo::KeyResolver::EncryptionPreferenceCounter;
00297     class SigningPreferenceCounter;
00298     friend class ::Kleo::KeyResolver::SigningPreferenceCounter;
00299 
00300     struct Private;
00301     Private * d;
00302 
00303     bool mEncryptToSelf;
00304     const bool mShowApprovalDialog : 1;
00305     const bool mOpportunisticEncyption : 1;
00306     const unsigned int mCryptoMessageFormats;
00307 
00308     const int mEncryptKeyNearExpiryWarningThreshold;
00309     const int mSigningKeyNearExpiryWarningThreshold;
00310     const int mEncryptRootCertNearExpiryWarningThreshold;
00311     const int mSigningRootCertNearExpiryWarningThreshold;
00312     const int mEncryptChainCertNearExpiryWarningThreshold;
00313     const int mSigningChainCertNearExpiryWarningThreshold;
00314   };
00315 
00316 } // namespace Kleo
00317 
00318 #endif // __KLEO_KEYRESOLVER_H__

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal