tpasswordprovider.h - sailfish-safe - Sailfish frontend for safe(1)
(HTM) git clone git://git.z3bra.org/sailfish-safe.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
tpasswordprovider.h (2282B)
---
1 /*
2 * Copyright (C) 2018 Daniel Vrátil <dvratil@kde.org>
3 * 2021 Willy Goiffon <contact@z3bra.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License as
7 * published by the Free Software Foundation; either version 2, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef PASSWORDPROVIDER_H_
22 #define PASSWORDPROVIDER_H_
23
24 #include <QObject>
25 #include <QTimer>
26
27 class QProcess;
28
29 class PasswordsModel;
30
31 class PasswordProvider : public QObject
32 {
33 Q_OBJECT
34
35 Q_PROPERTY(QString password READ password NOTIFY passwordChanged)
36 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
37 Q_PROPERTY(int timeout READ timeout NOTIFY timeoutChanged)
38 Q_PROPERTY(int defaultTimeout READ defaultTimeout CONSTANT)
39 Q_PROPERTY(bool hasError READ hasError NOTIFY errorChanged)
40 Q_PROPERTY(QString error READ error NOTIFY errorChanged)
41 public:
42 ~PasswordProvider() override;
43
44 QString password() const;
45 bool isValid() const;
46 int timeout() const;
47 int defaultTimeout() const;
48 bool hasError() const;
49 QString error() const;
50
51 public Q_SLOTS:
52 void requestPassword();
53 void cancel();
54 void expirePassword();
55
56 Q_SIGNALS:
57 void passwordChanged();
58 void validChanged();
59 void timeoutChanged();
60 void errorChanged();
61
62 private:
63 void setError(const QString &error);
64 void setPassword(const QString &password);
65
66 void removePasswordFromClipboard(const QString &password);
67 void clearClipboard();
68
69 friend class PasswordsModel;
70 explicit PasswordProvider(const QString &path, QObject *parent = nullptr);
71
72 QString mPath;
73 QString mPassword;
74 QString mError;
75 QTimer mTimer;
76 int mTimeout = 0;
77 };
78
79 #endif