core: Put query parsing in separate method
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 29 Sep 2009 12:09:56 +0000 (15:09 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 29 Sep 2009 12:09:56 +0000 (15:09 +0300)
src/rygel/rygel-http-request.vala

index 54bea27..52e23bc 100644 (file)
@@ -81,20 +81,10 @@ internal class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
             return;
         }
 
-        if (this.query != null) {
-            this.item_id = this.query.lookup ("itemid");
-            var target = this.query.lookup ("transcode");
-            if (target != null) {
-                var transcoder = this.http_server.get_transcoder (target);
-                this.request_handler = new HTTPTranscodeHandler (
-                                        transcoder,
-                                        this.cancellable);
-            }
-
-            var index = this.query.lookup ("thumbnail");
-            if (index != null) {
-                this.thumbnail_index = index.to_int ();
-            }
+        try {
+            this.parse_query ();
+        } catch (Error err) {
+            warning ("Failed to parse query: %s", err.message);
         }
 
         if (this.item_id == null) {
@@ -167,6 +157,25 @@ internal class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
         this.handle_item_request ();
     }
 
+    private void parse_query () throws Error {
+        if (this.query == null) {
+            return;
+        }
+
+        this.item_id = this.query.lookup ("itemid");
+        var target = this.query.lookup ("transcode");
+        if (target != null) {
+            var transcoder = this.http_server.get_transcoder (target);
+            this.request_handler = new HTTPTranscodeHandler (transcoder,
+                                                             this.cancellable);
+        }
+
+        var index = this.query.lookup ("thumbnail");
+        if (index != null) {
+            this.thumbnail_index = index.to_int ();
+        }
+    }
+
     private void handle_error (Error error) {
         warning ("%s", error.message);