[rygel] external: Make use of thumbnails
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] external: Make use of thumbnails
- Date: Sat, 24 Oct 2009 23:16:28 +0000 (UTC)
commit 2d11d101700b8888793c5b058e62d7ed76032b48
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Oct 20 01:28:38 2009 +0300
external: Make use of thumbnails
Now external plugins can provide thumbnails too, yay!
src/plugins/external/Makefile.am | 1 +
src/plugins/external/rygel-external-item.vala | 20 ++++-
src/plugins/external/rygel-external-thumbnail.vala | 89 ++++++++++++++++++++
3 files changed, 108 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/external/Makefile.am b/src/plugins/external/Makefile.am
index ad75d79..9974cef 100644
--- a/src/plugins/external/Makefile.am
+++ b/src/plugins/external/Makefile.am
@@ -18,6 +18,7 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
librygel_external_la_SOURCES = rygel-external-content-dir.vala \
rygel-external-container.vala \
rygel-external-item.vala \
+ rygel-external-thumbnail.vala \
rygel-external-plugin.vala \
rygel-external-interfaces.vala \
rygel-external-plugin-factory.vala
diff --git a/src/plugins/external/rygel-external-item.vala b/src/plugins/external/rygel-external-item.vala
index e306404..45cff59 100644
--- a/src/plugins/external/rygel-external-item.vala
+++ b/src/plugins/external/rygel-external-item.vala
@@ -62,18 +62,30 @@ public class Rygel.ExternalItem : Rygel.MediaItem {
var object_props = yield props.get_all (OBJECT_IFACE);
var item_props = yield props.get_all (ITEM_IFACE);
+ ExternalThumbnail thumbnail = null;
+ var value = item_props.lookup ("Thumbnail");
+ if (value != null) {
+ var thumbnail_path = value.get_string ();
+
+ thumbnail = yield ExternalThumbnail.create (thumbnail_path,
+ parent.service_name,
+ parent.host_ip);
+ }
+
return new ExternalItem (id,
object_path,
parent,
object_props,
- item_props);
+ item_props,
+ thumbnail);
}
private ExternalItem (string id,
string object_path,
ExternalContainer parent,
HashTable<string,Value?> object_props,
- HashTable<string,Value?> item_props)
+ HashTable<string,Value?> item_props,
+ Thumbnail? thumbnail)
throws GLib.Error {
base (id,
parent,
@@ -179,6 +191,10 @@ public class Rygel.ExternalItem : Rygel.MediaItem {
if (value != null) {
this.color_depth = value.get_int ();
}
+
+ if (thumbnail != null) {
+ this.thumbnails.add (thumbnail);
+ }
}
public static bool id_valid (string id) {
diff --git a/src/plugins/external/rygel-external-thumbnail.vala b/src/plugins/external/rygel-external-thumbnail.vala
new file mode 100644
index 0000000..9d381d8
--- /dev/null
+++ b/src/plugins/external/rygel-external-thumbnail.vala
@@ -0,0 +1,89 @@
+/*
+ * 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;
+
+/**
+ * Represents External thumbnail.
+ */
+public class Rygel.ExternalThumbnail : Rygel.Thumbnail {
+ private static string OBJECT_IFACE = "org.gnome.UPnP.MediaObject1";
+ private static string ITEM_IFACE = "org.gnome.UPnP.MediaItem1";
+
+ public static async ExternalThumbnail 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 object_props = yield props.get_all (OBJECT_IFACE);
+ var item_props = yield props.get_all (ITEM_IFACE);
+
+ return new ExternalThumbnail (object_props, item_props, host_ip);
+ }
+
+ private ExternalThumbnail (HashTable<string,Value?> object_props,
+ HashTable<string,Value?> item_props,
+ string host_ip) {
+ var value = item_props.lookup ("MIMEType");
+ this.mime_type = value.get_string ();
+
+ value = item_props.lookup ("URLs");
+ weak string[] uris = (string[]) value.get_boxed ();
+ if (uris != null && uris[0] != null) {
+ this.uri = uris[0].replace ("@ADDRESS@", host_ip);
+ }
+
+ value = item_props.lookup ("DLNAProfile");
+ if (value != null) {
+ this.dlna_profile = value.get_string ();
+ }
+
+ value = item_props.lookup ("Size");
+ if (value != null) {
+ this.size = value.get_int ();
+ }
+
+ value = item_props.lookup ("Width");
+ if (value != null) {
+ this.width = value.get_int ();
+ }
+
+ value = item_props.lookup ("Height");
+ if (value != null) {
+ this.height = value.get_int ();
+ }
+
+ value = item_props.lookup ("ColorDepth");
+ if (value != null) {
+ this.depth = value.get_int ();
+ }
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]