| 1 | /* |
| 2 | * Copyright (C) 2013 Canonical Ltd. |
| 3 | * |
| 4 | * Contact: Alberto Mardegan <[email protected]> |
| 5 | * |
| 6 | * This file is part of lomiri-online-accounts-ui |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License version 3, as published |
| 10 | * by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #ifndef OAU_REQUEST_H |
| 22 | #define OAU_REQUEST_H |
| 23 | |
| 24 | #include <QObject> |
| 25 | #include <QVariantMap> |
| 26 | #include <QWindow> |
| 27 | |
| 28 | namespace OnlineAccountsUi { |
| 29 | |
| 30 | class RequestPrivate; |
| 31 | class Request: public QObject |
| 32 | { |
| 33 | Q_OBJECT |
| 34 | |
| 35 | public: |
| 36 | static Request *newRequest(const QString &interface, |
| 37 | int id, |
| 38 | const QString &clientProfile, |
| 39 | const QVariantMap ¶meters, |
| 40 | QObject *parent = 0); |
| 41 | ~Request(); |
| 42 | |
| 43 | static Request *find(const QVariantMap &match); |
| 44 | |
| 45 | QString interface() const; |
| 46 | int id() const; |
| 47 | WId windowId() const; |
| 48 | bool isInProgress() const; |
| 49 | const QVariantMap ¶meters() const; |
| 50 | QString clientApparmorProfile() const; |
| 51 | QWindow *window() const; |
| 52 | |
| 53 | QVariantMap result() const; |
| 54 | QString errorName() const; |
| 55 | QString errorMessage() const; |
| 56 | int delay() const; |
| 57 | |
| 58 | public Q_SLOTS: |
| 59 | virtual void start(); |
| 60 | void cancel(); |
| 61 | |
| 62 | Q_SIGNALS: |
| 63 | void completed(); |
| 64 | |
| 65 | protected: |
| 66 | explicit Request(const QString &interface, |
| 67 | int id, |
| 68 | const QString &clientProfile, |
| 69 | const QVariantMap ¶meters, |
| 70 | QObject *parent = 0); |
| 71 | virtual void setWindow(QWindow *window); |
| 72 | void setDelay(int delay); |
| 73 | |
| 74 | QString mountPoint() const; |
| 75 | |
| 76 | protected Q_SLOTS: |
| 77 | void fail(const QString &name, const QString &message); |
| 78 | virtual void setCanceled(); |
| 79 | void setResult(const QVariantMap &result); |
| 80 | |
| 81 | private: |
| 82 | RequestPrivate *d_ptr; |
| 83 | Q_DECLARE_PRIVATE(Request) |
| 84 | }; |
| 85 | |
| 86 | } // namespace |
| 87 | |
| 88 | #endif // OAU_REQUEST_H |