Merge lp:~unity-api-team/libusermetrics/read-translations-from-click into lp:libusermetrics/rtm-14.09
- read-translations-from-click
- Merge into rtm-14.09
Proposed by
Pete Woods
Status: | Merged |
---|---|
Approved by: | Pete Woods |
Approved revision: | 195 |
Merged at revision: | 189 |
Proposed branch: | lp:~unity-api-team/libusermetrics/read-translations-from-click |
Merge into: | lp:libusermetrics/rtm-14.09 |
Diff against target: |
865 lines (+261/-56) 21 files modified
CMakeLists.txt (+10/-1) data/com.canonical.usermetrics.DataSource.xml (+2/-0) debian/control (+1/-0) src/libusermetricscommon/DateFactory.h (+1/-0) src/libusermetricsoutput/SyncedDataSource.cpp (+2/-2) src/libusermetricsoutput/SyncedDataSource.h (+1/-1) src/libusermetricsoutput/SyncedUserMetricsStore.cpp (+3/-5) src/libusermetricsoutput/SyncedUserMetricsStore.h (+1/-3) src/usermetricsservice/CMakeLists.txt (+6/-2) src/usermetricsservice/DBusDataSet.h (+1/-0) src/usermetricsservice/DBusDataSource.cpp (+9/-2) src/usermetricsservice/DBusDataSource.h (+14/-1) src/usermetricsservice/DBusUserMetrics.cpp (+5/-4) src/usermetricsservice/DBusUserMetrics.h (+5/-1) src/usermetricsservice/TranslationLocator.h (+34/-0) src/usermetricsservice/TranslationLocatorImpl.cpp (+69/-0) src/usermetricsservice/TranslationLocatorImpl.h (+34/-0) src/usermetricsservice/main.cpp (+3/-1) tests/data/valgrind.suppression (+15/-0) tests/integration/libusermetricsoutput/TestUserMetrics.cpp (+3/-3) tests/unit/usermetricsservice/TestUserMetricsService.cpp (+42/-30) |
To merge this branch: | bzr merge lp:~unity-api-team/libusermetrics/read-translations-from-click |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email: mp+247973@code.launchpad.net |
Commit message
Read translations from click packages
Description of the change
Read translations from click packages
To post a comment you must log in.
- 190. By Pete Woods
-
Remove debugging code
- 191. By Pete Woods
-
Remove noise
- 192. By Pete Woods
-
There's a new leak in QNetworkAccessM
anager - 193. By Pete Woods
-
Build under latest Qt revision
- 194. By Pete Woods
-
More fixes for new Qt version
- 195. By Pete Woods
-
Disable pointless test
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2013-09-26 09:12:58 +0000 |
3 | +++ CMakeLists.txt 2015-02-18 16:24:46 +0000 |
4 | @@ -40,6 +40,15 @@ |
5 | find_package(Qt5Qml REQUIRED) |
6 | include_directories(${Qt5Qml_INCLUDE_DIRS}) |
7 | |
8 | +pkg_check_modules(GLIB2 REQUIRED glib-2.0) |
9 | +include_directories(${GLIB2_INCLUDE_DIRS}) |
10 | + |
11 | +pkg_check_modules(GOBJECT2 REQUIRED gobject-2.0) |
12 | +include_directories(${GOBJECT2_INCLUDE_DIRS}) |
13 | + |
14 | +pkg_check_modules(CLICK REQUIRED click-0.4 REQUIRED) |
15 | +include_directories(${CLICK_INCLUDE_DIRS}) |
16 | + |
17 | pkg_check_modules(QDJANGO_DB REQUIRED qdjango-db REQUIRED) |
18 | include_directories(${QDJANGO_DB_INCLUDE_DIRS}) |
19 | |
20 | @@ -98,4 +107,4 @@ |
21 | ADD_CUSTOM_TARGET( |
22 | check |
23 | ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure |
24 | -) |
25 | \ No newline at end of file |
26 | +) |
27 | |
28 | === modified file 'data/com.canonical.usermetrics.DataSource.xml' |
29 | --- data/com.canonical.usermetrics.DataSource.xml 2013-09-03 14:59:00 +0000 |
30 | +++ data/com.canonical.usermetrics.DataSource.xml 2015-02-18 16:24:46 +0000 |
31 | @@ -38,5 +38,7 @@ |
32 | <arg name="options" type="a{sv}" direction="out"/> |
33 | </signal> |
34 | |
35 | + <property name="translationPath" type="s" access="read"/> |
36 | + |
37 | </interface> |
38 | </node> |
39 | \ No newline at end of file |
40 | |
41 | === modified file 'debian/control' |
42 | --- debian/control 2014-09-08 08:11:49 +0000 |
43 | +++ debian/control 2015-02-18 16:24:46 +0000 |
44 | @@ -9,6 +9,7 @@ |
45 | gettext, |
46 | google-mock (>= 1.6.0+svn437), |
47 | libapparmor-dev, |
48 | + libclick-0.4-dev, |
49 | libgsettings-qt-dev, |
50 | libgtest-dev, |
51 | libqdjango-dev, |
52 | |
53 | === modified file 'src/libusermetricscommon/DateFactory.h' |
54 | --- src/libusermetricscommon/DateFactory.h 2013-06-26 15:40:46 +0000 |
55 | +++ src/libusermetricscommon/DateFactory.h 2015-02-18 16:24:46 +0000 |
56 | @@ -20,6 +20,7 @@ |
57 | #define USERMETRICSCOMMON_DATEFACTORY_H_ |
58 | |
59 | #include <QtCore/QDate> |
60 | +#include <QtCore/QObject> |
61 | |
62 | namespace UserMetricsCommon { |
63 | |
64 | |
65 | === modified file 'src/libusermetricsoutput/SyncedDataSource.cpp' |
66 | --- src/libusermetricsoutput/SyncedDataSource.cpp 2013-09-04 09:09:23 +0000 |
67 | +++ src/libusermetricsoutput/SyncedDataSource.cpp 2015-02-18 16:24:46 +0000 |
68 | @@ -22,8 +22,8 @@ |
69 | |
70 | SyncedDataSource::SyncedDataSource( |
71 | QSharedPointer<com::canonical::usermetrics::DataSource> interface, |
72 | - const QString &localeDir, QObject *parent) : |
73 | - DataSource(localeDir, parent), m_interface(interface) { |
74 | + QObject *parent) : |
75 | + DataSource(interface->translationPath(), parent), m_interface(interface) { |
76 | |
77 | connect(m_interface.data(), SIGNAL(formatStringChanged(const QString &)), |
78 | this, SLOT(setFormatString(const QString &))); |
79 | |
80 | === modified file 'src/libusermetricsoutput/SyncedDataSource.h' |
81 | --- src/libusermetricsoutput/SyncedDataSource.h 2013-09-04 09:09:23 +0000 |
82 | +++ src/libusermetricsoutput/SyncedDataSource.h 2015-02-18 16:24:46 +0000 |
83 | @@ -30,7 +30,7 @@ |
84 | public: |
85 | SyncedDataSource( |
86 | QSharedPointer<com::canonical::usermetrics::DataSource> interface, |
87 | - const QString &localeDir = LOCALEDIR, QObject *parent = 0); |
88 | + QObject *parent = 0); |
89 | |
90 | virtual ~SyncedDataSource(); |
91 | |
92 | |
93 | === modified file 'src/libusermetricsoutput/SyncedUserMetricsStore.cpp' |
94 | --- src/libusermetricsoutput/SyncedUserMetricsStore.cpp 2013-10-22 08:53:23 +0000 |
95 | +++ src/libusermetricsoutput/SyncedUserMetricsStore.cpp 2015-02-18 16:24:46 +0000 |
96 | @@ -28,11 +28,9 @@ |
97 | using namespace UserMetricsOutput; |
98 | |
99 | SyncedUserMetricsStore::SyncedUserMetricsStore( |
100 | - const QDBusConnection &dbusConnection, const QString &localeDir, |
101 | - QObject *parent) : |
102 | + const QDBusConnection &dbusConnection, QObject *parent) : |
103 | UserMetricsStore(parent), m_interface(DBusPaths::serviceName(), |
104 | - DBusPaths::userMetrics(), dbusConnection), m_localeDir( |
105 | - localeDir) { |
106 | + DBusPaths::userMetrics(), dbusConnection) { |
107 | QTimer::singleShot(0, this, SLOT(sync())); |
108 | } |
109 | |
110 | @@ -134,7 +132,7 @@ |
111 | path.path(), m_interface.connection())); |
112 | |
113 | insert(path.path(), |
114 | - DataSourcePtr(new SyncedDataSource(dataSource, m_localeDir))); |
115 | + DataSourcePtr(new SyncedDataSource(dataSource))); |
116 | } |
117 | |
118 | void SyncedUserMetricsStore::removeDataSource(const QDBusObjectPath &path) { |
119 | |
120 | === modified file 'src/libusermetricsoutput/SyncedUserMetricsStore.h' |
121 | --- src/libusermetricsoutput/SyncedUserMetricsStore.h 2013-10-22 08:53:23 +0000 |
122 | +++ src/libusermetricsoutput/SyncedUserMetricsStore.h 2015-02-18 16:24:46 +0000 |
123 | @@ -30,7 +30,7 @@ |
124 | |
125 | public: |
126 | explicit SyncedUserMetricsStore(const QDBusConnection &dbusConnection, |
127 | - const QString &localeDir = LOCALEDIR, QObject *parent = 0); |
128 | + QObject *parent = 0); |
129 | |
130 | virtual ~SyncedUserMetricsStore(); |
131 | |
132 | @@ -53,8 +53,6 @@ |
133 | QSharedPointer<com::canonical::usermetrics::UserData> systemData); |
134 | |
135 | com::canonical::UserMetrics m_interface; |
136 | - |
137 | - QString m_localeDir; |
138 | } |
139 | ; |
140 | |
141 | |
142 | === modified file 'src/usermetricsservice/CMakeLists.txt' |
143 | --- src/usermetricsservice/CMakeLists.txt 2013-09-24 11:26:56 +0000 |
144 | +++ src/usermetricsservice/CMakeLists.txt 2015-02-18 16:24:46 +0000 |
145 | @@ -8,6 +8,7 @@ |
146 | DBusDataSource.cpp |
147 | DBusUserData.cpp |
148 | DBusUserMetrics.cpp |
149 | + TranslationLocatorImpl.cpp |
150 | ) |
151 | |
152 | qt5_add_dbus_adaptor( |
153 | @@ -58,8 +59,11 @@ |
154 | target_link_libraries( |
155 | usermetricsservice |
156 | usermetricscommon |
157 | - ${QDJANGO_DB_LIBRARIES} |
158 | - ${APPARMOR_LIBRARIES} |
159 | + ${QDJANGO_DB_LDFLAGS} |
160 | + ${APPARMOR_LDFLAGS} |
161 | + ${GLIB2_LDFLAGS} |
162 | + ${GOBJECT2_LDFLAGS} |
163 | + ${CLICK_LDFLAGS} |
164 | ) |
165 | |
166 | ############################ |
167 | |
168 | === modified file 'src/usermetricsservice/DBusDataSet.h' |
169 | --- src/usermetricsservice/DBusDataSet.h 2013-10-22 08:53:23 +0000 |
170 | +++ src/usermetricsservice/DBusDataSet.h 2015-02-18 16:24:46 +0000 |
171 | @@ -22,6 +22,7 @@ |
172 | #include <QtCore/QObject> |
173 | #include <QtCore/QDate> |
174 | #include <QtCore/QScopedPointer> |
175 | +#include <QtCore/QSharedPointer> |
176 | #include <QtDBus/QDBusContext> |
177 | #include <QtDBus/QDBusConnection> |
178 | #include <QtDBus/QDBusObjectPath> |
179 | |
180 | === modified file 'src/usermetricsservice/DBusDataSource.cpp' |
181 | --- src/usermetricsservice/DBusDataSource.cpp 2013-09-25 09:42:13 +0000 |
182 | +++ src/usermetricsservice/DBusDataSource.cpp 2015-02-18 16:24:46 +0000 |
183 | @@ -21,6 +21,7 @@ |
184 | #include <usermetricsservice/database/DataSource.h> |
185 | #include <usermetricsservice/DBusDataSource.h> |
186 | #include <usermetricsservice/DataSourceAdaptor.h> |
187 | +#include <usermetricsservice/TranslationLocator.h> |
188 | #include <libusermetricscommon/DBusPaths.h> |
189 | #include <libusermetricscommon/Localisation.h> |
190 | |
191 | @@ -31,10 +32,12 @@ |
192 | using namespace UserMetricsService; |
193 | |
194 | DBusDataSource::DBusDataSource(int id, const QString &name, |
195 | - QDBusConnection &dbusConnection, QObject *parent) : |
196 | + const QString &packageId, QDBusConnection &dbusConnection, |
197 | + QSharedPointer<TranslationLocator> translationLocator, QObject *parent) : |
198 | QObject(parent), m_dbusConnection(dbusConnection), m_adaptor( |
199 | new DataSourceAdaptor(this)), m_id(id), m_path( |
200 | - DBusPaths::dataSource(m_id)), m_name(name) { |
201 | + DBusPaths::dataSource(m_id)), m_name(name), m_packageId( |
202 | + packageId), m_translationLocator(translationLocator) { |
203 | |
204 | // DBus setup |
205 | m_dbusConnection.registerObject(m_path, this); |
206 | @@ -49,6 +52,10 @@ |
207 | return m_path; |
208 | } |
209 | |
210 | +QString DBusDataSource::translationPath() const { |
211 | + return m_translationLocator->locate(m_packageId); |
212 | +} |
213 | + |
214 | QString DBusDataSource::name() const { |
215 | return m_name; |
216 | } |
217 | |
218 | === modified file 'src/usermetricsservice/DBusDataSource.h' |
219 | --- src/usermetricsservice/DBusDataSource.h 2013-09-25 09:42:13 +0000 |
220 | +++ src/usermetricsservice/DBusDataSource.h 2015-02-18 16:24:46 +0000 |
221 | @@ -21,6 +21,7 @@ |
222 | |
223 | #include <QtCore/QObject> |
224 | #include <QtCore/QScopedPointer> |
225 | +#include <QtCore/QSharedPointer> |
226 | #include <QtDBus/QDBusContext> |
227 | #include <QtDBus/QDBusConnection> |
228 | |
229 | @@ -30,6 +31,7 @@ |
230 | |
231 | class DataSource; |
232 | class DBusDataSource; |
233 | +class TranslationLocator; |
234 | |
235 | typedef QSharedPointer<DBusDataSource> DBusDataSourcePtr; |
236 | |
237 | @@ -44,18 +46,23 @@ |
238 | |
239 | Q_PROPERTY(QString textDomain READ textDomain WRITE setTextDomain) |
240 | |
241 | +Q_PROPERTY(QString translationPath READ translationPath) |
242 | + |
243 | Q_PROPERTY(unsigned int metricType READ metricType WRITE setMetricType) |
244 | |
245 | Q_PROPERTY(QVariantMap options READ options) |
246 | |
247 | public: |
248 | - DBusDataSource(int id, const QString &name, QDBusConnection &dbusConnection, |
249 | + DBusDataSource(int id, const QString &name, const QString &packageId, |
250 | + QDBusConnection &dbusConnection, QSharedPointer<TranslationLocator>, |
251 | QObject *parent = 0); |
252 | |
253 | virtual ~DBusDataSource(); |
254 | |
255 | QString path() const; |
256 | |
257 | + QString translationPath() const; |
258 | + |
259 | QString name() const; |
260 | |
261 | QString formatString() const; |
262 | @@ -107,7 +114,13 @@ |
263 | |
264 | QString m_path; |
265 | |
266 | + QString m_translationPath; |
267 | + |
268 | QString m_name; |
269 | + |
270 | + QString m_packageId; |
271 | + |
272 | + QSharedPointer<TranslationLocator> m_translationLocator; |
273 | }; |
274 | |
275 | } |
276 | |
277 | === modified file 'src/usermetricsservice/DBusUserMetrics.cpp' |
278 | --- src/usermetricsservice/DBusUserMetrics.cpp 2013-10-22 08:53:23 +0000 |
279 | +++ src/usermetricsservice/DBusUserMetrics.cpp 2015-02-18 16:24:46 +0000 |
280 | @@ -39,10 +39,11 @@ |
281 | |
282 | DBusUserMetrics::DBusUserMetrics(const QDBusConnection &dbusConnection, |
283 | QSharedPointer<DateFactory> dateFactory, |
284 | - QSharedPointer<Authentication> authentication, QObject *parent) : |
285 | + QSharedPointer<Authentication> authentication, |
286 | + QSharedPointer<TranslationLocator> translationLocator, QObject *parent) : |
287 | QObject(parent), m_dbusConnection(dbusConnection), m_adaptor( |
288 | new UserMetricsAdaptor(this)), m_dateFactory(dateFactory), m_authentication( |
289 | - authentication) { |
290 | + authentication), m_translationLocator(translationLocator) { |
291 | // Database setup |
292 | QDjango::registerModel<DataSource>().createTable(); |
293 | QDjango::registerModel<UserData>().createTable(); |
294 | @@ -79,8 +80,8 @@ |
295 | // if we don't have a local cache |
296 | if (!m_dataSources.contains(id)) { |
297 | DBusDataSourcePtr dbusDataSource( |
298 | - new DBusDataSource(id, dataSource.name(), |
299 | - m_dbusConnection)); |
300 | + new DBusDataSource(id, dataSource.name(), dataSource.secret(), |
301 | + m_dbusConnection, m_translationLocator)); |
302 | m_dataSources.insert(id, dbusDataSource); |
303 | m_adaptor->dataSourceAdded( |
304 | QDBusObjectPath(dbusDataSource->path())); |
305 | |
306 | === modified file 'src/usermetricsservice/DBusUserMetrics.h' |
307 | --- src/usermetricsservice/DBusUserMetrics.h 2013-10-01 10:22:38 +0000 |
308 | +++ src/usermetricsservice/DBusUserMetrics.h 2015-02-18 16:24:46 +0000 |
309 | @@ -38,6 +38,7 @@ |
310 | class DBusDataSource; |
311 | class DBusUserData; |
312 | class Authentication; |
313 | +class TranslationLocator; |
314 | |
315 | class DBusUserMetrics: public QObject, protected QDBusContext { |
316 | Q_OBJECT |
317 | @@ -49,7 +50,8 @@ |
318 | public: |
319 | DBusUserMetrics(const QDBusConnection &dbusConnection, |
320 | QSharedPointer<UserMetricsCommon::DateFactory> dateFactory, |
321 | - QSharedPointer<Authentication> authentication, QObject *parent = 0); |
322 | + QSharedPointer<Authentication> authentication, |
323 | + QSharedPointer<TranslationLocator>, QObject *parent = 0); |
324 | |
325 | virtual ~DBusUserMetrics(); |
326 | |
327 | @@ -80,6 +82,8 @@ |
328 | |
329 | QSharedPointer<Authentication> m_authentication; |
330 | |
331 | + QSharedPointer<TranslationLocator> m_translationLocator; |
332 | + |
333 | QMap<int, QSharedPointer<DBusDataSource>> m_dataSources; |
334 | |
335 | QMap<int, QSharedPointer<DBusUserData>> m_userData; |
336 | |
337 | === added file 'src/usermetricsservice/TranslationLocator.h' |
338 | --- src/usermetricsservice/TranslationLocator.h 1970-01-01 00:00:00 +0000 |
339 | +++ src/usermetricsservice/TranslationLocator.h 2015-02-18 16:24:46 +0000 |
340 | @@ -0,0 +1,34 @@ |
341 | +/* |
342 | + * Copyright (C) 2013 Canonical, Ltd. |
343 | + * |
344 | + * This program is free software; you can redistribute it and/or modify |
345 | + * it under the terms of the GNU General Public License as published by |
346 | + * the Free Software Foundation; version 3. |
347 | + * |
348 | + * This program is distributed in the hope that it will be useful, |
349 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
350 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
351 | + * GNU General Public License for more details. |
352 | + * |
353 | + * You should have received a copy of the GNU General Public License |
354 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
355 | + * |
356 | + * Author: Pete Woods <pete.woods@canonical.com> |
357 | + */ |
358 | + |
359 | +#pragma once |
360 | + |
361 | +#include <QString> |
362 | + |
363 | +namespace UserMetricsService { |
364 | + |
365 | +class TranslationLocator { |
366 | +public: |
367 | + TranslationLocator() = default; |
368 | + |
369 | + virtual ~TranslationLocator() = default; |
370 | + |
371 | + virtual QString locate(const QString& id) = 0; |
372 | +}; |
373 | + |
374 | +} |
375 | |
376 | === added file 'src/usermetricsservice/TranslationLocatorImpl.cpp' |
377 | --- src/usermetricsservice/TranslationLocatorImpl.cpp 1970-01-01 00:00:00 +0000 |
378 | +++ src/usermetricsservice/TranslationLocatorImpl.cpp 2015-02-18 16:24:46 +0000 |
379 | @@ -0,0 +1,69 @@ |
380 | +/* |
381 | + * Copyright (C) 2013 Canonical, Ltd. |
382 | + * |
383 | + * This program is free software; you can redistribute it and/or modify |
384 | + * it under the terms of the GNU General Public License as published by |
385 | + * the Free Software Foundation; version 3. |
386 | + * |
387 | + * This program is distributed in the hope that it will be useful, |
388 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
389 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
390 | + * GNU General Public License for more details. |
391 | + * |
392 | + * You should have received a copy of the GNU General Public License |
393 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
394 | + * |
395 | + * Author: Pete Woods <pete.woods@canonical.com> |
396 | + */ |
397 | + |
398 | +#define QT_NO_SIGNALS_SLOTS_KEYWORDS 1 |
399 | + |
400 | +#include <usermetricsservice/TranslationLocatorImpl.h> |
401 | + |
402 | +#include <QDebug> |
403 | +#include <QDir> |
404 | +#include <QSharedPointer> |
405 | + |
406 | +#include <click-0.4/click.h> |
407 | + |
408 | +namespace UserMetricsService { |
409 | + |
410 | +namespace { |
411 | +QString pkgdir(const QString& id) { |
412 | + QSharedPointer<ClickDB> db(click_db_new(), &g_object_unref); |
413 | + |
414 | + GError *error = nullptr; |
415 | + click_db_read(db.data(), nullptr, &error); |
416 | + if (error != nullptr) { |
417 | + qWarning() << error->message; |
418 | + g_error_free(error); |
419 | + return QString(); |
420 | + } |
421 | + |
422 | + error = nullptr; |
423 | + char *path = click_db_get_path(db.data(), id.toUtf8().constData(), "current", &error); |
424 | + if (error != nullptr) { |
425 | + qWarning() << error->message; |
426 | + g_error_free(error); |
427 | + return QString(); |
428 | + } |
429 | + |
430 | + QString result = QString::fromUtf8(path); |
431 | + g_free(path); |
432 | + |
433 | + return result; |
434 | +} |
435 | +} |
436 | + |
437 | +TranslationLocatorImpl::TranslationLocatorImpl() { |
438 | +} |
439 | + |
440 | +QString TranslationLocatorImpl::locate(const QString& id) { |
441 | + QString translationPath = "/usr/share/locale-langpack"; |
442 | + if (id != "unconfined") { |
443 | + translationPath = QDir(pkgdir(id)).filePath("share/locale"); |
444 | + } |
445 | + return translationPath; |
446 | +} |
447 | + |
448 | +} |
449 | |
450 | === added file 'src/usermetricsservice/TranslationLocatorImpl.h' |
451 | --- src/usermetricsservice/TranslationLocatorImpl.h 1970-01-01 00:00:00 +0000 |
452 | +++ src/usermetricsservice/TranslationLocatorImpl.h 2015-02-18 16:24:46 +0000 |
453 | @@ -0,0 +1,34 @@ |
454 | +/* |
455 | + * Copyright (C) 2013 Canonical, Ltd. |
456 | + * |
457 | + * This program is free software; you can redistribute it and/or modify |
458 | + * it under the terms of the GNU General Public License as published by |
459 | + * the Free Software Foundation; version 3. |
460 | + * |
461 | + * This program is distributed in the hope that it will be useful, |
462 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
463 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
464 | + * GNU General Public License for more details. |
465 | + * |
466 | + * You should have received a copy of the GNU General Public License |
467 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
468 | + * |
469 | + * Author: Pete Woods <pete.woods@canonical.com> |
470 | + */ |
471 | + |
472 | +#pragma once |
473 | + |
474 | +#include <usermetricsservice/TranslationLocator.h> |
475 | + |
476 | +namespace UserMetricsService { |
477 | + |
478 | +class TranslationLocatorImpl: public TranslationLocator { |
479 | +public: |
480 | + TranslationLocatorImpl(); |
481 | + |
482 | + ~TranslationLocatorImpl() = default; |
483 | + |
484 | + QString locate(const QString& id) override; |
485 | +}; |
486 | + |
487 | +} |
488 | |
489 | === modified file 'src/usermetricsservice/main.cpp' |
490 | --- src/usermetricsservice/main.cpp 2014-01-16 14:07:02 +0000 |
491 | +++ src/usermetricsservice/main.cpp 2015-02-18 16:24:46 +0000 |
492 | @@ -18,6 +18,7 @@ |
493 | |
494 | #include <usermetricsservice/Authentication.h> |
495 | #include <usermetricsservice/DBusUserMetrics.h> |
496 | +#include <usermetricsservice/TranslationLocatorImpl.h> |
497 | #include <libusermetricscommon/DateFactoryImpl.h> |
498 | #include <libusermetricscommon/DBusPaths.h> |
499 | #include <libusermetricscommon/Localisation.h> |
500 | @@ -71,8 +72,9 @@ |
501 | |
502 | QSharedPointer<DateFactory> dateFactory(new DateFactoryImpl()); |
503 | QSharedPointer<Authentication> authentication(new Authentication()); |
504 | + QSharedPointer<TranslationLocator> translationLocator(new TranslationLocatorImpl()); |
505 | |
506 | - DBusUserMetrics userMetrics(connection, dateFactory, authentication); |
507 | + DBusUserMetrics userMetrics(connection, dateFactory, authentication, translationLocator); |
508 | if (!connection.registerService(DBusPaths::serviceName())) { |
509 | qWarning() << _("Unable to register user metrics service on DBus"); |
510 | return 1; |
511 | |
512 | === modified file 'tests/data/valgrind.suppression' |
513 | --- tests/data/valgrind.suppression 2014-01-20 12:28:40 +0000 |
514 | +++ tests/data/valgrind.suppression 2015-02-18 16:24:46 +0000 |
515 | @@ -36,6 +36,21 @@ |
516 | } |
517 | |
518 | { |
519 | + New leak in QNetworkConfiguratioManager |
520 | + Memcheck:Leak |
521 | + match-leak-kinds: definite |
522 | + fun:_Znw* |
523 | + obj:* |
524 | + fun:_ZN35QNetworkConfigurationManagerPrivate20updateConfigurationsEv |
525 | + fun:_ZN35QNetworkConfigurationManagerPrivate10initializeEv |
526 | + fun:_Z35qNetworkConfigurationManagerPrivatev |
527 | + fun:_ZN28QNetworkConfigurationManagerC1EP7QObject |
528 | + fun:_ZN21QNetworkAccessManagerC1EP7QObject |
529 | + obj:/usr/lib/*/libQt5XmlPatterns.so.* |
530 | + ... |
531 | +} |
532 | + |
533 | +{ |
534 | See bug report <https://bugreports.qt-project.org/browse/QTBUG-33677> |
535 | Memcheck:Leak |
536 | fun:_Znwj |
537 | |
538 | === modified file 'tests/integration/libusermetricsoutput/TestUserMetrics.cpp' |
539 | --- tests/integration/libusermetricsoutput/TestUserMetrics.cpp 2013-08-15 09:06:26 +0000 |
540 | +++ tests/integration/libusermetricsoutput/TestUserMetrics.cpp 2015-02-18 16:24:46 +0000 |
541 | @@ -38,9 +38,9 @@ |
542 | }; |
543 | |
544 | TEST_F(TestUserMetrics, MethodBarDoesAbc) { |
545 | - QScopedPointer<UserMetrics> model(UserMetrics::getInstance()); |
546 | - model->setUsername("guest"); |
547 | - EXPECT_EQ("guest", model->username()); |
548 | +// QScopedPointer<UserMetrics> model(UserMetrics::getInstance()); |
549 | +// model->setUsername("guest"); |
550 | +// EXPECT_EQ("guest", model->username()); |
551 | } |
552 | |
553 | } // namespace |
554 | |
555 | === modified file 'tests/unit/usermetricsservice/TestUserMetricsService.cpp' |
556 | --- tests/unit/usermetricsservice/TestUserMetricsService.cpp 2014-01-20 11:53:34 +0000 |
557 | +++ tests/unit/usermetricsservice/TestUserMetricsService.cpp 2015-02-18 16:24:46 +0000 |
558 | @@ -23,6 +23,7 @@ |
559 | #include <usermetricsservice/DBusDataSource.h> |
560 | #include <usermetricsservice/DBusUserData.h> |
561 | #include <usermetricsservice/DBusDataSet.h> |
562 | +#include <usermetricsservice/TranslationLocator.h> |
563 | #include <libusermetricscommon/DateFactory.h> |
564 | #include <libusermetricscommon/DBusPaths.h> |
565 | |
566 | @@ -55,6 +56,11 @@ |
567 | MOCK_CONST_METHOD3(sendErrorReply, void(const QDBusContext&, QDBusError::ErrorType, const QString &)); |
568 | }; |
569 | |
570 | +class MockTranslationLocator: public TranslationLocator { |
571 | +public: |
572 | + MOCK_METHOD1(locate, QString(const QString&)); |
573 | +}; |
574 | + |
575 | class MockDateFactory: public DateFactory { |
576 | public: |
577 | MOCK_CONST_METHOD0(currentDate, QDate()); |
578 | @@ -67,7 +73,8 @@ |
579 | QSqlDatabase::addDatabase("QSQLITE", |
580 | "test-user-metrics-service")), dateFactory( |
581 | new NiceMock<MockDateFactory>()), authentication( |
582 | - new NiceMock<MockAuthentication>()) { |
583 | + new NiceMock<MockAuthentication>()), translationLocator( |
584 | + new NiceMock<MockTranslationLocator>()) { |
585 | db.setDatabaseName(":memory:"); |
586 | if (!db.open()) { |
587 | throw logic_error("Could not open memory database"); |
588 | @@ -79,6 +86,9 @@ |
589 | ON_CALL(*authentication, getConfinementContext( |
590 | _)).WillByDefault(Return(QString("unconfined"))); |
591 | |
592 | + ON_CALL(*translationLocator, locate( |
593 | + _)).WillByDefault(Return(QString())); |
594 | + |
595 | // QDjango::setDebugEnabled(true); |
596 | QDjango::setDatabase(db); |
597 | } |
598 | @@ -94,12 +104,14 @@ |
599 | QSharedPointer<MockDateFactory> dateFactory; |
600 | |
601 | QSharedPointer<MockAuthentication> authentication; |
602 | + |
603 | + QSharedPointer<MockTranslationLocator> translationLocator; |
604 | }; |
605 | |
606 | TEST_F(TestUserMetricsService, PersistsDataSourcesBetweenRestart) { |
607 | { |
608 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
609 | - authentication); |
610 | + authentication, translationLocator); |
611 | |
612 | EXPECT_TRUE(userMetrics.dataSources().empty()); |
613 | |
614 | @@ -120,7 +132,7 @@ |
615 | |
616 | { |
617 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
618 | - authentication); |
619 | + authentication, translationLocator); |
620 | |
621 | QList<QDBusObjectPath> dataSources(userMetrics.dataSources()); |
622 | EXPECT_EQ(1, dataSources.size()); |
623 | @@ -138,7 +150,7 @@ |
624 | TEST_F(TestUserMetricsService, UpdatesFormatString) { |
625 | { |
626 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
627 | - authentication); |
628 | + authentication, translationLocator); |
629 | |
630 | userMetrics.createDataSource("twitter", "%1 tweets received", "", "", 0, |
631 | QVariantMap()); |
632 | @@ -152,7 +164,7 @@ |
633 | |
634 | { |
635 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
636 | - authentication); |
637 | + authentication, translationLocator); |
638 | |
639 | DBusDataSourcePtr twitter(userMetrics.dataSource("twitter")); |
640 | EXPECT_EQ(QString("%1 new format string"), twitter->formatString()); |
641 | @@ -162,7 +174,7 @@ |
642 | TEST_F(TestUserMetricsService, UpdatesEmptyDataString) { |
643 | { |
644 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
645 | - authentication); |
646 | + authentication, translationLocator); |
647 | |
648 | userMetrics.createDataSource("twitter", "%1 tweets received", |
649 | "no tweets today", "", 0, QVariantMap()); |
650 | @@ -176,7 +188,7 @@ |
651 | |
652 | { |
653 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
654 | - authentication); |
655 | + authentication, translationLocator); |
656 | |
657 | DBusDataSourcePtr twitter(userMetrics.dataSource("twitter")); |
658 | EXPECT_EQ(QString("no tweeties today"), twitter->emptyDataString()); |
659 | @@ -186,7 +198,7 @@ |
660 | TEST_F(TestUserMetricsService, UpdatesTextDomain) { |
661 | { |
662 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
663 | - authentication); |
664 | + authentication, translationLocator); |
665 | |
666 | userMetrics.createDataSource("twitter", "%1 tweets received", "", |
667 | "start text domain", 0, QVariantMap()); |
668 | @@ -200,7 +212,7 @@ |
669 | |
670 | { |
671 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
672 | - authentication); |
673 | + authentication, translationLocator); |
674 | |
675 | DBusDataSourcePtr twitter(userMetrics.dataSource("twitter")); |
676 | EXPECT_EQ(QString("changed text domain"), twitter->textDomain()); |
677 | @@ -210,7 +222,7 @@ |
678 | TEST_F(TestUserMetricsService, UpdatesFormatStringOnCreate) { |
679 | { |
680 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
681 | - authentication); |
682 | + authentication, translationLocator); |
683 | |
684 | userMetrics.createDataSource("twitter", "%1 tweets received", "", "", 0, |
685 | QVariantMap()); |
686 | @@ -228,7 +240,7 @@ |
687 | |
688 | { |
689 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
690 | - authentication); |
691 | + authentication, translationLocator); |
692 | |
693 | DBusDataSourcePtr twitter(userMetrics.dataSource("twitter")); |
694 | EXPECT_EQ(QString("%1 new format string"), twitter->formatString()); |
695 | @@ -241,7 +253,7 @@ |
696 | |
697 | { |
698 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
699 | - authentication); |
700 | + authentication, translationLocator); |
701 | |
702 | EXPECT_TRUE(userMetrics.dataSources().empty()); |
703 | |
704 | @@ -259,7 +271,7 @@ |
705 | |
706 | { |
707 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
708 | - authentication); |
709 | + authentication, translationLocator); |
710 | |
711 | QList<QDBusObjectPath> userData(userMetrics.userDatas()); |
712 | EXPECT_EQ(1, userData.size()); |
713 | @@ -279,7 +291,7 @@ |
714 | |
715 | { |
716 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
717 | - authentication); |
718 | + authentication, translationLocator); |
719 | |
720 | userMetrics.createDataSource("twitter", "%1 tweets received", "", "", 0, |
721 | QVariantMap()); |
722 | @@ -308,7 +320,7 @@ |
723 | |
724 | { |
725 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
726 | - authentication); |
727 | + authentication, translationLocator); |
728 | |
729 | DBusUserDataPtr alice(userMetrics.userData("alice")); |
730 | EXPECT_EQ(QString("alice"), alice->username()); |
731 | @@ -330,7 +342,7 @@ |
732 | _)).WillByDefault(Return(QString("bob"))); |
733 | |
734 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
735 | - authentication); |
736 | + authentication, translationLocator); |
737 | |
738 | userMetrics.createUserData("bob"); |
739 | DBusUserDataPtr bob(userMetrics.userData("bob")); |
740 | @@ -346,7 +358,7 @@ |
741 | Return(QDate(2001, 01, 5))).WillOnce(Return(QDate(2001, 01, 8))); |
742 | |
743 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
744 | - authentication); |
745 | + authentication, translationLocator); |
746 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
747 | |
748 | userMetrics.createUserData("bob"); |
749 | @@ -379,7 +391,7 @@ |
750 | Return(QDate(2001, 01, 5))).WillOnce(Return(QDate(2001, 01, 15))); |
751 | |
752 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
753 | - authentication); |
754 | + authentication, translationLocator); |
755 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
756 | |
757 | userMetrics.createUserData("bob"); |
758 | @@ -417,7 +429,7 @@ |
759 | Return(QDate(2001, 01, 5))).WillOnce(Return(QDate(2001, 01, 7))); |
760 | |
761 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
762 | - authentication); |
763 | + authentication, translationLocator); |
764 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
765 | |
766 | userMetrics.createUserData("bob"); |
767 | @@ -444,7 +456,7 @@ |
768 | |
769 | TEST_F(TestUserMetricsService, MultipleUsers) { |
770 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
771 | - authentication); |
772 | + authentication, translationLocator); |
773 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
774 | |
775 | ON_CALL(*authentication, getUsername( |
776 | @@ -484,7 +496,7 @@ |
777 | Return(QDate(2001, 03, 1))); |
778 | |
779 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
780 | - authentication); |
781 | + authentication, translationLocator); |
782 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
783 | |
784 | userMetrics.createUserData("bob"); |
785 | @@ -524,7 +536,7 @@ |
786 | Return(QDate(2001, 3, 5))); |
787 | |
788 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
789 | - authentication); |
790 | + authentication, translationLocator); |
791 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
792 | |
793 | userMetrics.createUserData("bob"); |
794 | @@ -557,7 +569,7 @@ |
795 | Return(QDate(2001, 3, 5))); |
796 | |
797 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
798 | - authentication); |
799 | + authentication, translationLocator); |
800 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
801 | |
802 | EXPECT_CALL(*authentication, |
803 | @@ -580,7 +592,7 @@ |
804 | Return(QDate(2001, 3, 5))); |
805 | |
806 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
807 | - authentication); |
808 | + authentication, translationLocator); |
809 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
810 | |
811 | ASSERT_NE(QDBusObjectPath(), userMetrics.createUserData("alice")); |
812 | @@ -610,7 +622,7 @@ |
813 | Return(QDate(2001, 3, 5))); |
814 | |
815 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
816 | - authentication); |
817 | + authentication, translationLocator); |
818 | |
819 | ASSERT_NE(QDBusObjectPath(), |
820 | userMetrics.createDataSource("twitter", "foo", "", "", 0, |
821 | @@ -643,7 +655,7 @@ |
822 | Return(QDate(2001, 3, 5))); |
823 | |
824 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
825 | - authentication); |
826 | + authentication, translationLocator); |
827 | |
828 | ASSERT_EQ(QDBusObjectPath(DBusPaths::dataSource(1)), |
829 | userMetrics.createDataSource("twitter", "foo", "", "", 0, |
830 | @@ -665,7 +677,7 @@ |
831 | Return(QDate(2001, 3, 5))); |
832 | |
833 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
834 | - authentication); |
835 | + authentication, translationLocator); |
836 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
837 | |
838 | ASSERT_NE(QDBusObjectPath(), userMetrics.createUserData("alice")); |
839 | @@ -708,7 +720,7 @@ |
840 | Return(QDate(2001, 3, 5))); |
841 | |
842 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
843 | - authentication); |
844 | + authentication, translationLocator); |
845 | userMetrics.createDataSource("twitter", "foo", "", "", 0, QVariantMap()); |
846 | |
847 | ASSERT_EQ(QDBusObjectPath(DBusPaths::userData(1)), |
848 | @@ -747,7 +759,7 @@ |
849 | Return(QDate(2001, 3, 5))); |
850 | |
851 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
852 | - authentication); |
853 | + authentication, translationLocator); |
854 | |
855 | ASSERT_EQ(QDBusObjectPath(DBusPaths::dataSource(1)), |
856 | userMetrics.createDataSource("twitter", "foo", "", "", 0, |
857 | @@ -773,7 +785,7 @@ |
858 | Return(QDate(2001, 3, 5))); |
859 | |
860 | DBusUserMetrics userMetrics(systemConnection(), dateFactory, |
861 | - authentication); |
862 | + authentication, translationLocator); |
863 | |
864 | ON_CALL(*authentication, getConfinementContext( |
865 | _)).WillByDefault(Return(QString("/bin/twitter"))); |