2
* Copyright (C) 2014 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
* In addition, as a special exception, the copyright holders give
17
* permission to link the code of portions of this program with the
18
* OpenSSL library under certain conditions as described in each
19
* individual source file, and distribute linked combinations
21
* You must obey the GNU General Public License in all respects
22
* for all of the code used other than OpenSSL. If you modify
23
* file(s) with this exception, you may extend this exception to your
24
* version of the file(s), but you are not obligated to do so. If you
25
* do not wish to do so, delete this exception statement from your
26
* version. If you delete this exception statement from all source
27
* files in the program, then also delete it here.
30
#ifndef _FAKE_LAUNCHER_H_
31
#define _FAKE_LAUNCHER_H_
34
#include <QDBusObjectPath>
35
#include <QDBusAbstractAdaptor>
37
#include <click/dbus_constants.h>
38
#include <ubuntu/download_manager/manager.h>
40
class FakeIcon : public QObject {
44
explicit FakeIcon(QString title, QString icon_url, QObject *parent=0)
45
: QObject(parent), title(title), icon_url(icon_url)
48
void downloadFound(Download& download);
49
void complete(QString app_id);
52
void handleProgress(qulonglong transferred, qulonglong total);
53
void handleDownloadError(Error* error);
59
void failure(QString message);
62
class FakeLauncher : public QObject {
66
explicit FakeLauncher(QObject *parent=0) : QObject(parent)
68
manager = Ubuntu::DownloadManager::Manager::createSessionManager();
69
connect(manager, SIGNAL(downloadsWithMetadataFound(QString,QString,DownloadsList*)),
70
this, SLOT(handleDownloadsFound(QString,QString,DownloadsList*)));
74
void startInstallation(QString title, QString icon_url, QString package_name);
75
void completeInstallation(QString package_name, QString app_id);
78
void handleDownloadsFound(const QString& key, const QString& value, DownloadsList* downloads);
83
Ubuntu::DownloadManager::Manager* manager;
84
QMap<QString, FakeIcon*> installations;
88
class FakeLauncherAdaptor : public QDBusAbstractAdaptor
91
Q_CLASSINFO("D-Bus Interface", LAUNCHER_INTERFACE)
94
FakeLauncher *_launcher;
97
FakeLauncherAdaptor(FakeLauncher *launcher) : QDBusAbstractAdaptor(launcher), _launcher(launcher)
102
Q_NOREPLY void startInstallation(QString title, QString icon_url, QString package_name)
104
_launcher->startInstallation(title, icon_url, package_name);
107
Q_NOREPLY void completeInstallation(QString package_name, QString app_id)
109
_launcher->completeInstallation(package_name, app_id);
114
#endif /* _FAKE_LAUNCHER_H_ */