Merge lp:~ken-vandine/content-hub/noclick into lp:content-hub

Proposed by Ken VanDine
Status: Merged
Approved by: Michael Sheldon
Approved revision: 334
Merged at revision: 332
Proposed branch: lp:~ken-vandine/content-hub/noclick
Merge into: lp:content-hub
Diff against target: 737 lines (+104/-256)
18 files modified
CMakeLists.txt (+0/-1)
debian/content-hub.install (+1/-2)
debian/control (+0/-2)
debian/rules (+2/-1)
include/com/ubuntu/content/type.h (+2/-2)
src/com/ubuntu/content/service/CMakeLists.txt (+7/-54)
src/com/ubuntu/content/service/content-hub-peer-hook-wrapper.in (+0/-13)
src/com/ubuntu/content/service/content-hub.hook.in (+0/-4)
src/com/ubuntu/content/service/helper.cpp (+0/-66)
src/com/ubuntu/content/service/main.cpp (+4/-1)
src/com/ubuntu/content/service/registry-updater.cpp (+57/-39)
src/com/ubuntu/content/service/registry-updater.h (+11/-9)
src/helper/CMakeLists.txt (+0/-2)
src/helper/exec-tool.c (+2/-43)
tests/acceptance-tests/CMakeLists.txt (+8/-8)
tests/acceptance-tests/test_registry_updater.cpp (+8/-7)
tools/peer-picker/content-hub-peer-picker.desktop (+1/-1)
tools/send/content-hub-send.desktop (+1/-1)
To merge this branch: bzr merge lp:~ken-vandine/content-hub/noclick
Reviewer Review Type Date Requested Status
Michael Sheldon (community) Approve
system-apps-ci-bot continuous-integration Needs Fixing
Review via email: mp+319356@code.launchpad.net

Commit message

* Removed the click hook and check for registered peers on service startup
* Removed click usage in the helper and dropped the depends
* Added QFileWatcher to watch for peers to be installed/removed

Description of the change

* Removed the click hook and check for registered peers on service startup
* Removed click usage in the helper and dropped the depends
* Added QFileWatcher to watch for peers to be installed/removed

To post a comment you must log in.
lp:~ken-vandine/content-hub/noclick updated
328. By Ken VanDine

Removed some debugging

329. By Ken VanDine

Rename the Hook class to RegistryUpdater

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~ken-vandine/content-hub/noclick updated
330. By Ken VanDine

merged trunk

331. By Ken VanDine

removed unused filed

332. By Ken VanDine

Added /var/cache/content-hub/peers/ to the list of directories watched for peers. The snap interface hook will install them there.

333. By Ken VanDine

Install an empty dir for the snap interface hook to install peers.

334. By Ken VanDine

updated copyright years

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Looks good

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 2017-02-16 12:08:29 +0000
+++ CMakeLists.txt 2017-03-15 13:33:04 +0000
@@ -72,7 +72,6 @@
72pkg_check_modules(UBUNTU_DOWNLOAD_MANAGER REQUIRED ubuntu-download-manager-client)72pkg_check_modules(UBUNTU_DOWNLOAD_MANAGER REQUIRED ubuntu-download-manager-client)
73pkg_check_modules(NOTIFY REQUIRED libnotify)73pkg_check_modules(NOTIFY REQUIRED libnotify)
74pkg_check_modules(MIRCLIENT REQUIRED mirclient)74pkg_check_modules(MIRCLIENT REQUIRED mirclient)
75pkg_check_modules(CLICK REQUIRED click-0.4)
76pkg_check_modules(APPARMOR REQUIRED libapparmor)75pkg_check_modules(APPARMOR REQUIRED libapparmor)
7776
78add_definitions(-DDEBUG_ENABLED)77add_definitions(-DDEBUG_ENABLED)
7978
=== modified file 'debian/content-hub.install'
--- debian/content-hub.install 2016-12-08 12:11:27 +0000
+++ debian/content-hub.install 2017-03-15 13:33:04 +0000
@@ -2,10 +2,8 @@
2usr/bin/content-hub-peer-picker2usr/bin/content-hub-peer-picker
3usr/bin/content-hub-send3usr/bin/content-hub-send
4usr/bin/content-hub-service4usr/bin/content-hub-service
5usr/lib/*/content-hub
6usr/lib/*/ubuntu-app-launch5usr/lib/*/ubuntu-app-launch
7usr/lib/systemd/user6usr/lib/systemd/user
8usr/share/click/hooks
9usr/share/dbus-17usr/share/dbus-1
10usr/share/glib-2.0/schemas8usr/share/glib-2.0/schemas
11usr/share/locale/*/LC_MESSAGES/content-hub.mo9usr/share/locale/*/LC_MESSAGES/content-hub.mo
@@ -14,5 +12,6 @@
14usr/share/applications/content-hub-peer-picker.desktop12usr/share/applications/content-hub-peer-picker.desktop
15usr/share/url-dispatcher/urls/content-hub-send.url-dispatcher13usr/share/url-dispatcher/urls/content-hub-send.url-dispatcher
16usr/share/content-hub/icons14usr/share/content-hub/icons
15var/cache/content-hub/peers
17debian/apparmor/content-hub-clipboard etc/apparmor.d16debian/apparmor/content-hub-clipboard etc/apparmor.d
18debian/apparmor/content-hub-peer-picker etc/apparmor.d17debian/apparmor/content-hub-peer-picker etc/apparmor.d
1918
=== modified file 'debian/control'
--- debian/control 2017-03-09 02:39:40 +0000
+++ debian/control 2017-03-15 13:33:04 +0000
@@ -2,7 +2,6 @@
2Priority: optional2Priority: optional
3Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>3Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
4Build-Depends: cmake,4Build-Depends: cmake,
5 click-dev,
6 dbus-test-runner,5 dbus-test-runner,
7 debhelper (>= 9),6 debhelper (>= 9),
8 dh-apparmor,7 dh-apparmor,
@@ -11,7 +10,6 @@
11 google-mock,10 google-mock,
12 lcov,11 lcov,
13 libapparmor-dev,12 libapparmor-dev,
14 libclick-0.4-dev,
15 libglib2.0-dev,13 libglib2.0-dev,
16 libgsettings-qt-dev,14 libgsettings-qt-dev,
17 libmirclient-dev [!powerpc !ppc64 !ppc64el],15 libmirclient-dev [!powerpc !ppc64 !ppc64el],
1816
=== modified file 'debian/rules'
--- debian/rules 2017-01-04 16:16:00 +0000
+++ debian/rules 2017-03-15 13:33:04 +0000
@@ -11,7 +11,7 @@
11LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)11LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)
1212
13%:13%:
14 dh $@ --with click,translations --fail-missing -- -B build14 dh $@ --with translations --fail-missing -- -B build
1515
16override_dh_auto_test:16override_dh_auto_test:
17 make -C build/tests/acceptance-tests test17 make -C build/tests/acceptance-tests test
@@ -21,6 +21,7 @@
21 dh_apparmor -pcontent-hub --profile-name=content-hub-clipboard21 dh_apparmor -pcontent-hub --profile-name=content-hub-clipboard
22 dh_apparmor -pcontent-hub --profile-name=content-hub-peer-picker22 dh_apparmor -pcontent-hub --profile-name=content-hub-peer-picker
23 dh_apparmor -pcontent-hub-testability --profile-name=content-hub-testability23 dh_apparmor -pcontent-hub-testability --profile-name=content-hub-testability
24 mkdir -p debian/tmp/var/cache/content-hub/peers
2425
25DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)26DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
26# Skip tests on the archs they are known to be flaky with current configuration27# Skip tests on the archs they are known to be flaky with current configuration
2728
=== modified file 'include/com/ubuntu/content/type.h'
--- include/com/ubuntu/content/type.h 2015-06-24 20:22:45 +0000
+++ include/com/ubuntu/content/type.h 2017-03-15 13:33:04 +0000
@@ -30,7 +30,7 @@
30namespace detail30namespace detail
31{31{
32class Service;32class Service;
33class Hook;33class RegistryUpdater;
34}34}
35class Type : public QObject35class Type : public QObject
36{36{
@@ -67,7 +67,7 @@
67 protected:67 protected:
68 friend struct Known;68 friend struct Known;
69 friend class detail::Service;69 friend class detail::Service;
70 friend class detail::Hook;70 friend class detail::RegistryUpdater;
7171
72 explicit Type(const QString&, QObject* = nullptr);72 explicit Type(const QString&, QObject* = nullptr);
73 73
7474
=== modified file 'src/com/ubuntu/content/service/CMakeLists.txt'
--- src/com/ubuntu/content/service/CMakeLists.txt 2016-11-15 19:45:40 +0000
+++ src/com/ubuntu/content/service/CMakeLists.txt 2017-03-15 13:33:04 +0000
@@ -37,11 +37,18 @@
3737
38 main.cpp38 main.cpp
39 registry.cpp39 registry.cpp
40 registry-updater.cpp
40 ../debug.cpp41 ../debug.cpp
41 ../utils.cpp42 ../utils.cpp
42 ${CONTENT_SERVICE_SKELETON}43 ${CONTENT_SERVICE_SKELETON}
43)44)
4445
46set_target_properties(
47 content-hub-service
48 PROPERTIES
49 AUTOMOC TRUE
50)
51
45qt5_use_modules(content-hub-service Core DBus Gui)52qt5_use_modules(content-hub-service Core DBus Gui)
4653
47target_link_libraries(54target_link_libraries(
@@ -85,60 +92,6 @@
8592
86add_schema ("com.ubuntu.content.hub.gschema.xml")93add_schema ("com.ubuntu.content.hub.gschema.xml")
8794
88add_executable(
89 content-hub-peer-hook
90
91 helper.cpp
92 registry.cpp
93 hook.cpp
94)
95
96qt5_use_modules(content-hub-peer-hook Core Gui DBus)
97
98target_link_libraries(
99 content-hub-peer-hook
100
101 content-hub
102 ${GSETTINGS_LDFLAGS}
103 ${UBUNTU_LAUNCH_LDFLAGS}
104)
105
106configure_file("content-hub-peer-hook-wrapper.in"
107 "content-hub-peer-hook-wrapper"
108 @ONLY
109)
110
111install(
112 PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/content-hub-peer-hook-wrapper"
113 DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/content-hub"
114)
115
116install(
117 TARGETS content-hub-peer-hook
118 RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/content-hub"
119)
120
121set_target_properties(
122 content-hub-peer-hook
123 PROPERTIES
124 AUTOMOC TRUE
125)
126
127set(CLICK_HOOK
128"${CMAKE_CURRENT_BINARY_DIR}/content-hub.hook"
129)
130
131configure_file("content-hub.hook.in"
132 "${CLICK_HOOK}"
133 @ONLY
134)
135
136install(
137FILES
138"${CLICK_HOOK}"
139DESTINATION "/usr/share/click/hooks"
140)
141
142install(95install(
143 FILES xorg.png96 FILES xorg.png
144 DESTINATION ${CMAKE_INSTALL_DATADIR}/content-hub/icons/97 DESTINATION ${CMAKE_INSTALL_DATADIR}/content-hub/icons/
14598
=== removed file 'src/com/ubuntu/content/service/content-hub-peer-hook-wrapper.in'
--- src/com/ubuntu/content/service/content-hub-peer-hook-wrapper.in 2014-11-10 12:57:43 +0000
+++ src/com/ubuntu/content/service/content-hub-peer-hook-wrapper.in 1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
1#!/bin/sh
2
3# PackageKit clears all environment variables, so we get the UID and then read
4# in $DBUS_SESSION_BUS_ADDRESS from /run/user/$UID/dbus-session
5
6USERID=`id -u`
7
8if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
9 [ -e /run/user/$USERID/dbus-session ] && . /run/user/$USERID/dbus-session
10 [ -n "$DBUS_SESSION_BUS_ADDRESS" ] && export DBUS_SESSION_BUS_ADDRESS
11fi
12
13@pkglibexecdir@/content-hub/content-hub-peer-hook
140
=== removed file 'src/com/ubuntu/content/service/content-hub.hook.in'
--- src/com/ubuntu/content/service/content-hub.hook.in 2014-06-02 16:33:13 +0000
+++ src/com/ubuntu/content/service/content-hub.hook.in 1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
1Pattern: ${home}/.local/share/content-hub/${id}
2Exec: @pkglibexecdir@/content-hub/content-hub-peer-hook-wrapper
3User-Level: yes
4Hook-Name: content-hub
50
=== removed file 'src/com/ubuntu/content/service/helper.cpp'
--- src/com/ubuntu/content/service/helper.cpp 2015-08-12 17:24:29 +0000
+++ src/com/ubuntu/content/service/helper.cpp 1970-01-01 00:00:00 +0000
@@ -1,66 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
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
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18
19#include <QCoreApplication>
20#include <QDir>
21#include <QStandardPaths>
22
23#include "hook.h"
24#include "debug.h"
25
26namespace cuc = com::ubuntu::content;
27
28int main(int argc, char** argv)
29{
30 QCoreApplication app(argc, argv);
31
32 TRACE() << Q_FUNC_INFO;
33
34 if (app.arguments().count() > 1)
35 {
36 qWarning() << "Shouldn't have arguments";
37 return 1;
38 }
39
40 /* read environment variables */
41 QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
42 if (environment.contains(QLatin1String("CONTENT_HUB_LOGGING_LEVEL"))) {
43 bool isOk;
44 int value = environment.value(
45 QLatin1String("CONTENT_HUB_LOGGING_LEVEL")).toInt(&isOk);
46 if (isOk)
47 setLoggingLevel(value);
48 }
49
50 QDir contentDir(
51 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
52 + QString("/")
53 + QString("content-hub"));
54
55 if (!contentDir.exists()) {
56 if (!contentDir.mkpath(contentDir.absolutePath()))
57 return 0;
58 }
59
60 new cuc::detail::Hook();
61
62 app.exec();
63
64 /* We always want to return 0 */
65 return 0;
66}
670
=== modified file 'src/com/ubuntu/content/service/main.cpp'
--- src/com/ubuntu/content/service/main.cpp 2014-07-15 14:31:08 +0000
+++ src/com/ubuntu/content/service/main.cpp 2017-03-15 13:33:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2017 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
25#include "debug.h"25#include "debug.h"
26#include "common.h"26#include "common.h"
27#include "registry.h"27#include "registry.h"
28#include "registry-updater.h"
28#include "detail/i18n.h"29#include "detail/i18n.h"
29#include "detail/service.h"30#include "detail/service.h"
30#include "detail/peer_registry.h"31#include "detail/peer_registry.h"
@@ -63,6 +64,8 @@
6364
64 auto registry = QSharedPointer<cucd::PeerRegistry>(new Registry());65 auto registry = QSharedPointer<cucd::PeerRegistry>(new Registry());
6566
67 auto updater = new cuc::detail::RegistryUpdater(registry);
68
66 auto app_manager = QSharedPointer<cuca::ApplicationManager>(new cucd::AppManager());69 auto app_manager = QSharedPointer<cuca::ApplicationManager>(new cucd::AppManager());
6770
68 auto server = new cucd::Service(connection, registry, app_manager, app->parent());71 auto server = new cucd::Service(connection, registry, app_manager, app->parent());
6972
=== renamed file 'src/com/ubuntu/content/service/hook.cpp' => 'src/com/ubuntu/content/service/registry-updater.cpp'
--- src/com/ubuntu/content/service/hook.cpp 2015-06-24 20:22:45 +0000
+++ src/com/ubuntu/content/service/registry-updater.cpp 2017-03-15 13:33:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2017 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
20#include <QJsonDocument>20#include <QJsonDocument>
21#include <QJsonObject>21#include <QJsonObject>
22#include <QFile>22#include <QFile>
23#include <QFileSystemWatcher>
23#include <QDir>24#include <QDir>
24#include <QStandardPaths>25#include <QStandardPaths>
25#include <QTimer>26#include <QTimer>
@@ -27,34 +28,18 @@
27#include <com/ubuntu/content/peer.h>28#include <com/ubuntu/content/peer.h>
2829
29#include "debug.h"30#include "debug.h"
30#include "hook.h"31#include "registry-updater.h"
3132
33namespace cuc = com::ubuntu::content;
32namespace cucd = com::ubuntu::content::detail;34namespace cucd = com::ubuntu::content::detail;
3335
34cucd::Hook::Hook(QObject *parent) :36cucd::RegistryUpdater::RegistryUpdater(const QSharedPointer<cucd::PeerRegistry>& registry, QObject *parent) :
35 QObject(parent),37 QObject(parent),
36 registry(new Registry())38 registry(registry),
37{39 watcher(new QFileSystemWatcher)
38 QTimer::singleShot(200, this, SLOT(run()));40{
39}41 /* Looks for files installed packages that define peer registration.
4042 * These files are JSON, for example:
41cucd::Hook::Hook(com::ubuntu::content::detail::PeerRegistry *registry, QObject *parent) :
42 QObject(parent),
43 registry(registry)
44{
45}
46
47cucd::Hook::~Hook()
48{
49 TRACE() << Q_FUNC_INFO;
50 delete registry;
51}
52
53void cucd::Hook::run()
54{
55 TRACE() << Q_FUNC_INFO;
56 /* Looks for files in ${HOME}/.local/share/content-hub/${id} installed
57 * by click packages. These files are JSON, for example:
58 *43 *
59 * {44 * {
60 * "source": [45 * "source": [
@@ -63,22 +48,56 @@
63 * ]48 * ]
64 * }49 * }
65 *50 *
66 * The hook also iterates known peers and removes them if there is51 * The updater also iterates known peers and removes them if there is
67 * no JSON file installed in this path.52 * no JSON file installed in this path.
68 */53 */
69
70 QVector<QDir> contentDirs;
71
72 contentDirs.append(QDir(54 contentDirs.append(QDir(
73 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)55 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
74 + QString("/")56 + QString("/")
75 + QString("content-hub")));57 + QString("content-hub")));
76 58
77 contentDirs.append(QDir("/usr/share/content-hub/peers/"));59 contentDirs.append(QDir("/usr/share/content-hub/peers/"));
78 contentDirs.append(QDir("/usr/share/local/content-hub/peers/"));60 contentDirs.append(QDir("/usr/share/local/content-hub/peers/"));
61 contentDirs.append(QDir("/var/cache/content-hub/peers/"));
62
63 QStringList dirs;
64 Q_FOREACH(QDir d, contentDirs)
65 {
66 if (d.exists())
67 dirs << d.path();
68 }
69
70 watcher->addPaths(dirs);
71 connect(watcher.data(), SIGNAL(directoryChanged(const QString&)), SLOT(refresh(const QString&)));
72
73 QTimer::singleShot(200, this, SLOT(run()));
74}
75
76cucd::RegistryUpdater::~RegistryUpdater()
77{
78 TRACE() << Q_FUNC_INFO;
79}
80
81void cucd::RegistryUpdater::refresh(const QString& dir)
82{
83 TRACE() << Q_FUNC_INFO << dir;
84 bool shouldRefresh = true;
85 /* Don't update the registry for temp files */
86 Q_FOREACH(QFileInfo f, QDir(dir).entryInfoList(QDir::Files))
87 {
88 if (f.completeSuffix().contains("dpkg-"))
89 shouldRefresh = false;
90 }
91 if (shouldRefresh)
92 run();
93}
94
95void cucd::RegistryUpdater::run()
96{
97 TRACE() << Q_FUNC_INFO;
7998
80 QStringList all_peers;99 QStringList all_peers;
81 registry->enumerate_known_peers([&all_peers](const com::ubuntu::content::Peer& peer)100 registry->enumerate_known_peers([&all_peers](const cuc::Peer& peer)
82 {101 {
83 all_peers.append(peer.id());102 all_peers.append(peer.id());
84 });103 });
@@ -95,7 +114,7 @@
95 }114 }
96 }115 }
97 if(!foundPeer) {116 if(!foundPeer) {
98 registry->remove_peer(com::ubuntu::content::Peer{p});117 registry->remove_peer(cuc::Peer{p});
99 }118 }
100 }119 }
101120
@@ -107,9 +126,10 @@
107 if (contentDir.exists()) 126 if (contentDir.exists())
108 {127 {
109 peerDirsExist = true;128 peerDirsExist = true;
110
111 Q_FOREACH(QFileInfo f, contentDir.entryInfoList(QDir::Files))129 Q_FOREACH(QFileInfo f, contentDir.entryInfoList(QDir::Files))
130 {
112 add_peer(f);131 add_peer(f);
132 }
113 }133 }
114134
115 }135 }
@@ -117,13 +137,11 @@
117 if(!peerDirsExist)137 if(!peerDirsExist)
118 return_error("No peer setting directories exist.");138 return_error("No peer setting directories exist.");
119139
120 deleteLater();
121 QCoreApplication::instance()->quit();
122}140}
123141
124bool cucd::Hook::add_peer(QFileInfo result)142bool cucd::RegistryUpdater::add_peer(QFileInfo result)
125{143{
126 TRACE() << Q_FUNC_INFO << "Hook:" << result.filePath();144 TRACE() << Q_FUNC_INFO << "RegistryUpdater:" << result.filePath();
127145
128 QStringList knownTypes;146 QStringList knownTypes;
129 knownTypes << "all" << "pictures" << "music" << "contacts" << "documents" << "videos" << "links" << "ebooks" << "text" << "events";147 knownTypes << "all" << "pictures" << "music" << "contacts" << "documents" << "videos" << "links" << "ebooks" << "text" << "events";
@@ -182,7 +200,7 @@
182 return true;200 return true;
183}201}
184202
185bool cucd::Hook::return_error(QString err)203bool cucd::RegistryUpdater::return_error(QString err)
186{204{
187 qWarning() << "Failed to install peer" << err;205 qWarning() << "Failed to install peer" << err;
188 return false;206 return false;
189207
=== renamed file 'src/com/ubuntu/content/service/hook.h' => 'src/com/ubuntu/content/service/registry-updater.h'
--- src/com/ubuntu/content/service/hook.h 2015-09-23 14:45:09 +0000
+++ src/com/ubuntu/content/service/registry-updater.h 2017-03-15 13:33:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2017 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -16,8 +16,8 @@
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */17 */
1818
19#ifndef HOOK_H19#ifndef REGISTRY_UPDATER_H
20#define HOOK_H20#define REGISTRY_UPDATER_H
2121
22#include <QObject>22#include <QObject>
23#include <QFileInfo>23#include <QFileInfo>
@@ -33,21 +33,23 @@
33{33{
34namespace detail34namespace detail
35{35{
36class Hook : public QObject36class RegistryUpdater : public QObject
37{37{
38 Q_OBJECT38 Q_OBJECT
39public:39public:
40 explicit Hook(QObject *parent = 0);40 RegistryUpdater(const QSharedPointer<com::ubuntu::content::detail::PeerRegistry>& registry, QObject *parent = 0);
41 Hook(com::ubuntu::content::detail::PeerRegistry *registry, QObject *parent = 0);41 ~RegistryUpdater();
42 ~Hook();
4342
44public Q_SLOTS:43public Q_SLOTS:
45 bool return_error(QString err = "");44 bool return_error(QString err = "");
45 void refresh(const QString&);
46 void run();46 void run();
47 bool add_peer(QFileInfo);47 bool add_peer(QFileInfo);
4848
49private:49private:
50 com::ubuntu::content::detail::PeerRegistry* registry;50 const QSharedPointer<com::ubuntu::content::detail::PeerRegistry>& registry;
51 QVector<QDir> contentDirs;
52 QScopedPointer<QFileSystemWatcher> watcher;
51 53
52};54};
53}55}
@@ -55,4 +57,4 @@
55}57}
56}58}
5759
58#endif // HOOK_H60#endif // REGISTRY_UPDATER_H
5961
=== modified file 'src/helper/CMakeLists.txt'
--- src/helper/CMakeLists.txt 2016-11-09 17:55:06 +0000
+++ src/helper/CMakeLists.txt 2017-03-15 13:33:04 +0000
@@ -21,7 +21,6 @@
21 ${UBUNTU_LAUNCH_INCLUDE_DIRS}21 ${UBUNTU_LAUNCH_INCLUDE_DIRS}
22 ${GIO_INCLUDE_DIRS}22 ${GIO_INCLUDE_DIRS}
23 ${GLIB_INCLUDE_DIRS}23 ${GLIB_INCLUDE_DIRS}
24 ${CLICK_INCLUDE_DIRS}
25 ${MIRCLIENT_INCLUDE_DIRS}24 ${MIRCLIENT_INCLUDE_DIRS}
26)25)
2726
@@ -37,7 +36,6 @@
37 exec-tool36 exec-tool
38 37
39 ${UBUNTU_LAUNCH_LDFLAGS}38 ${UBUNTU_LAUNCH_LDFLAGS}
40 ${CLICK_LDFLAGS}
41 ${GLIB_LDFLAGS}39 ${GLIB_LDFLAGS}
42 ${GIO_LDFLAGS}40 ${GIO_LDFLAGS}
43 ${MIRCLIENT_LDFLAGS}41 ${MIRCLIENT_LDFLAGS}
4442
=== modified file 'src/helper/exec-tool.c'
--- src/helper/exec-tool.c 2016-11-09 17:55:06 +0000
+++ src/helper/exec-tool.c 2017-03-15 13:33:04 +0000
@@ -18,7 +18,7 @@
18 */18 */
1919
20#include <glib.h>20#include <glib.h>
21#include <click.h>21#include <gio/gio.h>
22#include <ubuntu-app-launch.h>22#include <ubuntu-app-launch.h>
2323
24gchar *24gchar *
@@ -65,7 +65,6 @@
65gchar *65gchar *
66build_dir (const gchar * appid)66build_dir (const gchar * appid)
67{67{
68 GError * error = NULL;
69 gchar * package = NULL;68 gchar * package = NULL;
7069
71 /* 'Parse' the App ID */70 /* 'Parse' the App ID */
@@ -73,42 +72,9 @@
73 g_warning("Unable to parse App ID: '%s'", appid);72 g_warning("Unable to parse App ID: '%s'", appid);
74 return NULL;73 return NULL;
75 }74 }
76
77 /* Check click to find out where the files are */
78 ClickDB * db = click_db_new();
79
80 /* If TEST_CLICK_DB is unset, this reads the system database. */
81 click_db_read(db, g_getenv("TEST_CLICK_DB"), &error);
82 if (error != NULL) {
83 g_warning("Unable to read Click database: %s", error->message);
84 g_error_free(error);
85 g_free(package);
86 return NULL;
87 }
88
89 /* If TEST_CLICK_USER is unset, this uses the current user name. */
90 ClickUser * user = click_user_new_for_user(db, g_getenv("TEST_CLICK_USER"), &error);
91 if (error != NULL) {
92 g_warning("Unable to read Click database: %s", error->message);
93 g_error_free(error);
94 g_free(package);
95 g_object_unref(db);
96 return NULL;
97 }
98
99 gchar * pkgdir = click_user_get_path(user, package, &error);
100
101 g_object_unref(user);
102 g_object_unref(db);
103 g_free(package);75 g_free(package);
10476
105 if (error != NULL) {77 return NULL;
106 g_warning("Unable to get the Click package directory for %s: %s", package, error->message);
107 g_error_free(error);
108 return NULL;
109 }
110
111 return pkgdir;
112}78}
11379
114int80int
@@ -136,13 +102,6 @@
136 exec = build_exec(appid, SYSTEM_DIRECTORY);102 exec = build_exec(appid, SYSTEM_DIRECTORY);
137 }103 }
138104
139 /* If not there look to the user directory (click) */
140 if (exec == NULL) {
141 gchar * userdir = g_build_filename(g_get_user_cache_dir(), "ubuntu-app-launch", "desktop", NULL);
142 exec = build_exec(appid, userdir);
143 g_free(userdir);
144 }
145
146 if (exec == NULL) {105 if (exec == NULL) {
147 const gchar * props[3] = {106 const gchar * props[3] = {
148 "AppID",107 "AppID",
149108
=== modified file 'tests/acceptance-tests/CMakeLists.txt'
--- tests/acceptance-tests/CMakeLists.txt 2017-01-04 16:16:00 +0000
+++ tests/acceptance-tests/CMakeLists.txt 2017-03-15 13:33:04 +0000
@@ -71,25 +71,25 @@
71endforeach(test)71endforeach(test)
7272
73add_executable(73add_executable(
74 test_hook74 test_registry_updater
75 test_hook.cpp75 test_registry_updater.cpp
76 ${MOCS}76 ${MOCS}
77 ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content/service/hook.cpp77 ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content/service/registry-updater.cpp
78 ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content/service/registry.cpp78 ${CMAKE_SOURCE_DIR}/src/com/ubuntu/content/service/registry.cpp
79 good.json79 good.json
80 bad.json80 bad.json
81 source_all.json81 source_all.json
82)82)
8383
84qt5_use_modules(test_hook Core Gui DBus Test)84qt5_use_modules(test_registry_updater Core Gui DBus Test)
85target_link_libraries(test_hook content-hub ${GTEST_ALL_LIBRARIES} ${GSETTINGS_LDFLAGS})85target_link_libraries(test_registry_updater content-hub ${GTEST_ALL_LIBRARIES} ${GSETTINGS_LDFLAGS})
86add_test(NAME test_hook COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/test_hook)86add_test(NAME test_registry_updater COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/test_registry_updater)
8787
88SET_TESTS_PROPERTIES(test_hook88SET_TESTS_PROPERTIES(test_registry_updater
89 PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")89 PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
9090
91set_target_properties(91set_target_properties(
92 test_hook92 test_registry_updater
93 PROPERTIES93 PROPERTIES
94 AUTOMOC TRUE94 AUTOMOC TRUE
95)95)
9696
=== renamed file 'tests/acceptance-tests/test_hook.cpp' => 'tests/acceptance-tests/test_registry_updater.cpp'
--- tests/acceptance-tests/test_hook.cpp 2015-10-20 20:23:09 +0000
+++ tests/acceptance-tests/test_registry_updater.cpp 2017-03-15 13:33:04 +0000
@@ -19,7 +19,7 @@
19#include <com/ubuntu/content/peer.h>19#include <com/ubuntu/content/peer.h>
20#include <com/ubuntu/content/type.h>20#include <com/ubuntu/content/type.h>
21#include "com/ubuntu/content/detail/peer_registry.h"21#include "com/ubuntu/content/detail/peer_registry.h"
22#include "com/ubuntu/content/service/hook.h"22#include "com/ubuntu/content/service/registry-updater.h"
2323
24#include <gmock/gmock.h>24#include <gmock/gmock.h>
25#include <gtest/gtest.h>25#include <gtest/gtest.h>
@@ -60,7 +60,7 @@
60};60};
61}61}
6262
63TEST(Hook, parse_json)63TEST(RegistryUpdater, parse_json)
64{64{
65 using namespace ::testing;65 using namespace ::testing;
66 66
@@ -70,12 +70,13 @@
70 WillRepeatedly(Return(true));70 WillRepeatedly(Return(true));
7171
72 QFileInfo f("good.json");72 QFileInfo f("good.json");
73 cucd::Hook *hook = new cucd::Hook(mock);73 auto mock_ptr = QSharedPointer<cuc::detail::PeerRegistry>(mock);
74 cucd::RegistryUpdater *updater = new cucd::RegistryUpdater(mock_ptr);
7475
75 EXPECT_TRUE(hook->add_peer(f));76 EXPECT_TRUE(updater->add_peer(f));
76 f.setFile("bad.json");77 f.setFile("bad.json");
77 EXPECT_FALSE(hook->add_peer(f));78 EXPECT_FALSE(updater->add_peer(f));
78 f.setFile("source_all.json");79 f.setFile("source_all.json");
79 EXPECT_TRUE(hook->add_peer(f));80 EXPECT_TRUE(updater->add_peer(f));
80 delete mock;81 mock_ptr.clear();
81}82}
8283
=== modified file 'tools/peer-picker/content-hub-peer-picker.desktop'
--- tools/peer-picker/content-hub-peer-picker.desktop 2016-11-16 18:25:30 +0000
+++ tools/peer-picker/content-hub-peer-picker.desktop 2017-03-15 13:33:04 +0000
@@ -6,7 +6,7 @@
6Icon=6Icon=
7Terminal=false7Terminal=false
8Type=Application8Type=Application
9OnlyShowIn=Old9NoDisplay=true
10X-Ubuntu-Touch=true10X-Ubuntu-Touch=true
11X-Ubuntu-Single-Instance=false11X-Ubuntu-Single-Instance=false
12X-Ubuntu-Splash-Show-Header=true12X-Ubuntu-Splash-Show-Header=true
1313
=== modified file 'tools/send/content-hub-send.desktop'
--- tools/send/content-hub-send.desktop 2015-04-20 23:17:37 +0000
+++ tools/send/content-hub-send.desktop 2017-03-15 13:33:04 +0000
@@ -5,5 +5,5 @@
5Icon=5Icon=
6Terminal=false6Terminal=false
7Type=Application7Type=Application
8OnlyShowIn=Old8NoDisplay=true
9X-Ubuntu-Touch=true9X-Ubuntu-Touch=true

Subscribers

People subscribed via source and target branches