core: Provide "TransferIDs" state variable
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 18 Feb 2010 14:57:06 +0000 (16:57 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 18 Feb 2010 17:49:20 +0000 (19:49 +0200)
data/xml/ContentDirectory.xml
src/rygel/rygel-content-directory.vala

index ff2a722..3274104 100644 (file)
@@ -118,18 +118,18 @@ feature provided by your editor.
                        <dataType>ui4</dataType>
                </stateVariable>
 
-<!-- Optional state variables that are not implemented yet
                <stateVariable>
                        <Optional/>
-                       <name>SortExtensionCapabilities</name>
-                       <sendEventsAttribute>no</sendEventsAttribute>
+                       <name>TransferIDs</name>
+                       <sendEventsAttribute>yes</sendEventsAttribute>
                        <dataType>string</dataType>
                </stateVariable>
 
+<!-- Optional state variables that are not implemented yet
                <stateVariable>
                        <Optional/>
-                       <name>TransferIDs</name>
-                       <sendEventsAttribute>yes</sendEventsAttribute>
+                       <name>SortExtensionCapabilities</name>
+                       <sendEventsAttribute>no</sendEventsAttribute>
                        <dataType>string</dataType>
                </stateVariable>
 
index 902bb97..9000069 100644 (file)
@@ -104,6 +104,8 @@ public class Rygel.ContentDirectory: Service {
         this.action_invoked["CreateObject"] += this.create_object_cb;
         this.action_invoked["ImportResource"] += this.import_resource_cb;
 
+        this.query_variable["TransferIDs"] += this.query_transfer_ids;
+
         /* Connect SystemUpdateID related signals */
         this.action_invoked["GetSystemUpdateID"] +=
                                                 this.get_system_update_id_cb;
@@ -168,9 +170,17 @@ public class Rygel.ContentDirectory: Service {
         this.active_imports.add (import);
 
         import.run.begin ();
+
+        this.notify ("TransferIDs",
+                        typeof (string),
+                        this.create_transfer_ids ());
     }
 
     private void on_import_completed (ImportResource import) {
+        this.notify ("TransferIDs",
+                        typeof (string),
+                        this.create_transfer_ids ());
+
         // According to CDS specs (v3 section 2.4.17), we must not immediately
         // remove the import from out memory
         Timeout.add_seconds (30, () => {
@@ -180,6 +190,14 @@ public class Rygel.ContentDirectory: Service {
         });
     }
 
+    /* Query TransferIDs */
+    private void query_transfer_ids (ContentDirectory content_dir,
+                                     string           variable,
+                                     ref GLib.Value   value) {
+        value.init (typeof (string));
+        value.set_string (this.create_transfer_ids ());
+    }
+
     /* GetSystemUpdateID action implementation */
     private void get_system_update_id_cb (ContentDirectory    content_dir,
                                           owned ServiceAction action) {
@@ -317,5 +335,21 @@ public class Rygel.ContentDirectory: Service {
 
         return false;
     }
+
+    private string create_transfer_ids () {
+        var ids = "";
+
+        foreach (var import in this.active_imports) {
+            if (!import.complete) {
+                if (ids != "") {
+                    ids += ",";
+                }
+
+                ids += import.transfer_id.to_string ();
+            }
+        }
+
+        return ids;
+    }
 }