on xenial help sign in
Simplify logic
commitee9d7a614640a05fe3c5e88a9163aa1b32d7fe8c authorMichael Terry <michael.terry@canonical.com> dateFri 30 May 2014, 11:21 (12 years ago) parente0441d6
9 files changed+9−50
debian/control−1 plugins/Unity/Launcher/CMakeLists.txt−6 plugins/Unity/Launcher/launchermodel.cpp+5−17 tests/CMakeLists.txt−2 tests/data/click/db/test.conf.in−2 tests/data/click/root/.click/users/test-user/com.test.good−1 tests/data/click/root/com.test.good/1.2.3−1 tests/plugins/Unity/Launcher/CMakeLists.txt−7 tests/plugins/Unity/Launcher/launchermodeltest.cpp+4−13
debian/control−1
@@ -20,7 +20,6 @@ Build-Depends: cmake,
2020 libqt5xmlpatterns5-dev,
2121 libunity-api-dev (>= 7.80.6),
2222 libunity-mir-dev,
23− libupstart-app-launch2-dev,
2423 libusermetricsoutput1-dev,
2524 libxcb1-dev,
2625 pkg-config,
plugins/Unity/Launcher/CMakeLists.txt−6
@@ -1,18 +1,14 @@
11include(FindPkgConfig)
2−pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
32pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
43pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
54pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
6−pkg_check_modules(UPSTART_APP_LAUNCH REQUIRED upstart-app-launch-2)
75
86add_definitions(-DSM_BUSNAME=systemBus)
97
108include_directories(
119 ${CMAKE_CURRENT_SOURCE_DIR}
1210 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
13− ${GLIB_INCLUDE_DIRS}
1411 ${GSETTINGS_QT_INCLUDE_DIRS}
15− ${UPSTART_APP_LAUNCH_INCLUDE_DIRS}
1612)
1713
1814set(QMLLAUNCHERPLUGIN_SRC
@@ -33,9 +29,7 @@ add_library(UnityLauncher-qml MODULE
3329 )
3430
3531target_link_libraries(UnityLauncher-qml
36− ${GLIB_LDFLAGS}
3732 ${GSETTINGS_QT_LDFLAGS}
38− ${UPSTART_APP_LAUNCH_LDFLAGS}
3933)
4034
4135qt5_use_modules(UnityLauncher-qml DBus Qml)
plugins/Unity/Launcher/launchermodel.cpp+5−17
@@ -22,7 +22,6 @@
2222#include "backend/launcherbackend.h"
2323
2424#include <unity/shell/application/ApplicationInfoInterface.h>
25−#include <upstart-app-launch.h>
2625
2726using namespace unity::shell::application;
2827
@@ -199,28 +198,17 @@ void LauncherModel::setUser(const QString &username)
199198QString LauncherModel::getUrlForAppId(const QString &appId) const
200199{
201200 // appId is either an appId or a legacy app name. Let's find out which
202− QString url;
203− gchar *longAppId;
204−
205201 if (appId.isEmpty())
206202 return QString();
207203
208− // assume legacy app until proven otherwise
209− url = "application:///" + appId + ".desktop";
204+ QString df = m_backend->desktopFile(appId + ".desktop");
205+ if (!df.isEmpty())
206+ return "application:///" + appId + ".desktop";
210207
211− // Test if appid is really a click package name
212208 QStringList parts = appId.split('_');
213209 QString package = parts.value(0);
214− QString app = parts.value(1);
215− longAppId = upstart_app_launch_triplet_to_app_id(package.toLatin1().constData(),
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;
210+ QString app = parts.value(1, "first-listed-app");
211+ return "appid://" + package + "/" + app + "/current-user-version";
224212}
225213
226214void 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−
31# QML tests that do not require graphical capabilities.
42add_custom_target(qmlunittests)
53
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)
21pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
32pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
43pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
5−pkg_check_modules(UPSTART_APP_LAUNCH REQUIRED upstart-app-launch-2)
64
75include_directories(
86 ${CMAKE_CURRENT_BINARY_DIR}
97 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
108 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
119 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend
12− ${GLIB_INCLUDE_DIRS}
1310 ${GSETTINGS_QT_INCLUDE_DIRS}
14− ${UPSTART_APP_LAUNCH_INCLUDE_DIRS}
1511 )
1612
1713add_definitions(-DSM_BUSNAME=sessionBus)
1814add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
19−add_definitions(-DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}")
2015add_definitions(-DLAUNCHER_TESTING)
2116
2217### LauncherBackendTest
@@ -55,9 +50,7 @@ add_executable(launchermodeltestExec
5550 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
5651 )
5752target_link_libraries(launchermodeltestExec
58− ${GLIB_LDFLAGS}
5953 ${GSETTINGS_QT_LDFLAGS}
60− ${UPSTART_APP_LAUNCH_LDFLAGS}
6154)
6255qt5_use_modules(launchermodeltestExec Test Core DBus)
6356
tests/plugins/Unity/Launcher/launchermodeltest.cpp+4−13
@@ -127,9 +127,6 @@ private Q_SLOTS:
127127
128128 appManager->addApplication(new MockApp("no-icon"));
129129 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");
133130 }
134131
135132 // Removing apps from appmanager and launcher as pinned ones would stick
@@ -140,8 +137,6 @@ private Q_SLOTS:
140137 while (launcherModel->rowCount(QModelIndex()) > 0) {
141138 launcherModel->requestRemove(launcherModel->get(0)->appId());
142139 }
143− qputenv("TEST_CLICK_DB", "");
144− qputenv("TEST_CLICK_USER", "");
145140 }
146141
147142 void testMove() {
@@ -283,14 +278,10 @@ private Q_SLOTS:
283278 void testGetUrlForAppId() {
284279 QCOMPARE(launcherModel->getUrlForAppId(QString()), QString());
285280 QCOMPARE(launcherModel->getUrlForAppId(""), QString());
286− QCOMPARE(launcherModel->getUrlForAppId("not-an-app"), QString("application:///not-an-app.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"));
290− QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application"), QString("appid://com.test.good/application/1.2.3"));
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"));
281+ QCOMPARE(launcherModel->getUrlForAppId("no-name"), QString("application:///no-name.desktop"));
282+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good"), QString("appid://com.test.good/first-listed-app/current-user-version"));
283+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application"), QString("appid://com.test.good/application/current-user-version"));
284+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application_1.2.3"), QString("appid://com.test.good/application/current-user-version"));
294285 }
295286};
296287