1 #ifndef _KVI_CRYPTCONTROLLER_H_
2 #define _KVI_CRYPTCONTROLLER_H_
3 //=============================================================================
4 //
5 //   File : KviCryptController.h
6 //   Creation date : Fri Nov 03 2000 14:11:03 CEST by Szymon Stefanek
7 //
8 //   This file is part of the KVIrc IRC client distribution
9 //   Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 //   This program is FREE software. You can redistribute it and/or
12 //   modify it under the terms of the GNU General Public License
13 //   as published by the Free Software Foundation; either version 2
14 //   of the License, or (at your option) any later version.
15 //
16 //   This program is distributed in the HOPE that it will be USEFUL,
17 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
18 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 //   See the GNU General Public License for more details.
20 //
21 //   You should have received a copy of the GNU General Public License
22 //   along with this program. If not, write to the Free Software Foundation,
23 //   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "kvi_settings.h"
28 
29 #if defined(COMPILE_CRYPT_SUPPORT)
30 #include "KviCryptEngineDescription.h"
31 #include "KviCryptEngineManager.h"
32 #include "KviHeapObject.h"
33 #include "KviTalListWidget.h"
34 #include "KviWindowToolWidget.h"
35 
36 #include <QString>
37 
38 class KviCryptEngine;
39 class KviWindow;
40 class QCheckBox;
41 class QLabel;
42 class QLineEdit;
43 class QPushButton;
44 class QTextEdit;
45 class QWidget;
46 
47 class KVIRC_API KviCryptSessionInfo : public KviHeapObject
48 {
49 public:
50 	KviCryptEngine * m_pEngine;
51 	QString m_szEngineName;
52 	bool m_bDoEncrypt;
53 	bool m_bDoDecrypt;
54 };
55 
56 class KVIRC_API KviEngineListBoxItem : public KviTalListWidgetText
57 {
58 	friend class KviCryptController;
59 
60 public:
61 	KviEngineListBoxItem(KviTalListWidget * lb, KviCryptEngineDescription * d, const char * modName);
62 	~KviEngineListBoxItem();
63 
64 public:
65 	QString m_szName;
66 	QString m_szAuthor;
67 	QString m_szDescription;
68 	QString m_szModuleName;
69 	int m_iFlags;
70 };
71 
72 class KVIRC_API KviCryptController : public KviWindowToolWidget
73 {
74 	Q_OBJECT
75 public:
76 	KviCryptController(QWidget * pParent, KviWindowToolPageButton * pButton, KviWindow * pWnd, KviCryptSessionInfo * pInfo);
77 	~KviCryptController();
78 
79 protected:
80 	KviWindow * m_pWindow;
81 	KviTalListWidget * m_pListBox;
82 	QPushButton * m_pOkButton;
83 	QCheckBox * m_pEnableCheck;
84 	QTextEdit * m_pDescriptionText;
85 	QLabel * m_pAuthorLabel;
86 	QCheckBox * m_pEnableEncrypt;
87 	QLabel * m_pEncryptKeyLabel;
88 	QLineEdit * m_pEncryptKeyEdit;
89 	QCheckBox * m_pEncryptHexKeyCheck;
90 	QCheckBox * m_pEnableDecrypt;
91 	QLabel * m_pDecryptKeyLabel;
92 	QLineEdit * m_pDecryptKeyEdit;
93 	QCheckBox * m_pDecryptHexKeyCheck;
94 	KviEngineListBoxItem * m_pLastItem;
95 	KviCryptSessionInfo * m_pSessionInfo;
96 private slots:
97 	void enableCheckToggled(bool bChecked);
98 	void engineHighlighted(QListWidgetItem * pItem, QListWidgetItem *);
99 	void okClicked();
100 
101 public:
102 	KviCryptSessionInfo * getNewSessionInfo();
103 	static KviCryptSessionInfo * allocateCryptSessionInfo();
104 	static void destroyCryptSessionInfo(KviCryptSessionInfo ** ppInfo);
105 
106 private:
107 	void fillEngineList();
108 	void noEnginesAvailable();
109 	void enableWidgets(bool bEnabled);
110 	bool initializeEngine(KviCryptEngine * pEngine);
111 signals:
112 	void done();
113 };
114 #endif //COMPILE_CRYPT_SUPPORT
115 
116 #endif //!_KVI_CRYPTCONTROLLER_H_
117