[rygel] core: Provide "TransferIDs" state variable



commit 0e63c97d7a8a9530b63b1ae67d538950da84c85b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Feb 18 16:57:06 2010 +0200

    core: Provide "TransferIDs" state variable

 data/xml/ContentDirectory.xml          |   10 ++++----
 src/rygel/rygel-content-directory.vala |   34 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 5 deletions(-)
---
diff --git a/data/xml/ContentDirectory.xml b/data/xml/ContentDirectory.xml
index ff2a722..3274104 100644
--- a/data/xml/ContentDirectory.xml
+++ b/data/xml/ContentDirectory.xml
@@ -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>
 
diff --git a/src/rygel/rygel-content-directory.vala b/src/rygel/rygel-content-directory.vala
index 902bb97..9000069 100644
--- a/src/rygel/rygel-content-directory.vala
+++ b/src/rygel/rygel-content-directory.vala
@@ -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;
+    }
 }
 



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