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

libkleo

cryptplugfactory.cpp

Go to the documentation of this file.
00001 /*
00002     cryptplugfactory.cpp
00003 
00004     This file is part of libkleopatra, the KDE key management library
00005     Copyright (c) 2001,2004 Klarälvdalens Datakonsult AB
00006 
00007     Libkleopatra is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU General Public License as
00009     published by the Free Software Foundation; either version 2 of the
00010     License, or (at your option) any later version.
00011 
00012     Libkleopatra is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License along
00018     with this program; if not, write to the Free Software Foundation, Inc.,
00019     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021     In addition, as a special exception, the copyright holders give
00022     permission to link the code of this program with any edition of
00023     the Qt library by Trolltech AS, Norway (or with modified versions
00024     of Qt that use the same license as Qt), and distribute linked
00025     combinations including the two.  You must obey the GNU General
00026     Public License in all respects for all of the code used other than
00027     Qt.  If you modify this file, you may extend this exception to
00028     your version of the file, but you are not obligated to do so.  If
00029     you do not wish to do so, delete this exception statement from
00030     your version.
00031 */
00032 
00033 #include "cryptplugfactory.h"
00034 #include "cryptplugwrapperlist.h"
00035 
00036 #include <kconfig.h>
00037 #include <klocale.h>
00038 #include <kdebug.h>
00039 #include <kmessagebox.h>
00040 
00041 #include <assert.h>
00042 
00043 KMail::CryptPlugFactory * KMail::CryptPlugFactory::mSelf = 0;
00044 
00045 //
00046 //
00047 // KMail::CryptPlugFactory: backwards compat stuff (ugly)
00048 //
00049 //
00050 
00051 
00052 KMail::CryptPlugFactory::CryptPlugFactory()
00053   : Kleo::CryptoBackendFactory(),
00054     mCryptPlugWrapperList( 0 )
00055 {
00056   mSelf = this;
00057 
00058   mCryptPlugWrapperList = new CryptPlugWrapperList();
00059   mCryptPlugWrapperList->setAutoDelete( false );
00060   updateCryptPlugWrapperList();
00061 }
00062 
00063 KMail::CryptPlugFactory::~CryptPlugFactory() {
00064   mSelf = 0;
00065   delete mCryptPlugWrapperList; mCryptPlugWrapperList = 0;
00066 }
00067 
00068 KMail::CryptPlugFactory * KMail::CryptPlugFactory::instance() {
00069   if ( !mSelf )
00070     mSelf = new CryptPlugFactory();
00071   return mSelf;
00072 }
00073 
00074 CryptPlugWrapper * KMail::CryptPlugFactory::active() const {
00075   if ( smime() && smime()->active() )
00076     return smime();
00077   if ( openpgp() && openpgp()->active() )
00078     return openpgp();
00079   return 0;
00080 }
00081 
00082 CryptPlugWrapper * KMail::CryptPlugFactory::createForProtocol( const QString & proto ) const {
00083   QString p = proto.toLower();
00084   if ( p == "application/pkcs7-signature" || p == "application/x-pkcs7-signature" )
00085     return smime();
00086   if ( p == "application/pgp-signature" || p == "application/x-pgp-signature" )
00087     return openpgp();
00088   return 0;
00089 }
00090 
00091 CryptPlugWrapper * KMail::CryptPlugFactory::smime() const {
00092   return mCryptPlugWrapperList->findForLibName( "smime" );
00093 }
00094 
00095 CryptPlugWrapper * KMail::CryptPlugFactory::openpgp() const {
00096   return mCryptPlugWrapperList->findForLibName( "openpgp" );
00097 }
00098 
00099 void KMail::CryptPlugFactory::scanForBackends( QStringList * reason ) {
00100   Kleo::CryptoBackendFactory::scanForBackends( reason );
00101   updateCryptPlugWrapperList();
00102 }
00103 
00104 void KMail::CryptPlugFactory::updateCryptPlugWrapperList() {
00105   mCryptPlugWrapperList->clear();
00106   for ( std::vector<Kleo::CryptoBackend*>::const_iterator it = mBackendList.begin() ; it != mBackendList.end() ; ++it ) {
00107     if ( CryptPlugWrapper * w = dynamic_cast<CryptPlugWrapper*>( (*it)->openpgp() ) )
00108       mCryptPlugWrapperList->append( w );
00109     if ( CryptPlugWrapper * w = dynamic_cast<CryptPlugWrapper*>( (*it)->smime() ) )
00110       mCryptPlugWrapperList->append( w );
00111   }
00112 }
00113 
00114 #include "cryptplugfactory.moc"

libkleo

Skip menu "libkleo"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

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
  •   doc
  • 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