| 1 | /* |
| 2 | This file is part of KDE. |
| 3 | |
| 4 | SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org> |
| 5 | SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us> |
| 6 | |
| 7 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 8 | */ |
| 9 | |
| 10 | #ifndef ATTICA_PLATFORMDEPENDENT_H |
| 11 | #define ATTICA_PLATFORMDEPENDENT_H |
| 12 | |
| 13 | #include <QList> |
| 14 | #include <QtPlugin> |
| 15 | |
| 16 | class QByteArray; |
| 17 | class QIODevice; |
| 18 | class QNetworkAccessManager; |
| 19 | class QNetworkReply; |
| 20 | class QNetworkRequest; |
| 21 | class QString; |
| 22 | class QUrl; |
| 23 | |
| 24 | namespace Attica |
| 25 | { |
| 26 | class PlatformDependent |
| 27 | { |
| 28 | public: |
| 29 | virtual ~PlatformDependent() |
| 30 | { |
| 31 | } |
| 32 | virtual QList<QUrl> getDefaultProviderFiles() const = 0; |
| 33 | virtual void addDefaultProviderFile(const QUrl &url) = 0; |
| 34 | virtual void removeDefaultProviderFile(const QUrl &url) = 0; |
| 35 | |
| 36 | /*! |
| 37 | * Providers are enabled by default. Use this call to disable or enable them later. |
| 38 | */ |
| 39 | virtual void enableProvider(const QUrl &baseUrl, bool enabled) const = 0; |
| 40 | virtual bool isEnabled(const QUrl &baseUrl) const = 0; |
| 41 | |
| 42 | /*! |
| 43 | * Asks the PlatformDependent plugin if it have a credentials for baseUrl |
| 44 | */ |
| 45 | virtual bool hasCredentials(const QUrl &baseUrl) const = 0; |
| 46 | |
| 47 | /*! |
| 48 | * Asks the PlatformDependent plugin to load credentials from storage, |
| 49 | * and save it in user, password. |
| 50 | */ |
| 51 | virtual bool loadCredentials(const QUrl &baseUrl, QString &user, QString &password) = 0; |
| 52 | |
| 53 | /*! |
| 54 | * Asks the PlatformDependent plugin to ask user to login and expects it to be stored in |
| 55 | * user and password. |
| 56 | * TODO KF6: Remove, askForCredentials and loadCredentials is essentially same, loadCredentials |
| 57 | * can itself ask for credentials if it is not present in store. |
| 58 | */ |
| 59 | virtual bool askForCredentials(const QUrl &baseUrl, QString &user, QString &password) = 0; |
| 60 | |
| 61 | /*! |
| 62 | * Method to be called by attica to store the user and password in storage used by PlatformDependent |
| 63 | * plugin. |
| 64 | * TODO KF6: Remove, if you let platform plugin ask for credentials, you don't want to save credentials |
| 65 | * yourself and let plugin handle it. |
| 66 | */ |
| 67 | virtual bool saveCredentials(const QUrl &baseUrl, const QString &user, const QString &password) = 0; |
| 68 | |
| 69 | virtual QNetworkReply *get(const QNetworkRequest &request) = 0; |
| 70 | virtual QNetworkReply *post(const QNetworkRequest &request, QIODevice *data) = 0; |
| 71 | virtual QNetworkReply *post(const QNetworkRequest &request, const QByteArray &data) = 0; |
| 72 | virtual void setNam(QNetworkAccessManager *) |
| 73 | { |
| 74 | } |
| 75 | virtual QNetworkAccessManager *nam() = 0; |
| 76 | }; |
| 77 | |
| 78 | } |
| 79 | |
| 80 | Q_DECLARE_INTERFACE(Attica::PlatformDependent, "org.kde.Attica.Internals/1.2" ) |
| 81 | |
| 82 | #endif |
| 83 | |