certmanager Library API Documentation

crlview.cpp

00001 /* 00002 crlview.cpp 00003 00004 This file is part of Kleopatra, the KDE keymanager 00005 Copyright (c) 2001,2002,2004 Klarälvdalens Datakonsult AB 00006 00007 Kleopatra is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 Kleopatra is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 In addition, as a special exception, the copyright holders give 00022 permission to link the code of this program with any edition of 00023 the Qt library by Trolltech AS, Norway (or with modified versions 00024 of Qt that use the same license as Qt), and distribute linked 00025 combinations including the two. You must obey the GNU General 00026 Public License in all respects for all of the code used other than 00027 Qt. If you modify this file, you may extend this exception to 00028 your version of the file, but you are not obligated to do so. If 00029 you do not wish to do so, delete this exception statement from 00030 your version. 00031 */ 00032 00033 #ifdef HAVE_CONFIG_H 00034 #include <config.h> 00035 #endif 00036 00037 #include "crlview.h" 00038 00039 #include <klocale.h> 00040 #include <kprocess.h> 00041 #include <kmessagebox.h> 00042 #include <kpushbutton.h> 00043 #include <kstdguiitem.h> 00044 00045 #include <qlayout.h> 00046 #include <qlabel.h> 00047 #include <qtextview.h> 00048 #include <qfontmetrics.h> 00049 00050 CRLView::CRLView( QWidget* parent, const char* name, bool modal ) 00051 : QDialog( parent, name, modal ), _process(0) 00052 { 00053 QVBoxLayout* topLayout = new QVBoxLayout( this, 10, 4 ); 00054 00055 topLayout->addWidget( new QLabel( i18n("CRL cache dump:"), this ) ); 00056 00057 _textView = new QTextView( this ); 00058 _textView->setWordWrap( QTextEdit::NoWrap ); 00059 topLayout->addWidget( _textView ); 00060 00061 QHBoxLayout* hbLayout = new QHBoxLayout( topLayout ); 00062 00063 _updateButton = new KPushButton( i18n("&Update"), this ); 00064 _closeButton = new KPushButton( KStdGuiItem::close(), this ); 00065 00066 hbLayout->addWidget( _updateButton ); 00067 hbLayout->addStretch(); 00068 hbLayout->addWidget( _closeButton ); 00069 00070 // connections: 00071 connect( _updateButton, SIGNAL( clicked() ), 00072 this, SLOT( slotUpdateView() ) ); 00073 connect( _closeButton, SIGNAL( clicked() ), 00074 this, SLOT( close() ) ); 00075 00076 resize( _textView->fontMetrics().width( 'M' ) * 80, 00077 _textView->fontMetrics().lineSpacing() * 25 ); 00078 } 00079 00080 CRLView::~CRLView() 00081 { 00082 delete _process; 00083 } 00084 00085 void CRLView::slotUpdateView() 00086 { 00087 _updateButton->setEnabled( false ); 00088 _textView->clear(); 00089 if( _process == 0 ) { 00090 _process = new KProcess(); 00091 *_process << "gpgsm" << "--call-dirmngr" << "listcrls"; 00092 connect( _process, SIGNAL( receivedStdout( KProcess*, char*, int) ), 00093 this, SLOT( slotReadStdout( KProcess*, char*, int ) ) ); 00094 connect( _process, SIGNAL( processExited( KProcess* ) ), 00095 this, SLOT( slotProcessExited() ) ); 00096 } 00097 if( _process->isRunning() ) _process->kill(); 00098 if( !_process->start( KProcess::NotifyOnExit, KProcess::Stdout ) ) { 00099 KMessageBox::error( this, i18n( "Unable to start gpgsm process. Please check your installation." ), i18n( "Certificate Manager Error" ) ); 00100 slotProcessExited(); 00101 } 00102 } 00103 00104 void CRLView::slotReadStdout( KProcess*, char* buf, int len) 00105 { 00106 _textView->append( QString::fromUtf8( buf, len ) ); 00107 } 00108 00109 void CRLView::slotProcessExited() 00110 { 00111 _updateButton->setEnabled( true ); 00112 00113 if( !_process->normalExit() ) { 00114 KMessageBox::error( this, i18n( "The GpgSM process ended prematurely because of an unexpected error." ), i18n( "Certificate Manager Error" ) ); 00115 } 00116 } 00117 00118 #include "crlview.moc"
KDE Logo
This file is part of the documentation for certmanager Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:18:46 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003