core: More self-consistent API for HTTPItemURI
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 8 Mar 2010 16:55:01 +0000 (18:55 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 8 Mar 2010 17:03:34 +0000 (19:03 +0200)
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
src/rygel/rygel-http-request.vala
src/rygel/rygel-import-resource.vala

index 9cc5a51..2ef23bc 100644 (file)
@@ -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) {
index ac2118c..85df840 100644 (file)
@@ -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);
 
index e80af8a..e6c3b44 100644 (file)
@@ -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);