File indexing completed on 2024-11-24 04:53:25
0001 /* Copyright (C) 2013 Pali Rohár <pali.rohar@gmail.com> 0002 0003 This file is part of the Trojita Qt IMAP e-mail client, 0004 http://trojita.flaska.net/ 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License as 0008 published by the Free Software Foundation; either version 2 of 0009 the License or (at your option) version 3 or any later version 0010 accepted by the membership of KDE e.V. (or its successor approved 0011 by the membership of KDE e.V.), which shall act as a proxy 0012 defined in Section 14 of version 3 of the license. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #ifndef QTKEYCHAINPASSWORD_H 0024 #define QTKEYCHAINPASSWORD_H 0025 0026 #include <QString> 0027 0028 #include "Plugins/PasswordPlugin.h" 0029 #include "Plugins/PluginInterface.h" 0030 0031 namespace QKeychain 0032 { 0033 class Job; 0034 } 0035 0036 namespace Plugins 0037 { 0038 0039 class QtKeyChainPasswordJob : public PasswordJob 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 enum Type { 0045 Request, 0046 Store, 0047 Delete 0048 }; 0049 0050 QtKeyChainPasswordJob(const QString &accountId, const QString &accountType, const QString &password, enum Type type, QObject *parent); 0051 0052 public slots: 0053 virtual void doStart(); 0054 virtual void doStop(); 0055 0056 private slots: 0057 void result(); 0058 0059 private: 0060 QString m_accountId, m_accountType, m_password; 0061 enum Type m_type; 0062 QKeychain::Job *m_job; 0063 }; 0064 0065 class QtKeyChainPassword : public PasswordPlugin 0066 { 0067 Q_OBJECT 0068 0069 public: 0070 QtKeyChainPassword(QObject *parent); 0071 virtual Features features() const; 0072 0073 public slots: 0074 virtual PasswordJob *requestPassword(const QString &accountId, const QString &accountType); 0075 virtual PasswordJob *storePassword(const QString &accountId, const QString &accountType, const QString &password); 0076 virtual PasswordJob *deletePassword(const QString &accountId, const QString &accountType); 0077 }; 0078 0079 } 0080 0081 class trojita_plugin_QtKeyChainPasswordPlugin : public QObject, public Plugins::PasswordPluginInterface 0082 { 0083 Q_OBJECT 0084 Q_INTERFACES(Plugins::PasswordPluginInterface) 0085 Q_PLUGIN_METADATA(IID "net.flaska.trojita.plugins.password.qtkeychain") 0086 0087 public: 0088 QString name() const override; 0089 QString description() const override; 0090 Plugins::PasswordPlugin *create(QObject *parent, QSettings *) override; 0091 }; 0092 0093 #endif //QTKEYCHAINPASSWORD_H 0094 0095 // vim: set et ts=4 sts=4 sw=4