39 #include <tdelocale.h>
40 #include <tdeprocess.h>
41 #include <tdemessagebox.h>
42 #include <kpushbutton.h>
43 #include <kstdguiitem.h>
44 #include <tdeglobalsettings.h>
48 #include <tqtextedit.h>
49 #include <tqfontmetrics.h>
52 CRLView::CRLView( TQWidget* parent,
const char* name,
bool modal )
53 : TQDialog( parent, name, modal ), _process(0)
55 TQVBoxLayout* topLayout =
new TQVBoxLayout(
this, 10, 4 );
57 topLayout->addWidget(
new TQLabel( i18n(
"CRL cache dump:"),
this ) );
59 _textView =
new TQTextEdit(
this );
60 _textView->setFont( TDEGlobalSettings::fixedFont() );
61 _textView->setTextFormat( TQTextEdit::LogText );
62 topLayout->addWidget( _textView );
64 TQHBoxLayout* hbLayout =
new TQHBoxLayout( topLayout );
66 _updateButton =
new KPushButton( i18n(
"&Update"),
this );
67 _closeButton =
new KPushButton( KStdGuiItem::close(),
this );
69 hbLayout->addWidget( _updateButton );
70 hbLayout->addStretch();
71 hbLayout->addWidget( _closeButton );
74 connect( _updateButton, TQ_SIGNAL( clicked() ),
75 this, TQ_SLOT( slotUpdateView() ) );
76 connect( _closeButton, TQ_SIGNAL( clicked() ),
77 this, TQ_SLOT( close() ) );
79 resize( _textView->fontMetrics().width(
'M' ) * 80,
80 _textView->fontMetrics().lineSpacing() * 25 );
82 _timer =
new TQTimer(
this );
83 connect( _timer, TQ_SIGNAL(timeout()), TQ_SLOT(slotAppendBuffer()) );
88 delete _process; _process = 0;
91 void CRLView::closeEvent( TQCloseEvent * e ) {
92 TQDialog::closeEvent( e );
93 delete _process; _process = 0;
96 void CRLView::slotUpdateView()
98 _updateButton->setEnabled(
false );
100 _buffer = TQString();
101 if( _process == 0 ) {
102 _process =
new TDEProcess();
103 *_process <<
"gpgsm" <<
"--call-dirmngr" <<
"listcrls";
104 connect( _process, TQ_SIGNAL( receivedStdout( TDEProcess*,
char*,
int) ),
105 this, TQ_SLOT( slotReadStdout( TDEProcess*,
char*,
int ) ) );
106 connect( _process, TQ_SIGNAL( processExited( TDEProcess* ) ),
107 this, TQ_SLOT( slotProcessExited() ) );
109 if( _process->isRunning() ) _process->kill();
110 if( !_process->start( TDEProcess::NotifyOnExit, TDEProcess::Stdout ) ) {
111 KMessageBox::error(
this, i18n(
"Unable to start gpgsm process. Please check your installation." ), i18n(
"Certificate Manager Error" ) );
114 _timer->start( 1000 );
117 void CRLView::slotReadStdout( TDEProcess*,
char* buf,
int len)
119 _buffer.append( TQString::fromUtf8( buf, len ) );
122 void CRLView::slotAppendBuffer() {
123 _textView->append( _buffer );
124 _buffer = TQString();
127 void CRLView::slotProcessExited()
131 _updateButton->setEnabled(
true );
133 if( !_process->normalExit() ) {
134 KMessageBox::error(
this, i18n(
"The GpgSM process ended prematurely because of an unexpected error." ), i18n(
"Certificate Manager Error" ) );
138 #include "crlview.moc"