[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/enterprise4/kdepim/libkleo/kleo
From:       Marc Mutz <mutz () kde ! org>
Date:       2009-07-29 15:19:02
Message-ID: 1248880742.092370.6498.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1004201 by mutz:

KeyFilterImplBase::matches(): fix != where == would be correct. Extract Method is_card_key()

 M  +9 -8      kconfigbasedkeyfilter.cpp  


--- branches/kdepim/enterprise4/kdepim/libkleo/kleo/kconfigbasedkeyfilter.cpp #1004200:1004201
@@ -274,6 +274,12 @@
   }
 }
 
+static bool is_card_key( const Key & key ) {
+    const std::vector<Subkey> sks = key.subkeys();
+    return std::find_if( sks.begin(), sks.end(),
+                         mem_fn( &Subkey::isCardKey ) ) != sks.end() ;
+}
+
 bool KeyFilterImplBase::matches( const Key & key, MatchContexts contexts ) const {
   if ( !( mMatchContexts & contexts ) )
     return false;
@@ -294,15 +300,10 @@
   CAN_MATCH( Certify );
   CAN_MATCH( Authenticate );
   IS_MATCH( Qualified );
-  if ( mCardKey != DoesNotMatter ) {
-      const std::vector<Subkey> sks = key.subkeys();
-      const std::vector<Subkey>::const_iterator it
-          = std::find_if( sks.begin(), sks.end(),
-                          mem_fn( &Subkey::isCardKey ) );
-      if ( mCardKey == Set    && it == sks.end() ||
-           mCardKey != NotSet && it != sks.end() )
+  if ( mCardKey != DoesNotMatter )
+      if ( mCardKey == Set    && !is_card_key( key ) ||
+           mCardKey == NotSet &&  is_card_key( key ) )
           return false;
-  }
   MATCH( mHasSecret, hasSecret );
 #undef MATCH
   if ( mIsOpenPGP != DoesNotMatter &&
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic