on xenial help sign in
Simplify logic
ee9d7a6Michael Terry
debian/control−1
@@ -20,7 +20,6 @@ Build-Depends: cmake,
20 libqt5xmlpatterns5-dev,
20 libqt5xmlpatterns5-dev,
21 libunity-api-dev (>= 7.80.6),
21 libunity-api-dev (>= 7.80.6),
22 libunity-mir-dev,
22 libunity-mir-dev,
23− libupstart-app-launch2-dev,
24 libusermetricsoutput1-dev,
23 libusermetricsoutput1-dev,
25 libxcb1-dev,
24 libxcb1-dev,
26 pkg-config,
25 pkg-config,
plugins/Unity/Launcher/CMakeLists.txt−6
@@ -1,18 +1,14 @@
1include(FindPkgConfig)
1include(FindPkgConfig)
2−pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
3pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
2pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
4pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
3pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
5pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
4pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
6−pkg_check_modules(UPSTART_APP_LAUNCH REQUIRED upstart-app-launch-2)
7
5
8add_definitions(-DSM_BUSNAME=systemBus)
6add_definitions(-DSM_BUSNAME=systemBus)
9
7
10include_directories(
8include_directories(
11 ${CMAKE_CURRENT_SOURCE_DIR}
9 ${CMAKE_CURRENT_SOURCE_DIR}
12 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
10 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
13− ${GLIB_INCLUDE_DIRS}
14 ${GSETTINGS_QT_INCLUDE_DIRS}
11 ${GSETTINGS_QT_INCLUDE_DIRS}
15− ${UPSTART_APP_LAUNCH_INCLUDE_DIRS}
16)
12)
17
13
18set(QMLLAUNCHERPLUGIN_SRC
14set(QMLLAUNCHERPLUGIN_SRC
@@ -33,9 +29,7 @@ add_library(UnityLauncher-qml MODULE
33 )
29 )
34
30
35target_link_libraries(UnityLauncher-qml
31target_link_libraries(UnityLauncher-qml
36− ${GLIB_LDFLAGS}
37 ${GSETTINGS_QT_LDFLAGS}
32 ${GSETTINGS_QT_LDFLAGS}
38− ${UPSTART_APP_LAUNCH_LDFLAGS}
39)
33)
40
34
41qt5_use_modules(UnityLauncher-qml DBus Qml)
35qt5_use_modules(UnityLauncher-qml DBus Qml)
plugins/Unity/Launcher/launchermodel.cpp+5−17
@@ -22,7 +22,6 @@
22#include "backend/launcherbackend.h"
22#include "backend/launcherbackend.h"
23
23
24#include <unity/shell/application/ApplicationInfoInterface.h>
24#include <unity/shell/application/ApplicationInfoInterface.h>
25−#include <upstart-app-launch.h>
26
25
27using namespace unity::shell::application;
26using namespace unity::shell::application;
28
27
@@ -199,28 +198,17 @@ void LauncherModel::setUser(const QString &username)
199QString LauncherModel::getUrlForAppId(const QString &appId) const
198QString LauncherModel::getUrlForAppId(const QString &appId) const
200{
199{
201 // appId is either an appId or a legacy app name. Let's find out which
200 // appId is either an appId or a legacy app name. Let's find out which
202− QString url;
203− gchar *longAppId;
204−
205 if (appId.isEmpty())
201 if (appId.isEmpty())
206 return QString();
202 return QString();
207
203
208− // assume legacy app until proven otherwise
204+ QString df = m_backend->desktopFile(appId + ".desktop");
205+ if (!df.isEmpty())
209− url = "application:///" + appId + ".desktop";
206+ return "application:///" + appId + ".desktop";
210
207
211− // Test if appid is really a click package name
212 QStringList parts = appId.split('_');
208 QStringList parts = appId.split('_');
213 QString package = parts.value(0);
209 QString package = parts.value(0);
214− QString app = parts.value(1);
210+ QString app = parts.value(1, "first-listed-app");
215− longAppId = upstart_app_launch_triplet_to_app_id(package.toLatin1().constData(),
211+ return "appid://" + package + "/" + app + "/current-user-version";
216− app.isEmpty() ? nullptr : app.toLatin1().constData(),
217− nullptr);
218− if (longAppId != nullptr) { // it is a click app!
219− url = "appid://" + QString(longAppId).replace('_', '/');
220− g_free(longAppId);
221− }
222−
223− return url;
224}
212}
225
213
226void LauncherModel::refreshStoredApplications()
214void LauncherModel::refreshStoredApplications()
tests/CMakeLists.txt−2
@@ -1,5 +1,3 @@
1−configure_file("data/click/db/test.conf.in" "${CMAKE_CURRENT_BINARY_DIR}/data/click/db/test.conf" @ONLY)
2−
3# QML tests that do not require graphical capabilities.
1# QML tests that do not require graphical capabilities.
4add_custom_target(qmlunittests)
2add_custom_target(qmlunittests)
5
3
tests/data/click/db/test.conf.indeleted−2
@@ -1,2 +0,0 @@
1−[Click Database]
2−root = @CMAKE_SOURCE_DIR@/tests/data/click/root
tests/data/click/root/.click/users/test-user/com.test.gooddeleted−1
@@ -1 +0,0 @@
1−../../../com.test.good/1.2.3
tests/data/click/root/com.test.good/1.2.3deleted−1
@@ -1 +0,0 @@
1−../../app
tests/plugins/Unity/Launcher/CMakeLists.txt−7
@@ -1,22 +1,17 @@
1−pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
2pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
1pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
3pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
2pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
4pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
3pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
5−pkg_check_modules(UPSTART_APP_LAUNCH REQUIRED upstart-app-launch-2)
6
4
7include_directories(
5include_directories(
8 ${CMAKE_CURRENT_BINARY_DIR}
6 ${CMAKE_CURRENT_BINARY_DIR}
9 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
7 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
10 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
8 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
11 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend
9 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend
12− ${GLIB_INCLUDE_DIRS}
13 ${GSETTINGS_QT_INCLUDE_DIRS}
10 ${GSETTINGS_QT_INCLUDE_DIRS}
14− ${UPSTART_APP_LAUNCH_INCLUDE_DIRS}
15 )
11 )
16
12
17add_definitions(-DSM_BUSNAME=sessionBus)
13add_definitions(-DSM_BUSNAME=sessionBus)
18add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
14add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
19−add_definitions(-DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}")
20add_definitions(-DLAUNCHER_TESTING)
15add_definitions(-DLAUNCHER_TESTING)
21
16
22### LauncherBackendTest
17### LauncherBackendTest
@@ -55,9 +50,7 @@ add_executable(launchermodeltestExec
55 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
50 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
56 )
51 )
57target_link_libraries(launchermodeltestExec
52target_link_libraries(launchermodeltestExec
58− ${GLIB_LDFLAGS}
59 ${GSETTINGS_QT_LDFLAGS}
53 ${GSETTINGS_QT_LDFLAGS}
60− ${UPSTART_APP_LAUNCH_LDFLAGS}
61)
54)
62qt5_use_modules(launchermodeltestExec Test Core DBus)
55qt5_use_modules(launchermodeltestExec Test Core DBus)
63
56
tests/plugins/Unity/Launcher/launchermodeltest.cpp+4−13
@@ -127,9 +127,6 @@ private Q_SLOTS:
127
127
128 appManager->addApplication(new MockApp("no-icon"));
128 appManager->addApplication(new MockApp("no-icon"));
129 QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
129 QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
130−
131− qputenv("TEST_CLICK_DB", CMAKE_BINARY_DIR "/tests/data/click/db");
132− qputenv("TEST_CLICK_USER", "test-user");
133 }
130 }
134
131
135 // Removing apps from appmanager and launcher as pinned ones would stick
132 // Removing apps from appmanager and launcher as pinned ones would stick
@@ -140,8 +137,6 @@ private Q_SLOTS:
140 while (launcherModel->rowCount(QModelIndex()) > 0) {
137 while (launcherModel->rowCount(QModelIndex()) > 0) {
141 launcherModel->requestRemove(launcherModel->get(0)->appId());
138 launcherModel->requestRemove(launcherModel->get(0)->appId());
142 }
139 }
143− qputenv("TEST_CLICK_DB", "");
144− qputenv("TEST_CLICK_USER", "");
145 }
140 }
146
141
147 void testMove() {
142 void testMove() {
@@ -283,14 +278,10 @@ private Q_SLOTS:
283 void testGetUrlForAppId() {
278 void testGetUrlForAppId() {
284 QCOMPARE(launcherModel->getUrlForAppId(QString()), QString());
279 QCOMPARE(launcherModel->getUrlForAppId(QString()), QString());
285 QCOMPARE(launcherModel->getUrlForAppId(""), QString());
280 QCOMPARE(launcherModel->getUrlForAppId(""), QString());
286− QCOMPARE(launcherModel->getUrlForAppId("not-an-app"), QString("application:///not-an-app.desktop"));
281+ QCOMPARE(launcherModel->getUrlForAppId("no-name"), QString("application:///no-name.desktop"));
287− QCOMPARE(launcherModel->getUrlForAppId("not_an_app"), QString("application:///not_an_app.desktop"));
288− QCOMPARE(launcherModel->getUrlForAppId("notes-app"), QString("application:///notes-app.desktop"));
289− QCOMPARE(launcherModel->getUrlForAppId("com.test.good"), QString("appid://com.test.good/application/1.2.3"));
282+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good"), QString("appid://com.test.good/first-listed-app/current-user-version"));
290− QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application"), QString("appid://com.test.good/application/1.2.3"));
283+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application"), QString("appid://com.test.good/application/current-user-version"));
291− // Note that this version change is intentional -- we want to fix old links to use latest current version
292− QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application_0.0.0"), QString("appid://com.test.good/application/1.2.3"));
293− QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application_1.2.3"), QString("appid://com.test.good/application/1.2.3"));
284+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application_1.2.3"), QString("appid://com.test.good/application/current-user-version"));
294 }
285 }
295};
286};
296
287