33 #include <config-kleopatra.h>
43 #include <KMessageBox>
44 #include <KLocalizedString>
45 #include <KPushButton>
46 #include <KStandardGuiItem>
47 #include <KGlobalSettings>
48 #include <KConfigGroup>
53 #include <QHBoxLayout>
54 #include <QVBoxLayout>
59 class DumpCrlCacheDialog :
public QDialog {
62 explicit DumpCrlCacheDialog(
QWidget * parent=0 )
73 void updateRequested();
76 void append(
const QString & line ) {
77 ui.logTextWidget.message( line );
80 ui.logTextWidget.clear();
86 KConfigGroup dialog( KGlobal::config(),
"DumpCrlCacheDialog" );
87 const QSize size = dialog.readEntry(
"Size",
QSize(600, 400) );
95 KConfigGroup dialog( KGlobal::config(),
"DumpCrlCacheDialog" );
96 dialog.writeEntry(
"Size", size() );
102 KPushButton updateButton, closeButton;
106 explicit Ui( DumpCrlCacheDialog *
q )
107 : logTextWidget( q ),
108 updateButton( i18nc(
"@action:button Update the log text widget",
"&Update"), q ),
109 closeButton( KStandardGuiItem::close(), q ),
119 logTextWidget.setFont( KGlobalSettings::fixedFont() );
120 logTextWidget.setMinimumVisibleLines( 25 );
121 logTextWidget.setMinimumVisibleColumns( 80 );
123 vlay.addWidget( &logTextWidget, 1 );
124 vlay.addLayout( &hlay );
126 hlay.addWidget( &updateButton );
127 hlay.addStretch( 1 );
128 hlay.addWidget( &closeButton );
130 connect( &updateButton, SIGNAL(clicked()),
131 q, SIGNAL(updateRequested()) );
132 connect( &closeButton, SIGNAL(clicked()),
139 using namespace Kleo;
140 using namespace Kleo::Commands;
149 friend class ::Kleo::Commands::DumpCrlCacheCommand;
164 void slotProcessFinished(
int, QProcess::ExitStatus );
166 void slotProcessReadyReadStandardOutput() {
167 while (
process.canReadLine() ) {
174 void slotProcessReadyReadStandardError() {
175 errorBuffer +=
process.readAllStandardError();
178 void slotUpdateRequested() {
179 if (
process.state() == QProcess::NotRunning )
183 void slotDialogDestroyed() {
185 if (
process.state() != QProcess::NotRunning )
192 DumpCrlCacheDialog * dialog;
198 DumpCrlCacheCommand::Private * DumpCrlCacheCommand::d_func() {
return static_cast<Private*
>(
d.
get() ); }
199 const DumpCrlCacheCommand::Private * DumpCrlCacheCommand::d_func()
const {
return static_cast<const Private*
>(
d.
get() ); }
211 process.setOutputChannelMode( KProcess::SeparateChannels );
212 process.setReadChannel( KProcess::StandardOutput );
216 DumpCrlCacheCommand::Private::~Private() {
217 if ( dialog && !dialog->isVisible() )
222 :
Command( new Private( this, c ) )
228 :
Command( v, new Private( this, c ) )
233 void DumpCrlCacheCommand::Private::init() {
234 connect( &
process, SIGNAL(finished(
int,QProcess::ExitStatus)),
235 q, SLOT(slotProcessFinished(
int,QProcess::ExitStatus)) );
236 connect( &
process, SIGNAL(readyReadStandardError()),
237 q, SLOT(slotProcessReadyReadStandardError()) );
238 connect( &
process, SIGNAL(readyReadStandardOutput()),
239 q, SLOT(slotProcessReadyReadStandardOutput()) );
244 void DumpCrlCacheCommand::doStart() {
246 d->dialog =
new DumpCrlCacheDialog;
247 d->dialog->setAttribute( Qt::WA_DeleteOnClose );
248 d->dialog->setWindowTitle( i18n(
"CRL Cache Dump") );
250 connect(
d->dialog, SIGNAL(updateRequested()),
251 this, SLOT(slotUpdateRequested()) );
253 this, SLOT(slotDialogDestroyed()) );
258 void DumpCrlCacheCommand::Private::refreshView() {
264 if (
process.waitForStarted() ) {
267 KMessageBox::error( dialog ? static_cast<QWidget*>( dialog ) : parentWidgetOrView(),
268 i18n(
"Unable to start process gpgsm. "
269 "Please check your installation." ),
270 i18n(
"Dump CRL Cache Error" ) );
275 void DumpCrlCacheCommand::doCancel() {
277 if (
d->process.state() != QProcess::NotRunning ) {
278 d->process.terminate();
286 void DumpCrlCacheCommand::Private::slotProcessFinished(
int code, QProcess::ExitStatus
status ) {
288 if ( status == QProcess::CrashExit )
289 KMessageBox::error( dialog,
290 i18n(
"The GpgSM process that tried to dump the CRL cache "
291 "ended prematurely because of an unexpected error. "
292 "Please check the output of gpgsm --call-dirmngr listcrls for details." ),
293 i18n(
"Dump CRL Cache Error" ) );
295 KMessageBox::error( dialog,
296 i18n(
"An error occurred while trying to dump the CRL cache. "
297 "The output from GpgSM was:\n%1", errorString() ),
298 i18n(
"Dump CRL Cache Error" ) );
305 #include "moc_dumpcrlcachecommand.cpp"
306 #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
QString fromLocal8Bit(const char *str, int size)
static QString process(const Dir &dir, bool *fatal)
QByteArray & append(char ch)
static const int PROCESS_TERMINATE_TIMEOUT
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void destroyed(QObject *obj)
bool endsWith(const QByteArray &ba) const