Unity 8
DownloadTracker.h
1 /*
2  * Copyright (C) 2013 - Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License, as
6  * published by the Free Software Foundation; either version 2.1 or 3.0
7  * of the License.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranties of
11  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12  * PURPOSE. See the applicable version of the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of both the GNU Lesser General Public
16  * License along with this program. If not, see <http://www.gnu.org/licenses/>
17  *
18  * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>
19  */
20 
21 
22 #ifndef DOWNLOADTRACKER_H
23 #define DOWNLOADTRACKER_H
24 
25 #include <interface/downloadtrackeradaptor.h>
26 
27 #include <QObject>
28 #include <QDBusObjectPath>
29 
30 class DownloadTracker : public QObject
31 {
32  Q_OBJECT
33  Q_DISABLE_COPY(DownloadTracker)
34  Q_PROPERTY(QString service READ service WRITE setService NOTIFY serviceChanged)
35  Q_PROPERTY(QString dbusPath READ dbusPath WRITE setDbusPath NOTIFY dbusPathChanged)
36  Q_PROPERTY(bool serviceReady READ isServiceReady NOTIFY serviceReadyChanged)
37 
38 public:
39  explicit DownloadTracker(QObject *parent = 0);
40 
41  QString service() const;
42  QString dbusPath() const;
43  bool isServiceReady() const;
44 
45  void setDbusPath(const QString& path);
46  void setService(const QString& service);
47 
48 Q_SIGNALS:
49  void serviceChanged(const QString &service);
50  void dbusPathChanged(const QString &dbusPath);
51  void serviceReadyChanged(const bool &serviceReady);
52 
53  void canceled(bool success);
54  void error(const QString &error);
55  void finished(const QString &path);
56  void paused(bool success);
57  void progress(qulonglong received, qulonglong total);
58  void resumed(bool success);
59  void started(bool success);
60 
61 private:
62  QString m_dbusPath;
63  QString m_service;
64  DownloadTrackerAdaptor* m_adaptor;
65 
66  void startService();
67 };
68 
69 #endif // DOWNLOADTRACKER_H