certmanager

certmanager.h
1 /*
2  certmanager.h
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 TQt library by Trolltech AS, Norway (or with modified versions
24  of TQt that use the same license as TQt), 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  TQt. 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 #ifndef _CERTMANAGER_H_
34 #define _CERTMANAGER_H_
35 
36 //#include <gpgme.h>
37 
38 #include <tdemainwindow.h>
39 #include <tdemacros.h>
40 #include <kurl.h>
41 #include <tqcstring.h>
42 #include <tqptrlist.h>
43 
44 #include <set>
45 #include <string>
46 
47 namespace Kleo {
48  class KeyListView;
49  class KeyListViewItem;
50  class ProgressBar;
51  class Job;
52 }
53 
54 namespace TDEIO {
55  class Job;
56 }
57 class TDEProcess;
58 class TDEToolBar;
59 class TDEAction;
60 
61 class CRLView;
62 class HierarchyAnalyser;
63 
64 class LineEditAction;
65 class ComboAction;
66 
67 class KURL;
68 class TQFile;
69 class TQStringList;
70 class TQLabel;
71 
72 namespace GpgME {
73  class ImportResult;
74  class KeyListResult;
75  class Error;
76  class Key;
77 }
78 
79 class TDE_EXPORT CertManager : public TDEMainWindow {
80  TQ_OBJECT
81 
82 public:
83  CertManager( bool remote = false, const TQString& query = TQString(),
84  const TQString& import=TQString(),
85  TQWidget * parent=0, const char * name=0, WFlags f=0 );
86  ~CertManager();
87 
88  bool isRemote() const { return mRemote; }
89 
90 signals:
91  void stopOperations();
92  void enableOperations( bool );
93 
94 private slots:
95  void slotStartCertificateDownload( const TQString & fingerprint, const TQString& displayName );
96  void newCertificate();
97  void revokeCertificate();
98  void extendCertificate();
99  void slotDeleteCertificate();
100  void slotExportSecretKey();
101  void slotExportCertificate();
102  void slotUploadResult( TDEIO::Job* job );
103 
104  void slotImportCertFromFile();
105  void slotImportCertFromFile( const KURL & filename );
106  void slotImportResult( TDEIO::Job* );
107 
108  void slotCertificateImportResult( const GpgME::ImportResult & result );
109  void slotCertificateDownloadResult( const GpgME::Error & error, const TQByteArray & keyData );
110  void slotKeyListResult( const GpgME::KeyListResult & result );
111  void slotDeleteResult( const GpgME::Error & error, const GpgME::Key & );
112  void slotSecretKeyExportResult( const GpgME::Error & error, const TQByteArray & keyData );
113  void slotCertificateExportResult( const GpgME::Error & error, const TQByteArray & keyData );
114  void slotClearCRLsResult();
115 
116  void importCRLFromFile();
117  void importCRLFromLDAP();
118  void slotImportCRLJobFinished( TDEIO::Job * );
119 
120  void slotDirmngrExited();
121  void slotStderr( TDEProcess*, char*, int );
122 
123  void slotToggleRemote(int idx);
124  void slotToggleHierarchicalView( bool );
125 
126  void slotViewCRLs();
127  void slotClearCRLs();
128 
129  void slotViewDetails();
130  void slotViewDetails( Kleo::KeyListViewItem * item );
131  void slotSelectionChanged();
132  void slotDownloadCertificate();
133  void slotStartWatchGnuPG();
134 
135  void slotEditKeybindings();
136  void slotShowConfigurationDialog();
137  void slotConfigureGpgME();
138  void slotContextMenu(Kleo::KeyListViewItem*, const TQPoint& point);
139  void slotDropped(const KURL::List&);
142  void slotRepaint();
145  void slotValidate() { startRedisplay( true ); }
148  void slotRedisplay() { startRedisplay( false ); }
151  void slotSearch();
152 
153  void slotExpandAll();
154  void slotCollapseAll();
155  void slotRefreshKeys();
156  void slotRefreshKeysResult( const GpgME::Error & );
157 
158 private:
159  void createStatusBar();
160  void createActions();
161  void updateStatusBarLabels();
162  void updateImportActions( bool enable );
163  void startKeyListing( bool, bool, const TQStringList & );
164  void startKeyListing( bool, bool, const std::set<std::string> & );
165  void startCertificateImport( const TQByteArray & keyData, const TQString& certDisplayName );
166  void startImportCRL( const TQString& fileName, bool isTempFile );
167  void startClearCRLs();
168  void startSecretKeyExport( const TQString & fingerprint );
169  void startCertificateExport( const TQStringList & fingerprints );
170  bool connectAndStartDirmngr( const char*, const char* );
171  void connectJobToStatusBarProgress( Kleo::Job * job, const TQString & initialText );
172  void disconnectJobFromStatusBarProgress( const GpgME::Error & err );
173  void importNextURLOrRedisplay();
174  void startRedisplay( bool validating );
175  TQString displayNameForJob( const Kleo::Job *job );
176  void readConfig( bool noQueryGiven );
177  void writeConfig();
178 
179 private:
180  Kleo::KeyListView * mKeyListView;
181  CRLView * mCrlView;
182  Kleo::ProgressBar * mProgressBar;
183  TQLabel * mStatusLabel;
184 
185  TDEProcess * mDirmngrProc;
186  TQString mErrorbuffer;
187  TQPtrList<Kleo::KeyListViewItem> mItemsToDelete;
188  KURL::List mURLsToImport;
189  typedef TQMap<const Kleo::Job *, TQString> JobsDisplayNameMap;
190  JobsDisplayNameMap mJobsDisplayNameMap;
191  HierarchyAnalyser * mHierarchyAnalyser;
192 
193  LineEditAction * mLineEditAction;
194  ComboAction * mComboAction;
195  TDEAction * mFindAction;
196  TDEAction * mImportCertFromFileAction;
197  TDEAction * mImportCRLFromFileAction;
198  TDEAction * mExportCertificateAction;
199  TDEAction * mViewCertDetailsAction;
200  TDEAction * mDeleteCertificateAction;
201 #ifdef NOT_IMPLEMENTED_ANYWAY
202  TDEAction * mRevokeCertificateAction;
203  TDEAction * mExtendCertificateAction;
204 #endif
205  TDEAction * mExportSecretKeyAction;
206  TDEAction * mDownloadCertificateAction;
207  TDEAction * mValidateCertificateAction;
208 
209  TQString mImportCRLTempFile;
210  TQString mCurrentQuery;
211  std::set<std::string> mPreviouslySelectedFingerprints;
212  bool mNextFindRemote : 1; // state of the combo, i.e. whether the next find action will be remote
213  bool mRemote : 1; // whether the currently displayed items are from a remote listing
214  bool mDirMngrFound : 1;
215  bool mHierarchicalView : 1; // whether to display the list view in hierarchical mode
216 };
217 
218 #endif // _CERTMANAGER_H_