Merge lp:~jamesh/ubuntu-ui-toolkit/albumart-dbus into lp:ubuntu-ui-toolkit

Proposed by James Henstridge
Status: Rejected
Rejected by: Tim Peeters
Proposed branch: lp:~jamesh/ubuntu-ui-toolkit/albumart-dbus
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 230 lines (+142/-4)
6 files modified
debian/control (+2/-1)
modules/Ubuntu/Components/plugin/albumartgenerator.cpp (+90/-0)
modules/Ubuntu/Components/plugin/albumartgenerator.h (+36/-0)
modules/Ubuntu/Components/plugin/plugin.cpp (+6/-0)
modules/Ubuntu/Components/plugin/plugin.pro (+2/-0)
modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp (+6/-3)
To merge this branch: bzr merge lp:~jamesh/ubuntu-ui-toolkit/albumart-dbus
Reviewer Review Type Date Requested Status
Tim Peeters Disapprove
PS Jenkins bot continuous-integration Needs Fixing
Jussi Pakkanen (community) Approve
Review via email: mp+212362@code.launchpad.net

Commit message

Add an image://albumart image provider that retrieves album art for a particular (artist, album) pair. Artwork is retrieved via a D-Bus service so it is possible for confined applications to take advantage of a centralised media art cache.

Description of the change

Add an image://albumart image provider that retrieves album art for a particular (artist, album) pair. Artwork is retrieved via a D-Bus service so it is possible for confined applications to take advantage of a centralised media art cache.

The D-Bus service is being added to the thumbnailer here:

https://code.launchpad.net/~jamesh/thumbnailer/dbus-service/+merge/212347

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
Jussi Pakkanen (jpakkane) wrote :

Looks good.

review: Approve
974. By James Henstridge

Fix up constness of catch() clause.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

Why should an album art generator be part of the UITK? It seems specific for only a few apps to me and I don't like to add dependencies to the UITK because that gives problems with supporting and porting (to precise for example) the UITK. Could this be included in the apps that use it or as a separate module that they can use?

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

The album art image provider is conceptually the same as thumbnailer image provider. The latter says "get me a thumbnail for this file" and the former is "get me an image of this album". There is already code for this in the Dash (and I think duplicated in Unity8) but that is not the correct place for it for obvious reasons.

As far as dependencies go, this does not add any extra dependencies. The UITK part is just a dbus call (the actual generation happens in a service provided by libthumbnailer). If the album art service is not running (as it probably won't on precise), the code returns the default image. The dependency on >=1.1 of thumbnailer and thumbnailer-service is just to declare this and can be changed to just libthumbnailer>=1.0 if that makes supporting precise easier (note that neither AlbumArtGenerator.cpp nor AlbumArtGenerator.h includes anything from libthumbnnailer so they will compile and link just fine).

We proposed this for the UITK because we feel that it should be as widely available as the thumbnailing image provider is. That being said the current users are the shell and the music player app. If you feel that this code has a better location somewhere else then we are glad to work with you to find one. It is a very small change, after all.

Revision history for this message
Tim Peeters (tpeeters) wrote :

Yes it is similar to the thumbnailer image provider. I thought there were plans for the thumbnailer also to move it out of the UITK (cf. https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1237045/comments/17) but I don't know the status of those plans. I would not mind if the thumbnailer was also moved out of the UITK, that would prevent possible issues with porting such as https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1237045/

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

We need a QQuickImageProvider that can be used by all applications, the shell and so directly from their QML files. This is the requirement we were given. Where should this functionality live, then, if it needs to be moved out of uitk?

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

So what is the way forward here? Do we move the QML image providers to a new QML plugin in thumbnailer? If we do add a thumbnailer QML plugin, should the other image provider be moved to it? What effect does that have on application compatibility?

Also, its worth noting that the "new dependency" here is still part of the thumbnailer source package. It is a new binary package in order to satisfy multi-arch (we only want one copy of the D-Bus service on the system, as opposed to the library, where each architecture needs its own copy).

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

Wherever the code ends up, the thumbnailer-service dependency should probably be a Recommends:

18:36 <cjwatson> jamesh: what do thumbnailer-service's own Depends look like? I'm concerned that this will cause a problem for cross-installation in development chroots
18:37 <cjwatson> jamesh: and it's pretty questionable whether e.g. the d-bus service should be mandatorily installed during development
18:37 <cjwatson> those are usually run-time facilities that tests would have to mock anyway
18:42 <jamesh> cjwatson: it depends on libthumbnailer + its dependencies (which is already a dep for ubuntu-ui-toolkit)
18:44 <cjwatson> jamesh: right, but in cross-install situations that'll involve following the dep trees on both architectures
18:44 <cjwatson> best avoided if we don't have to
18:44 <jamesh> cjwatson: if the service isn't available, the image provider should present a fallback image and log the problem
18:45 <jamesh> I guess it could be a "Recommends" in that case
18:45 <cjwatson> jamesh: ok, so that sounds like it should be Recommends not Depends, and we should take other measures if necessary to ensure that it's on our images

Revision history for this message
Tim Peeters (tpeeters) wrote :

After some discussion with James and Jussi on irc we decided to move the thumbnailer QML bindings out of the UITK into a new package in the thumbnailer proejct.

review: Disapprove

Unmerged revisions

974. By James Henstridge

Fix up constness of catch() clause.

973. By James Henstridge

Make qtdeclarative5-ubuntu-ui-toolkit-plugin depend on
thumbnailer-service, since the album art image provider has a runtime
dependency on this D-Bus service.

972. By James Henstridge

Small cleanups.

971. By James Henstridge

Make album art image provider call out to the D-Bus service, and follow
the URI scheme used by Unity.

970. By Jussi Pakkanen

Now with xlarge goodness.

969. By Jussi Pakkanen

Basic work on album art downloader.

968. By Launchpad Translations on behalf of ubuntu-sdk-team

Launchpad automatic translations update.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2014-03-17 09:02:58 +0000
+++ debian/control 2014-03-24 10:25:09 +0000
@@ -33,7 +33,7 @@
33 libqt5organizer5,33 libqt5organizer5,
34 qtpim5-dev,34 qtpim5-dev,
35 language-pack-en-base,35 language-pack-en-base,
36 libthumbnailer-dev,36 libthumbnailer-dev (>=1.1),
37 libdbus-1-dev,37 libdbus-1-dev,
38 libnih-dbus-dev,38 libnih-dbus-dev,
39 xvfb,39 xvfb,
@@ -56,6 +56,7 @@
56 qtdeclarative5-window-plugin,56 qtdeclarative5-window-plugin,
57 qtdeclarative5-qtfeedback-plugin,57 qtdeclarative5-qtfeedback-plugin,
58 qtdeclarative5-unity-action-plugin (>= 1.1.0),58 qtdeclarative5-unity-action-plugin (>= 1.1.0),
59 thumbnailer-service,
59 ttf-ubuntu-font-family,60 ttf-ubuntu-font-family,
60 ubuntu-ui-toolkit-theme,61 ubuntu-ui-toolkit-theme,
61 ${misc:Depends},62 ${misc:Depends},
6263
=== added file 'modules/Ubuntu/Components/plugin/albumartgenerator.cpp'
--- modules/Ubuntu/Components/plugin/albumartgenerator.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/albumartgenerator.cpp 2014-03-24 10:25:09 +0000
@@ -0,0 +1,90 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Jussi Pakkanen <jussi.pakkanen@canonical.com>
17 * James Henstridge <james.henstridge@canonical.com>
18*/
19
20#include "albumartgenerator.h"
21#include <stdexcept>
22#include <QDebug>
23#include <QFile>
24#include <QUrlQuery>
25#include <QDBusUnixFileDescriptor>
26#include <QDBusReply>
27
28static const char DEFAULT_ALBUM_ART[] = "/usr/share/unity/icons/album_missing.png";
29
30static const char BUS_NAME[] = "com.canonical.Thumbnailer";
31static const char BUS_PATH[] = "/com/canonical/Thumbnailer";
32static const char THUMBNAILER_IFACE[] = "com.canonical.Thumbnailer";
33static const char GET_ALBUM_ART[] = "GetAlbumArt";
34
35AlbumArtGenerator::AlbumArtGenerator()
36 : QQuickImageProvider(QQuickImageProvider::Image, QQmlImageProviderBase::ForceAsynchronousImageLoading),
37 iface(BUS_NAME, BUS_PATH, THUMBNAILER_IFACE) {
38}
39
40static QImage fallbackImage(QSize *realSize) {
41 QImage fallback;
42 fallback.load(DEFAULT_ALBUM_ART);
43 *realSize = fallback.size();
44 return fallback;
45}
46
47QImage AlbumArtGenerator::requestImage(const QString &id, QSize *realSize,
48 const QSize &requestedSize) {
49 QUrlQuery query(id);
50 if (!query.hasQueryItem("artist") || !query.hasQueryItem("album")) {
51 qWarning() << "Invalid albumart uri:" << id;
52 return fallbackImage(realSize);
53 }
54
55 const QString artist = query.queryItemValue("artist", QUrl::FullyDecoded);
56 const QString album = query.queryItemValue("album", QUrl::FullyDecoded);
57
58 QString desiredSize = "original";
59 int size = requestedSize.width() > requestedSize.height() ? requestedSize.width() : requestedSize.height();
60 if (size < 128) {
61 desiredSize = "small";
62 } else if (size < 256) {
63 desiredSize = "large";
64 } else if (size < 512) {
65 desiredSize = "xlarge";
66 }
67
68 // perform dbus call
69 QDBusReply<QDBusUnixFileDescriptor> reply = iface.call(
70 GET_ALBUM_ART, artist, album, desiredSize);
71 if (!reply.isValid()) {
72 qWarning() << "D-Bus error: " << reply.error().message();
73 return fallbackImage(realSize);
74 }
75
76 try {
77 QFile file;
78 file.open(reply.value().fileDescriptor(), QIODevice::ReadOnly);
79 QImage image;
80 image.load(&file, NULL);
81 *realSize = image.size();
82 return image;
83 } catch (const std::exception &e) {
84 qDebug() << "Album art loader failed: " << e.what();
85 } catch (...) {
86 qDebug() << "Unknown error when generating image.";
87 }
88
89 return fallbackImage(realSize);
90}
091
=== added file 'modules/Ubuntu/Components/plugin/albumartgenerator.h'
--- modules/Ubuntu/Components/plugin/albumartgenerator.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/albumartgenerator.h 2014-03-24 10:25:09 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Jussi Pakkanen <jussi.pakkanen@canonical.com>
17 * James Henstridge <james.henstridge@canonical.com>
18*/
19
20#ifndef ALBUMART_GENERATOR_H
21#define ALBUMART_GENERATOR_H
22
23#include <QDBusInterface>
24#include <QQuickImageProvider>
25
26class AlbumArtGenerator: public QQuickImageProvider
27{
28private:
29 QDBusInterface iface;
30
31public:
32 AlbumArtGenerator();
33 QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
34};
35
36#endif
037
=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
--- modules/Ubuntu/Components/plugin/plugin.cpp 2014-02-13 17:16:06 +0000
+++ modules/Ubuntu/Components/plugin/plugin.cpp 2014-03-24 10:25:09 +0000
@@ -37,6 +37,7 @@
37#include "qquickmimedata.h"37#include "qquickmimedata.h"
38#include "bottombarvisibilitycommunicator.h"38#include "bottombarvisibilitycommunicator.h"
39#include "thumbnailgenerator.h"39#include "thumbnailgenerator.h"
40#include "albumartgenerator.h"
40#include "ucubuntuanimation.h"41#include "ucubuntuanimation.h"
41#include "ucfontutils.h"42#include "ucfontutils.h"
42#include "ucarguments.h"43#include "ucarguments.h"
@@ -237,6 +238,11 @@
237 } catch(std::runtime_error &e) {238 } catch(std::runtime_error &e) {
238 qDebug() << "Could not create thumbnailer: " << e.what();239 qDebug() << "Could not create thumbnailer: " << e.what();
239 }240 }
241 try {
242 engine->addImageProvider(QLatin1String("albumart"), new AlbumArtGenerator);
243 } catch(std::runtime_error &e) {
244 qDebug() << "Could not create albumart: " << e.what();
245 }
240246
241 // Necessary for Screen.orientation (from import QtQuick.Window 2.0) to work247 // Necessary for Screen.orientation (from import QtQuick.Window 2.0) to work
242 QGuiApplication::primaryScreen()->setOrientationUpdateMask(248 QGuiApplication::primaryScreen()->setOrientationUpdateMask(
243249
=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
--- modules/Ubuntu/Components/plugin/plugin.pro 2014-02-13 09:38:23 +0000
+++ modules/Ubuntu/Components/plugin/plugin.pro 2014-03-24 10:25:09 +0000
@@ -52,6 +52,7 @@
52 ucalarmmodel.h \52 ucalarmmodel.h \
53 unitythemeiconprovider.h \53 unitythemeiconprovider.h \
54 thumbnailgenerator.h \54 thumbnailgenerator.h \
55 albumartgenerator.h \
55 alarmrequest_p.h \56 alarmrequest_p.h \
56 alarmrequest_p_p.h \57 alarmrequest_p_p.h \
57 adapters/alarmsadapter_p.h \58 adapters/alarmsadapter_p.h \
@@ -86,6 +87,7 @@
86 ucalarmmodel.cpp \87 ucalarmmodel.cpp \
87 unitythemeiconprovider.cpp \88 unitythemeiconprovider.cpp \
88 thumbnailgenerator.cpp \89 thumbnailgenerator.cpp \
90 albumartgenerator.cpp \
89 alarmrequest_p.cpp \91 alarmrequest_p.cpp \
90 ucstatesaver.cpp \92 ucstatesaver.cpp \
91 statesaverbackend_p.cpp \93 statesaverbackend_p.cpp \
9294
=== modified file 'modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp'
--- modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-02-25 09:14:23 +0000
+++ modules/Ubuntu/Components/plugin/thumbnailgenerator.cpp 2014-03-24 10:25:09 +0000
@@ -22,8 +22,8 @@
22#include <QMimeDatabase>22#include <QMimeDatabase>
23#include <QUrl>23#include <QUrl>
2424
25const char *DEFAULT_VIDEO_ART = "/usr/share/unity/icons/video_missing.png";25static const char *DEFAULT_VIDEO_ART = "/usr/share/unity/icons/video_missing.png";
26const char *DEFAULT_ALBUM_ART = "/usr/share/unity/icons/album_missing.png";26static const char *DEFAULT_ALBUM_ART = "/usr/share/unity/icons/album_missing.png";
2727
28ThumbnailGenerator::ThumbnailGenerator() : QQuickImageProvider(QQuickImageProvider::Image,28ThumbnailGenerator::ThumbnailGenerator() : QQuickImageProvider(QQuickImageProvider::Image,
29 QQmlImageProviderBase::ForceAsynchronousImageLoading) {29 QQmlImageProviderBase::ForceAsynchronousImageLoading) {
@@ -45,10 +45,13 @@
45 std::string tgt_path;45 std::string tgt_path;
46 try {46 try {
47 ThumbnailSize desiredSize;47 ThumbnailSize desiredSize;
48 const int xlarge_cutoff = 512;
48 const int large_cutoff = 256;49 const int large_cutoff = 256;
49 const int small_cutoff = 128;50 const int small_cutoff = 128;
50 if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) {51 if(requestedSize.width() > xlarge_cutoff || requestedSize.height() > xlarge_cutoff) {
51 desiredSize = TN_SIZE_ORIGINAL;52 desiredSize = TN_SIZE_ORIGINAL;
53 } if(requestedSize.width() > large_cutoff || requestedSize.height() > large_cutoff) {
54 desiredSize = TN_SIZE_XLARGE;
52 } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) {55 } else if(requestedSize.width() > small_cutoff || requestedSize.height() > small_cutoff) {
53 desiredSize = TN_SIZE_LARGE;56 desiredSize = TN_SIZE_LARGE;
54 } else {57 } else {

Subscribers

People subscribed via source and target branches

to status/vote changes: