1 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net> 2 3 This file is part of the Trojita Qt IMAP e-mail client, 4 http://trojita.flaska.net/ 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License as 8 published by the Free Software Foundation; either version 2 of 9 the License or (at your option) version 3 or any later version 10 accepted by the membership of KDE e.V. (or its successor approved 11 by the membership of KDE e.V.), which shall act as a proxy 12 defined in Section 14 of version 3 of the license. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef TROJITA_UIUTILS_PASSWORDWATCHER_H 24 #define TROJITA_UIUTILS_PASSWORDWATCHER_H 25 26 #include <QObject> 27 #include "Plugins/PasswordPlugin.h" 28 29 namespace Plugins { 30 class PluginManager; 31 } 32 33 namespace UiUtils { 34 35 /** @short Process password requests from plugins */ 36 class PasswordWatcher: public QObject 37 { 38 Q_OBJECT 39 40 Q_PROPERTY(bool isStorageEncrypted READ isStorageEncrypted NOTIFY backendMaybeChanged) 41 Q_PROPERTY(bool isWaitingForPlugin READ isWaitingForPlugin NOTIFY stateChanged) 42 Q_PROPERTY(bool isPluginAvailable READ isPluginAvailable NOTIFY stateChanged) 43 Q_PROPERTY(QString progressMessage READ progressMessage NOTIFY stateChanged) 44 Q_PROPERTY(QString password READ password NOTIFY stateChanged) 45 Q_PROPERTY(bool didReadOk READ didReadOk NOTIFY stateChanged) 46 Q_PROPERTY(bool didWriteOk READ didWriteOk NOTIFY stateChanged) 47 48 public: 49 PasswordWatcher(QObject *parent, Plugins::PluginManager *manager, const QString &accountName, const QString &accountType); 50 51 bool isStorageEncrypted() const; 52 bool isWaitingForPlugin() const; 53 bool isPluginAvailable() const; 54 bool didReadOk() const; 55 bool didWriteOk() const; 56 QString progressMessage() const; 57 QString password() const; 58 59 public slots: 60 void reloadPassword(); 61 void setPassword(const QString &password); 62 63 private slots: 64 void passwordRetrieved(const QString &password); 65 void passwordReadingFailed(const Plugins::PasswordJob::Error errorCode, const QString &errorMessage); 66 void passwordWritten(); 67 void passwordWritingFailed(const Plugins::PasswordJob::Error errorCode, const QString &errorMessage); 68 69 signals: 70 void backendMaybeChanged(); 71 void stateChanged(); 72 void readingFailed(const QString &message); 73 void savingFailed(const QString &message); 74 void readingDone(); 75 void savingDone(); 76 77 private: 78 Plugins::PluginManager *m_manager; 79 bool m_isStorageEncrypted; 80 int m_pendingActions; 81 bool m_didReadOk; 82 bool m_didWriteOk; 83 84 85 QString m_accountName; 86 QString m_accountType; 87 QString m_progressMessage; 88 QString m_password; 89 90 }; 91 92 } 93 94 #endif // TROJITA_UIUTILS_PASSWORDWATCHER_H 95