• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kleopatra

  • sources
  • kde-4.14
  • kdepim
  • kleopatra
crlview.cpp
Go to the documentation of this file.
1 /*
2  crlview.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2001,2002,2004 Klarälvdalens Datakonsult AB
6 
7  Kleopatra is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  Kleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the Qt library by Trolltech AS, Norway (or with modified versions
24  of Qt that use the same license as Qt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  Qt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #include <config-kleopatra.h>
34 
35 #include "crlview.h"
36 
37 #include <klocale.h>
38 #include <kprocess.h>
39 #include <kmessagebox.h>
40 #include <kpushbutton.h>
41 #include <KStandardGuiItem>
42 #include <kglobalsettings.h>
43 
44 #include <QLabel>
45 #include <qtextedit.h>
46 #include <QTimer>
47 
48 #include <QVBoxLayout>
49 #include <QHBoxLayout>
50 #include <QCloseEvent>
51 
52 CRLView::CRLView( QWidget* parent )
53  : QDialog( parent ), _process(0)
54 {
55  QVBoxLayout* topLayout = new QVBoxLayout( this );
56  topLayout->setSpacing( 4 );
57  topLayout->setMargin( 10 );
58 
59  topLayout->addWidget( new QLabel( i18n("CRL cache dump:"), this ) );
60 
61  _textView = new QTextEdit( this );
62  _textView->setFont( KGlobalSettings::fixedFont() );
63  _textView->setReadOnly(true);
64  topLayout->addWidget( _textView );
65 
66  QHBoxLayout* hbLayout = new QHBoxLayout();
67  topLayout->addItem( hbLayout );
68 
69  _updateButton = new KPushButton( i18n("&Update"), this );
70  _closeButton = new KPushButton( KStandardGuiItem::close(), this );
71 
72  hbLayout->addWidget( _updateButton );
73  hbLayout->addStretch();
74  hbLayout->addWidget( _closeButton );
75 
76  // connections:
77  connect( _updateButton, SIGNAL(clicked()),
78  this, SLOT(slotUpdateView()) );
79  connect( _closeButton, SIGNAL(clicked()),
80  this, SLOT(close()) );
81 
82  resize( _textView->fontMetrics().width( 'M' ) * 80,
83  _textView->fontMetrics().lineSpacing() * 25 );
84 
85  _timer = new QTimer( this );
86  connect( _timer, SIGNAL(timeout()), SLOT(slotAppendBuffer()) );
87 }
88 
89 CRLView::~CRLView()
90 {
91  delete _process; _process = 0;
92 }
93 
94 void CRLView::closeEvent( QCloseEvent * e ) {
95  QDialog::closeEvent( e );
96  delete _process; _process = 0;
97 }
98 
99 void CRLView::slotUpdateView()
100 {
101  _updateButton->setEnabled( false );
102  _textView->clear();
103  _buffer.clear();
104  if( !_process ) {
105  _process = new KProcess();
106  *_process << "gpgsm" << "--call-dirmngr" << "listcrls";
107  connect( _process, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadStdout()));
108  connect( _process, SIGNAL(finished(int,QProcess::ExitStatus)),
109  this, SLOT(slotProcessExited(int,QProcess::ExitStatus)));
110  }
111  if( _process->state() == QProcess::Running ) _process->kill();
112  _process->setOutputChannelMode(KProcess::OnlyStdoutChannel);
113  _process->start();
114  if( !_process->waitForStarted()){
115  KMessageBox::error( this, i18n( "Unable to start gpgsm process. Please check your installation." ), i18n( "Certificate Manager Error" ) );
116  processExited();
117  }
118  _timer->start( 1000 );
119 }
120 
121 void CRLView::slotReadStdout()
122 {
123  _buffer.append( _process->readAllStandardOutput() );
124 }
125 
126 void CRLView::slotAppendBuffer() {
127  _textView->append( _buffer );
128  _buffer.clear();
129 }
130 
131 void CRLView::processExited()
132 {
133  _timer->stop();
134  slotAppendBuffer();
135  _updateButton->setEnabled( true );
136 }
137 
138 
139 void CRLView::slotProcessExited(int, QProcess::ExitStatus _status)
140 {
141  processExited();
142  if( _status != QProcess::NormalExit ) {
143  KMessageBox::error( this, i18n( "The GpgSM process ended prematurely because of an unexpected error." ), i18n( "Certificate Manager Error" ) );
144  }
145 }
146 
QTextEdit::append
void append(const QString &text)
QWidget::close
bool close()
QWidget
QString::append
QString & append(QChar ch)
CRLView::slotAppendBuffer
void slotAppendBuffer()
Definition: crlview.cpp:126
QDialog::closeEvent
virtual void closeEvent(QCloseEvent *e)
QHBoxLayout
QTextEdit::clear
void clear()
QString::clear
void clear()
QDialog::finished
void finished(int result)
QCloseEvent
QWidget::resize
void resize(int w, int h)
CRLView::~CRLView
~CRLView()
Definition: crlview.cpp:89
QWidget::setEnabled
void setEnabled(bool)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QTimer
QBoxLayout::addItem
virtual void addItem(QLayoutItem *item)
QVBoxLayout
CRLView::slotUpdateView
void slotUpdateView()
Definition: crlview.cpp:99
QLayout::setMargin
void setMargin(int margin)
crlview.h
QWidget::setFont
void setFont(const QFont &)
QFontMetrics::width
int width(const QString &text, int len) const
QTimer::stop
void stop()
QWidget::fontMetrics
QFontMetrics fontMetrics() const
CRLView::closeEvent
void closeEvent(QCloseEvent *)
Definition: crlview.cpp:94
CRLView::slotReadStdout
void slotReadStdout()
Definition: crlview.cpp:121
QBoxLayout::addStretch
void addStretch(int stretch)
QDialog
QTimer::start
void start(int msec)
CRLView::processExited
void processExited()
Definition: crlview.cpp:131
QTextEdit::setReadOnly
void setReadOnly(bool ro)
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QLabel
QTextEdit
CRLView::CRLView
CRLView(QWidget *parent=0)
Definition: crlview.cpp:52
QFontMetrics::lineSpacing
int lineSpacing() const
QBoxLayout::setSpacing
void setSpacing(int spacing)
CRLView::slotProcessExited
void slotProcessExited(int, QProcess::ExitStatus)
Definition: crlview.cpp:139
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal