Merge lp:~michihenning/thumbnailer/config-access into lp:thumbnailer/devel

Proposed by Michi Henning
Status: Merged
Approved by: James Henstridge
Approved revision: 335
Merged at revision: 339
Proposed branch: lp:~michihenning/thumbnailer/config-access
Merge into: lp:thumbnailer/devel
Diff against target: 357 lines (+94/-19)
15 files modified
data/com.canonical.Unity.Thumbnailer.gschema.xml (+1/-1)
debian/changelog (+1/-0)
include/internal/settings.h (+5/-0)
man/thumbnailer-settings.5 (+1/-1)
plugins/Ubuntu/Thumbnailer.0.1/plugin.cpp (+0/-1)
plugins/Ubuntu/Thumbnailer.0.1/thumbnailgenerator.cpp (+0/-1)
src/libthumbnailer-qt/CMakeLists.txt (+2/-0)
src/libthumbnailer-qt/libthumbnailer-qt.cpp (+47/-6)
src/service/dbusinterface.cpp (+13/-3)
src/service/dbusinterface.h (+9/-2)
src/service/dbusinterface.xml (+6/-0)
src/settings.cpp (+6/-1)
src/thumbnailer.cpp (+1/-1)
src/ubuntuserverdownloader.cpp (+1/-1)
tests/settings/settings_test.cpp (+1/-1)
To merge this branch: bzr merge lp:~michihenning/thumbnailer/config-access
Reviewer Review Type Date Requested Status
James Henstridge Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+281580@code.launchpad.net

Commit message

Made client-side config settings available from the server.

Description of the change

Made client-side config settings available from the server. That's because we can't access gsettings from the client-side API when under confinement. Because the Settings class is no longer used on the client side, I moved that back into the internal namespace.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Related branch for the apparmor profile update:

https://code.launchpad.net/~michihenning/apparmor-easyprof-ubuntu/new-thumbnailer-methods/+merge/281712

Note that this change can land regardless. If apparmor denies access, we use the defaults, so it'll magically work once apparmor catches up.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

I've left some inline comments. There are a few things to fix surrounding the use of the new D-Bus calls.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks better. I've left one more small note inline.

Revision history for this message
Michi Henning (michihenning) wrote :

Thanks for that!

It's also broken in another way: the number of CPUs really is irrelevant here. I wasn't thinking straight. What we want is 10 if max-downloads is set to 0, and whatever max-downloads is set to, otherwise, regardless of the number of CPUs. (As is, we are too low for a 2-core or 4-core machine because we need max-downloads at 10, even when there are fewer than 8 cores.)

I'll fix it.

Revision history for this message
Michi Henning (michihenning) wrote :

OK, should be good now. Default backlog is 10 now, regardless of CPU cores. I also fixed the QDBusReply thing. The explicit definition is needed because template deduction can't be used for the type returned by the invocation stub.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
335. By Michi Henning

Simplified dbus invocation.

Revision history for this message
James Henstridge (jamesh) :
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/com.canonical.Unity.Thumbnailer.gschema.xml'
--- data/com.canonical.Unity.Thumbnailer.gschema.xml 2016-01-07 01:21:03 +0000
+++ data/com.canonical.Unity.Thumbnailer.gschema.xml 2016-01-13 07:08:16 +0000
@@ -77,7 +77,7 @@
77 <default>10</default>77 <default>10</default>
78 <summary>Maximum number of pending DBus requests before the thumbnailer starts queuing them.</summary>78 <summary>Maximum number of pending DBus requests before the thumbnailer starts queuing them.</summary>
79 <description>79 <description>
80 This parameter limits the number of pending DBus requests to the thumbnailer service. If there are more requests than this currently in progress, additional requests are queued and sent once the backlog drops below the limit.80 This parameter limits the number of pending DBus requests to the thumbnailer service. If the number of concurrent requests exceeds the backlog, additional requests are queued and sent once the backlog drops below the limit.
81 </description>81 </description>
82 </key>82 </key>
8383
8484
=== modified file 'debian/changelog'
--- debian/changelog 2016-01-09 03:22:11 +0000
+++ debian/changelog 2016-01-13 07:08:16 +0000
@@ -10,6 +10,7 @@
10 [ Michi Henning ]10 [ Michi Henning ]
11 * Fixed incorrect display of cache policy by "thumbnailer-admin stats".11 * Fixed incorrect display of cache policy by "thumbnailer-admin stats".
12 * Limit GIF file size to 2 MB (LP: #1527315).12 * Limit GIF file size to 2 MB (LP: #1527315).
13 * Fix non-working config settings for client-side API (LP: #1528058).
1314
14 [ CI Train Bot ]15 [ CI Train Bot ]
15 * No-change rebuild.16 * No-change rebuild.
1617
=== renamed file 'include/settings.h' => 'include/internal/settings.h'
--- include/settings.h 2016-01-04 06:09:41 +0000
+++ include/internal/settings.h 2016-01-13 07:08:16 +0000
@@ -32,6 +32,9 @@
32namespace thumbnailer32namespace thumbnailer
33{33{
3434
35namespace internal
36{
37
35class Settings38class Settings
36{39{
37public:40public:
@@ -66,6 +69,8 @@
66 internal::gobj_ptr<GSettings> settings_;69 internal::gobj_ptr<GSettings> settings_;
67};70};
6871
72} // namespace internal
73
69} // namespace thumbnailer74} // namespace thumbnailer
7075
71} // namespace unity76} // namespace unity
7277
=== modified file 'man/thumbnailer-settings.5'
--- man/thumbnailer-settings.5 2016-01-07 01:21:03 +0000
+++ man/thumbnailer-settings.5 2016-01-13 07:08:16 +0000
@@ -59,7 +59,7 @@
59.TP59.TP
60.B max\-backlog \fR(int)\fP60.B max\-backlog \fR(int)\fP
61Controls the number of DBus requests that will be sent before queueing the requests internally.61Controls the number of DBus requests that will be sent before queueing the requests internally.
62The default is 10 requests.62The default is 10.
63.TP63.TP
64.B trace\-client \fR(bool)\fP64.B trace\-client \fR(bool)\fP
65If true, thumbnail and cancel requests are logged. Log messages are written to the calling application's log65If true, thumbnail and cancel requests are logged. Log messages are written to the calling application's log
6666
=== modified file 'plugins/Ubuntu/Thumbnailer.0.1/plugin.cpp'
--- plugins/Ubuntu/Thumbnailer.0.1/plugin.cpp 2015-09-30 10:08:20 +0000
+++ plugins/Ubuntu/Thumbnailer.0.1/plugin.cpp 2016-01-13 07:08:16 +0000
@@ -18,7 +18,6 @@
1818
19#include "plugin.h"19#include "plugin.h"
2020
21#include <settings.h>
22#include "albumartgenerator.h"21#include "albumartgenerator.h"
23#include "artistartgenerator.h"22#include "artistartgenerator.h"
24#include "thumbnailgenerator.h"23#include "thumbnailgenerator.h"
2524
=== modified file 'plugins/Ubuntu/Thumbnailer.0.1/thumbnailgenerator.cpp'
--- plugins/Ubuntu/Thumbnailer.0.1/thumbnailgenerator.cpp 2015-11-04 07:16:12 +0000
+++ plugins/Ubuntu/Thumbnailer.0.1/thumbnailgenerator.cpp 2016-01-13 07:08:16 +0000
@@ -22,7 +22,6 @@
22#include <QMimeDatabase>22#include <QMimeDatabase>
23#include <QUrl>23#include <QUrl>
2424
25#include <settings.h>
26#include "thumbnailerimageresponse.h"25#include "thumbnailerimageresponse.h"
2726
28namespace27namespace
2928
=== modified file 'src/libthumbnailer-qt/CMakeLists.txt'
--- src/libthumbnailer-qt/CMakeLists.txt 2015-11-30 06:36:53 +0000
+++ src/libthumbnailer-qt/CMakeLists.txt 2016-01-13 07:08:16 +0000
@@ -9,6 +9,8 @@
9 ${interface_files}9 ${interface_files}
10)10)
1111
12include_directories(${CMAKE_BINARY_DIR}/src)
13
12set_target_properties(${LIBTHUMBNAILER_QT} PROPERTIES14set_target_properties(${LIBTHUMBNAILER_QT} PROPERTIES
13 VERSION "${LIBTHUMBNAILER_QT_SO_VERSION_MAJOR}.${LIBTHUMBNAILER_QT_SO_VERSION_MINOR}.${LIBTHUMBNAILER_QT_SO_VERSION_MICRO}"15 VERSION "${LIBTHUMBNAILER_QT_SO_VERSION_MAJOR}.${LIBTHUMBNAILER_QT_SO_VERSION_MINOR}.${LIBTHUMBNAILER_QT_SO_VERSION_MICRO}"
14 SOVERSION ${LIBTHUMBNAILER_QT_SO_VERSION}16 SOVERSION ${LIBTHUMBNAILER_QT_SO_VERSION}
1517
=== modified file 'src/libthumbnailer-qt/libthumbnailer-qt.cpp'
--- src/libthumbnailer-qt/libthumbnailer-qt.cpp 2015-12-21 05:46:02 +0000
+++ src/libthumbnailer-qt/libthumbnailer-qt.cpp 2016-01-13 07:08:16 +0000
@@ -19,8 +19,8 @@
1919
20#include <unity/thumbnailer/qt/thumbnailer-qt.h>20#include <unity/thumbnailer/qt/thumbnailer-qt.h>
2121
22#include <settings-defaults.h>
22#include <ratelimiter.h>23#include <ratelimiter.h>
23#include <settings.h>
24#include <thumbnailerinterface.h>24#include <thumbnailerinterface.h>
25#include <service/dbus_names.h>25#include <service/dbus_names.h>
2626
@@ -132,8 +132,8 @@
132 QSize const& requested_size,132 QSize const& requested_size,
133 std::function<QDBusPendingReply<QByteArray>()> const& job);133 std::function<QDBusPendingReply<QByteArray>()> const& job);
134 std::unique_ptr<ThumbnailerInterface> iface_;134 std::unique_ptr<ThumbnailerInterface> iface_;
135 RateLimiter limiter_;
136 bool trace_client_;135 bool trace_client_;
136 std::unique_ptr<RateLimiter> limiter_;
137};137};
138138
139RequestImpl::RequestImpl(QString const& details,139RequestImpl::RequestImpl(QString const& details,
@@ -316,10 +316,51 @@
316}316}
317317
318ThumbnailerImpl::ThumbnailerImpl(QDBusConnection const& connection)318ThumbnailerImpl::ThumbnailerImpl(QDBusConnection const& connection)
319 : limiter_(Settings().max_backlog())
320 , trace_client_(Settings().trace_client())
321{319{
322 iface_.reset(new ThumbnailerInterface(service::BUS_NAME, service::THUMBNAILER_BUS_PATH, connection));320 iface_.reset(new ThumbnailerInterface(service::BUS_NAME, service::THUMBNAILER_BUS_PATH, connection));
321
322 // We need to retrieve config parameters from the server because, when an app runs confined,
323 // it cannot read gsettings. We do this synchronously because we can't do anything else until
324 // after we get the settings anyway.
325
326 auto trace_client_call = iface_->TraceClient();
327 auto max_backlog_call = iface_->MaxBacklog();
328
329 {
330 trace_client_call.waitForFinished();
331 if (trace_client_call.isValid())
332 {
333 trace_client_ = trace_client_call.value();
334 }
335 // LCOV_EXCL_START
336 else
337 {
338 bool const dflt = TRACE_CLIENT_DEFAULT;
339 trace_client_ = dflt;
340 qCritical().nospace() << "could not retrieve trace-client setting: " << trace_client_call.error().message()
341 << " (using default value of " << dflt << ")";
342
343 }
344 // LCOV_EXCL_STOP
345 }
346
347 {
348 int constexpr dflt_backlog = MAX_BACKLOG_DEFAULT;
349 max_backlog_call.waitForFinished();
350 if (max_backlog_call.isValid())
351 {
352 int backlog = max_backlog_call.value();
353 limiter_.reset(new RateLimiter(backlog));
354 }
355 // LCOV_EXCL_START
356 else
357 {
358 limiter_.reset(new RateLimiter(dflt_backlog));
359 qCritical().nospace() << "could not retrieve max-backlog setting: " << max_backlog_call.error().message()
360 << " (using default value of " << dflt_backlog << ")";
361 }
362 // LCOV_EXCL_STOP
363 }
323}364}
324365
325QSharedPointer<Request> ThumbnailerImpl::getAlbumArt(QString const& artist,366QSharedPointer<Request> ThumbnailerImpl::getAlbumArt(QString const& artist,
@@ -384,12 +425,12 @@
384425
385RateLimiter& ThumbnailerImpl::limiter()426RateLimiter& ThumbnailerImpl::limiter()
386{427{
387 return limiter_;428 return *limiter_;
388}429}
389430
390void ThumbnailerImpl::pump_limiter()431void ThumbnailerImpl::pump_limiter()
391{432{
392 return limiter_.done();433 return limiter_->done();
393}434}
394435
395} // namespace internal436} // namespace internal
396437
=== modified file 'src/service/dbusinterface.cpp'
--- src/service/dbusinterface.cpp 2016-01-10 07:00:47 +0000
+++ src/service/dbusinterface.cpp 2016-01-13 07:08:16 +0000
@@ -19,7 +19,6 @@
19#include "dbusinterface.h"19#include "dbusinterface.h"
2020
21#include <internal/file_io.h>21#include <internal/file_io.h>
22#include <settings.h>
2322
24#include <boost/algorithm/string.hpp>23#include <boost/algorithm/string.hpp>
25#include <boost/regex.hpp>24#include <boost/regex.hpp>
@@ -94,8 +93,9 @@
9493
95 extraction_limiter_ = make_shared<RateLimiter>(limit);94 extraction_limiter_ = make_shared<RateLimiter>(limit);
9695
97 Settings s;96 log_level_ = settings_.log_level();
98 log_level_ = s.log_level();97 trace_client_ = settings_.trace_client();
98 max_backlog_ = settings_.max_backlog();
99}99}
100100
101DBusInterface::~DBusInterface()101DBusInterface::~DBusInterface()
@@ -305,6 +305,16 @@
305 }305 }
306}306}
307307
308bool DBusInterface::TraceClient()
309{
310 return trace_client_;
311}
312
313int DBusInterface::MaxBacklog()
314{
315 return max_backlog_;
316}
317
308} // namespace service318} // namespace service
309319
310} // namespace thumbnailer320} // namespace thumbnailer
311321
=== modified file 'src/service/dbusinterface.h'
--- src/service/dbusinterface.h 2015-12-14 04:43:11 +0000
+++ src/service/dbusinterface.h 2016-01-13 07:08:16 +0000
@@ -22,7 +22,7 @@
22#include "handler.h"22#include "handler.h"
2323
24#include <ratelimiter.h>24#include <ratelimiter.h>
25#include <settings.h>25#include <internal/settings.h>
2626
27#include <QDBusContext>27#include <QDBusContext>
28#include <QThreadPool>28#include <QThreadPool>
@@ -53,6 +53,11 @@
53 QByteArray GetArtistArt(QString const& artist, QString const& album, QSize const& requestedSize);53 QByteArray GetArtistArt(QString const& artist, QString const& album, QSize const& requestedSize);
54 QByteArray GetThumbnail(QString const& filename, QSize const& requestedSize);54 QByteArray GetThumbnail(QString const& filename, QSize const& requestedSize);
5555
56 // These methods return the value of the corresponding gsettings key. We need to do this on the server
57 // side because the client-side API runs under confinement, which disallows access to gsettings.
58 bool TraceClient();
59 int MaxBacklog();
60
56private:61private:
57 void queueRequest(Handler* handler);62 void queueRequest(Handler* handler);
5863
@@ -72,10 +77,12 @@
72 std::shared_ptr<QThreadPool> create_thread_pool_;77 std::shared_ptr<QThreadPool> create_thread_pool_;
73 std::map<Handler*, std::unique_ptr<Handler>> requests_;78 std::map<Handler*, std::unique_ptr<Handler>> requests_;
74 std::map<std::string, std::vector<Handler*>> request_keys_;79 std::map<std::string, std::vector<Handler*>> request_keys_;
75 unity::thumbnailer::Settings settings_;80 unity::thumbnailer::internal::Settings settings_;
76 std::shared_ptr<RateLimiter> download_limiter_;81 std::shared_ptr<RateLimiter> download_limiter_;
77 std::shared_ptr<RateLimiter> extraction_limiter_;82 std::shared_ptr<RateLimiter> extraction_limiter_;
78 int log_level_;83 int log_level_;
84 bool trace_client_;
85 int max_backlog_;
79};86};
8087
81} // namespace service88} // namespace service
8289
=== modified file 'src/service/dbusinterface.xml'
--- src/service/dbusinterface.xml 2015-12-03 02:01:47 +0000
+++ src/service/dbusinterface.xml 2016-01-13 07:08:16 +0000
@@ -20,5 +20,11 @@
20 <arg direction="out" type="ay" name="thumbnail" />20 <arg direction="out" type="ay" name="thumbnail" />
21 <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QSize" />21 <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QSize" />
22 </method>22 </method>
23 <method name="TraceClient">
24 <arg direction="out" type="b" name="traceClient" />
25 </method>
26 <method name="MaxBacklog">
27 <arg direction="out" type="i" name="maxBacklog" />
28 </method>
23 </interface>29 </interface>
24</node>30</node>
2531
=== modified file 'src/settings.cpp'
--- src/settings.cpp 2016-01-04 06:09:41 +0000
+++ src/settings.cpp 2016-01-13 07:08:16 +0000
@@ -16,7 +16,7 @@
16 * Authored by: James Henstridge <james.henstridge@canonical.com>16 * Authored by: James Henstridge <james.henstridge@canonical.com>
17 */17 */
1818
19#include <settings.h>19#include <internal/settings.h>
2020
21#include <internal/env_vars.h>21#include <internal/env_vars.h>
22#include "settings-defaults.h"22#include "settings-defaults.h"
@@ -39,6 +39,9 @@
39namespace thumbnailer39namespace thumbnailer
40{40{
4141
42namespace internal
43{
44
42Settings::Settings()45Settings::Settings()
43 : Settings("com.canonical.Unity.Thumbnailer")46 : Settings("com.canonical.Unity.Thumbnailer")
44{47{
@@ -220,6 +223,8 @@
220 return g_settings_get_boolean(settings_.get(), key);223 return g_settings_get_boolean(settings_.get(), key);
221}224}
222225
226} // namespace internal
227
223} // namespace thumbnailer228} // namespace thumbnailer
224229
225} // namespace unity230} // namespace unity
226231
=== modified file 'src/thumbnailer.cpp'
--- src/thumbnailer.cpp 2016-01-08 09:22:07 +0000
+++ src/thumbnailer.cpp 2016-01-13 07:08:16 +0000
@@ -28,8 +28,8 @@
28#include <internal/make_directories.h>28#include <internal/make_directories.h>
29#include <internal/raii.h>29#include <internal/raii.h>
30#include <internal/safe_strerror.h>30#include <internal/safe_strerror.h>
31#include <internal/settings.h>
31#include <internal/ubuntuserverdownloader.h>32#include <internal/ubuntuserverdownloader.h>
32#include <settings.h>
3333
34#include <boost/filesystem.hpp>34#include <boost/filesystem.hpp>
3535
3636
=== modified file 'src/ubuntuserverdownloader.cpp'
--- src/ubuntuserverdownloader.cpp 2015-12-29 23:04:19 +0000
+++ src/ubuntuserverdownloader.cpp 2016-01-13 07:08:16 +0000
@@ -22,7 +22,7 @@
2222
23#include <internal/artreply.h>23#include <internal/artreply.h>
24#include <internal/env_vars.h>24#include <internal/env_vars.h>
25#include <settings.h>25#include <internal/settings.h>
2626
27#include <QNetworkReply>27#include <QNetworkReply>
28#include <QTimer>28#include <QTimer>
2929
=== modified file 'tests/settings/settings_test.cpp'
--- tests/settings/settings_test.cpp 2016-01-07 01:21:03 +0000
+++ tests/settings/settings_test.cpp 2016-01-13 07:08:16 +0000
@@ -18,7 +18,7 @@
1818
19#include <internal/env_vars.h>19#include <internal/env_vars.h>
20#include <internal/gobj_memory.h>20#include <internal/gobj_memory.h>
21#include <settings.h>21#include <internal/settings.h>
22#include <testsetup.h>22#include <testsetup.h>
23#include <utils/env_var_guard.h>23#include <utils/env_var_guard.h>
2424

Subscribers

People subscribed via source and target branches

to all changes: