[rygel] core: More self-consistent API for HTTPItemURI



commit 92534b8a283ceba946e12bd038c7dc58e1205f0a
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Mar 8 18:55:01 2010 +0200

    core: More self-consistent API for HTTPItemURI
    
    Both constructors should take HTTPServer as argument and keep it's
    reference since it's always needed in a method.

 src/rygel/rygel-http-item-uri.vala   |    7 +++++--
 src/rygel/rygel-http-request.vala    |    2 +-
 src/rygel/rygel-import-resource.vala |    2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/rygel/rygel-http-item-uri.vala b/src/rygel/rygel-http-item-uri.vala
index 9cc5a51..2ef23bc 100644
--- a/src/rygel/rygel-http-item-uri.vala
+++ b/src/rygel/rygel-http-item-uri.vala
@@ -36,12 +36,15 @@ internal class Rygel.HTTPItemURI : Object {
         this.http_server = http_server;
     }
 
-    public HTTPItemURI.from_string (string uri, string server_root = "")
+    public HTTPItemURI.from_string (string     uri,
+                                    HTTPServer http_server)
                                     throws HTTPRequestError {
         // do not decode the path here as it may contain encoded slashes
         this.thumbnail_index = -1;
         this.transcode_target = null;
-        var request_uri = uri.replace (server_root, "");
+        this.http_server = http_server;
+
+        var request_uri = uri.replace (http_server.path_root, "");
         var parts = request_uri.split ("/");
 
         if (parts.length < 2 || parts.length % 2 == 0) {
diff --git a/src/rygel/rygel-http-request.vala b/src/rygel/rygel-http-request.vala
index ac2118c..85df840 100644
--- a/src/rygel/rygel-http-request.vala
+++ b/src/rygel/rygel-http-request.vala
@@ -63,7 +63,7 @@ internal abstract class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
     protected virtual async void handle () {
         try {
             this.uri = new HTTPItemURI.from_string (this.msg.uri.path,
-                                                    this.http_server.path_root);
+                                                    this.http_server);
         } catch (Error error) {
             this.handle_error (error);
 
diff --git a/src/rygel/rygel-import-resource.vala b/src/rygel/rygel-import-resource.vala
index e80af8a..e6c3b44 100644
--- a/src/rygel/rygel-import-resource.vala
+++ b/src/rygel/rygel-import-resource.vala
@@ -143,7 +143,7 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
 
     private async string get_original_uri () throws Error {
         var uri = new HTTPItemURI.from_string (this.destination_uri,
-                                               this.http_server.path_root);
+                                               this.http_server);
         var media_object = yield this.root_container.find_object (uri.item_id,
                                                                   null);
 



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