[rygel] core,tracker: Plugin provide URIs for icons



commit c0e78dec9467860cbef8b0a899ff15f7c7d75bf0
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Oct 20 17:02:55 2009 +0300

    core,tracker: Plugin provide URIs for icons
    
    Plugin provide URIs for icons rather than path

 src/plugins/tracker/rygel-tracker-plugin.vala |   14 +++++++++-----
 src/rygel/rygel-icon-info.vala                |   11 +++++------
 src/rygel/rygel-root-device-factory.vala      |   22 ++++++++++++++++------
 src/rygel/rygel-thumbnail.vala                |    1 -
 src/rygel/rygel-thumbnailer.vala              |    1 -
 5 files changed, 30 insertions(+), 19 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-plugin.vala b/src/plugins/tracker/rygel-tracker-plugin.vala
index 0860bf8..d95ec8c 100644
--- a/src/plugins/tracker/rygel-tracker-plugin.vala
+++ b/src/plugins/tracker/rygel-tracker-plugin.vala
@@ -35,12 +35,16 @@ public class Rygel.TrackerPlugin : Rygel.Plugin {
 
         var icon_info = new IconInfo ("image/png");
 
-        icon_info.path = ICON;
-        icon_info.width = 48;
-        icon_info.height = 48;
-        icon_info.depth = 24;
+        try {
+            icon_info.uri = Filename.to_uri (ICON, null);
+            icon_info.width = 48;
+            icon_info.height = 48;
+            icon_info.depth = 24;
 
-        this.add_icon (icon_info);
+            this.add_icon (icon_info);
+        } catch (ConvertError err) {
+            warning ("Error creating URI from %s: %s", ICON, err.message);
+        }
     }
 }
 
diff --git a/src/rygel/rygel-icon-info.vala b/src/rygel/rygel-icon-info.vala
index 52607eb..0105404 100644
--- a/src/rygel/rygel-icon-info.vala
+++ b/src/rygel/rygel-icon-info.vala
@@ -26,16 +26,15 @@
  */
 public class Rygel.IconInfo {
     public string mime_type;
-    public string path;
+    public string uri;
 
-    public long size = -1;       // Size in bytes
-    public int width = -1;       // Width in pixels
-    public int height = -1;      // Height in pixels
-    public int depth = -1; // depth of pixels in bytes
+    public long size = -1;   // Size in bytes
+    public int width = -1;   // Width in pixels
+    public int height = -1;  // Height in pixels
+    public int depth = -1;   // depth of pixels in bytes
 
     public IconInfo (string mime_type) {
         this.mime_type = mime_type;
-        this.path = path;
     }
 }
 
diff --git a/src/rygel/rygel-root-device-factory.vala b/src/rygel/rygel-root-device-factory.vala
index 354e1e4..ffb6d29 100644
--- a/src/rygel/rygel-root-device-factory.vala
+++ b/src/rygel/rygel-root-device-factory.vala
@@ -250,12 +250,22 @@ public class Rygel.RootDeviceFactory {
         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);
+        var uri = icon_info.uri;
+
+        if (uri.has_prefix ("file://")) {
+            // /PLUGIN_NAME-WIDTHxHEIGHTxDEPTH.png
+            var remote_path = "/" + plugin.name + "-" +
+                              width + "x" +
+                              height + "x" +
+                              depth + ".png";
+            var local_path = uri.offset (7);
+
+            this.context.host_path (local_path, remote_path);
+            icon_node->new_child (null, "url", remote_path);
+        } else {
+            uri = uri.replace ("@ADDRESS@", this.context.host_ip);
+            icon_node->new_child (null, "url", uri);
+        }
     }
 
     private void save_modified_desc (XMLDoc doc,
diff --git a/src/rygel/rygel-thumbnail.vala b/src/rygel/rygel-thumbnail.vala
index d040fc9..1112b8c 100644
--- a/src/rygel/rygel-thumbnail.vala
+++ b/src/rygel/rygel-thumbnail.vala
@@ -26,7 +26,6 @@ using GUPnP;
  * Represents a picture or video thumbnail.
  */
 public class Rygel.Thumbnail : Rygel.IconInfo {
-    public string uri;
     public string dlna_profile;
 
     public Thumbnail (string mime_type = "image/jpeg",
diff --git a/src/rygel/rygel-thumbnailer.vala b/src/rygel/rygel-thumbnailer.vala
index 7fb9f3c..6376568 100644
--- a/src/rygel/rygel-thumbnailer.vala
+++ b/src/rygel/rygel-thumbnailer.vala
@@ -108,7 +108,6 @@ internal class Rygel.Thumbnailer : GLib.Object {
         thumbnail.width = this.template.width;
         thumbnail.height = this.template.height;
         thumbnail.depth = this.template.depth;
-        thumbnail.path = path;
         thumbnail.uri = Filename.to_uri (full_path, null);
         thumbnail.size = (long) info.get_attribute_uint64 (
                                         FILE_ATTRIBUTE_STANDARD_SIZE);



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