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

kleopatra

  • sources
  • kde-4.12
  • 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 <QLayout>
45 #include <QLabel>
46 #include <qtextedit.h>
47 #include <QFontMetrics>
48 #include <QTimer>
49 
50 #include <QVBoxLayout>
51 #include <QHBoxLayout>
52 #include <QCloseEvent>
53 
54 CRLView::CRLView( QWidget* parent )
55  : QDialog( parent ), _process(0)
56 {
57  QVBoxLayout* topLayout = new QVBoxLayout( this );
58  topLayout->setSpacing( 4 );
59  topLayout->setMargin( 10 );
60 
61  topLayout->addWidget( new QLabel( i18n("CRL cache dump:"), this ) );
62 
63  _textView = new QTextEdit( this );
64  _textView->setFont( KGlobalSettings::fixedFont() );
65  _textView->setReadOnly(true);
66  topLayout->addWidget( _textView );
67 
68  QHBoxLayout* hbLayout = new QHBoxLayout();
69  topLayout->addItem( hbLayout );
70 
71  _updateButton = new KPushButton( i18n("&Update"), this );
72  _closeButton = new KPushButton( KStandardGuiItem::close(), this );
73 
74  hbLayout->addWidget( _updateButton );
75  hbLayout->addStretch();
76  hbLayout->addWidget( _closeButton );
77 
78  // connections:
79  connect( _updateButton, SIGNAL(clicked()),
80  this, SLOT(slotUpdateView()) );
81  connect( _closeButton, SIGNAL(clicked()),
82  this, SLOT(close()) );
83 
84  resize( _textView->fontMetrics().width( 'M' ) * 80,
85  _textView->fontMetrics().lineSpacing() * 25 );
86 
87  _timer = new QTimer( this );
88  connect( _timer, SIGNAL(timeout()), SLOT(slotAppendBuffer()) );
89 }
90 
91 CRLView::~CRLView()
92 {
93  delete _process; _process = 0;
94 }
95 
96 void CRLView::closeEvent( QCloseEvent * e ) {
97  QDialog::closeEvent( e );
98  delete _process; _process = 0;
99 }
100 
101 void CRLView::slotUpdateView()
102 {
103  _updateButton->setEnabled( false );
104  _textView->clear();
105  _buffer.clear();
106  if( !_process ) {
107  _process = new KProcess();
108  *_process << "gpgsm" << "--call-dirmngr" << "listcrls";
109  connect( _process, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadStdout()));
110  connect( _process, SIGNAL(finished(int,QProcess::ExitStatus)),
111  this, SLOT(slotProcessExited(int,QProcess::ExitStatus)));
112  }
113  if( _process->state() == QProcess::Running ) _process->kill();
114  _process->setOutputChannelMode(KProcess::OnlyStdoutChannel);
115  _process->start();
116  if( !_process->waitForStarted()){
117  KMessageBox::error( this, i18n( "Unable to start gpgsm process. Please check your installation." ), i18n( "Certificate Manager Error" ) );
118  processExited();
119  }
120  _timer->start( 1000 );
121 }
122 
123 void CRLView::slotReadStdout()
124 {
125  _buffer.append( _process->readAllStandardOutput() );
126 }
127 
128 void CRLView::slotAppendBuffer() {
129  _textView->append( _buffer );
130  _buffer.clear();
131 }
132 
133 void CRLView::processExited()
134 {
135  _timer->stop();
136  slotAppendBuffer();
137  _updateButton->setEnabled( true );
138 }
139 
140 
141 void CRLView::slotProcessExited(int, QProcess::ExitStatus _status)
142 {
143  processExited();
144  if( _status != QProcess::NormalExit ) {
145  KMessageBox::error( this, i18n( "The GpgSM process ended prematurely because of an unexpected error." ), i18n( "Certificate Manager Error" ) );
146  }
147 }
148 
149 #include "crlview.moc"
CRLView::slotAppendBuffer
void slotAppendBuffer()
Definition: crlview.cpp:128
QDialog
QWidget
CRLView::~CRLView
~CRLView()
Definition: crlview.cpp:91
CRLView::slotUpdateView
void slotUpdateView()
Definition: crlview.cpp:101
crlview.h
CRLView::closeEvent
void closeEvent(QCloseEvent *)
Definition: crlview.cpp:96
CRLView::slotReadStdout
void slotReadStdout()
Definition: crlview.cpp:123
CRLView::processExited
void processExited()
Definition: crlview.cpp:133
CRLView::CRLView
CRLView(QWidget *parent=0)
Definition: crlview.cpp:54
CRLView::slotProcessExited
void slotProcessExited(int, QProcess::ExitStatus)
Definition: crlview.cpp:141
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:40 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

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