Ubuntu Download Manager: /build/ubuntu-download-manager-git/src/ubuntu-download-manager/src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp Source File

Ubuntu Download Manager 1.2.0 A session-wide downloading service |

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
24 #include <ubuntu/download_manager/error.h>
25 #include <ubuntu/download_manager/logging/logger.h>
26
27 #include <ubuntu/download_manager/download_pendingcall_watcher.h>
28
29 namespace Ubuntu {
30
31 namespace DownloadManager {
32
33 using namespace Logging;
34
35 DownloadPCW::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
48 void
49 DownloadPCW::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 } // Ubuntu
logger.h
Ubuntu
Definition: download.h:26
Ubuntu::DownloadManager::Logging::Logger::Critical
@ Critical
Definition: logger.h:73
Ubuntu::DownloadManager::Logging::Logger::Error
@ Error
Definition: logger.h:72
download_pendingcall_watcher.h
error.h