rygel r316 - in trunk: data/xml src/rygel



Author: zeeshanak
Date: Thu Nov 27 23:20:03 2008
New Revision: 316
URL: http://svn.gnome.org/viewvc/rygel?rev=316&view=rev

Log:
Add support for icons.

Plugins can now provide icons to represent themselves. Yay!

Added:
   trunk/src/rygel/rygel-icon-info.vala
Modified:
   trunk/data/xml/description.xml
   trunk/src/rygel/Makefile.am
   trunk/src/rygel/rygel-media-server-factory.vala
   trunk/src/rygel/rygel-plugin.vala

Modified: trunk/data/xml/description.xml
==============================================================================
--- trunk/data/xml/description.xml	(original)
+++ trunk/data/xml/description.xml	Thu Nov 27 23:20:03 2008
@@ -15,6 +15,8 @@
 <serialNumber>0000001</serialNumber>
 <UPC></UPC>
 <presentationURL></presentationURL>
+<iconList>
+</iconList>
 <serviceList>
 </serviceList>
 <dlna:X_DLNADOC>DMS-1.50</dlna:X_DLNADOC>

Modified: trunk/src/rygel/Makefile.am
==============================================================================
--- trunk/src/rygel/Makefile.am	(original)
+++ trunk/src/rygel/Makefile.am	Thu Nov 27 23:20:03 2008
@@ -37,6 +37,8 @@
 		rygel-plugin-loader.c \
 		rygel-resource-info.h \
 		rygel-resource-info.c \
+		rygel-icon-info.h \
+		rygel-icon-info.c \
 		rygel-connection-manager.h \
 		rygel-connection-manager.c \
 		rygel-media-receiver-registrar.h \
@@ -69,6 +71,8 @@
 		rygel-plugin-loader.vala \
 		rygel-resource-info.h \
 		rygel-resource-info.c \
+		rygel-icon-info.h \
+		rygel-icon-info.c \
 		rygel-connection-manager.h \
 		rygel-connection-manager.c \
 		rygel-media-receiver-registrar.h \
@@ -103,6 +107,7 @@
 		rygel-connection-manager.vala \
 		rygel-media-receiver-registrar.vala \
 		rygel-resource-info.vala \
+		rygel-icon-info.vala \
 		rygel-plugin.vala \
 		rygel-media-object.vala \
 		rygel-media-container.vala \

Added: trunk/src/rygel/rygel-icon-info.vala
==============================================================================
--- (empty file)
+++ trunk/src/rygel/rygel-icon-info.vala	Thu Nov 27 23:20:03 2008
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ */
+
+using Rygel;
+
+/**
+ * Holds information about an icon.
+ */
+public class Rygel.IconInfo {
+    public string mimetype;
+    public uint width;
+    public uint height;
+    public uint depth;
+    public string path;
+
+    public IconInfo (string mimetype,
+                     uint   width,
+                     uint   height,
+                     uint   depth,
+                     string path) {
+        this.mimetype = mimetype;
+        this.width = width;
+        this.height = height;
+        this.depth = depth;
+        this.path = path;
+    }
+}
+

Modified: trunk/src/rygel/rygel-media-server-factory.vala
==============================================================================
--- trunk/src/rygel/rygel-media-server-factory.vala	(original)
+++ trunk/src/rygel/rygel-media-server-factory.vala	Thu Nov 27 23:20:03 2008
@@ -207,6 +207,9 @@
                                         plugin.name,
                                         gconf_path);
 
+        /* Then list each icon */
+        this.add_icons_to_desc (device_element, plugin);
+
         /* Then list each service */
         this.add_services_to_desc (device_element, plugin);
     }
@@ -286,5 +289,44 @@
         url = plugin_name + "/" + resource_info.type.name () + "/Control";
         service_node->new_child (null, "controlURL", url);
     }
+
+    private void add_icons_to_desc (Xml.Node *device_element,
+                                    Plugin    plugin) {
+        Xml.Node *icon_list_node = Utils.get_xml_element (device_element,
+                                                          "iconList",
+                                                          null);
+        if (icon_list_node == null) {
+            warning ("Element /root/device/iconList not found.");
+
+            return;
+        }
+
+        foreach (IconInfo icon_info in plugin.icon_infos) {
+            add_icon_to_desc (icon_list_node, icon_info, plugin);
+        }
+    }
+
+    private void add_icon_to_desc (Xml.Node *icon_list_node,
+                                   IconInfo  icon_info,
+                                   Plugin    plugin) {
+        // Create the service node
+        Xml.Node *icon_node = icon_list_node->new_child (null, "icon");
+
+        string width = icon_info.width.to_string ();
+        string height = icon_info.height.to_string ();
+        string depth = icon_info.depth.to_string ();
+
+        icon_node->new_child (null, "mimetype", icon_info.mimetype);
+        icon_node->new_child (null, "width", width);
+        icon_node->new_child (null, "height", height);
+        icon_node->new_child (null, "depth", depth);
+
+        // PLUGIN_NAME-WIDTHxHEIGHTxDEPTH.png
+        string url = plugin.name + "-" +
+                     width + "x" + height + "x" + depth + ".png";
+
+        this.context.host_path (icon_info.path, "/" + url);
+        icon_node->new_child (null, "url", url);
+    }
 }
 

Modified: trunk/src/rygel/rygel-plugin.vala
==============================================================================
--- trunk/src/rygel/rygel-plugin.vala	(original)
+++ trunk/src/rygel/rygel-plugin.vala	Thu Nov 27 23:20:03 2008
@@ -34,11 +34,13 @@
     public string name;
 
     public ArrayList<ResourceInfo> resource_infos;
+    public ArrayList<IconInfo> icon_infos;
 
     public Plugin (string name) {
         this.name = name;
 
         this.resource_infos = new ArrayList<ResourceInfo> ();
+        this.icon_infos = new ArrayList<IconInfo> ();
 
         /* Register Rygel.ConnectionManager */
         var resource_info = new ResourceInfo
@@ -62,5 +64,9 @@
         this.register_resource_type (resource_info.upnp_type,
                                      resource_info.type);
     }
+
+    public void add_icon (IconInfo icon_info) {
+        this.icon_infos.add (icon_info);
+    }
 }
 



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