Ubuntu Download Manager  1.2.0
A session-wide downloading service
manager_pendingcall_watcher.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 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 #ifndef UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_PENDINGCALL_WATCHER_H
20 #define UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_PENDINGCALL_WATCHER_H
21 
22 #include <ubuntu/transfers/visibility.h>
23 #include <functional>
24 #include "pending_call_watcher.h"
25 
26 namespace Ubuntu {
27 
28 namespace DownloadManager {
29 
30 class Download;
31 class DownloadsList;
32 class Error;
33 class GroupDownload;
34 
35 typedef std::function<void(Download*)> DownloadCb;
36 typedef std::function<void(DownloadsList*)> DownloadsListCb;
37 typedef std::function<void(const QString&, const QString&, DownloadsList*)> MetadataDownloadsListCb;
38 typedef std::function<void(GroupDownload*)> GroupCb;
39 
40 
41 class UBUNTU_TRANSFERS_PRIVATE DownloadManagerPCW : public PendingCallWatcher {
42  Q_OBJECT
43 
44  public:
45  DownloadManagerPCW(const QDBusConnection& conn,
46  const QString& servicePath,
47  const QDBusPendingCall& call,
48  DownloadCb cb,
49  DownloadCb errCb,
50  QObject* parent = 0);
51 
52  private slots:
53  void onFinished(QDBusPendingCallWatcher* watcher);
54 
55  private:
56  DownloadCb _cb;
57  DownloadCb _errCb;
58 };
59 
60 
61 class UBUNTU_TRANSFERS_PRIVATE DownloadsListManagerPCW : public PendingCallWatcher {
62  Q_OBJECT
63 
64  public:
65  DownloadsListManagerPCW(const QDBusConnection& conn,
66  const QString& servicePath,
67  const QDBusPendingCall& call,
68  DownloadsListCb cb,
69  DownloadsListCb errCb,
70  QObject* parent = 0);
71  private slots:
72  void onFinished(QDBusPendingCallWatcher* watcher);
73 
74  private:
75  DownloadsListCb _cb;
76  DownloadsListCb _errCb;
77 };
78 
79 class UBUNTU_TRANSFERS_PRIVATE MetadataDownloadsListManagerPCW : public PendingCallWatcher {
80  Q_OBJECT
81 
82  public:
83  MetadataDownloadsListManagerPCW(const QDBusConnection& conn,
84  const QString& servicePath,
85  const QDBusPendingCall& call,
86  const QString& key,
87  const QString& value,
88  MetadataDownloadsListCb cb,
89  MetadataDownloadsListCb errCb,
90  QObject* parent = 0);
91  private slots:
92  void onFinished(QDBusPendingCallWatcher* watcher);
93 
94  private:
95  const QString& _key;
96  const QString& _value;
97  MetadataDownloadsListCb _cb;
98  MetadataDownloadsListCb _errCb;
99 };
100 
101 class UBUNTU_TRANSFERS_PRIVATE GroupManagerPCW : public PendingCallWatcher {
102  Q_OBJECT
103 
104  public:
105  GroupManagerPCW(const QDBusConnection& conn,
106  const QString& servicePath,
107  const QDBusPendingCall& call,
108  GroupCb cb,
109  GroupCb errCb,
110  QObject* parent = 0);
111 
112  private slots:
113  void onFinished(QDBusPendingCallWatcher* watcher);
114 
115  private:
116  GroupCb _cb;
117  GroupCb _errCb;
118 };
119 
120 } // DownloadManager
121 
122 } // Ubuntu
123 
124 #endif // UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_PENDINGCALL_WATCHER_H
std::function< void(Download *)> DownloadCb
Definition: manager.h:36
std::function< void(const QString &, const QString &, DownloadsList *)> MetadataDownloadsListCb
Definition: manager.h:54
std::function< void(GroupDownload *)> GroupCb
Definition: manager.h:60
std::function< void(DownloadsList *)> DownloadsListCb
Definition: manager.h:48