From 7bd54f5a796f6f1276bbd310deaf1f2ac673954d Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 28 Apr 2013 16:44:42 -0500 Subject: Fix retriggering of GPGMe socket notifiers in nested event loops This resolves Bug 825 Add missing GPGMe feature checks to CMake --- certmanager/lib/ui/keylistview.cpp | 9 ++-- certmanager/lib/ui/keyselectiondialog.cpp | 71 +++++++++++++++++++------------ 2 files changed, 50 insertions(+), 30 deletions(-) (limited to 'certmanager/lib') diff --git a/certmanager/lib/ui/keylistview.cpp b/certmanager/lib/ui/keylistview.cpp index 8e81b9768..00f69500b 100644 --- a/certmanager/lib/ui/keylistview.cpp +++ b/certmanager/lib/ui/keylistview.cpp @@ -333,13 +333,16 @@ Kleo::KeyListViewItem * Kleo::KeyListView::itemByFingerprint( const TQCString & void Kleo::KeyListView::slotRefreshKey( const GpgME::Key & key ) { const char * fpr = key.primaryFingerprint(); - if ( !fpr ) + if ( !fpr ) { return; - if ( KeyListViewItem * item = itemByFingerprint( fpr ) ) + } + if ( KeyListViewItem * item = itemByFingerprint( fpr ) ) { item->setKey ( key ); - else + } + else { // none found -> add it slotAddKey( key ); + } } // slots for the emission of covariant signals: diff --git a/certmanager/lib/ui/keyselectiondialog.cpp b/certmanager/lib/ui/keyselectiondialog.cpp index 9e005d583..c46228a43 100644 --- a/certmanager/lib/ui/keyselectiondialog.cpp +++ b/certmanager/lib/ui/keyselectiondialog.cpp @@ -265,29 +265,33 @@ namespace { } const TQPixmap * ColumnStrategy::pixmap( const GpgME::Key & key, int col ) const { - if ( col != 0 ) + if ( col != 0 ) { return 0; + } // this key did not undergo a validating keylisting yet: - if ( !( key.keyListMode() & GpgME::Context::Validate ) ) + if ( !( key.keyListMode() & GpgME::Context::Validate ) ) { return &mKeyUnknownPix; + } - if ( !checkKeyUsage( key, mKeyUsage ) ) + if ( !checkKeyUsage( key, mKeyUsage ) ) { return &mKeyBadPix; + } - if ( key.protocol() == GpgME::Context::CMS ) + if ( key.protocol() == GpgME::Context::CMS ) { return &mKeyGoodPix; + } switch ( key.userID(0).validity() ) { - default: - case GpgME::UserID::Unknown: - case GpgME::UserID::Undefined: - return &mKeyUnknownPix; - case GpgME::UserID::Never: - return &mKeyValidPix; - case GpgME::UserID::Marginal: - case GpgME::UserID::Full: - case GpgME::UserID::Ultimate: - return &mKeyGoodPix; + default: + case GpgME::UserID::Unknown: + case GpgME::UserID::Undefined: + return &mKeyUnknownPix; + case GpgME::UserID::Never: + return &mKeyValidPix; + case GpgME::UserID::Marginal: + case GpgME::UserID::Full: + case GpgME::UserID::Ultimate: + return &mKeyGoodPix; } } @@ -585,8 +589,9 @@ namespace { void Kleo::KeySelectionDialog::startKeyListJobForBackend( const CryptoBackend::Protocol * backend, const std::vector & keys, bool validate ) { assert( backend ); KeyListJob * job = backend->keyListJob( false, false, validate ); // local, w/o sigs, validation as givem - if ( !job ) + if ( !job ) { return; + } connect( job, TQT_SIGNAL(result(const GpgME::KeyListResult&)), TQT_SLOT(slotKeyListResult(const GpgME::KeyListResult&)) ); @@ -599,8 +604,9 @@ void Kleo::KeySelectionDialog::startKeyListJobForBackend( const CryptoBackend::P std::transform( keys.begin(), keys.end(), std::back_inserter( fprs ), ExtractFingerprint() ); const GpgME::Error err = job->start( fprs, mKeyUsage & SecretKeys && !( mKeyUsage & PublicKeys ) ); - if ( err ) + if ( err ) { return showKeyListError( this, err ); + } // FIXME: create a MultiProgressDialog: (void)new ProgressDialog( job, validate ? i18n( "Checking selected keys..." ) : i18n( "Fetching keys..." ), this ); @@ -617,15 +623,18 @@ static void selectKeys( Kleo::KeyListView * klv, const std::vector & } void Kleo::KeySelectionDialog::slotKeyListResult( const GpgME::KeyListResult & res ) { - if ( res.error() ) + if ( res.error() ) { showKeyListError( this, res.error() ); - else if ( res.isTruncated() ) + } + else if ( res.isTruncated() ) { ++mTruncated; + } - if ( --mListJobCount > 0 ) + if ( --mListJobCount > 0 ) { return; // not yet finished... + } - if ( mTruncated > 0 ) + if ( mTruncated > 0 ) { KMessageBox::information( this, i18n("One backend returned truncated output.
" "Not all available keys are shown
", @@ -633,6 +642,7 @@ void Kleo::KeySelectionDialog::slotKeyListResult( const GpgME::KeyListResult & r "Not all available keys are shown", mTruncated), i18n("Key List Result") ); + } mKeyListView->flushKeys(); @@ -677,13 +687,16 @@ void Kleo::KeySelectionDialog::slotCheckSelection( KeyListViewItem * item ) { mSelectedKeys.clear(); if ( !mKeyListView->isMultiSelection() ) { - if ( item ) + if ( item ) { mSelectedKeys.push_back( item->key() ); + } } - for ( KeyListViewItem * it = mKeyListView->firstChild() ; it ; it = it->nextSibling() ) - if ( it->isSelected() ) + for ( KeyListViewItem * it = mKeyListView->firstChild() ; it ; it = it->nextSibling() ) { + if ( it->isSelected() ) { mSelectedKeys.push_back( it->key() ); + } + } mKeysToCheck.clear(); std::remove_copy_if( mSelectedKeys.begin(), mSelectedKeys.end(), @@ -700,8 +713,9 @@ void Kleo::KeySelectionDialog::slotCheckSelection( KeyListViewItem * item ) { } void Kleo::KeySelectionDialog::startValidatingKeyListing() { - if ( mKeysToCheck.empty() ) + if ( mKeysToCheck.empty() ) { return; + } mListJobCount = 0; mTruncated = 0; @@ -711,11 +725,14 @@ void Kleo::KeySelectionDialog::startValidatingKeyListing() { mKeyListView->setEnabled( false ); std::vector smime, openpgp; - for ( std::vector::const_iterator it = mKeysToCheck.begin() ; it != mKeysToCheck.end() ; ++it ) - if ( it->protocol() == GpgME::Context::OpenPGP ) + for ( std::vector::const_iterator it = mKeysToCheck.begin() ; it != mKeysToCheck.end() ; ++it ) { + if ( it->protocol() == GpgME::Context::OpenPGP ) { openpgp.push_back( *it ); - else + } + else { smime.push_back( *it ); + } + } if ( !openpgp.empty() ) { assert( mOpenPGPBackend ); -- cgit v1.2.1