00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
#ifdef HAVE_CONFIG_H
00034
#include <config.h>
00035
#endif
00036
00037
#include "crlview.h"
00038
00039
#include <klocale.h>
00040
#include <kprocess.h>
00041
#include <kmessagebox.h>
00042
#include <kpushbutton.h>
00043
#include <kstdguiitem.h>
00044
00045
#include <qlayout.h>
00046
#include <qlabel.h>
00047
#include <qtextview.h>
00048
#include <qfontmetrics.h>
00049
00050 CRLView::CRLView(
QWidget* parent,
const char* name,
bool modal )
00051 :
QDialog( parent, name, modal ), _process(0)
00052 {
00053
QVBoxLayout* topLayout =
new QVBoxLayout(
this, 10, 4 );
00054
00055 topLayout->addWidget(
new QLabel( i18n(
"CRL cache dump:"),
this ) );
00056
00057 _textView =
new QTextView(
this );
00058 _textView->setWordWrap( QTextEdit::NoWrap );
00059 topLayout->addWidget( _textView );
00060
00061
QHBoxLayout* hbLayout =
new QHBoxLayout( topLayout );
00062
00063 _updateButton =
new KPushButton( i18n(
"&Update"),
this );
00064 _closeButton =
new KPushButton( KStdGuiItem::close(),
this );
00065
00066 hbLayout->addWidget( _updateButton );
00067 hbLayout->addStretch();
00068 hbLayout->addWidget( _closeButton );
00069
00070
00071 connect( _updateButton, SIGNAL( clicked() ),
00072
this, SLOT( slotUpdateView() ) );
00073 connect( _closeButton, SIGNAL( clicked() ),
00074
this, SLOT( close() ) );
00075
00076 resize( _textView->fontMetrics().width(
'M' ) * 80,
00077 _textView->fontMetrics().lineSpacing() * 25 );
00078 }
00079
00080 CRLView::~CRLView()
00081 {
00082
delete _process;
00083 }
00084
00085
void CRLView::slotUpdateView()
00086 {
00087 _updateButton->setEnabled(
false );
00088 _textView->clear();
00089
if( _process == 0 ) {
00090 _process =
new KProcess();
00091 *_process <<
"gpgsm" <<
"--call-dirmngr" <<
"listcrls";
00092 connect( _process, SIGNAL( receivedStdout( KProcess*,
char*,
int) ),
00093
this, SLOT( slotReadStdout( KProcess*,
char*,
int ) ) );
00094 connect( _process, SIGNAL( processExited( KProcess* ) ),
00095
this, SLOT( slotProcessExited() ) );
00096 }
00097
if( _process->isRunning() ) _process->kill();
00098
if( !_process->start( KProcess::NotifyOnExit, KProcess::Stdout ) ) {
00099 KMessageBox::error(
this, i18n(
"Unable to start gpgsm process. Please check your installation." ), i18n(
"Certificate Manager Error" ) );
00100 slotProcessExited();
00101 }
00102 }
00103
00104
void CRLView::slotReadStdout( KProcess*,
char* buf,
int len)
00105 {
00106 _textView->append( QString::fromUtf8( buf, len ) );
00107 }
00108
00109
void CRLView::slotProcessExited()
00110 {
00111 _updateButton->setEnabled(
true );
00112
00113
if( !_process->normalExit() ) {
00114 KMessageBox::error(
this, i18n(
"The GpgSM process ended prematurely because of an unexpected error." ), i18n(
"Certificate Manager Error" ) );
00115 }
00116 }
00117
00118
#include "crlview.moc"