~nitrokey/nitrokey/release

« back to all changes in this revision

Viewing changes to mainwindow.h

  • Committer: ggkitsas
  • Date: 2015-02-02 14:31:31 UTC
  • Revision ID: git-v1:b8ca589a5a5149133891043ed64b71d14d05e099
new directory structure

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
* Author: Copyright (C) Andrzej Surowiec 2012
3
 
*                                               Parts Rudolf Boeddeker  Date: 2013-08-13
4
 
*
5
 
* This file is part of Nitrokey.
6
 
*
7
 
* Nitrokey 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 3 of the License, or
10
 
* any later version.
11
 
*
12
 
* Nitrokey 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
15
 
* GNU General Public License for more details.
16
 
*
17
 
* You should have received a copy of the GNU General Public License
18
 
* along with Nitrokey. If not, see <http://www.gnu.org/licenses/>.
19
 
*/
20
 
 
21
 
#ifndef MAINWINDOW_H
22
 
#define MAINWINDOW_H
23
 
 
24
 
#include <QMainWindow>
25
 
#include <QSystemTrayIcon>
26
 
#include "device.h"
27
 
 
28
 
 
29
 
#define uint64_t unsigned long long
30
 
 
31
 
#define TRAY_MSG_TIMEOUT    5000
32
 
 
33
 
namespace Ui {
34
 
class MainWindow;
35
 
}
36
 
 
37
 
typedef struct {
38
 
    int  FlagDebug;
39
 
    int  ExtendedConfigActive;
40
 
    int  PasswordMatrix;
41
 
    int  LockHardware;
42
 
    int  Cmd;
43
 
    char *CmdLine;
44
 
} StartUpParameter_tst;
45
 
 
46
 
 
47
 
class MainWindow : public QMainWindow
48
 
{
49
 
    Q_OBJECT
50
 
    
51
 
public:
52
 
    explicit MainWindow(StartUpParameter_tst *StartupInfo_st,QWidget *parent = 0);
53
 
    void startTimer();
54
 
    ~MainWindow();
55
 
 
56
 
    bool DebugWindowActive;
57
 
    bool ExtendedConfigActive;
58
 
    bool MatrixInputActive;
59
 
    bool LockHardware;
60
 
 
61
 
    uint64_t lastTOTPTime;
62
 
 
63
 
    uint64_t lastClipboardTime;
64
 
 
65
 
    uint64_t lastAuthenticateTime;
66
 
 
67
 
    uint64_t lastUserAuthenticateTime;
68
 
 
69
 
    void resetTime();
70
 
 
71
 
protected:
72
 
     void closeEvent(QCloseEvent *event);
73
 
 
74
 
private:
75
 
    Ui::MainWindow *ui;
76
 
    QSystemTrayIcon *trayIcon;
77
 
    QMenu *trayMenu;
78
 
    QMenu *trayMenuSubConfigure;
79
 
    QMenu *trayMenuPasswdSubMenu;
80
 
    QMenu *trayMenuTOTPSubMenu;
81
 
    QMenu *trayMenuHOTPSubMenu;
82
 
    QMenu *trayMenuSubSpecialConfigure;
83
 
    QClipboard *clipboard;
84
 
    QValidator *validator;
85
 
 
86
 
    unsigned char HOTP_SlotCount;
87
 
    unsigned char TOTP_SlotCount;
88
 
 
89
 
    Device *cryptostick;
90
 
    void getSlotNames();
91
 
 
92
 
    int PWS_Access;
93
 
    int PWS_CreatePWSize;
94
 
 
95
 
    uint64_t currentTime;
96
 
    bool     Stick20ScSdCardOnline;
97
 
    bool     CryptedVolumeActive;
98
 
    bool     HiddenVolumeActive;
99
 
    bool     NormalVolumeRWActive;
100
 
    bool     HiddenVolumeAccessable;
101
 
    bool     StickNotInitated;
102
 
    bool     SdCardNotErased;
103
 
    bool     SdCardNotErased_DontAsk;
104
 
    bool     StickNotInitated_DontAsk;
105
 
    bool     set_initial_time;
106
 
 
107
 
    QAction *quitAction;
108
 
    QAction *restoreAction;
109
 
    QAction *resetAction;
110
 
    QAction *restoreActionStick20;
111
 
    QAction *Stick20Action;
112
 
    QAction *DebugAction;
113
 
    QAction *ActionAboutDialog;
114
 
    QAction *SecPasswordAction;
115
 
    QAction *Stick20SetupAction;
116
 
    QAction *Stick10ActionChangeUserPIN;
117
 
    QAction *Stick10ActionChangeAdminPIN;
118
 
    QAction *LockDeviceAction;
119
 
    QAction *UnlockPasswordSafe;
120
 
 
121
 
    QAction *Stick20ActionEnableCryptedVolume;
122
 
    QAction *Stick20ActionDisableCryptedVolume;
123
 
    QAction *Stick20ActionEnableHiddenVolume;
124
 
    QAction *Stick20ActionDisableHiddenVolume;
125
 
    QAction *Stick20ActionChangeUserPIN;
126
 
    QAction *Stick20ActionChangeAdminPIN;
127
 
    QAction *Stick20ActionEnableFirmwareUpdate;
128
 
    QAction *Stick20ActionExportFirmwareToFile;
129
 
    QAction *Stick20ActionDestroyCryptedVolume;
130
 
    QAction *Stick20ActionInitCryptedVolume;
131
 
    QAction *Stick20ActionFillSDCardWithRandomChars;
132
 
    QAction *Stick20ActionGetStickStatus;
133
 
    QAction *Stick20ActionUpdateStickStatus;
134
 
    QAction *Stick20ActionSetReadonlyUncryptedVolume;
135
 
    QAction *Stick20ActionSetReadWriteUncryptedVolume;
136
 
    QAction *Stick20ActionDebugAction;
137
 
    QAction *Stick20ActionSetupHiddenVolume;
138
 
    QAction *Stick20ActionClearNewSDCardFound;
139
 
    QAction *Stick20ActionSetupPasswordMatrix;
140
 
    QAction *Stick20ActionLockStickHardware;
141
 
    QAction *Stick20ActionResetUserPassword;
142
 
 
143
 
    QString DebugText;
144
 
    QString otpInClipboard;
145
 
    QString secretInClipboard;
146
 
 
147
 
 
148
 
    int ExecStickCmd(char *Cmdline);
149
 
 
150
 
    int getNextCode(uint8_t slotNumber);
151
 
 
152
 
    void generatePasswordMenu();
153
 
    void generateMenuForStick10();
154
 
    void initActionsForStick20();
155
 
    int  stick20SendCommand (uint8_t stick20Command, uint8_t *password);
156
 
 
157
 
    //QAction *totp1Action;
158
 
 
159
 
    void generateComboBoxEntrys();
160
 
    void generateMenu();
161
 
    void generateHOTPConfig(HOTPSlot *slot);
162
 
    void generateTOTPConfig(TOTPSlot *slot);
163
 
    void generateAllConfigs();
164
 
 
165
 
    void generateMenuForStick20();
166
 
    int  UpdateDynamicMenuEntrys (void);
167
 
    void AnalyseProductionInfos();
168
 
 
169
 
    void on_pushButton_clicked();           // RB function used ?
170
 
 
171
 
private slots:
172
 
    void checkConnection();
173
 
    void startConfiguration();
174
 
    int factoryReset();
175
 
    void getCode(uint8_t slotNo);
176
 
//    void on_pushButton_clicked();
177
 
//    void on_pushButton_2_clicked();
178
 
    void on_writeButton_clicked();
179
 
    void displayCurrentTotpSlotConfig(uint8_t slotNo);
180
 
    void displayCurrentHotpSlotConfig(uint8_t slotNo);
181
 
    void displayCurrentSlotConfig();
182
 
    void displayCurrentGeneralConfig();
183
 
    void on_slotComboBox_currentIndexChanged(int index);
184
 
//    void on_resetButton_clicked();
185
 
    void on_hexRadioButton_toggled(bool checked);
186
 
    void on_base32RadioButton_toggled(bool checked);
187
 
    void on_setToZeroButton_clicked();
188
 
    void on_setToRandomButton_clicked();
189
 
//    void on_checkBox_2_toggled(bool checked);
190
 
    void on_tokenIDCheckBox_toggled(bool checked);
191
 
    void on_enableUserPasswordCheckBox_toggled(bool checked);
192
 
    void on_writeGeneralConfigButton_clicked();
193
 
 
194
 
    void copyToClipboard(QString text);
195
 
    void checkClipboard_Valid();
196
 
    void checkPasswordTime_Valid();
197
 
    void checkTextEdited();
198
 
 
199
 
    //START - OTP Test Routine --------------------------------
200
 
    /*
201
 
    void on_testHOTPButton_clicked();
202
 
    void on_testTOTPButton_clicked();
203
 
    */
204
 
    //END - OTP Test Routine ----------------------------------
205
 
 
206
 
bool eventFilter (QObject *obj, QEvent *event);
207
 
void iconActivated(QSystemTrayIcon::ActivationReason reason);
208
 
 
209
 
// Functions for password safe
210
 
    void SetupPasswordSafeConfig (void);
211
 
    void generateMenuPasswordSafe();
212
 
    char *PWS_GetSlotName (int Slot);
213
 
    void PWS_ExceClickedSlot (int Slot);
214
 
 
215
 
    void PWS_Clicked_EnablePWSAccess ();
216
 
    void PWS_Clicked_Slot00 ();
217
 
    void PWS_Clicked_Slot01 ();
218
 
    void PWS_Clicked_Slot02 ();
219
 
    void PWS_Clicked_Slot03 ();
220
 
    void PWS_Clicked_Slot04 ();
221
 
    void PWS_Clicked_Slot05 ();
222
 
    void PWS_Clicked_Slot06 ();
223
 
    void PWS_Clicked_Slot07 ();
224
 
    void PWS_Clicked_Slot08 ();
225
 
    void PWS_Clicked_Slot09 ();
226
 
    void PWS_Clicked_Slot10 ();
227
 
    void PWS_Clicked_Slot11 ();
228
 
    void PWS_Clicked_Slot12 ();
229
 
    void PWS_Clicked_Slot13 ();
230
 
    void PWS_Clicked_Slot14 ();
231
 
    void PWS_Clicked_Slot15 ();
232
 
 
233
 
 
234
 
// Functions for OTP
235
 
    void getHOTPDialog (int slot);
236
 
    void getHOTP1();
237
 
    void getHOTP2();
238
 
    void getHOTP3();
239
 
 
240
 
    void getTOTPDialog (int slot);
241
 
    void getTOTP1();
242
 
    void getTOTP2();
243
 
    void getTOTP3();
244
 
    void getTOTP4();
245
 
    void getTOTP5();
246
 
    void getTOTP6();
247
 
    void getTOTP7();
248
 
    void getTOTP8();
249
 
    void getTOTP9();
250
 
    void getTOTP10();
251
 
    void getTOTP11();
252
 
    void getTOTP12();
253
 
    void getTOTP13();
254
 
    void getTOTP14();
255
 
    void getTOTP15();
256
 
    void on_eraseButton_clicked();
257
 
//    void on_resetGeneralConfigButton_clicked();
258
 
    void on_randomSecretButton_clicked();
259
 
    void on_checkBox_toggled(bool checked);
260
 
    
261
 
    void destroyPasswordSafeStick10();
262
 
    void startStick20Configuration();
263
 
    void startStickDebug();
264
 
    void startAboutDialog ();
265
 
    void startMatrixPasswordDialog();
266
 
    void startStick20Setup() ;
267
 
 
268
 
    void startStick10ActionChangeUserPIN();
269
 
    void startStick10ActionChangeAdminPIN();
270
 
 
271
 
    void startStick20EnableCryptedVolume();
272
 
    void startStick20DisableCryptedVolume();
273
 
    void startStick20EnableHiddenVolume();
274
 
    void startStick20DisableHiddenVolume();
275
 
    void startStick20ActionChangeUserPIN ();
276
 
    void startStick20ActionChangeAdminPIN ();
277
 
    void startStick20EnableFirmwareUpdate();
278
 
    void startStick20ExportFirmwareToFile();
279
 
    void startStick20DestroyCryptedVolume();
280
 
    void startStick20FillSDCardWithRandomChars();
281
 
    void startStick20GetStickStatus();
282
 
    void startStick20SetReadonlyUncryptedVolume();
283
 
    void startStick20SetReadWriteUncryptedVolume();
284
 
    void startStick20DebugAction();
285
 
    void startStick20SetupHiddenVolume();
286
 
    void startStick20ClearNewSdCardFound();
287
 
    void startStick20SetupPasswordMatrix();
288
 
    void startStick20LockStickHardware();
289
 
    void startResetUserPassword ();
290
 
    void startLockDeviceAction ();
291
 
 
292
 
    void on_PWS_ButtonClearSlot_clicked();
293
 
    void on_PWS_ComboBoxSelectSlot_currentIndexChanged(int index);
294
 
    void on_PWS_CheckBoxHideSecret_toggled(bool checked);
295
 
    void on_PWS_ButtonClose_pressed();
296
 
    void on_pushButton_GotoTOTP_clicked();
297
 
    void on_pushButton_GotoHOTP_clicked();
298
 
    void on_pushButton_StaticPasswords_clicked();
299
 
    void on_pushButton_GotoGenOTP_clicked();
300
 
    void on_PWS_ButtonCreatePW_clicked();
301
 
    void on_PWS_ButtonSaveSlot_clicked();
302
 
    void on_PWS_ButtonEnable_clicked();
303
 
    void on_counterEdit_editingFinished();
304
 
};
305
 
 
306
 
#endif // MAINWINDOW_H