Lomiri Download Manager 0.1.1
A session-wide downloading service
 
Loading...
Searching...
No Matches
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 LOMIRI_DOWNLOADMANAGER_CLIENT_MANAGER_IMPL_H
20#define LOMIRI_DOWNLOADMANAGER_CLIENT_MANAGER_IMPL_H
21
22#include <QDBusConnection>
23#include <QDBusObjectPath>
24
25#include <lomiri/transfers/visibility.h>
26#include <lomiri/transfers/system/dbus_connection.h>
27
33
34#include "manager.h"
35
36
37class QDBusConnection;
38
39namespace Lomiri {
40
41namespace DownloadManager {
42
43class Download;
44class Error;
45class GroupDownload;
46class ManagerInterface;
47
48class LOMIRI_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(const QString &appId, bool uncollected);
76 virtual void getAllDownloads(const QString &appId,
77 bool uncollected,
78 DownloadsListCb cb,
79 DownloadsListCb errCb);
80 virtual void getAllDownloadsWithMetadata(const QString &name,
81 const QString &value);
82 virtual void getAllDownloadsWithMetadata(const QString &name,
83 const QString &value,
84 MetadataDownloadsListCb cb,
85 MetadataDownloadsListCb errCb);
86
87 bool isError() const;
88 Error* lastError() const;
89 void allowMobileDataDownload(bool allowed);
90 bool isMobileDataDownload();
91 qulonglong defaultThrottle();
92 void setDefaultThrottle(qulonglong speed);
93 void exit();
94
95 protected:
96 ManagerImpl(const QDBusConnection& conn,
97 const QString& path = "",
98 QObject* parent= 0);
99 // used for testing purposes
100 ManagerImpl(const QDBusConnection& conn,
101 const QString& path,
102 ManagerInterface* interface,
103 QObject* parent);
104
105 private:
106 void init();
107 void onWatcherDone();
108 void setLastError(const QDBusError& err);
109
110 private:
111 bool _isError = false;
112 QDBusConnection _conn;
113 QString _servicePath;
114 Error* _lastError = nullptr;
115 ManagerInterface* _dbusInterface = nullptr;
116};
117
118} // DownloadManager
119
120} // Lomiri
121
122#endif // LOMIRI_DOWNLOADMANAGER_CLIENT_MANAGER_H