[rygel] external: Handle AlbumArt property



commit 8a53d8bacf828840c24a22a3c63d1f07fe29423e
Author: Jens Georg <mail jensge org>
Date:   Sat Jul 24 19:01:03 2010 +0300

    external: Handle AlbumArt property

 src/plugins/external/Makefile.am                   |    1 +
 .../external/rygel-external-album-art-factory.vala |   62 ++++++++++++++++++++
 .../external/rygel-external-item-factory.vala      |   13 +++-
 3 files changed, 72 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/external/Makefile.am b/src/plugins/external/Makefile.am
index 397f888..3bd958f 100644
--- a/src/plugins/external/Makefile.am
+++ b/src/plugins/external/Makefile.am
@@ -20,6 +20,7 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
 librygel_external_la_SOURCES = rygel-external-container.vala \
 			       rygel-external-dummy-container.vala \
 			       rygel-external-item-factory.vala \
+			       rygel-external-album-art-factory.vala \
 			       rygel-external-thumbnail-factory.vala \
 			       rygel-external-plugin.vala \
 			       rygel-external-interfaces.vala \
diff --git a/src/plugins/external/rygel-external-album-art-factory.vala b/src/plugins/external/rygel-external-album-art-factory.vala
new file mode 100644
index 0000000..7844323
--- /dev/null
+++ b/src/plugins/external/rygel-external-album-art-factory.vala
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2009 Nokia Corporation.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using DBus;
+using FreeDesktop;
+
+/**
+ * Factory for thumbnail from external plugins.
+ */
+public class Rygel.External.AlbumArtFactory {
+    public async Thumbnail create (string service_name,
+                                   string object_path,
+                                   string host_ip)
+                                   throws GLib.Error {
+        DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION);
+
+        var props = connection.get_object (service_name,
+                                           object_path)
+                                           as Properties;
+
+        var item_props = yield props.get_all (MediaItemProxy.IFACE);
+
+        var thumbnail = new AlbumArt ();
+
+        var value = item_props.lookup ("MIMEType");
+        thumbnail.mime_type = value.get_string ();
+
+        value = item_props.lookup ("URLs");
+        weak string[] uris = (string[]) value.get_boxed ();
+        if (uris != null && uris[0] != null) {
+            thumbnail.uri = uris[0].replace ("@ADDRESS@", host_ip);
+        }
+
+        value = item_props.lookup ("Size");
+        if (value != null) {
+            thumbnail.size = value.get_int ();
+        }
+
+        return thumbnail;
+    }
+}
diff --git a/src/plugins/external/rygel-external-item-factory.vala b/src/plugins/external/rygel-external-item-factory.vala
index 9a914bc..4d1edb7 100644
--- a/src/plugins/external/rygel-external-item-factory.vala
+++ b/src/plugins/external/rygel-external-item-factory.vala
@@ -70,10 +70,6 @@ public class Rygel.External.ItemFactory {
 
         // Optional properties
         //
-        // FIXME: Handle:
-        //
-        // MediaItem1.AlbumArt
-        //
 
         value = props.lookup ("DLNAProfile");
         if (value != null) {
@@ -127,6 +123,15 @@ public class Rygel.External.ItemFactory {
             item.bits_per_sample = value.get_int ();
         }
 
+        value = props.lookup ("AlbumArt");
+        if (value != null) {
+            var cover_factory = new AlbumArtFactory ();
+            var album_art = yield cover_factory.create (value.get_string (),
+                                                        service_name,
+                                                        host_ip);
+            item.thumbnails.add (album_art);
+        }
+
         // Properties specific to video and image
 
         value = props.lookup ("Width");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]