From cc29364f06178f8f6b457384f2ec37a042bd9d43 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 1 Sep 2010 00:37:02 +0000 Subject: * Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch * Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- certmanager/certmanager.cpp | 9 ++- certmanager/conf/kleopatra_config_appear.desktop | 6 +- certmanager/conf/kleopatra_config_dirserv.desktop | 11 ++-- certmanager/conf/kleopatra_config_dnorder.desktop | 3 - .../lib/backends/qgpgme/qgpgmecryptoconfig.cpp | 16 ++++- .../lib/backends/qgpgme/qgpgmedecryptjob.cpp | 5 +- .../lib/backends/qgpgme/qgpgmedecryptverifyjob.cpp | 8 ++- .../lib/backends/qgpgme/qgpgmedeletejob.cpp | 1 + .../lib/backends/qgpgme/qgpgmedownloadjob.cpp | 4 +- .../lib/backends/qgpgme/qgpgmeencryptjob.cpp | 5 +- .../lib/backends/qgpgme/qgpgmeexportjob.cpp | 4 +- .../lib/backends/qgpgme/qgpgmeimportjob.cpp | 8 ++- certmanager/lib/backends/qgpgme/qgpgmejob.cpp | 16 ++--- certmanager/lib/backends/qgpgme/qgpgmejob.h | 7 ++- .../lib/backends/qgpgme/qgpgmekeygenerationjob.cpp | 5 +- .../lib/backends/qgpgme/qgpgmekeylistjob.cpp | 16 +++++ certmanager/lib/backends/qgpgme/qgpgmekeylistjob.h | 1 + .../lib/backends/qgpgme/qgpgmesignencryptjob.cpp | 4 +- certmanager/lib/backends/qgpgme/qgpgmesignjob.cpp | 5 +- .../backends/qgpgme/qgpgmeverifydetachedjob.cpp | 4 +- .../lib/backends/qgpgme/qgpgmeverifyopaquejob.cpp | 5 +- certmanager/lib/kleo/job.cpp | 14 +++++ certmanager/lib/kleo/job.h | 6 ++ certmanager/lib/libkleopatrarc.desktop | 9 +-- certmanager/lib/tests/test_verify.cpp | 1 + certmanager/lib/ui/cryptoconfigdialog.cpp | 6 ++ certmanager/lib/ui/cryptoconfigmodule.cpp | 30 +++++++++- certmanager/lib/ui/cryptoconfigmodule.h | 2 + certmanager/lib/ui/keyselectiondialog.cpp | 57 ++++++++++++++++-- certmanager/lib/ui/keyselectiondialog.h | 15 ++++- certmanager/lib/ui/messagebox.cpp | 69 ++++++++++++++++++++-- certmanager/lib/ui/messagebox.h | 3 + 32 files changed, 290 insertions(+), 65 deletions(-) (limited to 'certmanager') diff --git a/certmanager/certmanager.cpp b/certmanager/certmanager.cpp index f12411bf5..c078315b9 100644 --- a/certmanager/certmanager.cpp +++ b/certmanager/certmanager.cpp @@ -889,7 +889,8 @@ void CertManager::slotDirmngrExited() { This slot will import CRLs from a file. */ void CertManager::importCRLFromFile() { - TQString filter = TQString("*.crl *.arl *-crl.der *-arl.der|") + i18n("Certificate Revocation List (*.crl *.arl *-crl.der *-arl.der)"); + // loadcrl can only work with DER encoded files (verified with dirmngr 1.0.3) + TQString filter = TQString("*.crl *.arl *-crl.der *-arl.der|") + i18n("Certificate Revocation List, DER encoded (*.crl *.arl *-crl.der *-arl.der)"); KURL url = KFileDialog::getOpenURL( TQString::null, filter, this, @@ -1277,9 +1278,11 @@ void CertManager::slotCertificateExportResult( const GpgME::Error & err, const T void CertManager::slotExportSecretKey() { Kleo::KeySelectionDialog dlg( i18n("Secret Key Export"), - i18n("Select the secret key to export " + "" + + i18n("Select the secret key to export " "(Warning: The PKCS#12 format is insecure; " - "exporting secret keys is discouraged):"), + "exporting secret keys is discouraged):") + + "", std::vector(), Kleo::KeySelectionDialog::SecretKeys|Kleo::KeySelectionDialog::SMIMEKeys, false /* no multiple selection */, diff --git a/certmanager/conf/kleopatra_config_appear.desktop b/certmanager/conf/kleopatra_config_appear.desktop index 8cbeaecf8..fa6fa6ba6 100644 --- a/certmanager/conf/kleopatra_config_appear.desktop +++ b/certmanager/conf/kleopatra_config_appear.desktop @@ -40,7 +40,6 @@ Name[hu]=Megjelenés Name[is]=Útlit Name[it]=Aspetto Name[ja]=外観 -Name[ka]=იერსახე Name[kk]=Сыртқы көрінісі Name[km]=រូបរាង Name[ko]=모양 @@ -67,8 +66,7 @@ Name[ta]=தோற்றம் Name[tg]=Намуди зоҳирӣ Name[tr]=Görünüm Name[uk]=Вигляд -Name[uz]=Koʻrinishi -Name[uz@cyrillic]=Кўриниши +Name[uz]=Кўриниши Name[zh_CN]=外观 Comment=Colors & Fonts Configuration Comment[af]=Kleur en skrif tipe opstelling @@ -97,7 +95,6 @@ Comment[hu]=A színek és betűtípusok beállítása Comment[is]=Stilling lita & leturgerða Comment[it]=Configurazione tipi di carattere e colori Comment[ja]=色とフォントの設定 -Comment[ka]=ფერთა და შრიფტთა კონფიგურაცია Comment[kk]=Түс & Қаріп параметрлері Comment[km]=ការ​កំណត់​រចនាសម្ព័ន្ធ​ពណ៌ & ពុម្ពអក្សរ Comment[ko]=색과 글꼴 설정 @@ -153,7 +150,6 @@ Keywords[hu]=szín,betűtípus,beállítások Keywords[is]=litir,letur, stillingar Keywords[it]=colori, font, caratteri, configurazione Keywords[ja]=色,フォント,設定 -Keywords[ka]=ფერები,შრიფტები, კონფიგურაცია Keywords[km]=ពណ៌,ពុម្ពអក្សរ,ការ​កំណត់​រចនាសម្ព័ន្ធ Keywords[ko]=색,글꼴,설정 Keywords[lt]=color,font, configuration, spalvų, šriftų konfigūravimas diff --git a/certmanager/conf/kleopatra_config_dirserv.desktop b/certmanager/conf/kleopatra_config_dirserv.desktop index 7a50a7c41..9153b003f 100644 --- a/certmanager/conf/kleopatra_config_dirserv.desktop +++ b/certmanager/conf/kleopatra_config_dirserv.desktop @@ -27,7 +27,7 @@ Name[et]=Kataloogiteenused Name[eu]=Direktorio zerbitzuak Name[fa]=خدمات فهرست راهنما Name[fi]=Hakemistopalvelut -Name[fr]=Services d'annuaire +Name[fr]=Services de répertoires Name[fy]=Maptsjinsten Name[ga]=Seirbhísí Eolaire Name[gl]=Servicios de Directorio @@ -36,7 +36,6 @@ Name[hu]=Címtárszolgáltatások Name[is]=Nafnaþjónustur Name[it]=Servizi Directory Name[ja]=ディレクトリサービス -Name[ka]=საცნობარო მომსახურება Name[kk]=Каталог қызметтері Name[km]=សេវា​ថត Name[ko]=디렉터리 서비스 @@ -80,7 +79,7 @@ Comment[et]=LDAP kataloogiteenuste seadistused Comment[eu]=LDAP direktorio zerbitzuen konfigurazioa Comment[fa]=پیکربندی خدمات فهرست راهنمای LDAP Comment[fi]=Hakemistopalveluiden asetukset -Comment[fr]=Configuration des services d'annuaire LDAP +Comment[fr]=Configuration des répertoires LDAP Comment[fy]=Konfiguraasje foar LDAP-tsjinsten Comment[gl]=Configuración dos servicios de directorio LDAP Comment[he]=תצורה של שירותי ספרייה עבור LDAP @@ -88,7 +87,6 @@ Comment[hu]=Az LDAP címtárszolgáltatások beállításai Comment[is]=Stillingar LDAP uppflettingaþjónustunnar Comment[it]=Configurazione servizi LDAP Comment[ja]=LDAP ディレクトリサービスの設定 -Comment[ka]=LDAP საცნობარო მომსახურების კონფიგურაცია Comment[kk]=LDAP каталог қызметтер параметрлері Comment[km]=ការ​កំណត់​រចនាសម្ព័ន្ធ​របស់​សេវា​ថត LDAP Comment[ko]=LDAP 디렉터리 서비스 설정 @@ -133,7 +131,7 @@ Keywords[et]=ldap,kataloog,teenused Keywords[eu]=Idap, direktorio, zerbitzuak Keywords[fa]=ldap، فهرست راهنما، خدمات Keywords[fi]=ldap,hakemisto,palvelut -Keywords[fr]=ldap,annuaire,annuaires,service,services +Keywords[fr]=ldap,dossier,dossiers,service,services Keywords[fy]=ldap,directory,services,triemtafel,tsjinsten Keywords[ga]=ldap,eolaire,seirbhísí Keywords[gl]=ldap,directorio,servicios @@ -142,7 +140,6 @@ Keywords[hu]=ldap,címtár,szolgáltatások Keywords[is]=ldap,directory,services,nafnaþjónusta Keywords[it]=ldap, servizi, directory Keywords[ja]=ldap,ディレクトリ,サービス -Keywords[ka]=ldap,ცნობარი,მომსახურება Keywords[km]=ldap,ថត,សេវា Keywords[ko]=ldap,디렉터리,서비스 Keywords[lt]=ldap,directory,services,aplankai,tarnybos @@ -152,7 +149,7 @@ Keywords[nb]=ldap,mappe,tjenester Keywords[nds]=LDAP,Verteken,Deensten Keywords[ne]=ldap,डाइरेक्टरी,कार्य Keywords[nn]=ldap,katalog,tenester -Keywords[pl]=katalog,usługi katalogowe,usługi,LDAP +Keywords[pl]=ldap,katalog,usługi katalogowe,usługi,LDAP Keywords[pt]=ldap,directório,serviços Keywords[pt_BR]=ldap,diretório,serviços Keywords[ru]=LDAP,службы каталогов diff --git a/certmanager/conf/kleopatra_config_dnorder.desktop b/certmanager/conf/kleopatra_config_dnorder.desktop index dc46c3314..a14ffb3c7 100644 --- a/certmanager/conf/kleopatra_config_dnorder.desktop +++ b/certmanager/conf/kleopatra_config_dnorder.desktop @@ -34,7 +34,6 @@ Name[hu]=DN-attribútumsorrend Name[is]=DN eiginleikaröðun Name[it]=Attributi DN, ordine Name[ja]=DN 属性順位 -Name[ka]=DN ატრიბუტთა რიგი Name[kk]=DN-атрибуттер реті Name[km]=លំដាប់​គុណលក្ខណៈ DN Name[ko]=DN 분배 순서 @@ -85,7 +84,6 @@ Comment[hu]=A DN-attribútumok megjelenítési sorrendjének beállítása Comment[is]=Stilla röð DN eiginleikanna Comment[it]=Configura l'ordine in cui sono mostrati gli attributi DN Comment[ja]=DN 属性を表示する順位を設定 -Comment[ka]=DN ატრიბუტთა ჩვენების რიგის კონფიგურაცია Comment[kk]=DN атрибуттерді көрсету ретін баптау Comment[km]=កំណត់​រចនាសម្ព័ន្ធ​លំដាប់ ដែល​ត្រូវ​បង្ហាញ​គុណលក្ខណៈ DN Comment[lt]=Konfigūruoti DN savybių rodymo tvarką @@ -137,7 +135,6 @@ Keywords[hu]=DN,sorrend,RDN,attribútum Keywords[is]=DN,röð,order,RDN,attribute Keywords[it]=DN,ordine,RDN,attributi Keywords[ja]=DN,順位,RDN,属性 -Keywords[ka]=DN,რიგი,RDN,ატრიბუტი Keywords[km]=DN,លំដាប់,RDN,គុណលក្ខណៈ Keywords[lt]=DN,order,RDN,attribute,savybė,tvarka Keywords[mk]=DN,order,RDN,attribute,редослед,атрибут diff --git a/certmanager/lib/backends/qgpgme/qgpgmecryptoconfig.cpp b/certmanager/lib/backends/qgpgme/qgpgmecryptoconfig.cpp index c67800502..ae45d6833 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmecryptoconfig.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmecryptoconfig.cpp @@ -447,6 +447,13 @@ TQVariant QGpgMECryptoConfigEntry::stringToValue( const TQString& str, bool unes bool isString = isStringType(); if ( isList() ) { + if ( argType() == ArgType_None ) { + bool ok = true; + const TQVariant v = str.isEmpty() ? 0U : str.toUInt( &ok ) ; + if ( !ok ) + kdWarning(5150) << "list-of-none should have an unsigned int as value:" << str << endl; + return v; + } TQValueList lst; TQStringList items = TQStringList::split( ',', str ); for( TQStringList::const_iterator valit = items.begin(); valit != items.end(); ++valit ) { @@ -657,7 +664,10 @@ void QGpgMECryptoConfigEntry::resetToDefault() if ( mFlags & GPGCONF_FLAG_DEFAULT ) mValue = mDefaultValue; else if ( mArgType == ArgType_None ) - mValue = false; + if ( isList() ) + mValue = 0U; + else + mValue = false; } void QGpgMECryptoConfigEntry::setBoolValue( bool b ) @@ -715,7 +725,9 @@ void QGpgMECryptoConfigEntry::setNumberOfTimesSet( unsigned int i ) { Q_ASSERT( mArgType == ArgType_None ); Q_ASSERT( isList() ); - setUIntValue( i ); + mValue = i; + mSet = i > 0; + mDirty = true; } void QGpgMECryptoConfigEntry::setStringValueList( const TQStringList& lst ) diff --git a/certmanager/lib/backends/qgpgme/qgpgmedecryptjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmedecryptjob.cpp index 692efa322..15d3246fe 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmedecryptjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmedecryptjob.cpp @@ -85,7 +85,10 @@ GpgME::DecryptionResult Kleo::QGpgMEDecryptJob::exec( const TQByteArray & cipher } void Kleo::QGpgMEDecryptJob::doOperationDoneEvent( const GpgME::Error & ) { - emit result( mCtx->decryptionResult(), mOutDataDataProvider->data() ); + const GpgME::DecryptionResult res = mCtx->decrypt( *mInData, *mOutData ); + const TQByteArray plainText = mOutDataDataProvider->data(); + getAuditLog(); + emit result( res, plainText ); } #include "qgpgmedecryptjob.moc" diff --git a/certmanager/lib/backends/qgpgme/qgpgmedecryptverifyjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmedecryptverifyjob.cpp index 68f67d0fd..a14e7e18f 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmedecryptverifyjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmedecryptverifyjob.cpp @@ -87,9 +87,11 @@ Kleo::QGpgMEDecryptVerifyJob::exec( const TQByteArray & cipherText, TQByteArray } void Kleo::QGpgMEDecryptVerifyJob::doOperationDoneEvent( const GpgME::Error & ) { - emit result( mCtx->decryptionResult(), - mCtx->verificationResult(), - mOutDataDataProvider->data() ); + const GpgME::DecryptionResult dr = mCtx->decryptionResult(); + const GpgME::VerificationResult vr = mCtx->verificationResult(); + const TQByteArray plainText = mOutDataDataProvider->data(); + getAuditLog(); + emit result( dr, vr, plainText ); } #include "qgpgmedecryptverifyjob.moc" diff --git a/certmanager/lib/backends/qgpgme/qgpgmedeletejob.cpp b/certmanager/lib/backends/qgpgme/qgpgmedeletejob.cpp index c06907eea..3665ee668 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmedeletejob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmedeletejob.cpp @@ -64,6 +64,7 @@ GpgME::Error Kleo::QGpgMEDeleteJob::start( const GpgME::Key & key, bool allowSec } void Kleo::QGpgMEDeleteJob::doOperationDoneEvent( const GpgME::Error & error ) { + getAuditLog(); emit result( error ); } diff --git a/certmanager/lib/backends/qgpgme/qgpgmedownloadjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmedownloadjob.cpp index 364e8f9f7..979a85490 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmedownloadjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmedownloadjob.cpp @@ -72,7 +72,9 @@ GpgME::Error Kleo::QGpgMEDownloadJob::start( const TQStringList & pats ) { } void Kleo::QGpgMEDownloadJob::doOperationDoneEvent( const GpgME::Error & error ) { - emit result( error, mOutDataDataProvider->data() ); + const TQByteArray data = mOutDataDataProvider->data(); + getAuditLog(); + emit result( error, data ); } #include "qgpgmedownloadjob.moc" diff --git a/certmanager/lib/backends/qgpgme/qgpgmeencryptjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmeencryptjob.cpp index ddd51717f..a6a380b0b 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmeencryptjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmeencryptjob.cpp @@ -97,7 +97,10 @@ GpgME::EncryptionResult Kleo::QGpgMEEncryptJob::exec( const std::vectorencryptionResult(), mOutDataDataProvider->data() ); + mResult = mCtx->encryptionResult(); + const TQByteArray ciphertext = mOutDataDataProvider->data(); + getAuditLog(); + emit result( mResult, ciphertext ); } void Kleo::QGpgMEEncryptJob::showErrorDialog( TQWidget * parent, const TQString & caption ) const { diff --git a/certmanager/lib/backends/qgpgme/qgpgmeexportjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmeexportjob.cpp index c31074aff..16e5fb773 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmeexportjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmeexportjob.cpp @@ -72,7 +72,9 @@ GpgME::Error Kleo::QGpgMEExportJob::start( const TQStringList & pats ) { } void Kleo::QGpgMEExportJob::doOperationDoneEvent( const GpgME::Error & error ) { - emit result( error, mOutDataDataProvider->data() ); + const TQByteArray data = mOutDataDataProvider->data(); + getAuditLog(); + emit result( error, data ); } #include "qgpgmeexportjob.moc" diff --git a/certmanager/lib/backends/qgpgme/qgpgmeimportjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmeimportjob.cpp index 7c698e7e7..80792161f 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmeimportjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmeimportjob.cpp @@ -75,11 +75,15 @@ GpgME::Error Kleo::QGpgMEImportJob::start( const TQByteArray & keyData ) { GpgME::ImportResult Kleo::QGpgMEImportJob::exec( const TQByteArray & keyData ) { setup( keyData ); - return mCtx->importKeys( *mInData ); + const GpgME::ImportResult res = mCtx->importKeys( *mInData ); + getAuditLog(); + return res; } void Kleo::QGpgMEImportJob::doOperationDoneEvent( const GpgME::Error & ) { - emit result( mCtx->importResult() ); + const GpgME::ImportResult res = mCtx->importResult(); + getAuditLog(); + emit result( res ); } diff --git a/certmanager/lib/backends/qgpgme/qgpgmejob.cpp b/certmanager/lib/backends/qgpgme/qgpgmejob.cpp index 72f9f77ff..6d7ae5b45 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmejob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmejob.cpp @@ -236,21 +236,19 @@ void Kleo::QGpgMEJob::createOutData() { static const unsigned int GetAuditLogFlags = GpgME::Context::AuditLogWithHelp|GpgME::Context::HtmlAuditLog; -static TQString audit_log_as_html( GpgME::Context * ctx ) { - if ( !ctx ) - return TQString(); +static TQString audit_log_as_html( GpgME::Context * ctx, GpgME::Error & err ) { + assert( ctx ); QGpgME::QByteArrayDataProvider dp; GpgME::Data data( &dp ); assert( !data.isNull() ); - if ( const GpgME::Error err = ctx->getAuditLog( data, GetAuditLogFlags ) ) + if ( ( err = ctx->getAuditLog( data, GetAuditLogFlags ) ) ) return TQString(); - else - return TQString::fromUtf8( dp.data().data() ); + const TQByteArray ba = dp.data(); + return TQString::fromUtf8( ba.data(), ba.size() ); } void Kleo::QGpgMEJob::doSlotOperationDoneEvent( GpgME::Context * context, const GpgME::Error & e ) { if ( context == mCtx ) { - getAuditLog(); doEmitDoneSignal(); doOperationDoneEvent( e ); mThis->deleteLater(); @@ -258,7 +256,9 @@ void Kleo::QGpgMEJob::doSlotOperationDoneEvent( GpgME::Context * context, const } void Kleo::QGpgMEJob::getAuditLog() { - mAuditLogAsHtml = audit_log_as_html( mCtx ); + if ( !mCtx ) + return; + mAuditLogAsHtml = audit_log_as_html( mCtx, mAuditLogError ); } void Kleo::QGpgMEJob::doSlotCancel() { diff --git a/certmanager/lib/backends/qgpgme/qgpgmejob.h b/certmanager/lib/backends/qgpgme/qgpgmejob.h index 984bed445..0681c165d 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmejob.h +++ b/certmanager/lib/backends/qgpgme/qgpgmejob.h @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -45,8 +46,6 @@ #include namespace GpgME { - class Error; - class Context; class Data; } @@ -120,6 +119,7 @@ namespace Kleo { virtual void doEmitDoneSignal() = 0; void doSlotCancel(); TQString auditLogAsHtml() const { return mAuditLogAsHtml; } + GpgME::Error auditLogError() const { return mAuditLogError; } private: /*! \reimp from GpgME::ProgressProvider */ @@ -146,6 +146,7 @@ namespace Kleo { unsigned int mNumPatterns; unsigned int mChunkSize; unsigned int mPatternStartIndex, mPatternEndIndex; + GpgME::Error mAuditLogError; TQString mAuditLogAsHtml; }; @@ -154,7 +155,7 @@ namespace Kleo { #define make_slot_cancel private: void slotCancel() { QGpgMEJob::doSlotCancel(); } #define make_progress_emitter private: void doEmitProgressSignal( const TQString & what, int cur, int tot ) { emit progress( what, cur, tot ); } #define make_done_emitter private: void doEmitDoneSignal() { emit done(); } -#define make_auditLogAsHtml private: TQString auditLogAsHtml() const { return QGpgMEJob::auditLogAsHtml(); } +#define make_auditLogAsHtml private: TQString auditLogAsHtml() const { return QGpgMEJob::auditLogAsHtml(); } GpgME::Error auditLogError() const { return QGpgMEJob::auditLogError(); } #define QGPGME_JOB make_slot_cancel make_progress_emitter make_done_emitter make_auditLogAsHtml #endif // __KLEO_QGPGMEJOB_H__ diff --git a/certmanager/lib/backends/qgpgme/qgpgmekeygenerationjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmekeygenerationjob.cpp index b226d6498..16e131348 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmekeygenerationjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmekeygenerationjob.cpp @@ -80,7 +80,10 @@ GpgME::Error Kleo::QGpgMEKeyGenerationJob::start( const TQString & parameters ) } void Kleo::QGpgMEKeyGenerationJob::doOperationDoneEvent( const GpgME::Error & ) { - emit result( mCtx->keyGenerationResult(), mPubKeyDataProvider ? mPubKeyDataProvider->data() : TQByteArray() ); + const GpgME::KeyGenerationResult res = mCtx->keyGenerationResult(); + const TQByteArray data = mPubKeyDataProvider ? mPubKeyDataProvider->data() : TQByteArray() ; + getAuditLog(); + emit result( res, data ); } #include "qgpgmekeygenerationjob.moc" diff --git a/certmanager/lib/backends/qgpgme/qgpgmekeylistjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmekeylistjob.cpp index 9e663e92d..b07135f01 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmekeylistjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmekeylistjob.cpp @@ -48,6 +48,7 @@ #include #include +#include #include @@ -97,6 +98,10 @@ GpgME::Error Kleo::QGpgMEKeyListJob::start( const TQStringList & pats, bool secr kdDebug(5150) << "QGpgMEKeyListJob::start(): retrying keylisting with chunksize " << chunkSize() << endl; continue; } + } else if ( err.code() == GPG_ERR_EOF ) { + kdDebug(5150) << "QGpgMEKeyListJob::start(): early end of keylisting, trying to fake an empty result" << endl; + TQTimer::singleShot( 10, this, TQT_SLOT(slotFakeOperationDoneEvent()) ); + return GpgME::Error(); } deleteLater(); mResult = GpgME::KeyListResult( 0, err ); @@ -158,6 +163,17 @@ void Kleo::QGpgMEKeyListJob::slotNextKeyEvent( GpgME::Context * context, const G emit nextKey( key ); } +void Kleo::QGpgMEKeyListJob::slotFakeOperationDoneEvent() { + const GpgME::KeyListResult res = mCtx->keyListResult(); + if ( !res.error().code() == GPG_ERR_EOF ) + kdDebug(5150) << "QGpgMEKeyListJob::slotFakeOperationDoneEvent: expected EOF, got " + << res.error().asString() << endl; + mResult = GpgME::KeyListResult(); + emit done(); + emit result( mResult ); + deleteLater(); +} + void Kleo::QGpgMEKeyListJob::slotOperationDoneEvent( GpgME::Context * context, const GpgME::Error & ) { if ( context != mCtx ) return; diff --git a/certmanager/lib/backends/qgpgme/qgpgmekeylistjob.h b/certmanager/lib/backends/qgpgme/qgpgmekeylistjob.h index 0bc84c08c..388641076 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmekeylistjob.h +++ b/certmanager/lib/backends/qgpgme/qgpgmekeylistjob.h @@ -65,6 +65,7 @@ namespace Kleo { private slots: void slotNextKeyEvent( GpgME::Context * context, const GpgME::Key & key ); void slotOperationDoneEvent( GpgME::Context * context, const GpgME::Error & e ); + void slotFakeOperationDoneEvent(); private: void doOperationDoneEvent( const GpgME::Error &) {} // unused, we implement slotOperationDoneEvent ourselves. diff --git a/certmanager/lib/backends/qgpgme/qgpgmesignencryptjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmesignencryptjob.cpp index bc05eb86c..9a469001c 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmesignencryptjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmesignencryptjob.cpp @@ -109,7 +109,9 @@ Kleo::QGpgMESignEncryptJob::exec( const std::vector & signers, void Kleo::QGpgMESignEncryptJob::doOperationDoneEvent( const GpgME::Error & ) { mResult.first = mCtx->signingResult(); mResult.second = mCtx->encryptionResult(); - emit result( mResult.first, mResult.second, mOutDataDataProvider->data() ); + const TQByteArray cipherText = mOutDataDataProvider->data(); + getAuditLog(); + emit result( mResult.first, mResult.second, cipherText ); } void Kleo::QGpgMESignEncryptJob::showErrorDialog( TQWidget * parent, const TQString & caption ) const { diff --git a/certmanager/lib/backends/qgpgme/qgpgmesignjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmesignjob.cpp index 0042d6a38..01ae8a91f 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmesignjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmesignjob.cpp @@ -102,7 +102,10 @@ GpgME::SigningResult Kleo::QGpgMESignJob::exec( const std::vector & } void Kleo::QGpgMESignJob::doOperationDoneEvent( const GpgME::Error & ) { - emit result( mResult = mCtx->signingResult(), mOutDataDataProvider->data() ); + mResult = mCtx->signingResult(); + const TQByteArray signature = mOutDataDataProvider->data(); + getAuditLog(); + emit result( mResult, signature ); } void Kleo::QGpgMESignJob::showErrorDialog( TQWidget * parent, const TQString & caption ) const { diff --git a/certmanager/lib/backends/qgpgme/qgpgmeverifydetachedjob.cpp b/certmanager/lib/backends/qgpgme/qgpgmeverifydetachedjob.cpp index b1022f61b..41fa48494 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmeverifydetachedjob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmeverifydetachedjob.cpp @@ -89,7 +89,9 @@ GpgME::VerificationResult Kleo::QGpgMEVerifyDetachedJob::exec( const TQByteArray } void Kleo::QGpgMEVerifyDetachedJob::doOperationDoneEvent( const GpgME::Error & ) { - emit result( mCtx->verificationResult() ); + const GpgME::VerificationResult res = mCtx->verificationResult(); + getAuditLog(); + emit result( res ); } diff --git a/certmanager/lib/backends/qgpgme/qgpgmeverifyopaquejob.cpp b/certmanager/lib/backends/qgpgme/qgpgmeverifyopaquejob.cpp index 92e1917b7..e4340aa39 100644 --- a/certmanager/lib/backends/qgpgme/qgpgmeverifyopaquejob.cpp +++ b/certmanager/lib/backends/qgpgme/qgpgmeverifyopaquejob.cpp @@ -84,7 +84,10 @@ GpgME::VerificationResult Kleo::QGpgMEVerifyOpaqueJob::exec( const TQByteArray & } void Kleo::QGpgMEVerifyOpaqueJob::doOperationDoneEvent( const GpgME::Error & ) { - emit result( mCtx->verificationResult(), mOutDataDataProvider->data() ); + const GpgME::VerificationResult res = mCtx->verificationResult(); + const TQByteArray plainText = mOutDataDataProvider->data(); + getAuditLog(); + emit result( res, plainText ); } diff --git a/certmanager/lib/kleo/job.cpp b/certmanager/lib/kleo/job.cpp index c5371b646..dedbebfc2 100644 --- a/certmanager/lib/kleo/job.cpp +++ b/certmanager/lib/kleo/job.cpp @@ -52,9 +52,13 @@ #include "refreshkeysjob.h" #include "specialjob.h" +#include + #include #include +#include + Kleo::Job::Job( TQObject * parent, const char * name ) : TQObject( parent, name ) { @@ -75,6 +79,16 @@ TQString Kleo::Job::auditLogAsHtml() const { return TQString(); } +GpgME::Error Kleo::Job::auditLogError() const { + kdDebug() << "Kleo::Job::auditLogError() should be reimplemented in Kleo::Job subclasses!" << endl; + return GpgME::Error( gpg_error( GPG_ERR_NOT_IMPLEMENTED ) ); +} + +bool Kleo::Job::isAuditLogSupported() const { + const GpgME::Error err = auditLogError(); + return err.code() != GPG_ERR_NOT_IMPLEMENTED ; +} + #define make_job_subclass(x) \ Kleo::x::x( TQObject * parent, const char * name ) : Job( parent, name ) {} \ Kleo::x::~x() {} diff --git a/certmanager/lib/kleo/job.h b/certmanager/lib/kleo/job.h index 1c091bab3..78ff58ce1 100644 --- a/certmanager/lib/kleo/job.h +++ b/certmanager/lib/kleo/job.h @@ -38,6 +38,10 @@ class TQWidget; +namespace GpgME { + class Error; +} + namespace Kleo { /** @@ -67,6 +71,8 @@ namespace Kleo { virtual void showErrorDialog( TQWidget * parent=0, const TQString & caption=TQString::null ) const; virtual TQString auditLogAsHtml() const; + virtual GpgME::Error auditLogError() const; + bool isAuditLogSupported() const; public slots: virtual void slotCancel() = 0; diff --git a/certmanager/lib/libkleopatrarc.desktop b/certmanager/lib/libkleopatrarc.desktop index 3af8feaf0..07af3adcd 100644 --- a/certmanager/lib/libkleopatrarc.desktop +++ b/certmanager/lib/libkleopatrarc.desktop @@ -22,7 +22,6 @@ Name[hu]=Nem ellenőrzött kulcs Name[is]=Ekki staðfestur lykill Name[it]=Chiave non convalidata Name[ja]=認証されていない鍵 -Name[ka]=დაუმოწმებელი გასაღები Name[kk]=Тексерілмеген кілт Name[km]=កូនសោ​គ្មាន​សុពលភាព Name[ko]=검증되지 않은 키 @@ -77,7 +76,6 @@ Name[hu]=Lejárt kulcs Name[is]=Útrunninn lykill Name[it]=Chiave scaduta Name[ja]=期限切れの鍵 -Name[ka]=ვადაგასული გასაღები Name[kk]=Ескірген кілт Name[km]=កូនសោ​បាន​ផុតកំណត់ Name[ko]=만료된 키 @@ -130,7 +128,6 @@ Name[hu]=Visszavont kulcs Name[is]=Afturkallaður lykill Name[it]=Chiave revocata Name[ja]=破棄された鍵 -Name[ka]=ანულირებული გასაღები Name[kk]=Күші жойылған кілт Name[km]=កូនសោ​ត្រូវ​បាន​ដកហូត Name[ko]=거부된 키 @@ -183,7 +180,6 @@ Name[hu]=Megbízható gyökértanúsítvány Name[is]=Treyst rótarskilríki Name[it]=Certificato radice affidabile Name[ja]=信頼されたルート証明書 -Name[ka]= რუტის სანდო სერთიფიკატი Name[kk]=Сенім артылған түбір куәлігі Name[km]=វិញ្ញាបនបត្រ Root ដែល​អាច​ជឿទុកចិត្ត Name[lt]=Patikimas root sertifikatas @@ -236,7 +232,6 @@ Name[hu]=Nem megbízható gyökértanúsítvány Name[is]=Ekki traust rótarskilríki Name[it]=Certificato radice non affidabile Name[ja]=信頼されてないルート証明書 -Name[ka]=რუტის არასანდო სერტიფიკატი Name[kk]=Сенім артылмаған түбір куәлігі Name[km]=វិញ្ញាបនបត្រ Root ដែល​មិន​អាច​ជឿទុកចិត្ត Name[lt]=Nepatikimas root sertifikatas @@ -290,7 +285,6 @@ Name[hu]=Egyéb kulcsok Name[is]=Aðrir lyklar Name[it]=Altre chiavi Name[ja]=他の鍵 -Name[ka]=სხვა გასაღებები Name[kk]=Басқа кілттер Name[km]=កូនសោ​ផ្សេង​ទៀត Name[ko]=기타 키 @@ -316,8 +310,7 @@ Name[sv]=Andra nycklar Name[ta]=மற்ற விசைகள் Name[tr]=Diğer Anahtarlar Name[uk]=Інші ключі -Name[uz]=Boshqa kalitlar -Name[uz@cyrillic]=Бошқа калитлар +Name[uz]=Бошқа калитлар Name[zh_CN]=其它密钥 Name[zh_TW]=其他金鑰 diff --git a/certmanager/lib/tests/test_verify.cpp b/certmanager/lib/tests/test_verify.cpp index 54a88b4c2..cb5db396a 100644 --- a/certmanager/lib/tests/test_verify.cpp +++ b/certmanager/lib/tests/test_verify.cpp @@ -29,6 +29,7 @@ */ #include +#include #include #include diff --git a/certmanager/lib/ui/cryptoconfigdialog.cpp b/certmanager/lib/ui/cryptoconfigdialog.cpp index 472429942..0d383083b 100644 --- a/certmanager/lib/ui/cryptoconfigdialog.cpp +++ b/certmanager/lib/ui/cryptoconfigdialog.cpp @@ -46,6 +46,12 @@ Kleo::CryptoConfigDialog::CryptoConfigDialog( Kleo::CryptoConfig* config, TQWidg setMainWidget( mMainWidget ); connect( mMainWidget, TQT_SIGNAL( changed() ), TQT_SLOT( slotChanged() ) ); enableButton( Apply, false ); + if ( mMainWidget->hasError() ) { + showButton( Default, false ); + showButton( User1, false ); + showButton( Apply, false ); + showButton( Ok, false ); + } // Automatically assign accelerators KAcceleratorManager::manage( this ); diff --git a/certmanager/lib/ui/cryptoconfigmodule.cpp b/certmanager/lib/ui/cryptoconfigmodule.cpp index 33e7129c4..5b14d7c41 100644 --- a/certmanager/lib/ui/cryptoconfigmodule.cpp +++ b/certmanager/lib/ui/cryptoconfigmodule.cpp @@ -62,8 +62,20 @@ static inline TQPixmap loadIcon( TQString s ) { ->loadIcon( s.replace( TQRegExp( "[^a-zA-Z0-9_]" ), "_" ), KIcon::NoGroup, KIcon::SizeMedium ); } +static unsigned int num_components_with_options( const Kleo::CryptoConfig * config ) { + if ( !config ) + return 0; + const TQStringList components = config->componentList(); + unsigned int result = 0; + for ( TQStringList::const_iterator it = components.begin() ; it != components.end() ; ++it ) + if ( const Kleo::CryptoConfigComponent * const comp = config->component( *it ) ) + if ( !comp->groupList().empty() ) + ++result; + return result; +} + static const KJanusWidget::Face determineJanusFace( const Kleo::CryptoConfig * config ) { - return config && config->componentList().size() < 2 + return num_components_with_options( config ) < 2 ? KJanusWidget::Plain : KJanusWidget::IconList ; } @@ -115,6 +127,22 @@ Kleo::CryptoConfigModule::CryptoConfigModule( Kleo::CryptoConfig* config, TQWidg + scrollView->style().pixelMetric(TQStyle::PM_ScrollBarExtent), QMIN( compGUI->sizeHint().height(), dialogHeight ) ); } + if ( mComponentGUIs.empty() ) { + Q_ASSERT( face() == Plain ); + const TQString msg = i18n("The gpgconf tool used to provide the information " + "for this dialog does not seem to be installed " + "properly. It did not return any components. " + "Try running \"%1\" on the command line for more " + "information.") + .arg( components.empty() ? "gpgconf --list-components" : "gpgconf --list-options gpg" ); + TQLabel * label = new TQLabel( msg, vbox ); + label->setAlignment( TQt::WordBreak ); + label->setMinimumHeight( fontMetrics().lineSpacing() * 5 ); + } +} + +bool Kleo::CryptoConfigModule::hasError() const { + return mComponentGUIs.empty(); } void Kleo::CryptoConfigModule::save() diff --git a/certmanager/lib/ui/cryptoconfigmodule.h b/certmanager/lib/ui/cryptoconfigmodule.h index 70c4a2691..167c3ac84 100644 --- a/certmanager/lib/ui/cryptoconfigmodule.h +++ b/certmanager/lib/ui/cryptoconfigmodule.h @@ -50,6 +50,8 @@ namespace Kleo { public: CryptoConfigModule( Kleo::CryptoConfig* config, TQWidget * parent=0, const char * name=0 ); + bool hasError() const; + void save(); void reset(); // i.e. reload current settings, discarding user input void defaults(); diff --git a/certmanager/lib/ui/keyselectiondialog.cpp b/certmanager/lib/ui/keyselectiondialog.cpp index fcb257514..fc590d49b 100644 --- a/certmanager/lib/ui/keyselectiondialog.cpp +++ b/certmanager/lib/ui/keyselectiondialog.cpp @@ -61,6 +61,8 @@ #include #include #include +#include +#include // Qt #include @@ -85,7 +87,12 @@ static bool checkKeyUsage( const GpgME::Key & key, unsigned int keyUsage ) { if ( keyUsage & Kleo::KeySelectionDialog::ValidKeys ) { if ( key.isInvalid() ) - kdDebug() << "key is invalid - ignoring" << endl; + if ( key.keyListMode() & GpgME::Context::Validate ) { + kdDebug() << "key is invalid" << endl; + return false; + } else { + kdDebug() << "key is invalid - ignoring" << endl; + } if ( key.isExpired() ) { kdDebug() << "key is expired" << endl; return false; @@ -307,6 +314,28 @@ Kleo::KeySelectionDialog::KeySelectionDialog( const TQString & title, init( rememberChoice, extendedSelection, text, TQString::null ); } +Kleo::KeySelectionDialog::KeySelectionDialog( const TQString & title, + const TQString & text, + const TQString & initialQuery, + const std::vector & selectedKeys, + unsigned int keyUsage, + bool extendedSelection, + bool rememberChoice, + TQWidget * parent, const char * name, + bool modal ) + : KDialogBase( parent, name, modal, title, Default|Ok|Cancel|Help, Ok ), + mOpenPGPBackend( 0 ), + mSMIMEBackend( 0 ), + mRememberCB( 0 ), + mSelectedKeys( selectedKeys ), + mKeyUsage( keyUsage ), + mSearchText( initialQuery ), + mInitialQuery( initialQuery ), + mCurrentContextMenuItem( 0 ) +{ + init( rememberChoice, extendedSelection, text, initialQuery ); +} + Kleo::KeySelectionDialog::KeySelectionDialog( const TQString & title, const TQString & text, const TQString & initialQuery, @@ -321,6 +350,7 @@ Kleo::KeySelectionDialog::KeySelectionDialog( const TQString & title, mRememberCB( 0 ), mKeyUsage( keyUsage ), mSearchText( initialQuery ), + mInitialQuery( initialQuery ), mCurrentContextMenuItem( 0 ) { init( rememberChoice, extendedSelection, text, initialQuery ); @@ -340,11 +370,26 @@ void Kleo::KeySelectionDialog::init( bool rememberChoice, bool extendedSelection mTopLayout = new TQVBoxLayout( page, 0, spacingHint() ); if ( !text.isEmpty() ) { - TQLabel* textLabel = new TQLabel( text, page ); - textLabel->setAlignment( textLabel->alignment() | Qt::WordBreak ); - mTopLayout->addWidget( textLabel ); + if ( text.startsWith( "" ) ) { + KActiveLabel *textLabel = new KActiveLabel( text, page ); + disconnect( textLabel, TQT_SIGNAL(linkClicked(const TQString&)), textLabel, TQT_SLOT(openLink(const TQString&)) ); + connect( textLabel, TQT_SIGNAL(linkClicked(const TQString&)), TQT_SLOT(slotStartCertificateManager(const TQString&)) ); + textLabel->setAlignment( textLabel->alignment() | TQt::WordBreak ); + mTopLayout->addWidget( textLabel ); + } else { + KActiveLabel *textLabel = new KActiveLabel( text, page ); + textLabel->setAlignment( textLabel->alignment() | TQt::WordBreak ); + mTopLayout->addWidget( textLabel ); + } } + TQPushButton * const searchExternalPB + = new TQPushButton( i18n("Search for &External Certificates"), page ); + mTopLayout->addWidget( searchExternalPB, 0, TQt::AlignLeft ); + connect( searchExternalPB, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotStartSearchForExternalCertificates()) ); + if ( initialQuery.isEmpty() ) + searchExternalPB->hide(); + TQHBoxLayout * hlay = new TQHBoxLayout( mTopLayout ); // inherits spacing TQLineEdit * le = new TQLineEdit( page ); le->setText( initialQuery ); @@ -500,10 +545,12 @@ void Kleo::KeySelectionDialog::slotHelp() emit helpClicked(); } -void Kleo::KeySelectionDialog::slotStartCertificateManager() +void Kleo::KeySelectionDialog::slotStartCertificateManager( const TQString &query ) { KProcess certManagerProc; certManagerProc << "kleopatra"; + if ( !query.isEmpty() ) + certManagerProc << "--external" << "--query" << KURL::decode_string( query ); if( !certManagerProc.start( KProcess::DontCare ) ) KMessageBox::error( this, i18n( "Could not start certificate manager; " diff --git a/certmanager/lib/ui/keyselectiondialog.h b/certmanager/lib/ui/keyselectiondialog.h index fd8f67394..ab8dc756d 100644 --- a/certmanager/lib/ui/keyselectiondialog.h +++ b/certmanager/lib/ui/keyselectiondialog.h @@ -91,6 +91,15 @@ namespace Kleo { bool rememberChoice=false, TQWidget * parent=0, const char * name=0, bool modal=true ); + KeySelectionDialog( const TQString & title, + const TQString & text, + const TQString & initialPattern, + const std::vector & selectedKeys, + unsigned int keyUsage=AllKeys, + bool extendedSelection=false, + bool rememberChoice=false, + TQWidget * parent=0, const char * name=0, + bool modal=true ); KeySelectionDialog( const TQString & title, const TQString & text, const TQString & initialPattern, @@ -129,7 +138,10 @@ namespace Kleo { private slots: void slotRereadKeys(); - void slotStartCertificateManager(); + void slotStartCertificateManager( const TQString &query = TQString() ); + void slotStartSearchForExternalCertificates() { + slotStartCertificateManager( mInitialQuery ); + } void slotKeyListResult( const GpgME::KeyListResult & ); void slotSelectionChanged(); void slotCheckSelection() { slotCheckSelection( 0 ); } @@ -170,6 +182,7 @@ namespace Kleo { TQTimer * mStartSearchTimer; // cross-eventloop temporaries: TQString mSearchText; + const TQString mInitialQuery; Kleo::KeyListViewItem * mCurrentContextMenuItem; int mTruncated, mListJobCount, mSavedOffsetY; }; diff --git a/certmanager/lib/ui/messagebox.cpp b/certmanager/lib/ui/messagebox.cpp index ddce8f04d..e05a21b9a 100644 --- a/certmanager/lib/ui/messagebox.cpp +++ b/certmanager/lib/ui/messagebox.cpp @@ -46,10 +46,15 @@ #include #include #include +#include #include #include #include +#include +#include + +#include using namespace Kleo; using namespace GpgME; @@ -74,6 +79,7 @@ public: explicit AuditLogViewer( const TQString & log, TQWidget * parent=0, const char * name=0, WFlags f=0 ) : KDialogBase( parent, name, false, i18n("View GnuPG Audit Log"), Close|User1|User2, Close, false, KGuiItem_save(), KGuiItem_copy() ), + m_log( /* sic */ ), m_textEdit( new TQTextEdit( this, "m_textEdit" ) ) { setWFlags( f ); @@ -85,7 +91,18 @@ public: ~AuditLogViewer() {} void setAuditLog( const TQString & log ) { - m_textEdit->setText( log ); + if ( log == m_log ) + return; + m_log = log; + m_textEdit->setText( "" + log + "" ); + const TQRect rect = m_textEdit->paragraphRect( 0 ); + kdDebug() << "setAuditLog: rect = " << rect << endl; + if ( !rect.isValid() ) + return; + TQSize maxSize = qApp->desktop()->screenGeometry( this ).size() * 2 / 3 ; + if ( !maxSize.isValid() ) + maxSize = TQSize( 640, 480 ); + m_textEdit->setMinimumSize( rect.size().boundedTo( maxSize ) ); } private: @@ -98,7 +115,12 @@ private: KSaveFile file( fileName ); if ( TQTextStream * const s = file.textStream() ) { - *s << m_textEdit->text() << endl; + *s << ""; + if ( !caption().isEmpty() ) + *s << "\n" << /*TQt*/TQStyleSheet::escape( caption() ) << "\n"; + *s << "\n" + << m_log + << "\n" << endl; file.close(); } @@ -114,6 +136,7 @@ private: } private: + TQString m_log; TQTextEdit * m_textEdit; }; @@ -125,13 +148,23 @@ void MessageBox::auditLog( TQWidget * parent, const Job * job, const TQString & if ( !job ) return; - if ( !GpgME::hasFeature( AuditLogFeature ) ) { + if ( !GpgME::hasFeature( AuditLogFeature ) || !job->isAuditLogSupported() ) { KMessageBox::information( parent, i18n("Your system does not have support for GnuPG Audit Logs"), i18n("System Error") ); return; } + const GpgME::Error err = job->auditLogError(); + + if ( err.code() != GPG_ERR_NO_DATA ) { + KMessageBox::information( parent, i18n("An error occurred while trying to retrieve the GnuPG Audit Log:\n%1") + .arg( TQString::fromLocal8Bit( err.asString() ) ), + i18n("GnuPG Audit Log Error") ); + return; + } + const TQString log = job->auditLogAsHtml(); + if ( log.isEmpty() ) { KMessageBox::information( parent, i18n("No GnuPG Audit Log available for this operation."), i18n("No GnuPG Audit Log") ); @@ -143,7 +176,7 @@ void MessageBox::auditLog( TQWidget * parent, const Job * job, const TQString & // static void MessageBox::auditLog( TQWidget * parent, const TQString & log, const TQString & caption ) { - AuditLogViewer * const alv = new AuditLogViewer( "" + log + "", parent, "alv", Qt::WDestructiveClose ); + AuditLogViewer * const alv = new AuditLogViewer( log, parent, "alv", Qt::WDestructiveClose ); alv->setCaption( caption ); alv->show(); } @@ -246,9 +279,35 @@ void MessageBox::error( TQWidget * parent, const SigningResult & sresult, const make( parent, TQMessageBox::Critical, to_error_string( sresult, eresult ), job, caption, options ); } +// static +bool MessageBox::showAuditLogButton( const Kleo::Job * job ) { + if ( !job ) { + kdDebug() << "not showing audit log button (no job instance)" << endl; + return false; + } + if ( !GpgME::hasFeature( GpgME::AuditLogFeature ) ) { + kdDebug() << "not showing audit log button (gpgme too old)" << endl; + return false; + } + if ( !job->isAuditLogSupported() ) { + kdDebug() << "not showing audit log button (not supported)" << endl; + return false; + } + if ( job->auditLogError().code() == GPG_ERR_NO_DATA ) { + kdDebug() << "not showing audit log button (GPG_ERR_NO_DATA)" << endl; + return false; + } + if ( !job->auditLogError() && job->auditLogAsHtml().isEmpty() ) { + kdDebug() << "not showing audit log button (success, but result empty)" << endl; + return false; + } + return true; +} + + // static void MessageBox::make( TQWidget * parent, TQMessageBox::Icon icon, const TQString & text, const Job * job, const TQString & caption, int options ) { - KDialogBase * dialog = GpgME::hasFeature( GpgME::AuditLogFeature ) + KDialogBase * dialog = showAuditLogButton( job ) ? new KDialogBase( caption, KDialogBase::Yes | KDialogBase::No, KDialogBase::Yes, KDialogBase::Yes, parent, "error", true, true, diff --git a/certmanager/lib/ui/messagebox.h b/certmanager/lib/ui/messagebox.h index 5ed2edaf4..ee72e43c3 100644 --- a/certmanager/lib/ui/messagebox.h +++ b/certmanager/lib/ui/messagebox.h @@ -40,6 +40,7 @@ namespace GpgME { class EncryptionResult; class DecryptionResult; class VerificationResult; + class Error; } namespace Kleo { @@ -73,6 +74,8 @@ namespace Kleo { static void auditLog( TQWidget * parent, const TQString & log, const TQString & caption ); static void auditLog( TQWidget * parent, const TQString & log ); + static bool showAuditLogButton( const Kleo::Job * job ); + private: static void make( TQWidget * parent, TQMessageBox::Icon icon, const TQString & text, const Kleo::Job * job, const TQString & caption, int options ); }; -- cgit v1.2.1