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