From: Zeeshan Ali (Khattak) Date: Thu, 27 Nov 2008 23:20:03 +0000 (+0000) Subject: Add support for icons. X-Git-Tag: RYGEL_0_2~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf17dc35936953812d52641615a5979d32511ec1;p=profile%2Fivi%2Frygel.git Add support for icons. Plugins can now provide icons to represent themselves. Yay! svn path=/trunk/; revision=316 --- diff --git a/data/xml/description.xml b/data/xml/description.xml index 6f023dd..d8b5ede 100644 --- a/data/xml/description.xml +++ b/data/xml/description.xml @@ -15,6 +15,8 @@ 0000001 + + DMS-1.50 diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am index 647fae4..9edc20f 100644 --- a/src/rygel/Makefile.am +++ b/src/rygel/Makefile.am @@ -37,6 +37,8 @@ BUILT_SOURCES = rygel-1.0.vapi \ 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_SOURCES = rygel-1.0.vapi \ 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-1.0.vapi: rygel-content-directory.vala \ 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 \ diff --git a/src/rygel/rygel-icon-info.vala b/src/rygel/rygel-icon-info.vala new file mode 100644 index 0000000..5dde82e --- /dev/null +++ b/src/rygel/rygel-icon-info.vala @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2008 Nokia Corporation, all rights reserved. + * + * Author: Zeeshan Ali (Khattak) + * + * + * 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; + } +} + diff --git a/src/rygel/rygel-media-server-factory.vala b/src/rygel/rygel-media-server-factory.vala index 270ca09..ec3711b 100644 --- a/src/rygel/rygel-media-server-factory.vala +++ b/src/rygel/rygel-media-server-factory.vala @@ -207,6 +207,9 @@ public class Rygel.MediaServerFactory { 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 @@ public class Rygel.MediaServerFactory { 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); + } } diff --git a/src/rygel/rygel-plugin.vala b/src/rygel/rygel-plugin.vala index 2f2aacd..07f217f 100644 --- a/src/rygel/rygel-plugin.vala +++ b/src/rygel/rygel-plugin.vala @@ -34,11 +34,13 @@ public class Rygel.Plugin : GUPnP.ResourceFactory { public string name; public ArrayList resource_infos; + public ArrayList icon_infos; public Plugin (string name) { this.name = name; this.resource_infos = new ArrayList (); + this.icon_infos = new ArrayList (); /* Register Rygel.ConnectionManager */ var resource_info = new ResourceInfo @@ -62,5 +64,9 @@ public class Rygel.Plugin : GUPnP.ResourceFactory { this.register_resource_type (resource_info.upnp_type, resource_info.type); } + + public void add_icon (IconInfo icon_info) { + this.icon_infos.add (icon_info); + } }