[rygel] external: Async creation of plugin instance



commit 65bd9afb8ae330958cd4e60052802bd36ee853b7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Oct 20 14:46:12 2009 +0300

    external: Async creation of plugin instance

 .../external/rygel-external-plugin-factory.vala    |   16 ++++++++++------
 src/plugins/external/rygel-external-plugin.vala    |   15 ++++++++++++---
 2 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/external/rygel-external-plugin-factory.vala b/src/plugins/external/rygel-external-plugin-factory.vala
index caf3dc8..4e3750f 100644
--- a/src/plugins/external/rygel-external-plugin-factory.vala
+++ b/src/plugins/external/rygel-external-plugin-factory.vala
@@ -66,8 +66,7 @@ public class ExternalPluginFactory {
         foreach (var service in services) {
             if (service.has_prefix (SERVICE_PREFIX) &&
                 this.loader.get_plugin_by_name (service) == null) {
-                this.loader.add_plugin (new ExternalPlugin (this.connection,
-                                                            service));
+                yield this.load_plugin (this.connection, service);
             }
         }
 
@@ -80,8 +79,7 @@ public class ExternalPluginFactory {
         foreach (var service in services) {
             if (service.has_prefix (SERVICE_PREFIX) &&
                 this.loader.get_plugin_by_name (service) == null) {
-                this.loader.add_plugin (new ExternalPlugin (this.connection,
-                                                            service));
+                yield this.load_plugin (this.connection, service);
             }
         }
 
@@ -106,8 +104,14 @@ public class ExternalPluginFactory {
             }
         } else if (name.has_prefix (SERVICE_PREFIX)) {
                 // Ah, new plugin available, lets use it
-                this.loader.add_plugin (new ExternalPlugin (this.connection,
-                                                            name));
+                this.load_plugin.begin (this.connection, name);
         }
     }
+
+    private async void load_plugin (DBus.Connection connection,
+                                    string          service_name) {
+        var plugin = yield ExternalPlugin.create (connection, service_name);
+
+        this.loader.add_plugin (plugin);
+    }
 }
diff --git a/src/plugins/external/rygel-external-plugin.vala b/src/plugins/external/rygel-external-plugin.vala
index 896f133..7b4c356 100644
--- a/src/plugins/external/rygel-external-plugin.vala
+++ b/src/plugins/external/rygel-external-plugin.vala
@@ -26,16 +26,25 @@ public class Rygel.ExternalPlugin : Rygel.Plugin {
     public string service_name;
     public string root_object;
 
-    public ExternalPlugin (DBus.Connection connection,
-                           string          service_name) {
+    public static async ExternalPlugin create (DBus.Connection connection,
+                                               string          service_name) {
         // org.gnome.UPnP.MediaServer1.NAME => /org/gnome/UPnP/MediaServer1/NAME
         var root_object = "/" + service_name.replace (".", "/");
 
         // Create proxy to MediaObject iface to get the display name through
         var obj = (ExternalMediaObject) connection.get_object (service_name,
                                                                root_object);
+
+        return new ExternalPlugin (service_name,
+                                   obj.display_name,
+                                   root_object);
+    }
+
+    public ExternalPlugin (string service_name,
+                           string title,
+                           string root_object) {
         base.MediaServer (service_name,
-                          obj.display_name,
+                          title,
                           typeof (ExternalContentDir));
 
         this.service_name = service_name;



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