CVS commit by faure: backport error handling fix M +10 -5 qgpgmecryptoconfig.cpp 1.16.2.8 M +2 -2 qgpgmecryptoconfig.h 1.9.2.2 --- kdepim/certmanager/lib/backends/qgpgme/qgpgmecryptoconfig.cpp #1.16.2.7:1.16.2.8 @@ -57,9 +57,8 @@ static bool s_duringClear = false; // Change size of mFlags bitfield if adding new values here -QGpgMECryptoConfig::QGpgMECryptoConfig( bool showErrors ) +QGpgMECryptoConfig::QGpgMECryptoConfig() : mComponents( 7 ), mParsed( false ) { mComponents.setAutoDelete( true ); - runGpgConf( showErrors ); } @@ -84,9 +83,15 @@ void QGpgMECryptoConfig::runGpgConf( boo rc = -1; else - rc = ( proc.normalExit() ) ? proc.exitStatus() : -1 ; + rc = ( proc.normalExit() ) ? proc.exitStatus() : -2 ; // handle errors, if any (and if requested) if ( showErrors && rc != 0 ) { - QString wmsg = i18n("Failed to execute gpgconf:
%1
").arg( strerror(rc) ); + QString wmsg = i18n("Failed to execute gpgconf:
%1
"); + if ( rc == -1 ) + wmsg = wmsg.arg( i18n( "program not found" ) ); + else if ( rc == -2 ) + wmsg = wmsg.arg( i18n( "program cannot be executed" ) ); + else + wmsg = wmsg.arg( strerror(rc) ); kdWarning(5150) << wmsg << endl; // to see it from test_cryptoconfig.cpp KMessageBox::error(0, wmsg); @@ -114,5 +119,5 @@ QStringList QGpgMECryptoConfig::componen { if ( !mParsed ) - const_cast( this )->runGpgConf( false ); + const_cast( this )->runGpgConf( true ); QDictIterator it( mComponents ); QStringList names; --- kdepim/certmanager/lib/backends/qgpgme/qgpgmecryptoconfig.h #1.9.2.1:1.9.2.2 @@ -53,7 +53,6 @@ public: /** * Constructor - * @param showErrors if true, a messagebox will be shown if e.g. gpgconf wasn't found */ - QGpgMECryptoConfig( bool showErrors = true ); + QGpgMECryptoConfig(); virtual ~QGpgMECryptoConfig(); @@ -68,4 +67,5 @@ private slots: void slotCollectStdOut( KProcIO* proc ); private: + /// @param showErrors if true, a messagebox will be shown if e.g. gpgconf wasn't found void runGpgConf( bool showErrors );