| 1 | /* |
| 2 | * This file is part of libOnlineAccounts |
| 3 | * |
| 4 | * Copyright (C) 2015 Canonical Ltd. |
| 5 | * |
| 6 | * Contact: Alberto Mardegan <[email protected]> |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU Lesser General Public License version 3, as |
| 10 | * published 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 Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "pending_call_p.h" |
| 22 | |
| 23 | #include <QDBusPendingCallWatcher> |
| 24 | |
| 25 | using namespace OnlineAccounts; |
| 26 | |
| 27 | PendingCallPrivate::PendingCallPrivate(Manager *manager, |
| 28 | const QDBusPendingCall &call, |
| 29 | InvokedMethod method, |
| 30 | AuthenticationMethod authMethod): |
| 31 | m_manager(manager), |
| 32 | m_call(call), |
| 33 | m_invokedMethod(method), |
| 34 | m_authenticationMethod(authMethod) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | PendingCall::PendingCall(PendingCallPrivate *priv): |
| 39 | d(priv) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | PendingCall::PendingCall(const PendingCall &other): |
| 44 | d(other.d) |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | PendingCall::~PendingCall() |
| 49 | { |
| 50 | } |
| 51 | |
| 52 | PendingCall &PendingCall::operator=(const PendingCall &other) |
| 53 | { |
| 54 | d = other.d; |
| 55 | return *this; |
| 56 | } |
| 57 | |
| 58 | bool PendingCall::isFinished() const |
| 59 | { |
| 60 | return d->m_call.isFinished(); |
| 61 | } |
| 62 | |
| 63 | void PendingCall::waitForFinished() |
| 64 | { |
| 65 | d->m_call.waitForFinished(); |
| 66 | } |
| 67 | |
| 68 | namespace OnlineAccounts { |
| 69 | |
| 70 | class PendingCallWatcherPrivate |
| 71 | { |
| 72 | public: |
| 73 | PendingCallWatcherPrivate(PendingCallWatcher *q); |
| 74 | |
| 75 | private: |
| 76 | QDBusPendingCallWatcher m_watcher; |
| 77 | }; |
| 78 | |
| 79 | } // namespace |
| 80 | |
| 81 | PendingCallWatcherPrivate::PendingCallWatcherPrivate(PendingCallWatcher *q): |
| 82 | m_watcher(q->d->dbusCall()) |
| 83 | { |
| 84 | QObject::connect(&m_watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), |
| 85 | q, SIGNAL(finished())); |
| 86 | } |
| 87 | |
| 88 | PendingCallWatcher::PendingCallWatcher(const PendingCall &call, |
| 89 | QObject *parent): |
| 90 | QObject(parent), |
| 91 | PendingCall(call), |
| 92 | d_ptr(new PendingCallWatcherPrivate(this)) |
| 93 | { |
| 94 | } |
| 95 | |
| 96 | PendingCallWatcher::~PendingCallWatcher() |
| 97 | { |
| 98 | } |