33 #include <config-kleopatra.h>
43 #include <KMessageBox>
45 #include <KPushButton>
46 #include <KStandardGuiItem>
47 #include <KGlobalSettings>
58 class DumpCrlCacheDialog :
public QDialog {
61 explicit DumpCrlCacheDialog(
QWidget * parent=0 )
68 void updateRequested();
71 void append(
const QString & line ) {
72 ui.logTextWidget.message( line );
75 ui.logTextWidget.clear();
81 KPushButton updateButton, closeButton;
85 explicit Ui( DumpCrlCacheDialog *
q )
87 updateButton( i18nc(
"@action:button Update the log text widget",
"&Update"), q ),
88 closeButton( KStandardGuiItem::close(), q ),
98 logTextWidget.setFont( KGlobalSettings::fixedFont() );
99 logTextWidget.setMinimumVisibleLines( 25 );
100 logTextWidget.setMinimumVisibleColumns( 80 );
102 vlay.addWidget( &logTextWidget, 1 );
103 vlay.addLayout( &hlay );
105 hlay.addWidget( &updateButton );
106 hlay.addStretch( 1 );
107 hlay.addWidget( &closeButton );
109 connect( &updateButton, SIGNAL(clicked()),
110 q, SIGNAL(updateRequested()) );
111 connect( &closeButton, SIGNAL(clicked()),
118 using namespace Kleo;
119 using namespace Kleo::Commands;
122 while ( ba.endsWith(
'\n' ) || ba.endsWith(
'\r' ) )
128 friend class ::Kleo::Commands::DumpCrlCacheCommand;
134 QString errorString()
const {
135 return QString::fromLocal8Bit( errorBuffer );
143 void slotProcessFinished(
int, QProcess::ExitStatus );
145 void slotProcessReadyReadStandardOutput() {
146 while (
process.canReadLine() ) {
149 dialog->append( QString::fromLocal8Bit( line ) );
153 void slotProcessReadyReadStandardError() {
154 errorBuffer +=
process.readAllStandardError();
157 void slotUpdateRequested() {
158 if (
process.state() == QProcess::NotRunning )
162 void slotDialogDestroyed() {
164 if (
process.state() != QProcess::NotRunning )
171 DumpCrlCacheDialog * dialog;
173 QByteArray errorBuffer;
177 DumpCrlCacheCommand::Private * DumpCrlCacheCommand::d_func() {
return static_cast<Private*
>(
d.
get() ); }
178 const DumpCrlCacheCommand::Private * DumpCrlCacheCommand::d_func()
const {
return static_cast<const Private*
>(
d.
get() ); }
190 process.setOutputChannelMode( KProcess::SeparateChannels );
191 process.setReadChannel( KProcess::StandardOutput );
192 process <<
gpgSmPath() << QLatin1String(
"--call-dirmngr") << QLatin1String(
"listcrls");
195 DumpCrlCacheCommand::Private::~Private() {
196 if ( dialog && !dialog->isVisible() )
201 :
Command( new Private( this, c ) )
207 :
Command( v, new Private( this, c ) )
212 void DumpCrlCacheCommand::Private::init() {
213 connect( &
process, SIGNAL(finished(
int,QProcess::ExitStatus)),
214 q, SLOT(slotProcessFinished(
int,QProcess::ExitStatus)) );
215 connect( &
process, SIGNAL(readyReadStandardError()),
216 q, SLOT(slotProcessReadyReadStandardError()) );
217 connect( &
process, SIGNAL(readyReadStandardOutput()),
218 q, SLOT(slotProcessReadyReadStandardOutput()) );
223 void DumpCrlCacheCommand::doStart() {
225 d->dialog =
new DumpCrlCacheDialog;
226 d->dialog->setAttribute( Qt::WA_DeleteOnClose );
227 d->dialog->setWindowTitle( i18n(
"CRL Cache Dump") );
229 connect(
d->dialog, SIGNAL(updateRequested()),
230 this, SLOT(slotUpdateRequested()) );
231 connect(
d->dialog, SIGNAL(destroyed()),
232 this, SLOT(slotDialogDestroyed()) );
237 void DumpCrlCacheCommand::Private::refreshView() {
243 if (
process.waitForStarted() ) {
246 KMessageBox::error( dialog ? static_cast<QWidget*>( dialog ) : parentWidgetOrView(),
247 i18n(
"Unable to start process gpgsm. "
248 "Please check your installation." ),
249 i18n(
"Dump CRL Cache Error" ) );
254 void DumpCrlCacheCommand::doCancel() {
256 if (
d->process.state() != QProcess::NotRunning ) {
257 d->process.terminate();
265 void DumpCrlCacheCommand::Private::slotProcessFinished(
int code, QProcess::ExitStatus
status ) {
267 if ( status == QProcess::CrashExit )
268 KMessageBox::error( dialog,
269 i18n(
"The GpgSM process that tried to dump the CRL cache "
270 "ended prematurely because of an unexpected error. "
271 "Please check the output of gpgsm --call-dirmngr listcrls for details." ),
272 i18n(
"Dump CRL Cache Error" ) );
274 KMessageBox::error( dialog,
275 i18n(
"An error occurred while trying to dump the CRL cache. "
276 "The output from GpgSM was:\n%1", errorString() ),
277 i18n(
"Dump CRL Cache Error" ) );
284 #include "moc_dumpcrlcachecommand.cpp"
285 #include "dumpcrlcachecommand.moc"
DumpCrlCacheCommand(QAbstractItemView *view, KeyListController *parent)
A high-speed text display widget.
static QByteArray chomped(QByteArray ba)
kdtools::pimpl_ptr< Private > d
VerifyChecksumsDialog::Status status
static QString process(const Dir &dir, bool *fatal)
static const int PROCESS_TERMINATE_TIMEOUT