[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdepim/enterprise/kdepim/certmanager/lib/ui
From: Marc Mutz <mutz () kde ! org>
Date: 2008-11-19 16:57:43
Message-ID: 1227113863.216159.14781.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 886603 by mutz:
Show the audit log button in fewer cases. Pt.2 of kolab/issue 2627: Kleo::MessageBox \
(used elsewhere).
M +41 -2 messagebox.cpp
M +3 -0 messagebox.h
--- branches/kdepim/enterprise/kdepim/certmanager/lib/ui/messagebox.cpp \
#886602:886603 @@ -46,11 +46,14 @@
#include <klocale.h>
#include <ksavefile.h>
#include <kguiitem.h>
+#include <kdebug.h>
#include <qtextedit.h>
#include <qtextstream.h>
#include <qvbox.h>
+#include <gpg-error.h>
+
using namespace Kleo;
using namespace GpgME;
@@ -125,13 +128,23 @@
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( \
QString::fromLocal8Bit( err.asString() ) ), + \
i18n("GnuPG Audit Log Error") ); + return;
+ }
+
const QString log = job->auditLogAsHtml();
+
if ( log.isEmpty() ) {
KMessageBox::information( parent, i18n("No GnuPG Audit Log available for \
this operation."), i18n("No GnuPG Audit Log") );
@@ -247,8 +260,34 @@
}
// 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( QWidget * parent, QMessageBox::Icon icon, const QString & \
text, const Job * job, const QString & 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,
--- branches/kdepim/enterprise/kdepim/certmanager/lib/ui/messagebox.h #886602:886603
@@ -40,6 +40,7 @@
class EncryptionResult;
class DecryptionResult;
class VerificationResult;
+ class Error;
}
namespace Kleo {
@@ -73,6 +74,8 @@
static void auditLog( QWidget * parent, const QString & log, const QString & \
caption ); static void auditLog( QWidget * parent, const QString & log );
+ static bool showAuditLogButton( const Kleo::Job * job );
+
private:
static void make( QWidget * parent, QMessageBox::Icon icon, const QString & \
text, const Kleo::Job * job, const QString & caption, int options ); };
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic