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

Ubuntu Download Manager 1.2.0 A session-wide downloading service |

manager.h
Go to the documentation of this file.
1 /*
2 * Copyright 2013-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 #ifndef UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_H
20 #define UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_H
21
22 #include <functional>
23 #include <QObject>
24 #include <ubuntu/download_manager/metatypes.h>
25 #include <ubuntu/download_manager/download_struct.h>
26 #include <ubuntu/download_manager/group_download_struct.h>
27
28
29 namespace Ubuntu {
30
31 namespace DownloadManager {
32
33 class Download;
34 class DownloadsList;
35 class Error;
36 class GroupDownload;
37
42 typedef std::function<void(Download*)> DownloadCb;
43
48 typedef std::function<void(DownloadsList*)> DownloadsListCb;
49
54 typedef std::function<void(const QString&, const QString&, DownloadsList*)> MetadataDownloadsListCb;
55
60 typedef std::function<void(GroupDownload*)> GroupCb;
61
80 class Manager : public QObject {
81 Q_OBJECT
82
83 public:
84 explicit Manager(QObject* parent = 0)
85 : QObject(parent) {}
86
94 virtual Download* getDownloadForId(const QString& id) = 0;
95
107 virtual void createDownload(DownloadStruct downStruct) = 0;
108
124 virtual void createDownload(DownloadStruct downStruct,
125 DownloadCb cb,
126 DownloadCb errCb) = 0;
127
139 virtual void createDownload(StructList downs,
140 const QString& algorithm,
141 bool allowed3G,
142 const QVariantMap& metadata,
143 StringMap headers) = 0;
144
160 virtual void createDownload(StructList downs,
161 const QString& algorithm,
162 bool allowed3G,
163 const QVariantMap& metadata,
164 StringMap headers,
165 GroupCb cb,
166 GroupCb errCb) = 0;
181 virtual void getAllDownloads(const QString& appId, bool uncollected) = 0;
182
197 virtual void getAllDownloads(const QString& appId,
198 bool uncollected,
199 DownloadsListCb cb,
200 DownloadsListCb errCb) = 0;
211 virtual void getAllDownloadsWithMetadata(const QString &name,
212 const QString &value) = 0;
225 virtual void getAllDownloadsWithMetadata(const QString &name,
226 const QString &value,
227 MetadataDownloadsListCb cb,
228 MetadataDownloadsListCb errCb) = 0;
229
235 virtual bool isError() const = 0;
236
243 virtual Error* lastError() const = 0;
244
255 virtual void allowMobileDataDownload(bool allowed) = 0;
256
263 virtual bool isMobileDataDownload() = 0;
264
271 virtual qulonglong defaultThrottle() = 0;
272
282 virtual void setDefaultThrottle(qulonglong speed) = 0;
283
294 virtual void exit() = 0;
295
308 static Manager* createSessionManager(const QString& path = "", QObject* parent=0);
309
322 static Manager* createSystemManager(const QString& path = "", QObject* parent=0);
323
324 signals:
325
332 void downloadCreated(Download* down);
333 void downloadsFound(DownloadsList* downloads);
334 void downloadsWithMetadataFound(const QString& name,
335 const QString& value,
336 DownloadsList* downloads);
337
344 void groupCreated(GroupDownload* down);
345
346 };
347
348 } // DownloadManager
349
350 } // Ubuntu
351
352 #endif // UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_H
Ubuntu::DownloadManager::DownloadCb
std::function< void(Download *)> DownloadCb
Definition: manager.h:36
Ubuntu::DownloadManager::Manager::createSystemManager
static Manager * createSystemManager(const QString &path="", QObject *parent=0)
Definition: manager.cpp:40
QObject
Ubuntu::DownloadManager::Manager::allowMobileDataDownload
virtual void allowMobileDataDownload(bool allowed)=0
Ubuntu::DownloadManager::Manager::getAllDownloadsWithMetadata
virtual void getAllDownloadsWithMetadata(const QString &name, const QString &value)=0
Ubuntu::DownloadManager::Manager::exit
virtual void exit()=0
Ubuntu::DownloadManager::Manager::getAllDownloads
virtual void getAllDownloads(const QString &appId, bool uncollected)=0
Ubuntu::DownloadManager::Download
The Download class allows to control a download that was created in the download manager.
Definition: download.h:49
Ubuntu
Definition: download.h:26
Ubuntu::DownloadManager::Manager::Manager
Manager(QObject *parent=0)
Definition: manager.h:84
Ubuntu::DownloadManager::MetadataDownloadsListCb
std::function< void(const QString &, const QString &, DownloadsList *)> MetadataDownloadsListCb
Definition: manager.h:54
Ubuntu::DownloadManager::DownloadsList
Definition: downloads_list.h:33
Ubuntu::DownloadManager::Manager::setDefaultThrottle
virtual void setDefaultThrottle(qulonglong speed)=0
Ubuntu::DownloadManager::Manager::downloadCreated
void downloadCreated(Download *down)
Definition: moc_manager.cpp:172
Ubuntu::DownloadManager::Manager::isMobileDataDownload
virtual bool isMobileDataDownload()=0
Ubuntu::DownloadManager::Manager::createDownload
virtual void createDownload(StructList downs, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers, GroupCb cb, GroupCb errCb)=0
Ubuntu::DownloadManager::Manager::createDownload
virtual void createDownload(DownloadStruct downStruct)=0
Ubuntu::DownloadManager::Manager
The Manager class is the entry point of the download manager API and allows the client to create down...
Definition: manager.h:80
Ubuntu::DownloadManager::Manager::createSessionManager
static Manager * createSessionManager(const QString &path="", QObject *parent=0)
Definition: manager.cpp:31
Ubuntu::DownloadManager::Manager::getDownloadForId
virtual Download * getDownloadForId(const QString &id)=0
Ubuntu::DownloadManager::Manager::createDownload
virtual void createDownload(DownloadStruct downStruct, DownloadCb cb, DownloadCb errCb)=0
Ubuntu::DownloadManager::Manager::getAllDownloads
virtual void getAllDownloads(const QString &appId, bool uncollected, DownloadsListCb cb, DownloadsListCb errCb)=0
Ubuntu::DownloadManager::GroupCb
std::function< void(GroupDownload *)> GroupCb
Definition: manager.h:60
Ubuntu::DownloadManager::Manager::createDownload
virtual void createDownload(StructList downs, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers)=0
Ubuntu::DownloadManager::Manager::downloadsFound
void downloadsFound(DownloadsList *downloads)
Definition: moc_manager.cpp:179
Ubuntu::DownloadManager::Manager::defaultThrottle
virtual qulonglong defaultThrottle()=0
Ubuntu::DownloadManager::Error
The Error class is the base class that represents an error in the download manager API.
Definition: error.h:55
Ubuntu::DownloadManager::DownloadsListCb
std::function< void(DownloadsList *)> DownloadsListCb
Definition: manager.h:48
Ubuntu::DownloadManager::Manager::downloadsWithMetadataFound
void downloadsWithMetadataFound(const QString &name, const QString &value, DownloadsList *downloads)
Definition: moc_manager.cpp:186
Ubuntu::DownloadManager::Manager::getAllDownloadsWithMetadata
virtual void getAllDownloadsWithMetadata(const QString &name, const QString &value, MetadataDownloadsListCb cb, MetadataDownloadsListCb errCb)=0
Ubuntu::DownloadManager::Manager::lastError
virtual Error * lastError() const =0
Ubuntu::DownloadManager::Manager::groupCreated
void groupCreated(GroupDownload *down)
Definition: moc_manager.cpp:193
Ubuntu::DownloadManager::GroupDownload
Definition: group_download.h:32
Ubuntu::DownloadManager::Manager::isError
virtual bool isError() const =0