rygel r637 - trunk/src/rygel



Author: zeeshanak
Date: Sat Feb 21 12:03:13 2009
New Revision: 637
URL: http://svn.gnome.org/viewvc/rygel?rev=637&view=rev

Log:
HTTPServer implements StateMachine interface.

Modified:
   trunk/src/rygel/rygel-content-directory.vala
   trunk/src/rygel/rygel-http-server.vala

Modified: trunk/src/rygel/rygel-content-directory.vala
==============================================================================
--- trunk/src/rygel/rygel-content-directory.vala	(original)
+++ trunk/src/rygel/rygel-content-directory.vala	Sat Feb 21 12:03:13 2009
@@ -111,13 +111,13 @@
         /* Connect FeatureList related signals */
         this.action_invoked["GetFeatureList"] += this.get_feature_list_cb;
         this.query_variable["FeatureList"] += this.query_feature_list;
+
+        this.http_server.run (this.cancellable);
     }
 
     ~ContentDirectory () {
         // Cancel all state machines
         this.cancellable.cancel ();
-
-        this.http_server.destroy ();
     }
 
     /* Browse action implementation */

Modified: trunk/src/rygel/rygel-http-server.vala
==============================================================================
--- trunk/src/rygel/rygel-http-server.vala	(original)
+++ trunk/src/rygel/rygel-http-server.vala	Sat Feb 21 12:03:13 2009
@@ -26,7 +26,7 @@
 using GUPnP;
 using Gee;
 
-public class Rygel.HTTPServer : GLib.Object {
+public class Rygel.HTTPServer : GLib.Object, Rygel.StateMachine {
     private const string SERVER_PATH_PREFIX = "/RygelHTTPServer";
     private string path_root;
 
@@ -41,19 +41,27 @@
                        string           name) {
         this.root_container = content_dir.root_container;
         this.context = content_dir.context;
-        this.cancellable = content_dir.cancellable;
         this.requests = new ArrayList<HTTPRequest> ();
 
         this.path_root = SERVER_PATH_PREFIX + "/" + name;
+    }
 
+    public void run (Cancellable? cancellable) {
         context.server.add_handler (this.path_root, server_handler);
+
+        if (cancellable != null) {
+            this.cancellable = cancellable;
+            this.cancellable.cancelled += this.on_cancelled;
+        }
     }
 
-    public void destroy () {
+    private void on_cancelled (Cancellable cancellable) {
         // Cancel all state machines
         this.cancellable.cancel ();
 
         context.server.remove_handler (this.path_root);
+
+        this.completed ();
     }
 
     private string create_uri_for_path (string path) {



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