Lomiri Download Manager 0.1.1
A session-wide downloading service
 
Loading...
Searching...
No Matches
download_pendingcall_watcher.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#include <QDBusPendingReply>
20
21#include <boost/log/sources/record_ostream.hpp>
22#include <boost/log/sources/severity_feature.hpp>
23
26
28
29namespace Lomiri {
30
31namespace DownloadManager {
32
33using namespace Logging;
34
35DownloadPCW::DownloadPCW(const QDBusConnection& conn,
36 const QString& servicePath,
37 const QDBusPendingCall& call,
38 Download* parent)
39 : PendingCallWatcher(conn, servicePath, call, parent) {
40 auto connected = connect(this, &DownloadPCW::finished,
41 this, &DownloadPCW::onFinished);
42 if (!connected) {
43 Logger::log(Logger::Critical,
44 "Could not connect to signal &DownloadPCW::finished");
45 }
46}
47
48void
49DownloadPCW::onFinished(QDBusPendingCallWatcher* watcher) {
50 auto down = qobject_cast<Download*>(parent());
51 QDBusPendingReply<> reply = *watcher;
52 if (reply.isError()) {
53 auto dbusErr = reply.error();
54 Logger::log(Logger::Error,
55 QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message()));
56 auto err = new DBusError(reply.error());
57 down->error(err);
58 }
59 watcher->deleteLater();
60}
61
62} // DownloadManager
63
64} // Lomiri