[rygel] external: Asynchronously update container information



commit 1e8dca8c77e1e09dfe99b1ebe53b5d25138bcf62
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Jun 24 18:07:05 2010 +0300

    external: Asynchronously update container information

 src/plugins/external/rygel-external-container.vala |   24 +++++++++++--------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/src/plugins/external/rygel-external-container.vala b/src/plugins/external/rygel-external-container.vala
index d4c5158..bd4c9d6 100644
--- a/src/plugins/external/rygel-external-container.vala
+++ b/src/plugins/external/rygel-external-container.vala
@@ -62,15 +62,11 @@ public class Rygel.ExternalContainer : Rygel.MediaContainer {
 
         try {
             this.connection = DBus.Bus.get (DBus.BusType.SESSION);
-
-            this.update_container ();
-
-            this.actual_container.updated.connect (this.on_updated);
         } catch (GLib.Error err) {
-            critical ("Failed to fetch information about container '%s': %s",
-                      actual_container.get_path (),
-                      err.message);
+            critical ("Failed to connect to session bus: %s", err.message);
         }
+
+        this.update_container.begin (true);
     }
 
     public override async Gee.List<MediaObject>? get_children (
@@ -241,7 +237,7 @@ public class Rygel.ExternalContainer : Rygel.MediaContainer {
         return media_objects;
     }
 
-    private void update_container () throws GLib.Error {
+    private async void refresh_child_containers () throws GLib.Error {
         this.containers.clear ();
 
         var container_paths = this.actual_container.containers;
@@ -261,10 +257,10 @@ public class Rygel.ExternalContainer : Rygel.MediaContainer {
         }
     }
 
-    private void on_updated (ExternalMediaContainer actual_container) {
+    private async void update_container (bool connect_signal = false) {
         try {
             // Update our information about the container
-            this.update_container ();
+            yield this.refresh_child_containers ();
         } catch (GLib.Error err) {
             warning ("Failed to update information about container '%s': %s",
                      this.actual_container.get_path (),
@@ -273,6 +269,14 @@ public class Rygel.ExternalContainer : Rygel.MediaContainer {
 
         // and signal the clients
         this.updated ();
+
+        if (connect_signal) {
+            this.actual_container.updated.connect (this.on_updated);
+        }
+    }
+
+    private void on_updated (ExternalMediaContainer actual_container) {
+        this.update_container.begin ();
     }
 
     private MediaContainer find_container_by_id (string id) {



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