1 /*
2  * Author: Copyright (C) Rudolf Boeddeker  Date: 2013-08-13
3  * Copyright (c) 2013-2018 Nitrokey UG
4  *
5  * This file is part of Nitrokey App.
6  *
7  * Nitrokey App 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 App 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 App. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * SPDX-License-Identifier: GPL-3.0
21  */
22 
23 
24 #ifndef DIALOGCHANGEPASSWORD_H
25 #define DIALOGCHANGEPASSWORD_H
26 
27  enum class PasswordKind {
28      USER,
29      ADMIN,
30      RESET_USER,
31      UPDATE
32  };
33 
34 #include <QDialog>
35 
36 namespace Ui {
37 class DialogChangePassword;
38 }
39 
40 class DialogChangePassword : public QDialog {
41   Q_OBJECT
42   public :
43   // FIXME extract constant to global config
44     const static int minimumPasswordLengthUser = 6;
45     const static int minimumPasswordLengthAdmin = 8;
46     const static int minimumPasswordLengthFirmware = 8;
47     const static int maximumPasswordLengthFirmware = 20;
48     static constexpr auto defaultFirmwarePassword = "12345678";
49     int minimumPasswordLength = {};
50 
51   explicit DialogChangePassword(QWidget *parent, PasswordKind _kind);
52     ~DialogChangePassword();
53 
54     void InitData(void);
55     virtual int exec() override;
56 //
57   signals:
58     void UserPinLocked();
59 //    void error(int errcode);
60 
61 private slots:
62   void on_checkBox_clicked(bool checked);
63 
64 private:
65   Ui::DialogChangePassword *ui;
66   PasswordKind kind;
67   void _changePassword();
68   void accept(void) override;
69   void UpdatePasswordRetry(void);
70   void clearFields();
71   void fixWindowGeometry();
72   void UI_deviceNotInitialized() const;
73   void moveWindowToCenter();
74 };
75 
76 #endif // DIALOGCHANGEPASSWORD_H
77