certmanager

certmanager.h

00001 /* -*- mode: c++; c-basic-offset:4 -*-
00002     certmanager.h
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  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 TQt library by Trolltech AS, Norway (or with modified versions
00024     of TQt that use the same license as TQt), 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     TQt.  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 #ifndef _CERTMANAGER_H_
00034 #define _CERTMANAGER_H_
00035 
00036 //#include <gpgme.h>
00037 
00038 #include <tdemainwindow.h>
00039 #include <tdepimmacros.h>
00040 #include <kurl.h>
00041 #include <tqcstring.h>
00042 #include <tqptrlist.h>
00043 
00044 #include <set>
00045 #include <string>
00046 
00047 namespace Kleo {
00048   class KeyListView;
00049   class KeyListViewItem;
00050   class ProgressBar;
00051   class Job;
00052 }
00053 
00054 namespace TDEIO {
00055   class Job;
00056 }
00057 class TDEProcess;
00058 class TDEToolBar;
00059 class TDEAction;
00060 
00061 class CRLView;
00062 class HierarchyAnalyser;
00063 
00064 class LineEditAction;
00065 class ComboAction;
00066 
00067 class KURL;
00068 class TQFile;
00069 class TQStringList;
00070 class TQLabel;
00071 
00072 namespace GpgME {
00073   class ImportResult;
00074   class KeyListResult;
00075   class Error;
00076   class Key;
00077 }
00078 
00079 class KDE_EXPORT CertManager : public TDEMainWindow {
00080   Q_OBJECT
00081   
00082 public:
00083     CertManager( bool remote = false, const TQString& query = TQString(),
00084          const TQString& import=TQString(),
00085          TQWidget * parent=0, const char * name=0, WFlags f=0 );
00086     ~CertManager();
00087 
00088     bool isRemote() const { return mRemote; }
00089 
00090 signals:
00091     void stopOperations();
00092     void enableOperations( bool );
00093 
00094 private slots:
00095     void slotStartCertificateDownload( const TQString & fingerprint, const TQString& displayName );
00096     void newCertificate();
00097     void revokeCertificate();
00098     void extendCertificate();
00099     void slotDeleteCertificate();
00100     void slotExportSecretKey();
00101     void slotExportCertificate();
00102     void slotUploadResult( TDEIO::Job* job );
00103 
00104     void slotImportCertFromFile();
00105     void slotImportCertFromFile( const KURL & filename );
00106     void slotImportResult( TDEIO::Job* );
00107 
00108     void slotCertificateImportResult( const GpgME::ImportResult & result );
00109     void slotCertificateDownloadResult( const GpgME::Error & error, const TQByteArray & keyData );
00110     void slotKeyListResult( const GpgME::KeyListResult & result );
00111     void slotDeleteResult( const GpgME::Error & error, const GpgME::Key & );
00112     void slotSecretKeyExportResult( const GpgME::Error & error, const TQByteArray & keyData );
00113     void slotCertificateExportResult( const GpgME::Error & error, const TQByteArray & keyData );
00114     void slotClearCRLsResult();
00115 
00116     void importCRLFromFile();
00117     void importCRLFromLDAP();
00118     void slotImportCRLJobFinished( TDEIO::Job * );
00119 
00120     void slotDirmngrExited();
00121     void slotStderr( TDEProcess*, char*, int );
00122 
00123     void slotToggleRemote(int idx);
00124     void slotToggleHierarchicalView( bool );
00125 
00126     void slotViewCRLs();
00127     void slotClearCRLs();
00128 
00129     void slotViewDetails();
00130     void slotViewDetails( Kleo::KeyListViewItem * item );
00131     void slotSelectionChanged();
00132     void slotDownloadCertificate();
00133     void slotStartWatchGnuPG();
00134 
00135     void slotEditKeybindings();
00136     void slotShowConfigurationDialog();
00137     void slotConfigureGpgME();
00138     void slotContextMenu(Kleo::KeyListViewItem*, const TQPoint& point);
00139     void slotDropped(const KURL::List&);
00142     void slotRepaint();
00145     void slotValidate() { startRedisplay( true ); }
00148     void slotRedisplay() { startRedisplay( false ); }
00151     void slotSearch();
00152 
00153     void slotExpandAll();
00154     void slotCollapseAll();
00155     void slotRefreshKeys();
00156     void slotRefreshKeysResult( const GpgME::Error & );
00157 
00158 private:
00159     void createStatusBar();
00160     void createActions();
00161     void updateStatusBarLabels();
00162     void updateImportActions( bool enable );
00163     void startKeyListing( bool, bool, const TQStringList & );
00164     void startKeyListing( bool, bool, const std::set<std::string> & );
00165     void startCertificateImport( const TQByteArray & keyData, const TQString& certDisplayName );
00166     void startImportCRL( const TQString& fileName, bool isTempFile );
00167     void startClearCRLs();
00168     void startSecretKeyExport( const TQString & fingerprint );
00169     void startCertificateExport( const TQStringList & fingerprints );
00170     bool connectAndStartDirmngr( const char*, const char* );
00171     void connectJobToStatusBarProgress( Kleo::Job * job, const TQString & initialText );
00172     void disconnectJobFromStatusBarProgress( const GpgME::Error & err );
00173     void importNextURLOrRedisplay();
00174     void startRedisplay( bool validating );
00175     TQString displayNameForJob( const Kleo::Job *job );
00176     void readConfig( bool noQueryGiven );
00177     void writeConfig();
00178 
00179 private:
00180     Kleo::KeyListView * mKeyListView;
00181     CRLView * mCrlView;
00182     Kleo::ProgressBar * mProgressBar;
00183     TQLabel * mStatusLabel;
00184 
00185     TDEProcess * mDirmngrProc;
00186     TQString mErrorbuffer;
00187     TQPtrList<Kleo::KeyListViewItem> mItemsToDelete;
00188     KURL::List mURLsToImport;
00189     typedef TQMap<const Kleo::Job *, TQString> JobsDisplayNameMap;
00190     JobsDisplayNameMap mJobsDisplayNameMap;
00191     HierarchyAnalyser * mHierarchyAnalyser;
00192 
00193     LineEditAction * mLineEditAction;
00194     ComboAction * mComboAction;
00195     TDEAction * mFindAction;
00196     TDEAction * mImportCertFromFileAction;
00197     TDEAction * mImportCRLFromFileAction;
00198     TDEAction * mExportCertificateAction;
00199     TDEAction * mViewCertDetailsAction;
00200     TDEAction * mDeleteCertificateAction;
00201 #ifdef NOT_IMPLEMENTED_ANYWAY
00202     TDEAction * mRevokeCertificateAction;
00203     TDEAction * mExtendCertificateAction;
00204 #endif
00205     TDEAction * mExportSecretKeyAction;
00206     TDEAction * mDownloadCertificateAction;
00207     TDEAction * mValidateCertificateAction;
00208 
00209     TQString mImportCRLTempFile;
00210     TQString mCurrentQuery;
00211     std::set<std::string> mPreviouslySelectedFingerprints;
00212     bool     mNextFindRemote : 1; // state of the combo, i.e. whether the next find action will be remote
00213     bool     mRemote : 1; // whether the currently displayed items are from a remote listing
00214     bool     mDirMngrFound : 1;
00215     bool     mHierarchicalView : 1; // whether to display the list view in hierarchical mode
00216 };
00217 
00218 #endif // _CERTMANAGER_H_