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
1=== modified file 'plugins/OnlineAccountsPlugin/application-manager.cpp'
2--- plugins/OnlineAccountsPlugin/application-manager.cpp 2016-06-06 10:24:55 +0000
3+++ plugins/OnlineAccountsPlugin/application-manager.cpp 2017-01-16 13:22:19 +0000
4@@ -54,13 +54,17 @@
5 {
6 /* We need to load the XML file and look for the "profile" element. The
7 * file lookup would become unnecessary if a domDocument() method were
8- * added to the Accounts::Application class. */
9- QString localShare =
10- QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
11- QFile file(QString("%1/accounts/applications/%2.application").
12- arg(localShare).arg(applicationId));
13- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
14- qDebug() << "file not found:" << file.fileName();
15+ * added to the Accounts::Application class.
16+ * https://gitlab.com/accounts-sso/libaccounts-qt/issues/2
17+ */
18+ QString subPath(QString("accounts/applications/%2.application").
19+ arg(applicationId));
20+ QString filePath =
21+ QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath);
22+ QFile file(filePath);
23+ if (filePath.isEmpty() ||
24+ !file.open(QIODevice::ReadOnly | QIODevice::Text)) {
25+ qDebug() << "Application file not found:" << file.fileName();
26 /* libaccounts would fall back to looking into /usr/share/accounts/,
27 * but we know that .click packages don't install files in there, and
28 * currently the profile information is only attached to click
29
30=== modified file 'tests/plugin/tst_application_manager.cpp'
31--- tests/plugin/tst_application_manager.cpp 2015-09-24 12:58:34 +0000
32+++ tests/plugin/tst_application_manager.cpp 2017-01-16 13:22:19 +0000
33@@ -299,6 +299,37 @@
34 "unconfined" <<
35 "unconfined" <<
36 (QStringList() << "cool-mail");
37+
38+ QTest::newRow("confined app, no profile") <<
39+ "confinedApp" <<
40+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
41+ "<application id=\"confinedApp\">\n"
42+ " <description>My application 6</description>\n"
43+ " <services>\n"
44+ " <service id=\"cool-mail\">\n"
45+ " <description>Send email</description>\n"
46+ " </service>\n"
47+ " </services>\n"
48+ "</application>" <<
49+ "confinedApp" <<
50+ "" <<
51+ QStringList();
52+
53+ QTest::newRow("confined app, correct profile") <<
54+ "confinedApp" <<
55+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
56+ "<application id=\"confinedApp\">\n"
57+ " <description>My application 6</description>\n"
58+ " <services>\n"
59+ " <service id=\"cool-mail\">\n"
60+ " <description>Send email</description>\n"
61+ " </service>\n"
62+ " </services>\n"
63+ " <profile>confinedAppProfile</profile>\n"
64+ "</application>" <<
65+ "confinedAppProfile" <<
66+ "confinedAppProfile" <<
67+ (QStringList() << "cool-mail");
68 }
69
70 void ApplicationManagerTest::testApplicationInfo()
71@@ -316,9 +347,13 @@
72 ApplicationManager manager;
73
74 QVariantMap info = manager.applicationInfo(applicationId, inputProfile);
75- QCOMPARE(info.value("id").toString(), applicationId);
76- QCOMPARE(info.value("profile").toString(), expectedProfile);
77- QCOMPARE(info.value("services").toStringList().toSet(), services.toSet());
78+ if (expectedProfile.isEmpty()) {
79+ QVERIFY(info.isEmpty());
80+ } else {
81+ QCOMPARE(info.value("id").toString(), applicationId);
82+ QCOMPARE(info.value("profile").toString(), expectedProfile);
83+ QCOMPARE(info.value("services").toStringList().toSet(), services.toSet());
84+ }
85 }
86
87 void ApplicationManagerTest::testAclAdd_data()

Subscribers

People subscribed via source and target branches