Merge lp:~seb128/ubuntu-system-settings/security-trust-localized-names into lp:ubuntu-system-settings

Proposed by Sebastien Bacher
Status: Merged
Approved by: Ken VanDine
Approved revision: 1084
Merged at revision: 1105
Proposed branch: lp:~seb128/ubuntu-system-settings/security-trust-localized-names
Merge into: lp:ubuntu-system-settings
Diff against target: 103 lines (+40/-8)
3 files modified
plugins/security-privacy/CMakeLists.txt (+2/-0)
plugins/security-privacy/trust-store-model.cpp (+36/-6)
tests/plugins/security-privacy/CMakeLists.txt (+2/-2)
To merge this branch: bzr merge lp:~seb128/ubuntu-system-settings/security-trust-localized-names
Reviewer Review Type Date Requested Status
Alberto Mardegan Approve
Ken VanDine Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+236137@code.launchpad.net

Commit message

[security] get localized application names from the trust-store

Description of the change

[security] get localized application names from the trust-store

use glib api for that since qt/qsettings don't seem to support that feature, and it's better to use a tested and supported glib function than doing a custom implementation around qt

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :

Just a few comments, but otherwise it looks good!

By the way, do we have a dependency on libglib2.0-dev in debian/control? (we might not need it, if we already depend on some library which depend on it)

review: Needs Fixing
Revision history for this message
Alberto Mardegan (mardy) wrote :

Oh, and please remove the QSettings #include.

1081. By Sebastien Bacher

indentation and spacing

1082. By Sebastien Bacher

Use QString::fromUtf8 as recommended in the review

Revision history for this message
Sebastien Bacher (seb128) wrote :

> Just a few comments, but otherwise it looks good!

thanks, addressed those

> By the way, do we have a dependency on libglib2.0-dev in debian/control?

yes we do, quite some of the backends use glib or glib based libraries

> Oh, and please remove the QSettings #include.

done as well

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1083. By Sebastien Bacher

some extra spacing tweak

1084. By Sebastien Bacher

update the cmakelist to fix build issue

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

the CI errors seem to have nothing to do with those changes (they are in the phone/sim section)

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good

review: Approve
Revision history for this message
Alberto Mardegan (mardy) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/security-privacy/CMakeLists.txt'
2--- plugins/security-privacy/CMakeLists.txt 2014-08-27 05:19:24 +0000
3+++ plugins/security-privacy/CMakeLists.txt 2014-09-29 11:03:33 +0000
4@@ -47,6 +47,7 @@
5 include_directories(
6 ${CMAKE_CURRENT_BINARY_DIR}
7 ${TRUST_STORE_INCLUDE_DIRS}
8+ ${GLIB_INCLUDE_DIRS}
9 )
10
11 set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/SecurityPrivacy)
12@@ -54,6 +55,7 @@
13 uss-accountsservice
14 ${ACCOUNTSSERVICE_LDFLAGS}
15 ${TRUST_STORE_LDFLAGS}
16+ ${GLIB_LDFLAGS}
17 )
18 install(TARGETS UbuntuSecurityPrivacyPanel UbuntuSecurityPrivacyHelper DESTINATION ${PLUG_DIR})
19 install(FILES qmldir DESTINATION ${PLUG_DIR})
20
21=== modified file 'plugins/security-privacy/trust-store-model.cpp'
22--- plugins/security-privacy/trust-store-model.cpp 2014-09-04 14:04:22 +0000
23+++ plugins/security-privacy/trust-store-model.cpp 2014-09-29 11:03:33 +0000
24@@ -25,12 +25,13 @@
25 #include <QList>
26 #include <QMap>
27 #include <QSet>
28-#include <QSettings>
29 #include <QStandardPaths>
30
31 #include <core/trust/resolve.h>
32 #include <core/trust/store.h>
33
34+#include <glib.h>
35+
36 class Application
37 {
38 public:
39@@ -39,12 +40,41 @@
40 void setId(const QString &id) {
41 this->id = id;
42
43+ GKeyFile *desktopInfo = g_key_file_new();
44 QString desktopFilename = resolveDesktopFilename(id);
45- QSettings desktopFile(desktopFilename, QSettings::IniFormat);
46- desktopFile.beginGroup("Desktop Entry");
47- displayName = desktopFile.value("Name").toString();
48- iconName = resolveIcon(desktopFile.value("Icon").toString(),
49- desktopFile.value("Path").toString());
50+
51+ gboolean loaded = g_key_file_load_from_file(desktopInfo,
52+ desktopFilename.toUtf8().data(),
53+ G_KEY_FILE_NONE,
54+ nullptr);
55+
56+ if (!loaded) {
57+ g_warning("Couldn't parse the desktop: %s", desktopFilename.toUtf8().data());
58+ g_key_file_free(desktopInfo);
59+ return;
60+ }
61+
62+ gchar *name = g_key_file_get_locale_string(desktopInfo,
63+ G_KEY_FILE_DESKTOP_GROUP,
64+ G_KEY_FILE_DESKTOP_KEY_NAME,
65+ nullptr,
66+ nullptr);
67+ displayName = QString::fromUtf8(name);
68+
69+ gchar *icon = g_key_file_get_string(desktopInfo,
70+ G_KEY_FILE_DESKTOP_GROUP,
71+ G_KEY_FILE_DESKTOP_KEY_ICON,
72+ nullptr);
73+ gchar *path = g_key_file_get_string(desktopInfo,
74+ G_KEY_FILE_DESKTOP_GROUP,
75+ G_KEY_FILE_DESKTOP_KEY_PATH,
76+ nullptr);
77+ iconName = resolveIcon(QString::fromUtf8(icon),
78+ QString::fromUtf8(path));
79+ g_free(name);
80+ g_free(icon);
81+ g_free(path);
82+ g_key_file_free(desktopInfo);
83 }
84
85 QString resolveDesktopFilename(const QString &id) {
86
87=== modified file 'tests/plugins/security-privacy/CMakeLists.txt'
88--- tests/plugins/security-privacy/CMakeLists.txt 2014-08-18 07:50:41 +0000
89+++ tests/plugins/security-privacy/CMakeLists.txt 2014-09-29 11:03:33 +0000
90@@ -1,11 +1,11 @@
91 set(XVFB_CMD xvfb-run -a -s "-screen 0 640x480x24")
92-include_directories(${CMAKE_CURRENT_BINARY_DIR} ../../../plugins/security-privacy)
93+include_directories(${CMAKE_CURRENT_BINARY_DIR} ../../../plugins/security-privacy ${GLIB_INCLUDE_DIRS})
94 add_definitions(-DTESTS)
95
96 add_executable(tst-trust-store-model
97 tst_trust_store_model.cpp
98 ../../../plugins/security-privacy/trust-store-model.cpp
99 )
100-
101+target_link_libraries (tst-trust-store-model ${GLIB_LDFLAGS})
102 qt5_use_modules(tst-trust-store-model Core Gui DBus Qml Test)
103 add_test(NAME tst-trust-store-model COMMAND ${XVFB_CMD} ${CMAKE_CURRENT_BINARY_DIR}/tst-trust-store-model)

Subscribers

People subscribed via source and target branches