From 64df902cf71a8ee258fb85f6be26248f399aa01f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 01:05:15 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- certmanager/certificatewizardimpl.cpp | 4 +- certmanager/certmanager.cpp | 6 +- certmanager/conf/appearanceconfigwidget.cpp | 2 +- certmanager/conf/configuredialog.cpp | 2 +- certmanager/conf/dirservconfigpage.cpp | 2 +- certmanager/kwatchgnupg/kwatchgnupgconfig.cpp | 2 +- certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp | 4 +- certmanager/lib/CMakeLists.txt | 2 +- .../lib/backends/chiasmus/chiasmusbackend.cpp | 2 +- certmanager/lib/cryptplugfactory.cpp | 2 +- certmanager/lib/cryptplugwrapper.cpp | 2 +- certmanager/lib/kleo/CMakeLists.txt | 2 +- certmanager/lib/kleo/Makefile.am | 2 +- certmanager/lib/kleo/cryptobackendfactory.cpp | 2 +- certmanager/lib/kleo/dn.cpp | 2 +- certmanager/lib/kleo/kconfigbasedkeyfilter.cpp | 251 --------------------- certmanager/lib/kleo/kconfigbasedkeyfilter.h | 104 --------- certmanager/lib/kleo/keyfiltermanager.cpp | 4 +- certmanager/lib/kleo/tdeconfigbasedkeyfilter.cpp | 251 +++++++++++++++++++++ certmanager/lib/kleo/tdeconfigbasedkeyfilter.h | 104 +++++++++ .../lib/ui/dnattributeorderconfigwidget.cpp | 2 +- certmanager/lib/ui/keyselectiondialog.cpp | 2 +- certmanager/lib/ui/messagebox.cpp | 2 +- certmanager/storedtransferjob.h | 2 +- 24 files changed, 380 insertions(+), 380 deletions(-) delete mode 100644 certmanager/lib/kleo/kconfigbasedkeyfilter.cpp delete mode 100644 certmanager/lib/kleo/kconfigbasedkeyfilter.h create mode 100644 certmanager/lib/kleo/tdeconfigbasedkeyfilter.cpp create mode 100644 certmanager/lib/kleo/tdeconfigbasedkeyfilter.h (limited to 'certmanager') diff --git a/certmanager/certificatewizardimpl.cpp b/certmanager/certificatewizardimpl.cpp index 364c5cd0..f153674b 100644 --- a/certmanager/certificatewizardimpl.cpp +++ b/certmanager/certificatewizardimpl.cpp @@ -60,8 +60,8 @@ #include #include #include -#include -#include +#include +#include // TQt #include diff --git a/certmanager/certmanager.cpp b/certmanager/certmanager.cpp index 7c86e8b2..9c1fe389 100644 --- a/certmanager/certmanager.cpp +++ b/certmanager/certmanager.cpp @@ -71,7 +71,7 @@ #include // KDE -#include +#include #include #include #include @@ -85,8 +85,8 @@ #include #include #include -#include -#include +#include +#include #include // TQt diff --git a/certmanager/conf/appearanceconfigwidget.cpp b/certmanager/conf/appearanceconfigwidget.cpp index 96c0bfff..3c2c7c04 100644 --- a/certmanager/conf/appearanceconfigwidget.cpp +++ b/certmanager/conf/appearanceconfigwidget.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include #include diff --git a/certmanager/conf/configuredialog.cpp b/certmanager/conf/configuredialog.cpp index fde9df9d..83879de8 100644 --- a/certmanager/conf/configuredialog.cpp +++ b/certmanager/conf/configuredialog.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include ConfigureDialog::ConfigureDialog( TQWidget *parent, const char *name, bool modal ) diff --git a/certmanager/conf/dirservconfigpage.cpp b/certmanager/conf/dirservconfigpage.cpp index 40ab0998..769b9532 100644 --- a/certmanager/conf/dirservconfigpage.cpp +++ b/certmanager/conf/dirservconfigpage.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include diff --git a/certmanager/kwatchgnupg/kwatchgnupgconfig.cpp b/certmanager/kwatchgnupg/kwatchgnupgconfig.cpp index 200175b2..1cb31ef4 100644 --- a/certmanager/kwatchgnupg/kwatchgnupgconfig.cpp +++ b/certmanager/kwatchgnupg/kwatchgnupgconfig.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp b/certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp index 9bcd0b39..6dbca982 100644 --- a/certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp +++ b/certmanager/kwatchgnupg/kwatchgnupgmainwin.cpp @@ -44,8 +44,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/certmanager/lib/CMakeLists.txt b/certmanager/lib/CMakeLists.txt index 79c729f3..74dc46ea 100644 --- a/certmanager/lib/CMakeLists.txt +++ b/certmanager/lib/CMakeLists.txt @@ -47,6 +47,6 @@ tde_add_library( kleopatra SHARED AUTOMOC LINK kleopatra_backend_qgpgme-static kleopatra_backend_chiasmus-static - qgpgme-shared kio-shared + qgpgme-shared tdeio-shared DESTINATION ${LIB_INSTALL_DIR} ) diff --git a/certmanager/lib/backends/chiasmus/chiasmusbackend.cpp b/certmanager/lib/backends/chiasmus/chiasmusbackend.cpp index da875e30..53ad316d 100644 --- a/certmanager/lib/backends/chiasmus/chiasmusbackend.cpp +++ b/certmanager/lib/backends/chiasmus/chiasmusbackend.cpp @@ -43,7 +43,7 @@ #include "kleo/cryptoconfig.h" #include -#include +#include #include #include diff --git a/certmanager/lib/cryptplugfactory.cpp b/certmanager/lib/cryptplugfactory.cpp index a5015a54..50db2ab7 100644 --- a/certmanager/lib/cryptplugfactory.cpp +++ b/certmanager/lib/cryptplugfactory.cpp @@ -37,7 +37,7 @@ #include "cryptplugfactory.h" #include "cryptplugwrapperlist.h" -#include +#include #include #include #include diff --git a/certmanager/lib/cryptplugwrapper.cpp b/certmanager/lib/cryptplugwrapper.cpp index f997e930..eb2ccafe 100644 --- a/certmanager/lib/cryptplugwrapper.cpp +++ b/certmanager/lib/cryptplugwrapper.cpp @@ -64,7 +64,7 @@ #include #include #include -#include +#include // other #include diff --git a/certmanager/lib/kleo/CMakeLists.txt b/certmanager/lib/kleo/CMakeLists.txt index 63d238e7..aab4ce21 100644 --- a/certmanager/lib/kleo/CMakeLists.txt +++ b/certmanager/lib/kleo/CMakeLists.txt @@ -43,6 +43,6 @@ tde_add_library( kleopatra_core STATIC_PIC AUTOMOC SOURCES cryptobackend.cpp cryptobackendfactory.cpp enum.cpp dn.cpp job.cpp multideletejob.cpp - hierarchicalkeylistjob.cpp kconfigbasedkeyfilter.cpp + hierarchicalkeylistjob.cpp tdeconfigbasedkeyfilter.cpp keyfiltermanager.cpp ) diff --git a/certmanager/lib/kleo/Makefile.am b/certmanager/lib/kleo/Makefile.am index ad9054d1..b81d43bf 100644 --- a/certmanager/lib/kleo/Makefile.am +++ b/certmanager/lib/kleo/Makefile.am @@ -14,7 +14,7 @@ libkleopatra_core_la_SOURCES = \ multideletejob.cpp \ hierarchicalkeylistjob.cpp \ \ - kconfigbasedkeyfilter.cpp \ + tdeconfigbasedkeyfilter.cpp \ keyfiltermanager.cpp kleodir = $(includedir)/kleo diff --git a/certmanager/lib/kleo/cryptobackendfactory.cpp b/certmanager/lib/kleo/cryptobackendfactory.cpp index f67343ca..0397e168 100644 --- a/certmanager/lib/kleo/cryptobackendfactory.cpp +++ b/certmanager/lib/kleo/cryptobackendfactory.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include #include diff --git a/certmanager/lib/kleo/dn.cpp b/certmanager/lib/kleo/dn.cpp index 3249cc73..847127ea 100644 --- a/certmanager/lib/kleo/dn.cpp +++ b/certmanager/lib/kleo/dn.cpp @@ -40,7 +40,7 @@ #include "ui/dnattributeorderconfigwidget.h" #include -#include +#include #include #include diff --git a/certmanager/lib/kleo/kconfigbasedkeyfilter.cpp b/certmanager/lib/kleo/kconfigbasedkeyfilter.cpp deleted file mode 100644 index 4ed6ab37..00000000 --- a/certmanager/lib/kleo/kconfigbasedkeyfilter.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* - kconfigbasedkeyfilter.cpp - - This file is part of libkleopatra, the KDE keymanagement library - Copyright (c) 2004 Klarälvdalens Datakonsult AB - - Libkleopatra is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - Libkleopatra is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "kconfigbasedkeyfilter.h" - -#include -#include - -static const struct { - const char * name; - GpgME::Key::OwnerTrust trust; - GpgME::UserID::Validity validity; -} ownerTrustAndValidityMap[] = { - { "unknown", GpgME::Key::Unknown, GpgME::UserID::Unknown }, - { "undefined", GpgME::Key::Undefined, GpgME::UserID::Undefined }, - { "never", GpgME::Key::Never, GpgME::UserID::Never }, - { "marginal", GpgME::Key::Marginal, GpgME::UserID::Marginal }, - { "full", GpgME::Key::Full, GpgME::UserID::Full }, - { "ultimate", GpgME::Key::Ultimate, GpgME::UserID::Ultimate }, -}; - -static GpgME::Key::OwnerTrust map2OwnerTrust( const TQString & s ) { - for ( unsigned int i = 0 ; i < sizeof ownerTrustAndValidityMap / sizeof *ownerTrustAndValidityMap ; ++i ) - if ( s.lower() == ownerTrustAndValidityMap[i].name ) - return ownerTrustAndValidityMap[i].trust; - return ownerTrustAndValidityMap[0].trust; -} - -static GpgME::UserID::Validity map2Validity( const TQString & s ) { - for ( unsigned int i = 0 ; i < sizeof ownerTrustAndValidityMap / sizeof *ownerTrustAndValidityMap ; ++i ) - if ( s.lower() == ownerTrustAndValidityMap[i].name ) - return ownerTrustAndValidityMap[i].validity; - return ownerTrustAndValidityMap[0].validity; -} - - -Kleo::TDEConfigBasedKeyFilter::TDEConfigBasedKeyFilter( const TDEConfigBase & config ) - : KeyFilter(), - mSpecificity( 0 ), - mItalic( false ), - mBold( false ), - mStrikeOut( false ), - mUseFullFont( false ), - mRevoked( DoesNotMatter ), - mExpired( DoesNotMatter ), - mDisabled( DoesNotMatter ), - mRoot( DoesNotMatter ), - mCanEncrypt( DoesNotMatter ), - mCanSign( DoesNotMatter ), - mCanCertify( DoesNotMatter ), - mCanAuthenticate( DoesNotMatter ), - mHasSecret( DoesNotMatter ), - mIsOpenPGP( DoesNotMatter ), - mWasValidated( DoesNotMatter ), - mOwnerTrust( LevelDoesNotMatter ), - mOwnerTrustReferenceLevel( GpgME::Key::Unknown ), - mValidity( LevelDoesNotMatter ), - mValidityReferenceLevel( GpgME::UserID::Unknown ) -{ - mFgColor = config.readColorEntry( "foreground-color" ); - mBgColor = config.readColorEntry( "background-color" ); - mName = config.readEntry( "name", i18n("") ); - mIcon = config.readEntry( "icon" ); - if ( config.hasKey( "font" ) ) { - mUseFullFont = true; - mFont = config.readFontEntry( "font" ); - } else { - mItalic = config.readBoolEntry( "font-italic", false ); - mBold = config.readBoolEntry( "font-bold", false ); - } - mStrikeOut = config.readBoolEntry( "font-strikeout", false ); -#ifdef SET -#undef SET -#endif -#define SET(member,key) \ - if ( config.hasKey( key ) ) { \ - member = config.readBoolEntry( key ) ? Set : NotSet ; \ - ++mSpecificity; \ - } - SET( mRevoked, "is-revoked" ); - SET( mExpired, "is-expired" ); - SET( mDisabled, "is-disabled" ); - SET( mRoot, "is-root-certificate" ); - SET( mCanEncrypt, "can-encrypt" ); - SET( mCanSign, "can-sign" ); - SET( mCanCertify, "can-certify" ); - SET( mCanAuthenticate, "can-authenticate" ); - SET( mHasSecret, "has-secret-key" ); - SET( mIsOpenPGP, "is-openpgp-key" ); - SET( mWasValidated, "was-validated" ); -#undef SET - static const struct { - const char * prefix; - LevelState state; - } prefixMap[] = { - { "is-", Is }, - { "is-not-", IsNot }, - { "is-at-least-", IsAtLeast }, - { "is-at-most-", IsAtMost }, - }; - for ( unsigned int i = 0 ; i < sizeof prefixMap / sizeof *prefixMap ; ++i ) { - const TQString key = TQString( prefixMap[i].prefix ) + "ownertrust"; - if ( config.hasKey( key ) ) { - mOwnerTrust = prefixMap[i].state; - mOwnerTrustReferenceLevel = map2OwnerTrust( config.readEntry( key ) ); - ++mSpecificity; - break; - } - } - for ( unsigned int i = 0 ; i < sizeof prefixMap / sizeof *prefixMap ; ++i ) { - const TQString key = TQString( prefixMap[i].prefix ) + "validity"; - if ( config.hasKey( key ) ) { - mValidity = prefixMap[i].state; - mValidityReferenceLevel = map2Validity( config.readEntry( key ) ); - ++mSpecificity; - break; - } - } -} - -Kleo::TDEConfigBasedKeyFilter::~TDEConfigBasedKeyFilter() { - -} - -bool Kleo::TDEConfigBasedKeyFilter::matches( const GpgME::Key & key ) const { -#ifdef MATCH -#undef MATCH -#endif -#define MATCH(member,method) \ - if ( member != DoesNotMatter && key.method() != bool( member == Set ) ) \ - return false -#define IS_MATCH(what) MATCH( m##what, is##what ) -#define CAN_MATCH(what) MATCH( mCan##what, can##what ) - IS_MATCH( Revoked ); - IS_MATCH( Expired ); - IS_MATCH( Disabled ); - IS_MATCH( Root ); - CAN_MATCH( Encrypt ); - CAN_MATCH( Sign ); - CAN_MATCH( Certify ); - CAN_MATCH( Authenticate ); - MATCH( mHasSecret, isSecret ); -#undef MATCH - if ( mIsOpenPGP != DoesNotMatter && - bool( key.protocol() == GpgME::Context::OpenPGP ) != bool( mIsOpenPGP == Set ) ) - return false; - if ( mWasValidated != DoesNotMatter && - bool( key.keyListMode() & GpgME::Context::Validate ) != bool( mWasValidated == Set ) ) - return false; - switch ( mOwnerTrust ) { - default: - case LevelDoesNotMatter: - break; - case Is: - if ( key.ownerTrust() != mOwnerTrustReferenceLevel ) - return false; - break; - case IsNot: - if ( key.ownerTrust() == mOwnerTrustReferenceLevel ) - return false; - break; - case IsAtLeast: - if ( (int)key.ownerTrust() < (int)mOwnerTrustReferenceLevel ) - return false; - break; - case IsAtMost: - if ( (int)key.ownerTrust() > (int)mOwnerTrustReferenceLevel ) - return false; - break; - } - const GpgME::UserID uid = key.userID(0); - switch ( mValidity ) { - default: - case LevelDoesNotMatter: - break; - case Is: - if ( uid.validity() != mValidityReferenceLevel ) - return false; - break; - case IsNot: - if ( uid.validity() == mValidityReferenceLevel ) - return false; - break; - case IsAtLeast: - if ( (int)uid.validity() < (int)mValidityReferenceLevel ) - return false; - break; - case IsAtMost: - if ( (int)uid.validity() > (int)mValidityReferenceLevel ) - return false; - break; - } - return true; -} - -static inline TQFont resizedFont( TQFont font, int pointSize, bool strike ) { - font.setPointSize( pointSize ); - if ( strike ) - font.setStrikeOut( true ); - return font; -} - -static inline TQFont adapt( TQFont font, bool it, bool b, bool strike ) { - if ( it ) - font.setItalic( true ); - if ( b ) - font.setBold( true ); - if ( strike ) - font.setStrikeOut( true ); - return font; -} - -TQFont Kleo::TDEConfigBasedKeyFilter::font( const TQFont & f ) const { - if ( mUseFullFont ) - return resizedFont( mFont, f.pointSize(), mStrikeOut ); - else - return adapt( f, mItalic, mBold, mStrikeOut ); -} diff --git a/certmanager/lib/kleo/kconfigbasedkeyfilter.h b/certmanager/lib/kleo/kconfigbasedkeyfilter.h deleted file mode 100644 index 487b3791..00000000 --- a/certmanager/lib/kleo/kconfigbasedkeyfilter.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - kconfigbasedkeyfilter.h - - This file is part of libkleopatra, the KDE keymanagement library - Copyright (c) 2004 Klarälvdalens Datakonsult AB - - Libkleopatra is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - Libkleopatra is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_KCONFIGBASEDKEYFILTER_H__ -#define __KLEO_KCONFIGBASEDKEYFILTER_H__ - -#include "keyfilter.h" - -#include -#include -#include - -#include - -class TDEConfigBase; - -namespace Kleo { - - class TDEConfigBasedKeyFilter : public KeyFilter { - public: - explicit TDEConfigBasedKeyFilter( const TDEConfigBase & config ); - ~TDEConfigBasedKeyFilter(); - bool matches( const GpgME::Key & key ) const; - - unsigned int specificity() const { return mSpecificity; } - - TQColor fgColor() const { return mFgColor; } - TQColor bgColor() const { return mBgColor; } - TQFont font( const TQFont & ) const; - TQString name() const { return mName; } - TQString icon() const { return mIcon; } - - private: - TQColor mFgColor, mBgColor; - TQString mName; - TQString mIcon; - unsigned int mSpecificity; - bool mItalic; - bool mBold; - bool mStrikeOut; - bool mUseFullFont; - TQFont mFont; - - enum TriState { - DoesNotMatter = 0, - Set = 1, - NotSet = 2 - }; - TriState mRevoked; - TriState mExpired; - TriState mDisabled; - TriState mRoot; - TriState mCanEncrypt; - TriState mCanSign; - TriState mCanCertify; - TriState mCanAuthenticate; - TriState mHasSecret; - TriState mIsOpenPGP; - TriState mWasValidated; - enum LevelState { - LevelDoesNotMatter = 0, - Is = 1, - IsNot = 2, - IsAtLeast = 3, - IsAtMost = 4 - }; - LevelState mOwnerTrust; - GpgME::Key::OwnerTrust mOwnerTrustReferenceLevel; - LevelState mValidity; - GpgME::UserID::Validity mValidityReferenceLevel; - }; - -} - -#endif // __KLEO_KCONFIGBASEDKEYFILTER_H__ diff --git a/certmanager/lib/kleo/keyfiltermanager.cpp b/certmanager/lib/kleo/keyfiltermanager.cpp index 1276f9fd..1aa2b170 100644 --- a/certmanager/lib/kleo/keyfiltermanager.cpp +++ b/certmanager/lib/kleo/keyfiltermanager.cpp @@ -35,11 +35,11 @@ #endif #include "keyfiltermanager.h" -#include "kconfigbasedkeyfilter.h" +#include "tdeconfigbasedkeyfilter.h" #include "cryptobackendfactory.h" -#include +#include #include #include diff --git a/certmanager/lib/kleo/tdeconfigbasedkeyfilter.cpp b/certmanager/lib/kleo/tdeconfigbasedkeyfilter.cpp new file mode 100644 index 00000000..05c6d04d --- /dev/null +++ b/certmanager/lib/kleo/tdeconfigbasedkeyfilter.cpp @@ -0,0 +1,251 @@ +/* + tdeconfigbasedkeyfilter.cpp + + This file is part of libkleopatra, the KDE keymanagement library + Copyright (c) 2004 Klarälvdalens Datakonsult AB + + Libkleopatra is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + Libkleopatra is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "tdeconfigbasedkeyfilter.h" + +#include +#include + +static const struct { + const char * name; + GpgME::Key::OwnerTrust trust; + GpgME::UserID::Validity validity; +} ownerTrustAndValidityMap[] = { + { "unknown", GpgME::Key::Unknown, GpgME::UserID::Unknown }, + { "undefined", GpgME::Key::Undefined, GpgME::UserID::Undefined }, + { "never", GpgME::Key::Never, GpgME::UserID::Never }, + { "marginal", GpgME::Key::Marginal, GpgME::UserID::Marginal }, + { "full", GpgME::Key::Full, GpgME::UserID::Full }, + { "ultimate", GpgME::Key::Ultimate, GpgME::UserID::Ultimate }, +}; + +static GpgME::Key::OwnerTrust map2OwnerTrust( const TQString & s ) { + for ( unsigned int i = 0 ; i < sizeof ownerTrustAndValidityMap / sizeof *ownerTrustAndValidityMap ; ++i ) + if ( s.lower() == ownerTrustAndValidityMap[i].name ) + return ownerTrustAndValidityMap[i].trust; + return ownerTrustAndValidityMap[0].trust; +} + +static GpgME::UserID::Validity map2Validity( const TQString & s ) { + for ( unsigned int i = 0 ; i < sizeof ownerTrustAndValidityMap / sizeof *ownerTrustAndValidityMap ; ++i ) + if ( s.lower() == ownerTrustAndValidityMap[i].name ) + return ownerTrustAndValidityMap[i].validity; + return ownerTrustAndValidityMap[0].validity; +} + + +Kleo::TDEConfigBasedKeyFilter::TDEConfigBasedKeyFilter( const TDEConfigBase & config ) + : KeyFilter(), + mSpecificity( 0 ), + mItalic( false ), + mBold( false ), + mStrikeOut( false ), + mUseFullFont( false ), + mRevoked( DoesNotMatter ), + mExpired( DoesNotMatter ), + mDisabled( DoesNotMatter ), + mRoot( DoesNotMatter ), + mCanEncrypt( DoesNotMatter ), + mCanSign( DoesNotMatter ), + mCanCertify( DoesNotMatter ), + mCanAuthenticate( DoesNotMatter ), + mHasSecret( DoesNotMatter ), + mIsOpenPGP( DoesNotMatter ), + mWasValidated( DoesNotMatter ), + mOwnerTrust( LevelDoesNotMatter ), + mOwnerTrustReferenceLevel( GpgME::Key::Unknown ), + mValidity( LevelDoesNotMatter ), + mValidityReferenceLevel( GpgME::UserID::Unknown ) +{ + mFgColor = config.readColorEntry( "foreground-color" ); + mBgColor = config.readColorEntry( "background-color" ); + mName = config.readEntry( "name", i18n("") ); + mIcon = config.readEntry( "icon" ); + if ( config.hasKey( "font" ) ) { + mUseFullFont = true; + mFont = config.readFontEntry( "font" ); + } else { + mItalic = config.readBoolEntry( "font-italic", false ); + mBold = config.readBoolEntry( "font-bold", false ); + } + mStrikeOut = config.readBoolEntry( "font-strikeout", false ); +#ifdef SET +#undef SET +#endif +#define SET(member,key) \ + if ( config.hasKey( key ) ) { \ + member = config.readBoolEntry( key ) ? Set : NotSet ; \ + ++mSpecificity; \ + } + SET( mRevoked, "is-revoked" ); + SET( mExpired, "is-expired" ); + SET( mDisabled, "is-disabled" ); + SET( mRoot, "is-root-certificate" ); + SET( mCanEncrypt, "can-encrypt" ); + SET( mCanSign, "can-sign" ); + SET( mCanCertify, "can-certify" ); + SET( mCanAuthenticate, "can-authenticate" ); + SET( mHasSecret, "has-secret-key" ); + SET( mIsOpenPGP, "is-openpgp-key" ); + SET( mWasValidated, "was-validated" ); +#undef SET + static const struct { + const char * prefix; + LevelState state; + } prefixMap[] = { + { "is-", Is }, + { "is-not-", IsNot }, + { "is-at-least-", IsAtLeast }, + { "is-at-most-", IsAtMost }, + }; + for ( unsigned int i = 0 ; i < sizeof prefixMap / sizeof *prefixMap ; ++i ) { + const TQString key = TQString( prefixMap[i].prefix ) + "ownertrust"; + if ( config.hasKey( key ) ) { + mOwnerTrust = prefixMap[i].state; + mOwnerTrustReferenceLevel = map2OwnerTrust( config.readEntry( key ) ); + ++mSpecificity; + break; + } + } + for ( unsigned int i = 0 ; i < sizeof prefixMap / sizeof *prefixMap ; ++i ) { + const TQString key = TQString( prefixMap[i].prefix ) + "validity"; + if ( config.hasKey( key ) ) { + mValidity = prefixMap[i].state; + mValidityReferenceLevel = map2Validity( config.readEntry( key ) ); + ++mSpecificity; + break; + } + } +} + +Kleo::TDEConfigBasedKeyFilter::~TDEConfigBasedKeyFilter() { + +} + +bool Kleo::TDEConfigBasedKeyFilter::matches( const GpgME::Key & key ) const { +#ifdef MATCH +#undef MATCH +#endif +#define MATCH(member,method) \ + if ( member != DoesNotMatter && key.method() != bool( member == Set ) ) \ + return false +#define IS_MATCH(what) MATCH( m##what, is##what ) +#define CAN_MATCH(what) MATCH( mCan##what, can##what ) + IS_MATCH( Revoked ); + IS_MATCH( Expired ); + IS_MATCH( Disabled ); + IS_MATCH( Root ); + CAN_MATCH( Encrypt ); + CAN_MATCH( Sign ); + CAN_MATCH( Certify ); + CAN_MATCH( Authenticate ); + MATCH( mHasSecret, isSecret ); +#undef MATCH + if ( mIsOpenPGP != DoesNotMatter && + bool( key.protocol() == GpgME::Context::OpenPGP ) != bool( mIsOpenPGP == Set ) ) + return false; + if ( mWasValidated != DoesNotMatter && + bool( key.keyListMode() & GpgME::Context::Validate ) != bool( mWasValidated == Set ) ) + return false; + switch ( mOwnerTrust ) { + default: + case LevelDoesNotMatter: + break; + case Is: + if ( key.ownerTrust() != mOwnerTrustReferenceLevel ) + return false; + break; + case IsNot: + if ( key.ownerTrust() == mOwnerTrustReferenceLevel ) + return false; + break; + case IsAtLeast: + if ( (int)key.ownerTrust() < (int)mOwnerTrustReferenceLevel ) + return false; + break; + case IsAtMost: + if ( (int)key.ownerTrust() > (int)mOwnerTrustReferenceLevel ) + return false; + break; + } + const GpgME::UserID uid = key.userID(0); + switch ( mValidity ) { + default: + case LevelDoesNotMatter: + break; + case Is: + if ( uid.validity() != mValidityReferenceLevel ) + return false; + break; + case IsNot: + if ( uid.validity() == mValidityReferenceLevel ) + return false; + break; + case IsAtLeast: + if ( (int)uid.validity() < (int)mValidityReferenceLevel ) + return false; + break; + case IsAtMost: + if ( (int)uid.validity() > (int)mValidityReferenceLevel ) + return false; + break; + } + return true; +} + +static inline TQFont resizedFont( TQFont font, int pointSize, bool strike ) { + font.setPointSize( pointSize ); + if ( strike ) + font.setStrikeOut( true ); + return font; +} + +static inline TQFont adapt( TQFont font, bool it, bool b, bool strike ) { + if ( it ) + font.setItalic( true ); + if ( b ) + font.setBold( true ); + if ( strike ) + font.setStrikeOut( true ); + return font; +} + +TQFont Kleo::TDEConfigBasedKeyFilter::font( const TQFont & f ) const { + if ( mUseFullFont ) + return resizedFont( mFont, f.pointSize(), mStrikeOut ); + else + return adapt( f, mItalic, mBold, mStrikeOut ); +} diff --git a/certmanager/lib/kleo/tdeconfigbasedkeyfilter.h b/certmanager/lib/kleo/tdeconfigbasedkeyfilter.h new file mode 100644 index 00000000..3d65e7a2 --- /dev/null +++ b/certmanager/lib/kleo/tdeconfigbasedkeyfilter.h @@ -0,0 +1,104 @@ +/* + tdeconfigbasedkeyfilter.h + + This file is part of libkleopatra, the KDE keymanagement library + Copyright (c) 2004 Klarälvdalens Datakonsult AB + + Libkleopatra is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + Libkleopatra is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#ifndef __KLEO_KCONFIGBASEDKEYFILTER_H__ +#define __KLEO_KCONFIGBASEDKEYFILTER_H__ + +#include "keyfilter.h" + +#include +#include +#include + +#include + +class TDEConfigBase; + +namespace Kleo { + + class TDEConfigBasedKeyFilter : public KeyFilter { + public: + explicit TDEConfigBasedKeyFilter( const TDEConfigBase & config ); + ~TDEConfigBasedKeyFilter(); + bool matches( const GpgME::Key & key ) const; + + unsigned int specificity() const { return mSpecificity; } + + TQColor fgColor() const { return mFgColor; } + TQColor bgColor() const { return mBgColor; } + TQFont font( const TQFont & ) const; + TQString name() const { return mName; } + TQString icon() const { return mIcon; } + + private: + TQColor mFgColor, mBgColor; + TQString mName; + TQString mIcon; + unsigned int mSpecificity; + bool mItalic; + bool mBold; + bool mStrikeOut; + bool mUseFullFont; + TQFont mFont; + + enum TriState { + DoesNotMatter = 0, + Set = 1, + NotSet = 2 + }; + TriState mRevoked; + TriState mExpired; + TriState mDisabled; + TriState mRoot; + TriState mCanEncrypt; + TriState mCanSign; + TriState mCanCertify; + TriState mCanAuthenticate; + TriState mHasSecret; + TriState mIsOpenPGP; + TriState mWasValidated; + enum LevelState { + LevelDoesNotMatter = 0, + Is = 1, + IsNot = 2, + IsAtLeast = 3, + IsAtMost = 4 + }; + LevelState mOwnerTrust; + GpgME::Key::OwnerTrust mOwnerTrustReferenceLevel; + LevelState mValidity; + GpgME::UserID::Validity mValidityReferenceLevel; + }; + +} + +#endif // __KLEO_KCONFIGBASEDKEYFILTER_H__ diff --git a/certmanager/lib/ui/dnattributeorderconfigwidget.cpp b/certmanager/lib/ui/dnattributeorderconfigwidget.cpp index 4cfcfb20..67f1929e 100644 --- a/certmanager/lib/ui/dnattributeorderconfigwidget.cpp +++ b/certmanager/lib/ui/dnattributeorderconfigwidget.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include diff --git a/certmanager/lib/ui/keyselectiondialog.cpp b/certmanager/lib/ui/keyselectiondialog.cpp index adb25749..b785137d 100644 --- a/certmanager/lib/ui/keyselectiondialog.cpp +++ b/certmanager/lib/ui/keyselectiondialog.cpp @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/certmanager/lib/ui/messagebox.cpp b/certmanager/lib/ui/messagebox.cpp index 96b710c3..571ceccd 100644 --- a/certmanager/lib/ui/messagebox.cpp +++ b/certmanager/lib/ui/messagebox.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include #include diff --git a/certmanager/storedtransferjob.h b/certmanager/storedtransferjob.h index 7fab7706..276d5db4 100644 --- a/certmanager/storedtransferjob.h +++ b/certmanager/storedtransferjob.h @@ -20,7 +20,7 @@ #ifndef STOREDTRANSFERJOB_H #define STOREDTRANSFERJOB_H -#include +#include // To be moved to KIO? namespace TDEIOext { -- cgit v1.2.3