Lomiri Download Manager 0.1.1
A session-wide downloading service
 
Loading...
Searching...
No Matches
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 LOMIRI_DOWNLOADMANAGER_CLIENT_MANAGER_H
20#define LOMIRI_DOWNLOADMANAGER_CLIENT_MANAGER_H
21
22#include <functional>
23#include <QObject>
24#include <lomiri/download_manager/metatypes.h>
25#include <lomiri/download_manager/download_struct.h>
26#include <lomiri/download_manager/group_download_struct.h>
27
28
29namespace Lomiri {
30
31namespace DownloadManager {
32
33class Download;
34class DownloadsList;
35class Error;
36class GroupDownload;
37
42typedef std::function<void(Download*)> DownloadCb;
43
48typedef std::function<void(DownloadsList*)> DownloadsListCb;
49
54typedef std::function<void(const QString&, const QString&, DownloadsList*)> MetadataDownloadsListCb;
55
60typedef std::function<void(GroupDownload*)> GroupCb;
61
80class 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,
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,
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
334 void downloadsWithMetadataFound(const QString& name,
335 const QString& value,
336 DownloadsList* downloads);
337
345
346};
347
348} // DownloadManager
349
350} // Lomiri
351
352#endif // LOMIRI_DOWNLOADMANAGER_CLIENT_MANAGER_H
The Download class allows to control a download that was created in the download manager.
Definition download.h:49
The Error class is the base class that represents an error in the download manager API.
Definition error.h:55
The Manager class is the entry point of the download manager API and allows the client to create down...
Definition manager.h:80
void downloadCreated(Download *down)
virtual void getAllDownloads(const QString &appId, bool uncollected, DownloadsListCb cb, DownloadsListCb errCb)=0
virtual Download * getDownloadForId(const QString &id)=0
virtual void createDownload(DownloadStruct downStruct)=0
virtual void getAllDownloads(const QString &appId, bool uncollected)=0
virtual void setDefaultThrottle(qulonglong speed)=0
virtual void allowMobileDataDownload(bool allowed)=0
virtual void createDownload(DownloadStruct downStruct, DownloadCb cb, DownloadCb errCb)=0
virtual void getAllDownloadsWithMetadata(const QString &name, const QString &value, MetadataDownloadsListCb cb, MetadataDownloadsListCb errCb)=0
virtual void getAllDownloadsWithMetadata(const QString &name, const QString &value)=0
static Manager * createSessionManager(const QString &path="", QObject *parent=0)
Definition manager.cpp:31
virtual void createDownload(StructList downs, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers, GroupCb cb, GroupCb errCb)=0
void downloadsFound(DownloadsList *downloads)
virtual bool isError() const =0
virtual void createDownload(StructList downs, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers)=0
virtual bool isMobileDataDownload()=0
virtual Error * lastError() const =0
Manager(QObject *parent=0)
Definition manager.h:84
void groupCreated(GroupDownload *down)
virtual qulonglong defaultThrottle()=0
void downloadsWithMetadataFound(const QString &name, const QString &value, DownloadsList *downloads)
static Manager * createSystemManager(const QString &path="", QObject *parent=0)
Definition manager.cpp:40
std::function< void(DownloadsList *) DownloadsListCb)
Definition manager.h:48
std::function< void(Download *) DownloadCb)
Definition manager.h:42
std::function< void(GroupDownload *) GroupCb)
Definition manager.h:60
std::function< void(const QString &, const QString &, DownloadsList *) MetadataDownloadsListCb)
Definition manager.h:54