2
* Author: Copyright (C) Andrzej Surowiec 2012
3
* Parts Rudolf Boeddeker Date: 2013-08-13
5
* This file is part of Nitrokey.
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
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.
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/>.
24
#include <QMainWindow>
25
#include <QSystemTrayIcon>
29
#define uint64_t unsigned long long
31
#define TRAY_MSG_TIMEOUT 5000
39
int ExtendedConfigActive;
44
} StartUpParameter_tst;
47
class MainWindow : public QMainWindow
52
explicit MainWindow(StartUpParameter_tst *StartupInfo_st,QWidget *parent = 0);
56
bool DebugWindowActive;
57
bool ExtendedConfigActive;
58
bool MatrixInputActive;
61
uint64_t lastTOTPTime;
63
uint64_t lastClipboardTime;
65
uint64_t lastAuthenticateTime;
67
uint64_t lastUserAuthenticateTime;
72
void closeEvent(QCloseEvent *event);
76
QSystemTrayIcon *trayIcon;
78
QMenu *trayMenuSubConfigure;
79
QMenu *trayMenuPasswdSubMenu;
80
QMenu *trayMenuTOTPSubMenu;
81
QMenu *trayMenuHOTPSubMenu;
82
QMenu *trayMenuSubSpecialConfigure;
83
QClipboard *clipboard;
84
QValidator *validator;
86
unsigned char HOTP_SlotCount;
87
unsigned char TOTP_SlotCount;
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;
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;
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;
144
QString otpInClipboard;
145
QString secretInClipboard;
148
int ExecStickCmd(char *Cmdline);
150
int getNextCode(uint8_t slotNumber);
152
void generatePasswordMenu();
153
void generateMenuForStick10();
154
void initActionsForStick20();
155
int stick20SendCommand (uint8_t stick20Command, uint8_t *password);
157
//QAction *totp1Action;
159
void generateComboBoxEntrys();
161
void generateHOTPConfig(HOTPSlot *slot);
162
void generateTOTPConfig(TOTPSlot *slot);
163
void generateAllConfigs();
165
void generateMenuForStick20();
166
int UpdateDynamicMenuEntrys (void);
167
void AnalyseProductionInfos();
169
void on_pushButton_clicked(); // RB function used ?
172
void checkConnection();
173
void startConfiguration();
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();
194
void copyToClipboard(QString text);
195
void checkClipboard_Valid();
196
void checkPasswordTime_Valid();
197
void checkTextEdited();
199
//START - OTP Test Routine --------------------------------
201
void on_testHOTPButton_clicked();
202
void on_testTOTPButton_clicked();
204
//END - OTP Test Routine ----------------------------------
206
bool eventFilter (QObject *obj, QEvent *event);
207
void iconActivated(QSystemTrayIcon::ActivationReason reason);
209
// Functions for password safe
210
void SetupPasswordSafeConfig (void);
211
void generateMenuPasswordSafe();
212
char *PWS_GetSlotName (int Slot);
213
void PWS_ExceClickedSlot (int Slot);
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 ();
235
void getHOTPDialog (int slot);
240
void getTOTPDialog (int slot);
256
void on_eraseButton_clicked();
257
// void on_resetGeneralConfigButton_clicked();
258
void on_randomSecretButton_clicked();
259
void on_checkBox_toggled(bool checked);
261
void destroyPasswordSafeStick10();
262
void startStick20Configuration();
263
void startStickDebug();
264
void startAboutDialog ();
265
void startMatrixPasswordDialog();
266
void startStick20Setup() ;
268
void startStick10ActionChangeUserPIN();
269
void startStick10ActionChangeAdminPIN();
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 ();
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();
306
#endif // MAINWINDOW_H