[rygel] core: Put query parsing in separate method



commit 30a45e0513e39f2f56e51c6f865c6e39785439e8
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Sep 29 15:09:56 2009 +0300

    core: Put query parsing in separate method

 src/rygel/rygel-http-request.vala |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/src/rygel/rygel-http-request.vala b/src/rygel/rygel-http-request.vala
index 54bea27..52e23bc 100644
--- a/src/rygel/rygel-http-request.vala
+++ b/src/rygel/rygel-http-request.vala
@@ -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);
 



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