Merge lp:~mterry/content-hub/ual-parse into lp:content-hub

Proposed by Michael Terry
Status: Approved
Approved by: Ken VanDine
Approved revision: 323
Proposed branch: lp:~mterry/content-hub/ual-parse
Merge into: lp:content-hub
Diff against target: 99 lines (+21/-17)
3 files modified
src/com/ubuntu/content/hub.cpp (+8/-2)
src/com/ubuntu/content/service/registry.cpp (+9/-12)
src/com/ubuntu/content/utils.cpp (+4/-3)
To merge this branch: bzr merge lp:~mterry/content-hub/ual-parse
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
Ken VanDine Approve
Review via email: mp+318791@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.

Tests weren't passing for me, but they aren't on trunk either. So I wasn't sure if I broke anything or not.

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Tests pass for me and look good. Thanks!

review: Approve
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)

Unmerged revisions

323. By Michael Terry

Use find, not parse, so that legacy apps are still supported

322. By Michael Terry

Use UAL to parse appids rather than embedding format information in content hub

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/com/ubuntu/content/hub.cpp'
2--- src/com/ubuntu/content/hub.cpp 2016-11-15 15:08:38 +0000
3+++ src/com/ubuntu/content/hub.cpp 2017-03-02 16:12:18 +0000
4@@ -352,7 +352,10 @@
5
6 cuc::Transfer *transfer = cuc::Transfer::Private::make_transfer(reply.value(), this);
7
8- QString peerName = peer.id().split("_")[0];
9+ auto ualAppID = ual::AppID::find(peer.id().toStdString());
10+ QString peerName = QString::fromStdString(ualAppID.package.value());
11+ if (peerName.isEmpty())
12+ return nullptr;
13 TRACE() << Q_FUNC_INFO << "peerName: " << peerName;
14 const cuc::Store *store = new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/" + peerName + "/HubIncoming/" + QString::number(transfer->id()), this};
15 TRACE() << Q_FUNC_INFO << "STORE:" << store->uri();
16@@ -378,7 +381,10 @@
17 return nullptr;
18
19 cuc::Transfer *transfer = cuc::Transfer::Private::make_transfer(reply.value(), this);
20- QString peerName = peer.id().split("_")[0];
21+ auto ualAppID = ual::AppID::find(peer.id().toStdString());
22+ QString peerName = QString::fromStdString(ualAppID.package.value());
23+ if (peerName.isEmpty())
24+ return nullptr;
25 TRACE() << Q_FUNC_INFO << "peerName: " << peerName;
26 const cuc::Store *store = new cuc::Store{QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/" + peerName + "/HubIncoming/" + QString::number(transfer->id()), this};
27 TRACE() << Q_FUNC_INFO << "STORE:" << store->uri();
28
29=== modified file 'src/com/ubuntu/content/service/registry.cpp'
30--- src/com/ubuntu/content/service/registry.cpp 2016-12-14 12:58:17 +0000
31+++ src/com/ubuntu/content/service/registry.cpp 2017-03-02 16:12:18 +0000
32@@ -25,6 +25,9 @@
33 #include <gio/gdesktopappinfo.h>
34 #include <libertine.h>
35 #include <ubuntu-app-launch.h>
36+#include <ubuntu-app-launch/appid.h>
37+
38+namespace ual = ubuntu::app_launch;
39
40 // Begin anonymous namespace
41 namespace {
42@@ -180,11 +183,8 @@
43 std::string pkg = as[0].toStdString();
44 std::string app = as[1].toStdString();
45 std::string ver = as[2].toStdString();
46- cuc::Peer peer;
47- if (app.empty() || ver.empty())
48- peer = QString::fromStdString(pkg);
49- else
50- peer = QString::fromLocal8Bit(ubuntu_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str()));
51+ auto appID = ual::AppID::discover(pkg, app, ver);
52+ cuc::Peer peer = QString::fromStdString(appID);
53 install_source_for_type(type, cuc::Peer{peer.id(), true});
54 }
55 }
56@@ -211,9 +211,8 @@
57 std::string pkg = as[0].toStdString();
58 std::string app = as[1].toStdString();
59 std::string ver = as[2].toStdString();
60- if (app.empty() || ver.empty())
61- return cuc::Peer(QString::fromStdString(pkg));
62- return cuc::Peer(QString::fromLocal8Bit(ubuntu_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str())), true);
63+ auto appID = ual::AppID::discover(pkg, app, ver);
64+ return cuc::Peer(QString::fromStdString(appID), true);
65 }
66 }
67
68@@ -277,10 +276,8 @@
69 std::string pkg = as[0].toStdString();
70 std::string app = as[1].toStdString();
71 std::string ver = as[2].toStdString();
72- if (app.empty() || ver.empty())
73- defaultPeer = QString::fromStdString(pkg) == k;
74- else
75- defaultPeer = QString::fromLocal8Bit(ubuntu_app_launch_triplet_to_app_id(pkg.c_str(), app.c_str(), ver.c_str())) == k;
76+ auto appID = ual::AppID::discover(pkg, app, ver);
77+ defaultPeer = QString::fromStdString(appID) == k;
78 }
79 }
80 for_each(cuc::Peer{k, defaultPeer});
81
82=== modified file 'src/com/ubuntu/content/utils.cpp'
83--- src/com/ubuntu/content/utils.cpp 2017-01-25 19:57:28 +0000
84+++ src/com/ubuntu/content/utils.cpp 2017-03-02 16:12:18 +0000
85@@ -404,10 +404,11 @@
86 QString shared_dir_for_peer(QString peer)
87 {
88 TRACE() << Q_FUNC_INFO << "PEER:" << peer;
89- QString container = peer.split("_")[0];
90- if (container.isEmpty())
91+ auto ualAppID = ual::AppID::find(peer.toStdString());
92+ std::string container = ualAppID.package.value();
93+ if (container.empty())
94 return QString();
95- QString home_path = libertine_container_home_path(container.toStdString().c_str());
96+ QString home_path = libertine_container_home_path(container.c_str());
97 if (home_path.isEmpty())
98 return QString();
99 QString path = home_path + "/shared";

Subscribers

People subscribed via source and target branches