Ubuntu Download Manager  0.3.0
A session-wide downloading service
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator
manager_impl.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_IMPL_H
20 #define UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_IMPL_H
21 
22 #include <QDBusConnection>
23 #include <QDBusObjectPath>
24 #include <ubuntu/transfers/system/dbus_connection.h>
25 #include "download.h"
26 #include "error.h"
27 #include "group_download.h"
28 #include "manager_interface.h"
30 #include "manager.h"
31 
32 
33 class QDBusConnection;
34 
35 namespace Ubuntu {
36 
37 namespace DownloadManager {
38 
39 class Download;
40 class Error;
41 class GroupDownload;
42 class ManagerInterface;
43 
44 class ManagerImpl : public Manager {
45  Q_OBJECT
46 
47  // allow watchers to emit the signals
48  friend class Manager;
49  friend class DownloadManagerPCW;
50  friend class GroupManagerPCW;
51 
52  public:
53  virtual ~ManagerImpl();
54  virtual Download* getDownloadForId(const QString& id);
55  virtual void createDownload(DownloadStruct downStruct);
56  virtual void createDownload(DownloadStruct downStruct,
57  DownloadCb cb,
58  DownloadCb errCb);
59  virtual void createDownload(StructList downs,
60  const QString &algorithm,
61  bool allowed3G,
62  const QVariantMap &metadata,
63  StringMap headers);
64  virtual void createDownload(StructList downs,
65  const QString &algorithm,
66  bool allowed3G,
67  const QVariantMap &metadata,
68  StringMap headers,
69  GroupCb cb,
70  GroupCb errCb);
71  virtual void getAllDownloads();
72  virtual void getAllDownloads(DownloadsListCb cb,
73  DownloadsListCb errCb);
74  virtual void getAllDownloadsWithMetadata(const QString &name,
75  const QString &value);
76  virtual void getAllDownloadsWithMetadata(const QString &name,
77  const QString &value,
80 
81  bool isError() const;
82  Error* lastError() const;
83  void allowMobileDataDownload(bool allowed);
84  bool isMobileDataDownload();
85  qulonglong defaultThrottle();
86  void setDefaultThrottle(qulonglong speed);
87  void exit();
88 
89  protected:
90  ManagerImpl(const QDBusConnection& conn,
91  const QString& path = "",
92  QObject* parent= 0);
93  // used for testing purposes
94  ManagerImpl(const QDBusConnection& conn,
95  const QString& path,
96  ManagerInterface* interface,
97  QObject* parent);
98 
99  private:
100  void init();
101  void onWatcherDone();
102  void setLastError(const QDBusError& err);
103 
104  private:
105  bool _isError = false;
106  QDBusConnection _conn;
107  QString _servicePath;
108  Error* _lastError = nullptr;
109  ManagerInterface* _dbusInterface = nullptr;
110 
111 };
112 
113 } // DownloadManager
114 
115 } // Ubuntu
116 
117 #endif // UBUNTU_DOWNLOADMANAGER_CLIENT_MANAGER_H
std::function< void(Download *)> DownloadCb
Definition: manager.h:37
std::function< void(const QString &, const QString &, DownloadsList *)> MetadataDownloadsListCb
Definition: manager.h:55
virtual void createDownload(DownloadStruct downStruct)=0
virtual Error * lastError() const =0
virtual void allowMobileDataDownload(bool allowed)=0
virtual bool isError() const =0
virtual bool isMobileDataDownload()=0
virtual void setDefaultThrottle(qulonglong speed)=0
Manager(QObject *parent=0)
Definition: manager.h:85
std::function< void(GroupDownload *)> GroupCb
Definition: manager.h:61
std::function< void(DownloadsList *)> DownloadsListCb
Definition: manager.h:49
virtual void getAllDownloadsWithMetadata(const QString &name, const QString &value)=0
virtual qulonglong defaultThrottle()=0
virtual Download * getDownloadForId(const QString &id)=0