Merge lp:~mterry/qtmir/ual-parse into lp:qtmir

Proposed by Michael Terry
Status: Work in progress
Proposed branch: lp:~mterry/qtmir/ual-parse
Merge into: lp:qtmir
Diff against target: 45 lines (+8/-7)
2 files modified
debian/control (+1/-1)
src/modules/Unity/Application/application_manager.cpp (+7/-6)
To merge this branch: bzr merge lp:~mterry/qtmir/ual-parse
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+318795@code.launchpad.net

Commit message

Use ubuntu-app-launch to parse AppIDs, instead of doing it ourselves.

Description of the change

In an effort to allow UAL flexibility to change appid formats in the future, I'm trying to remove instances of appid parsing elsewhere, and filter it all through UAL.

This branch does cause UAL to bleed out of the upstart/ folder. But since UAL is the sole authority for what appids are and how to parse them, I'm not sure that's avoidable. Plus, I think that level of abstraction has been pushed down into UAL which also uses systemd these days.

To post a comment you must log in.

Unmerged revisions

609. By Michael Terry

Let UAL parse appids for us

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2017-02-21 13:21:31 +0000
3+++ debian/control 2017-03-02 16:28:48 +0000
4@@ -22,7 +22,7 @@
5 libqt5sensors5-dev,
6 libqtdbusmock1-dev (>= 0.2),
7 libqtdbustest1-dev (>= 0.2),
8- libubuntu-app-launch3-dev,
9+ libubuntu-app-launch3-dev (>= 0.11),
10 libubuntu-application-api-dev (>= 2.1.0),
11 libudev-dev,
12 libunity-api-dev (>= 8.2),
13
14=== modified file 'src/modules/Unity/Application/application_manager.cpp'
15--- src/modules/Unity/Application/application_manager.cpp 2017-02-02 09:36:07 +0000
16+++ src/modules/Unity/Application/application_manager.cpp 2017-03-02 16:28:48 +0000
17@@ -50,8 +50,11 @@
18 // Unity API
19 #include <unity/shell/application/MirSurfaceInterface.h>
20
21+// Ubuntu App Launch
22+#include <ubuntu-app-launch/appid.h>
23+
24 namespace ms = mir::scene;
25-
26+namespace ual = ubuntu::app_launch;
27 namespace unityapi = unity::shell::application;
28
29 #define DEBUG_MSG qCDebug(QTMIR_APPLICATIONS).nospace() << "ApplicationManager::" << __func__
30@@ -63,12 +66,10 @@
31
32 // FIXME: To be removed once shell has fully adopted short appIds!!
33 QString toShortAppIdIfPossible(const QString &appId) {
34- QRegExp longAppIdMask(QStringLiteral("[a-z0-9][a-z0-9+.-]+_[a-zA-Z0-9+.-]+_[0-9][a-zA-Z0-9.+:~-]*"));
35- if (longAppIdMask.exactMatch(appId)) {
36+ auto ualAppID = ual::AppID::parse(appId.toStdString());
37+ if (!ualAppID.empty()) {
38 qWarning() << "WARNING: long App ID encountered:" << appId;
39- // input string a long AppId, chop the version string off the end
40- QStringList parts = appId.split(QStringLiteral("_"));
41- return QStringLiteral("%1_%2").arg(parts.first(), parts.at(1));
42+ return QString::fromStdString(ualApp.persistentID());
43 }
44 return appId;
45 }

Subscribers

People subscribed via source and target branches