Ubuntu Download Manager  1.2.0
A session-wide downloading service
download.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_DOWNLOAD_H
20 #define UBUNTU_DOWNLOADMANAGER_CLIENT_DOWNLOAD_H
21 
22 #include <QObject>
23 #include <QVariantMap>
24 #include <QString>
25 
26 namespace Ubuntu {
27 
28 namespace DownloadManager {
29 
30 class Error;
31 
49 class Download : public QObject {
50  Q_OBJECT
51  Q_PROPERTY(QString ClickPackage READ clickPackage NOTIFY clickPackagedChanged)
53  Q_PROPERTY(QString Title READ title NOTIFY titleChanged)
54  Q_PROPERTY(QString DownloadOwner READ destinationApp NOTIFY destinationAppChanged)
55 
56  public:
57  explicit Download(QObject* parent = 0)
58  : QObject(parent) {}
59 
60  enum State {
69  };
70 
84  virtual void start() = 0;
85 
92  virtual void pause() = 0;
93 
101  virtual void resume() = 0;
102 
109  virtual void cancel() = 0;
110 
118  virtual void collected() = 0;
119 
129  virtual void allowMobileDownload(bool allowed) = 0;
130 
137  virtual bool isMobileDownloadAllowed() = 0;
138 
146  virtual void setDestinationDir(const QString& path) = 0;
147 
156  virtual void setHeaders(QMap<QString, QString> headers) = 0;
157 
164  virtual void setMetadata(QVariantMap map) = 0;
165 
173  virtual QMap<QString, QString> headers() = 0;
174 
182  virtual void setThrottle(qulonglong speed) = 0;
183 
190  virtual qulonglong throttle() = 0;
191 
198  virtual QString id() const = 0;
199 
206  virtual QVariantMap metadata() = 0;
207 
213  virtual qulonglong progress() = 0;
214 
222  virtual qulonglong totalSize() = 0;
223 
230  virtual QString filePath() = 0;
231 
237  virtual State state() = 0;
238 
244  virtual bool isError() const = 0;
245 
251  virtual Error* error() const = 0;
252 
261  virtual QString clickPackage() const = 0;
262 
271  virtual bool showInIndicator() const = 0;
272 
281  virtual QString title() const = 0;
282 
289  virtual QString destinationApp() const = 0;
290 
291  signals:
292 
299  void canceled(bool success);
300 
309  void error(Error* error);
310 
318  void finished(const QString& path);
319 
326  void paused(bool success);
327 
334  void processing(const QString &path);
335 
350  void progress(qulonglong received, qulonglong total);
351 
358  void resumed(bool success);
359 
366  void started(bool success);
367 
374  void clickPackagedChanged();
375 
382  void showInIndicatorChanged();
383 
384 
391  void titleChanged();
392 
399  void destinationAppChanged();
400 
401 };
402 
403 } // Ubuntu
404 
405 } // DownloadManager
406 
407 #endif
virtual QString destinationApp() const =0
The Error class is the base class that represents an error in the download manager API...
Definition: error.h:55
virtual void setMetadata(QVariantMap map)=0
void finished(const QString &path)
virtual void setDestinationDir(const QString &path)=0
virtual bool showInIndicator() const =0
virtual bool isError() const =0
virtual QString clickPackage() const =0
virtual QMap< QString, QString > headers()=0
virtual void setThrottle(qulonglong speed)=0
virtual QVariantMap metadata()=0
The Download class allows to control a download that was created in the download manager.
Definition: download.h:49
virtual QString title() const =0
virtual qulonglong totalSize()=0
virtual void setHeaders(QMap< QString, QString > headers)=0
virtual QString id() const =0
void processing(const QString &path)
virtual Error * error() const =0
virtual bool isMobileDownloadAllowed()=0
virtual qulonglong throttle()=0
virtual void allowMobileDownload(bool allowed)=0
virtual qulonglong progress()=0