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 PASSWORD_INTERFACE
0024 #define PASSWORD_INTERFACE
0025 
0026 #include <QObject>
0027 #include <QString>
0028 
0029 #include "PluginJob.h"
0030 
0031 namespace Plugins
0032 {
0033 
0034 class PLUGINMANAGER_EXPORT PasswordJob : public PluginJob
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039     /** @short Error emitted by error signal */
0040     enum Error {
0041         UnknownError, /**< Unknown error */
0042         Stopped, /**< Emitted when job stopped */
0043         NoSuchPassword /**< Emitted when password is not available */
0044     };
0045 
0046 signals:
0047     /** @short Emitted when password is available */
0048     void passwordAvailable(const QString &password);
0049 
0050     /** @short Emitted when job finish storing password */
0051     void passwordStored();
0052 
0053     /** @short Emitted when job finish deleting password */
0054     void passwordDeleted();
0055 
0056     /** @short Emitted when job finish unsuccessful with error */
0057     void error(const Plugins::PasswordJob::Error error, const QString &errorMessage);
0058 
0059 protected:
0060     PasswordJob(QObject *parent);
0061 };
0062 
0063 class PLUGINMANAGER_EXPORT PasswordPlugin : public QObject
0064 {
0065     Q_OBJECT
0066 
0067 public:
0068     /** @short Features returned by method features */
0069     enum Feature {
0070         FeatureEncryptedStorage = 1 << 0 /**< Plugin using encrypted storage */
0071     };
0072 
0073     Q_DECLARE_FLAGS(Features, Feature)
0074 
0075     /** @short Return implementation features */
0076     virtual Features features() const = 0;
0077 
0078 public slots:
0079     /** @short Request password associated with accountId and accountType and return PasswordJob */
0080     virtual PasswordJob *requestPassword(const QString &accountId, const QString &accountType) = 0;
0081 
0082     /** @short Save password for accountId and accountType and return PasswordJob */
0083     virtual PasswordJob *storePassword(const QString &accountId, const QString &accountType, const QString &password) = 0;
0084 
0085     /** @short Delete password for accountId and accountType and return PasswordJob */
0086     virtual PasswordJob *deletePassword(const QString &accountId, const QString &accountType) = 0;
0087 
0088 protected:
0089     PasswordPlugin(QObject *parent);
0090 };
0091 
0092 Q_DECLARE_OPERATORS_FOR_FLAGS(PasswordPlugin::Features)
0093 
0094 }
0095 
0096 #endif //PASSWORD_INTERFACE
0097 
0098 // vim: set et ts=4 sts=4 sw=4