Merge lp:~alecu/unity-scope-click/launcher-integration into lp:unity-scope-click/devel

Proposed by Alejandro J. Cura
Status: Merged
Approved by: dobey
Approved revision: 308
Merged at revision: 297
Proposed branch: lp:~alecu/unity-scope-click/launcher-integration
Merge into: lp:unity-scope-click/devel
Diff against target: 744 lines (+494/-50)
19 files modified
CMakeLists.txt (+1/-0)
bin/CMakeLists.txt (+1/-0)
bin/install-helper (+77/-0)
debian/control (+1/-0)
debian/unity-scope-click.install (+2/-1)
libclickscope/click/CMakeLists.txt (+2/-0)
libclickscope/click/dbus_constants.h (+37/-0)
libclickscope/click/download-manager.cpp (+9/-18)
libclickscope/click/download-manager.h (+1/-2)
libclickscope/click/launcher.cpp (+26/-0)
libclickscope/click/launcher.h (+56/-0)
libclickscope/click/launcher.xml (+16/-0)
libclickscope/click/preview.cpp (+15/-2)
libclickscope/click/preview.h (+1/-1)
libclickscope/tests/test_download_manager.cpp (+0/-26)
scope/tests/CMakeLists.txt (+1/-0)
scope/tests/fake_launcher/CMakeLists.txt (+14/-0)
scope/tests/fake_launcher/fake_launcher.cpp (+118/-0)
scope/tests/fake_launcher/fake_launcher.h (+116/-0)
To merge this branch: bzr merge lp:~alecu/unity-scope-click/launcher-integration
Reviewer Review Type Date Requested Status
dobey (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+223461@code.launchpad.net

Commit message

Send the dbus signals to the launcher, when a download is started and when it's completed.

Description of the change

To test this branch irl: start scope/tests/fake_launcher/fake_launcher on a terminal. Then, try installing an app, and watch the fake_launcher debug log for the dbus calls when starting the download, for progress 0-80% and when a download is completed.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
296. By Alejandro J. Cura

Call installationStarted from the scope; use package_name instead of download_id

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
297. By Alejandro J. Cura

a skeleton for install_helper

298. By Alejandro J. Cura

merged with /devel

299. By Alejandro J. Cura

merged from /devel

300. By Alejandro J. Cura

remove skeleton of the install-helper

301. By Alejandro J. Cura

The install helper

302. By Alejandro J. Cura

Typo in helper

303. By Alejandro J. Cura

Use the install-helper instead of the hacky commandline

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
304. By Alejandro J. Cura

Use CMake to install and find the install-helper

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
305. By Alejandro J. Cura

Install the helper in the proper directory

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
306. By Alejandro J. Cura

Pass the right commandline, and return the proper errors

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
307. By Alejandro J. Cura

Fix the dbus command line to refresh the launcher

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) wrote :

A few small issues. I'll let the lack of unit tests mocking the new dbus calls slide for now, as the fake_launcher is added as well. I also don't like having the generated code, and dbus XML (especially when the scope is the client, not the service) here, but I don't guess there is much we can do about that for the time being. We'll likely need to migrate away from using QDbus here though, and use dbus-cpp in the future. There's no particular need for us to use QDbus here AFAICT, as we're just the client, and not a service trying to provide magic introspected paths.

review: Needs Fixing
308. By Alejandro J. Cura

Fixes requested on review

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-06-16 12:40:06 +0000
+++ CMakeLists.txt 2014-06-20 20:01:57 +0000
@@ -49,6 +49,7 @@
4949
50# Add our own subdirectories.50# Add our own subdirectories.
51add_subdirectory(autopilot)51add_subdirectory(autopilot)
52add_subdirectory(bin)
52add_subdirectory(libclickscope)53add_subdirectory(libclickscope)
53add_subdirectory(scope)54add_subdirectory(scope)
54add_subdirectory(data)55add_subdirectory(data)
5556
=== added directory 'bin'
=== added file 'bin/CMakeLists.txt'
--- bin/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ bin/CMakeLists.txt 2014-06-20 20:01:57 +0000
@@ -0,0 +1,1 @@
1install(PROGRAMS install-helper DESTINATION lib/unity-scope-click/)
02
=== added file 'bin/install-helper'
--- bin/install-helper 1970-01-01 00:00:00 +0000
+++ bin/install-helper 2014-06-20 20:01:57 +0000
@@ -0,0 +1,77 @@
1#!/bin/bash
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
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 GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# In addition, as a special exception, the copyright holders give
18# permission to link the code of portions of this program with the
19# OpenSSL library under certain conditions as described in each
20# individual source file, and distribute linked combinations
21# including the two.
22# You must obey the GNU General Public License in all respects
23# for all of the code used other than OpenSSL. If you modify
24# file(s) with this exception, you may extend this exception to your
25# version of the file(s), but you are not obligated to do so. If you
26# do not wish to do so, delete this exception statement from your
27# version. If you delete this exception statement from all source
28# files in the program, then also delete it here.
29#
30
31FILE_NAME="$1"
32PACKAGE_NAME="$2"
33
34SCOPES_OBJECTPATH=/com/canonical/unity/scopes
35SCOPES_INTERFACE=com.canonical.unity.scopes
36SCOPES_METHOD=InvalidateResults
37
38LAUNCHER_BUS=com.ubuntu.unity.launcher
39LAUNCHER_OBJECTPATH=/com/ubuntu/unity/launcher/installations
40LAUNCHER_INTERFACE=com.ubuntu.unity.launcher.Installations
41LAUNCHER_METHOD=completeInstallation
42
43function invalidate-scope {
44 SCOPE_ID=$1
45 dbus-send $SCOPES_OBJECTPATH $SCOPES_INTERFACE.$SCOPES_METHOD string:$SCOPE_ID
46}
47
48function install-package {
49 FILE_NAME="$1"
50 pkcon -p install-local "$FILE_NAME"
51}
52
53function app_id-from-package_name {
54 PACKAGE_NAME=$1
55 IFS=_
56 TRIPLET=($(ubuntu-app-triplet $PACKAGE_NAME))
57 unset IFS
58 echo ${TRIPLET[0]}_${TRIPLET[1]}_current-user-version
59}
60
61function complete-installation {
62 PACKAGE_NAME=$1
63 APP_ID=$2
64 dbus-send --dest=$LAUNCHER_BUS --type=method_call $LAUNCHER_OBJECTPATH $LAUNCHER_INTERFACE.$LAUNCHER_METHOD string:$PACKAGE_NAME string:$APP_ID
65}
66
67if install-package "$FILE_NAME" ; then
68 invalidate-scope clickscope
69 invalidate-scope com.canonical.scopes.clickstore
70 APP_ID=$(app_id-from-package_name $PACKAGE_NAME)
71 complete-installation $PACKAGE_NAME $APP_ID
72else
73 PKCON_STATUS=$?
74 NO_APP_ID=""
75 complete-installation $PACKAGE_NAME $NO_APP_ID
76 exit $PKCON_STATUS
77fi
078
=== modified file 'debian/control'
--- debian/control 2014-06-18 12:32:49 +0000
+++ debian/control 2014-06-20 20:01:57 +0000
@@ -26,6 +26,7 @@
26Architecture: armhf i386 amd6426Architecture: armhf i386 amd64
27Depends: account-plugin-ubuntuone,27Depends: account-plugin-ubuntuone,
28 packagekit-tools,28 packagekit-tools,
29 ubuntu-app-launch-tools,
29 ubuntu-download-manager,30 ubuntu-download-manager,
30 ubuntu-sdk-libs,31 ubuntu-sdk-libs,
31 ${misc:Depends},32 ${misc:Depends},
3233
=== modified file 'debian/unity-scope-click.install'
--- debian/unity-scope-click.install 2014-05-06 21:28:13 +0000
+++ debian/unity-scope-click.install 2014-06-20 20:01:57 +0000
@@ -1,3 +1,4 @@
1usr/lib/*/unity-scopes/*1usr/lib/*/unity-scopes/*
2usr/lib/unity-scope-click/*
2usr/share/unity/scopes/*3usr/share/unity/scopes/*
3usr/share/locale/*/LC_MESSAGES/unity-scope-click.mo
4\ No newline at end of file4\ No newline at end of file
5usr/share/locale/*/LC_MESSAGES/unity-scope-click.mo
56
=== modified file 'libclickscope/click/CMakeLists.txt'
--- libclickscope/click/CMakeLists.txt 2014-06-13 15:21:16 +0000
+++ libclickscope/click/CMakeLists.txt 2014-06-20 20:01:57 +0000
@@ -6,6 +6,7 @@
6add_definitions(6add_definitions(
7 -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\"7 -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\"
8 -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\"8 -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\"
9 -DCLICK_INSTALL_HELPER=\"${CMAKE_INSTALL_PREFIX}/lib/unity-scope-click/install-helper\"
9)10)
1011
11add_library(${SCOPE_LIB_NAME} STATIC12add_library(${SCOPE_LIB_NAME} STATIC
@@ -14,6 +15,7 @@
14 index.cpp15 index.cpp
15 interface.cpp16 interface.cpp
16 key_file_locator.cpp17 key_file_locator.cpp
18 launcher.cpp
17 network_access_manager.cpp19 network_access_manager.cpp
18 package.cpp20 package.cpp
19 preview.cpp21 preview.cpp
2022
=== added file 'libclickscope/click/dbus_constants.h'
--- libclickscope/click/dbus_constants.h 1970-01-01 00:00:00 +0000
+++ libclickscope/click/dbus_constants.h 2014-06-20 20:01:57 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
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
20 * including the two.
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.
28 */
29
30#ifndef DBUS_CONSTANTS_H
31#define DBUS_CONSTANTS_H
32
33#define LAUNCHER_BUSNAME "com.ubuntu.unity.launcher"
34#define LAUNCHER_OBJECT_PATH "/com/ubuntu/unity/launcher/installations"
35#define LAUNCHER_INTERFACE "com.ubuntu.unity.launcher.Installations"
36
37#endif // DBUS_CONSTANTS_H
038
=== modified file 'libclickscope/click/download-manager.cpp'
--- libclickscope/click/download-manager.cpp 2014-05-26 14:02:45 +0000
+++ libclickscope/click/download-manager.cpp 2014-06-20 20:01:57 +0000
@@ -52,19 +52,7 @@
52static const QString DOWNLOAD_APP_ID_KEY = "app_id";52static const QString DOWNLOAD_APP_ID_KEY = "app_id";
53static const QString DOWNLOAD_COMMAND_KEY = "post-download-command";53static const QString DOWNLOAD_COMMAND_KEY = "post-download-command";
5454
55// Pass two commands using sh -c because UDM expects a single55static const QString DOWNLOAD_COMMAND = CLICK_INSTALL_HELPER;
56// executable.
57// Use a single string for both commands because the
58// list is eventually given to QProcess, which adds quotes around each
59// argument, while -c expects a single quoted string.
60// Then, use the $0 positional variable in the pkcon command to let us
61// pass "$file" as a separate list element, which UDM requires for
62// substitution.
63
64static const QString DOWNLOAD_COMMAND = QStringLiteral("pkcon -p install-local ") % click::QUOTED_ARG0 % QStringLiteral(" && ") % click::DBUSSEND_COMMAND;
65static const QVariant DOWNLOAD_CMDLINE = QVariant(QStringList()
66 << "/bin/sh" << "-c" <<
67 DOWNLOAD_COMMAND << "$file");
6856
69static const QString DOWNLOAD_MANAGER_DO_NOT_HASH = "";57static const QString DOWNLOAD_MANAGER_DO_NOT_HASH = "";
70static const QString DOWNLOAD_MANAGER_IGNORE_HASH_ALGORITHM = "";58static const QString DOWNLOAD_MANAGER_IGNORE_HASH_ALGORITHM = "";
@@ -90,7 +78,7 @@
90 QSharedPointer<udm::Manager> systemDownloadManager;78 QSharedPointer<udm::Manager> systemDownloadManager;
91 QSharedPointer<click::network::Reply> reply;79 QSharedPointer<click::network::Reply> reply;
92 QString downloadUrl;80 QString downloadUrl;
93 QString appId;81 QString package_name;
94};82};
9583
96const QByteArray& click::CLICK_TOKEN_HEADER()84const QByteArray& click::CLICK_TOKEN_HEADER()
@@ -133,9 +121,9 @@
133click::DownloadManager::~DownloadManager(){121click::DownloadManager::~DownloadManager(){
134}122}
135123
136void click::DownloadManager::startDownload(const QString& downloadUrl, const QString& appId)124void click::DownloadManager::startDownload(const QString& downloadUrl, const QString& package_name)
137{125{
138 impl->appId = appId;126 impl->package_name = package_name;
139127
140 // NOTE: using SIGNAL/SLOT macros here because new-style128 // NOTE: using SIGNAL/SLOT macros here because new-style
141 // connections are flaky on ARM.129 // connections are flaky on ARM.
@@ -151,8 +139,11 @@
151void click::DownloadManager::handleClickTokenFetched(const QString& clickToken)139void click::DownloadManager::handleClickTokenFetched(const QString& clickToken)
152{140{
153 QVariantMap metadata;141 QVariantMap metadata;
154 metadata[DOWNLOAD_COMMAND_KEY] = DOWNLOAD_CMDLINE;142
155 metadata[DOWNLOAD_APP_ID_KEY] = impl->appId;143 QVariant commandline = QVariant(QStringList() << DOWNLOAD_COMMAND << "$file" << impl->package_name);
144 metadata[DOWNLOAD_COMMAND_KEY] = commandline;
145 metadata[DOWNLOAD_APP_ID_KEY] = impl->package_name;
146 metadata["package_name"] = impl->package_name;
156147
157 QMap<QString, QString> headers;148 QMap<QString, QString> headers;
158 headers[CLICK_TOKEN_HEADER()] = clickToken;149 headers[CLICK_TOKEN_HEADER()] = clickToken;
159150
=== modified file 'libclickscope/click/download-manager.h'
--- libclickscope/click/download-manager.h 2014-05-26 14:02:45 +0000
+++ libclickscope/click/download-manager.h 2014-06-20 20:01:57 +0000
@@ -49,7 +49,6 @@
4949
50namespace click50namespace click
51{51{
52static const QString QUOTED_ARG0 = QStringLiteral("\"$0\"");
53// The dbus-send command to refresh the search results in the dash.52// The dbus-send command to refresh the search results in the dash.
54static const QString DBUSSEND_COMMAND = QStringLiteral("dbus-send /com/canonical/unity/scopes com.canonical.unity.scopes.InvalidateResults string:clickscope");53static const QString DBUSSEND_COMMAND = QStringLiteral("dbus-send /com/canonical/unity/scopes com.canonical.unity.scopes.InvalidateResults string:clickscope");
5554
@@ -67,7 +66,7 @@
67 virtual ~DownloadManager();66 virtual ~DownloadManager();
6867
69public slots:68public slots:
70 virtual void startDownload(const QString& downloadUrl, const QString& appId);69 virtual void startDownload(const QString& downloadUrl, const QString& package_name);
71 virtual void fetchClickToken(const QString& downloadUrl);70 virtual void fetchClickToken(const QString& downloadUrl);
7271
73signals:72signals:
7473
=== added file 'libclickscope/click/launcher.cpp'
--- libclickscope/click/launcher.cpp 1970-01-01 00:00:00 +0000
+++ libclickscope/click/launcher.cpp 2014-06-20 20:01:57 +0000
@@ -0,0 +1,26 @@
1/*
2 * This file was generated by qdbusxml2cpp version 0.8
3 * Command line was: qdbusxml2cpp launcher.xml -p launcher -c Launcher -N
4 *
5 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
6 *
7 * This is an auto-generated file.
8 * This file may have been hand-edited. Look for HAND-EDIT comments
9 * before re-generating it.
10 */
11
12#include "launcher.h"
13
14/*
15 * Implementation of interface class Launcher
16 */
17
18Launcher::Launcher(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
19 : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
20{
21}
22
23Launcher::~Launcher()
24{
25}
26
027
=== added file 'libclickscope/click/launcher.h'
--- libclickscope/click/launcher.h 1970-01-01 00:00:00 +0000
+++ libclickscope/click/launcher.h 2014-06-20 20:01:57 +0000
@@ -0,0 +1,56 @@
1/*
2 * This file was generated by qdbusxml2cpp version 0.8
3 * Command line was: qdbusxml2cpp launcher.xml -p launcher -c Launcher -N
4 *
5 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
6 *
7 * This is an auto-generated file.
8 * Do not edit! All changes made to it will be lost.
9 */
10
11#ifndef LAUNCHER_H_1403062747
12#define LAUNCHER_H_1403062747
13
14#include <QtCore/QObject>
15#include <QtCore/QByteArray>
16#include <QtCore/QList>
17#include <QtCore/QMap>
18#include <QtCore/QString>
19#include <QtCore/QStringList>
20#include <QtCore/QVariant>
21#include <QtDBus/QtDBus>
22
23/*
24 * Proxy class for interface com.ubuntu.unity.launcher.Installations
25 */
26class Launcher: public QDBusAbstractInterface
27{
28 Q_OBJECT
29public:
30 static inline const char *staticInterfaceName()
31 { return "com.ubuntu.unity.launcher.Installations"; }
32
33public:
34 Launcher(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
35
36 ~Launcher();
37
38public Q_SLOTS: // METHODS
39 inline Q_NOREPLY void completeInstallation(const QString &package_name, const QString &app_id)
40 {
41 QList<QVariant> argumentList;
42 argumentList << QVariant::fromValue(package_name) << QVariant::fromValue(app_id);
43 callWithArgumentList(QDBus::NoBlock, QLatin1String("completeInstallation"), argumentList);
44 }
45
46 inline Q_NOREPLY void startInstallation(const QString &title, const QString &icon_url, const QString &package_name)
47 {
48 QList<QVariant> argumentList;
49 argumentList << QVariant::fromValue(title) << QVariant::fromValue(icon_url) << QVariant::fromValue(package_name);
50 callWithArgumentList(QDBus::NoBlock, QLatin1String("startInstallation"), argumentList);
51 }
52
53Q_SIGNALS: // SIGNALS
54};
55
56#endif
057
=== added file 'libclickscope/click/launcher.xml'
--- libclickscope/click/launcher.xml 1970-01-01 00:00:00 +0000
+++ libclickscope/click/launcher.xml 2014-06-20 20:01:57 +0000
@@ -0,0 +1,16 @@
1<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
2<node>
3 <interface name="com.ubuntu.unity.launcher.Installations">
4 <method name="startInstallation">
5 <arg name="title" type="s" direction="in"/>
6 <arg name="icon_url" type="s" direction="in"/>
7 <arg name="package_name" type="s" direction="in"/>
8 <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
9 </method>
10 <method name="completeInstallation">
11 <arg name="package_name" type="s" direction="in"/>
12 <arg name="app_id" type="s" direction="in"/>
13 <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
14 </method>
15 </interface>
16</node>
017
=== modified file 'libclickscope/click/preview.cpp'
--- libclickscope/click/preview.cpp 2014-06-19 16:55:02 +0000
+++ libclickscope/click/preview.cpp 2014-06-20 20:01:57 +0000
@@ -32,6 +32,8 @@
32#include "preview.h"32#include "preview.h"
33#include <click/qtbridge.h>33#include <click/qtbridge.h>
34#include <click/download-manager.h>34#include <click/download-manager.h>
35#include <click/launcher.h>
36#include <click/dbus_constants.h>
3537
36#include <boost/algorithm/string/replace.hpp>38#include <boost/algorithm/string/replace.hpp>
3739
@@ -354,6 +356,15 @@
354{356{
355}357}
356358
359void InstallingPreview::startLauncherAnimation(const PackageDetails &details)
360{
361 Launcher l(LAUNCHER_BUSNAME, LAUNCHER_OBJECT_PATH, QDBusConnection::sessionBus());
362 l.startInstallation(QString::fromStdString(details.package.title),
363 QString::fromStdString(details.package.icon_url),
364 QString::fromStdString(details.package.name));
365
366}
367
357void InstallingPreview::run(const unity::scopes::PreviewReplyProxy &reply)368void InstallingPreview::run(const unity::scopes::PreviewReplyProxy &reply)
358{369{
359 downloader->startDownload(download_url, result["name"].get_string(),370 downloader->startDownload(download_url, result["name"].get_string(),
@@ -370,11 +381,13 @@
370 reply->push(downloadErrorWidgets());381 reply->push(downloadErrorWidgets());
371 return;382 return;
372 default:383 default:
384 std::string object_path = rc.first;
373 qDebug() << "Successfully created UDM Download.";385 qDebug() << "Successfully created UDM Download.";
374 populateDetails([this, reply, rc](const PackageDetails &details){386 populateDetails([this, reply, object_path](const PackageDetails &details){
375 reply->push(headerWidgets(details));387 reply->push(headerWidgets(details));
376 reply->push(progressBarWidget(rc.first));388 reply->push(progressBarWidget(object_path));
377 reply->push(descriptionWidgets(details));389 reply->push(descriptionWidgets(details));
390 startLauncherAnimation(details);
378 },391 },
379 [this, reply](const ReviewList& reviewlist,392 [this, reply](const ReviewList& reviewlist,
380 click::Reviews::Error error) {393 click::Reviews::Error error) {
381394
=== modified file 'libclickscope/click/preview.h'
--- libclickscope/click/preview.h 2014-06-12 21:05:25 +0000
+++ libclickscope/click/preview.h 2014-06-20 20:01:57 +0000
@@ -150,7 +150,7 @@
150 virtual scopes::PreviewWidgetList progressBarWidget(const std::string& object_path);150 virtual scopes::PreviewWidgetList progressBarWidget(const std::string& object_path);
151 std::string download_url;151 std::string download_url;
152 QSharedPointer<click::Downloader> downloader;152 QSharedPointer<click::Downloader> downloader;
153153 void startLauncherAnimation(const PackageDetails& details);
154};154};
155155
156class InstalledPreview : public PreviewStrategy156class InstalledPreview : public PreviewStrategy
157157
=== modified file 'libclickscope/tests/test_download_manager.cpp'
--- libclickscope/tests/test_download_manager.cpp 2014-05-26 14:27:31 +0000
+++ libclickscope/tests/test_download_manager.cpp 2014-06-20 20:01:57 +0000
@@ -482,29 +482,3 @@
482 StartDownloadTestParameters(true, false, false),482 StartDownloadTestParameters(true, false, false),
483 StartDownloadTestParameters(false, true, false)483 StartDownloadTestParameters(false, true, false)
484 ));484 ));
485
486class ArgZeroTest : public ::testing::TestWithParam<QString> {};
487
488TEST_P(ArgZeroTest, testArgZero)
489{
490 auto expected_arg = GetParam();
491 auto fake_command = "for n in " % click::QUOTED_ARG0 % "; do echo $n; done";
492 QStringList arguments;
493 arguments << "-c" << fake_command << expected_arg;
494
495 QProcess sh;
496 sh.start("/bin/sh", arguments);
497
498 EXPECT_TRUE(sh.waitForStarted());
499 sh.closeWriteChannel();
500
501 EXPECT_TRUE(sh.waitForFinished());
502 QByteArray result = sh.readAll().trimmed();
503 EXPECT_EQ(sh.exitCode(), 0);
504
505 ASSERT_EQ(expected_arg, QString(result));
506}
507
508INSTANTIATE_TEST_CASE_P(TestSampleFilenames,
509 ArgZeroTest,
510 ::testing::Values("sample_filename.click", "spaced_filename (1).click"));
511485
=== modified file 'scope/tests/CMakeLists.txt'
--- scope/tests/CMakeLists.txt 2014-05-26 15:56:40 +0000
+++ scope/tests/CMakeLists.txt 2014-06-20 20:01:57 +0000
@@ -59,3 +59,4 @@
59add_subdirectory(integration)59add_subdirectory(integration)
60add_subdirectory(download_manager_tool)60add_subdirectory(download_manager_tool)
61add_subdirectory(click_interface_tool)61add_subdirectory(click_interface_tool)
62add_subdirectory(fake_launcher)
6263
=== added directory 'scope/tests/fake_launcher'
=== added file 'scope/tests/fake_launcher/CMakeLists.txt'
--- scope/tests/fake_launcher/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ scope/tests/fake_launcher/CMakeLists.txt 2014-06-20 20:01:57 +0000
@@ -0,0 +1,14 @@
1set(FAKE_LAUNCHER_TARGET fake_launcher)
2
3include_directories (
4 ${CMAKE_SOURCE_DIR}/scope/click
5)
6
7add_executable (${FAKE_LAUNCHER_TARGET}
8 fake_launcher.cpp
9 fake_launcher.h
10)
11
12target_link_libraries (${FAKE_LAUNCHER_TARGET}
13 ${STORE_LIB_UNVERSIONED}
14)
015
=== added file 'scope/tests/fake_launcher/fake_launcher.cpp'
--- scope/tests/fake_launcher/fake_launcher.cpp 1970-01-01 00:00:00 +0000
+++ scope/tests/fake_launcher/fake_launcher.cpp 2014-06-20 20:01:57 +0000
@@ -0,0 +1,118 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
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
20 * including the two.
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.
28 */
29
30#include <ubuntu/download_manager/download.h>
31#include <ubuntu/download_manager/downloads_list.h>
32#include <ubuntu/download_manager/error.h>
33
34#include <QCoreApplication>
35#include <QDBusConnection>
36#include <QDebug>
37#include <QString>
38#include <QTimer>
39#include <QTextStream>
40
41#include <iostream>
42
43#include <boost/optional.hpp>
44
45#include <fake_launcher.h>
46
47void FakeLauncher::startInstallation(QString title, QString icon_url, QString package_name)
48{
49 qDebug() << "startInstallation" << title << icon_url << package_name;
50 installations.insert(package_name, new FakeIcon(title, icon_url, this));
51 manager->getAllDownloadsWithMetadata("package_name", package_name);
52}
53
54void FakeLauncher::handleDownloadsFound(const QString& key, const QString& value, DownloadsList *download_list)
55{
56 Q_UNUSED(key)
57 Q_UNUSED(value)
58 foreach (const QSharedPointer<Download> download, download_list->downloads()) {
59 QString package_name{download->metadata()["package_name"].toString()};
60 qDebug() << "download found for" << package_name;
61 installations[package_name]->downloadFound(*download);
62 }
63}
64
65void FakeLauncher::completeInstallation(QString package_name, QString app_id)
66{
67 qDebug() << "completeInstallation" << package_name << app_id;
68 installations[package_name]->complete(app_id);
69}
70
71void FakeIcon::downloadFound(Download& download)
72{
73 connect(&download, SIGNAL(progress(qulonglong,qulonglong)), this, SLOT(handleProgress(qulonglong,qulonglong)));
74 connect(&download, SIGNAL(error(Error*)), this, SLOT(handleDownloadError(Error*)));
75 qDebug() << title << "starting installation";
76 // TODO: add icon to the launcher
77}
78
79void FakeIcon::handleProgress(qulonglong transferred, qulonglong total)
80{
81 qDebug() << title << "download progress" << double(transferred)/total*80;
82 // TODO: update progress bar
83}
84
85void FakeIcon::handleDownloadError(Error *error)
86{
87 failure(error->errorString());
88}
89
90void FakeIcon::failure(QString message)
91{
92 qDebug() << title << "installation failed" << message;
93 // TODO: remove icon from the launcher
94}
95
96void FakeIcon::complete(QString app_id)
97{
98 if (app_id.isEmpty()) {
99 failure("Failed to install");
100 } else {
101 qDebug() << title << "installation completed" << app_id;
102 // TODO: update icon with proper app_id
103 }
104}
105
106int main(int argc, char *argv[])
107{
108
109 QCoreApplication app(argc, argv);
110 FakeLauncher launcher;
111 new FakeLauncherAdaptor(&launcher);
112 qDebug() << "starting";
113 auto bus = QDBusConnection::sessionBus();
114 bus.registerObject(LAUNCHER_OBJECT_PATH, &launcher);
115 bus.registerService(LAUNCHER_BUSNAME);
116 return app.exec();
117}
118
0119
=== added file 'scope/tests/fake_launcher/fake_launcher.h'
--- scope/tests/fake_launcher/fake_launcher.h 1970-01-01 00:00:00 +0000
+++ scope/tests/fake_launcher/fake_launcher.h 2014-06-20 20:01:57 +0000
@@ -0,0 +1,116 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
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
20 * including the two.
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.
28 */
29
30#ifndef _FAKE_LAUNCHER_H_
31#define _FAKE_LAUNCHER_H_
32
33#include <QObject>
34#include <QDBusObjectPath>
35#include <QDBusAbstractAdaptor>
36
37#include <click/dbus_constants.h>
38#include <ubuntu/download_manager/manager.h>
39
40class FakeIcon : public QObject {
41 Q_OBJECT
42
43public:
44 explicit FakeIcon(QString title, QString icon_url, QObject *parent=0)
45 : QObject(parent), title(title), icon_url(icon_url)
46 {
47 }
48 void downloadFound(Download& download);
49 void complete(QString app_id);
50
51private slots:
52 void handleProgress(qulonglong transferred, qulonglong total);
53 void handleDownloadError(Error* error);
54
55private:
56 Download* download;
57 QString title;
58 QString icon_url;
59 void failure(QString message);
60};
61
62class FakeLauncher : public QObject {
63 Q_OBJECT
64
65public:
66 explicit FakeLauncher(QObject *parent=0) : QObject(parent)
67 {
68 manager = Ubuntu::DownloadManager::Manager::createSessionManager();
69 connect(manager, SIGNAL(downloadsWithMetadataFound(QString,QString,DownloadsList*)),
70 this, SLOT(handleDownloadsFound(QString,QString,DownloadsList*)));
71 }
72
73public slots:
74 void startInstallation(QString title, QString icon_url, QString package_name);
75 void completeInstallation(QString package_name, QString app_id);
76
77private slots:
78 void handleDownloadsFound(const QString& key, const QString& value, DownloadsList* downloads);
79
80signals:
81
82private:
83 Ubuntu::DownloadManager::Manager* manager;
84 QMap<QString, FakeIcon*> installations;
85};
86
87
88class FakeLauncherAdaptor : public QDBusAbstractAdaptor
89{
90 Q_OBJECT
91 Q_CLASSINFO("D-Bus Interface", LAUNCHER_INTERFACE)
92
93private:
94 FakeLauncher *_launcher;
95
96public:
97 FakeLauncherAdaptor(FakeLauncher *launcher) : QDBusAbstractAdaptor(launcher), _launcher(launcher)
98 {
99 }
100
101public slots:
102 Q_NOREPLY void startInstallation(QString title, QString icon_url, QString package_name)
103 {
104 _launcher->startInstallation(title, icon_url, package_name);
105 }
106
107 Q_NOREPLY void completeInstallation(QString package_name, QString app_id)
108 {
109 _launcher->completeInstallation(package_name, app_id);
110 }
111};
112
113
114#endif /* _FAKE_LAUNCHER_H_ */
115
116

Subscribers

People subscribed via source and target branches

to all changes: