Ubuntu Download Manager  0.3.0
A session-wide downloading service
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator
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 <QDebug>
20 #include <QDBusPendingReply>
21 #include <glog/logging.h>
22 #include "error.h"
24 
25 namespace Ubuntu {
26 
27 namespace DownloadManager {
28 
29 DownloadPCW::DownloadPCW(
30  const QDBusConnection& conn,
31  const QString& servicePath,
32  const QDBusPendingCall& call,
33  Download* parent)
34  : PendingCallWatcher(conn, servicePath, call, parent) {
35  CHECK(connect(this, &DownloadPCW::finished,
36  this, &DownloadPCW::onFinished))
37  << "Could not connect to signal";
38 }
39 
40 void
41 DownloadPCW::onFinished(QDBusPendingCallWatcher* watcher) {
42  auto down = qobject_cast<Download*>(parent());
43  QDBusPendingReply<> reply = *watcher;
44  if (reply.isError()) {
45  qDebug() << "ERROR" << reply.error() << reply.error().type();
46  auto err = new DBusError(reply.error());
47  down->error(err);
48  }
49  watcher->deleteLater();
50 }
51 
52 } // DownloadManager
53 
54 } // Ubuntu