Merge lp:~mardy/ubuntu-system-settings-online-accounts/confined-xdg-1656806 into lp:ubuntu-system-settings-online-accounts

Proposed by Alberto Mardegan
Status: Merged
Approved by: Alberto Mardegan
Approved revision: 413
Merged at revision: 413
Proposed branch: lp:~mardy/ubuntu-system-settings-online-accounts/confined-xdg-1656806
Merge into: lp:ubuntu-system-settings-online-accounts
Diff against target: 87 lines (+49/-10)
2 files modified
plugins/OnlineAccountsPlugin/application-manager.cpp (+11/-7)
tests/plugin/tst_application_manager.cpp (+38/-3)
To merge this branch: bzr merge lp:~mardy/ubuntu-system-settings-online-accounts/confined-xdg-1656806
Reviewer Review Type Date Requested Status
Renato Araujo Oliveira Filho (community) Approve
Review via email: mp+314846@code.launchpad.net

Commit message

Look for .application files in all XDG directories

Description of the change

Look for .application files in all XDG directories

To post a comment you must log in.
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

works nice.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/OnlineAccountsPlugin/application-manager.cpp'
--- plugins/OnlineAccountsPlugin/application-manager.cpp 2016-06-06 10:24:55 +0000
+++ plugins/OnlineAccountsPlugin/application-manager.cpp 2017-01-16 13:22:19 +0000
@@ -54,13 +54,17 @@
54{54{
55 /* We need to load the XML file and look for the "profile" element. The55 /* We need to load the XML file and look for the "profile" element. The
56 * file lookup would become unnecessary if a domDocument() method were56 * file lookup would become unnecessary if a domDocument() method were
57 * added to the Accounts::Application class. */57 * added to the Accounts::Application class.
58 QString localShare =58 * https://gitlab.com/accounts-sso/libaccounts-qt/issues/2
59 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);59 */
60 QFile file(QString("%1/accounts/applications/%2.application").60 QString subPath(QString("accounts/applications/%2.application").
61 arg(localShare).arg(applicationId));61 arg(applicationId));
62 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {62 QString filePath =
63 qDebug() << "file not found:" << file.fileName();63 QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath);
64 QFile file(filePath);
65 if (filePath.isEmpty() ||
66 !file.open(QIODevice::ReadOnly | QIODevice::Text)) {
67 qDebug() << "Application file not found:" << file.fileName();
64 /* libaccounts would fall back to looking into /usr/share/accounts/,68 /* libaccounts would fall back to looking into /usr/share/accounts/,
65 * but we know that .click packages don't install files in there, and69 * but we know that .click packages don't install files in there, and
66 * currently the profile information is only attached to click70 * currently the profile information is only attached to click
6771
=== modified file 'tests/plugin/tst_application_manager.cpp'
--- tests/plugin/tst_application_manager.cpp 2015-09-24 12:58:34 +0000
+++ tests/plugin/tst_application_manager.cpp 2017-01-16 13:22:19 +0000
@@ -299,6 +299,37 @@
299 "unconfined" <<299 "unconfined" <<
300 "unconfined" <<300 "unconfined" <<
301 (QStringList() << "cool-mail");301 (QStringList() << "cool-mail");
302
303 QTest::newRow("confined app, no profile") <<
304 "confinedApp" <<
305 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
306 "<application id=\"confinedApp\">\n"
307 " <description>My application 6</description>\n"
308 " <services>\n"
309 " <service id=\"cool-mail\">\n"
310 " <description>Send email</description>\n"
311 " </service>\n"
312 " </services>\n"
313 "</application>" <<
314 "confinedApp" <<
315 "" <<
316 QStringList();
317
318 QTest::newRow("confined app, correct profile") <<
319 "confinedApp" <<
320 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
321 "<application id=\"confinedApp\">\n"
322 " <description>My application 6</description>\n"
323 " <services>\n"
324 " <service id=\"cool-mail\">\n"
325 " <description>Send email</description>\n"
326 " </service>\n"
327 " </services>\n"
328 " <profile>confinedAppProfile</profile>\n"
329 "</application>" <<
330 "confinedAppProfile" <<
331 "confinedAppProfile" <<
332 (QStringList() << "cool-mail");
302}333}
303334
304void ApplicationManagerTest::testApplicationInfo()335void ApplicationManagerTest::testApplicationInfo()
@@ -316,9 +347,13 @@
316 ApplicationManager manager;347 ApplicationManager manager;
317348
318 QVariantMap info = manager.applicationInfo(applicationId, inputProfile);349 QVariantMap info = manager.applicationInfo(applicationId, inputProfile);
319 QCOMPARE(info.value("id").toString(), applicationId);350 if (expectedProfile.isEmpty()) {
320 QCOMPARE(info.value("profile").toString(), expectedProfile);351 QVERIFY(info.isEmpty());
321 QCOMPARE(info.value("services").toStringList().toSet(), services.toSet());352 } else {
353 QCOMPARE(info.value("id").toString(), applicationId);
354 QCOMPARE(info.value("profile").toString(), expectedProfile);
355 QCOMPARE(info.value("services").toStringList().toSet(), services.toSet());
356 }
322}357}
323358
324void ApplicationManagerTest::testAclAdd_data()359void ApplicationManagerTest::testAclAdd_data()

Subscribers

People subscribed via source and target branches