[rygel] core: Implement StopTransferResource action of CDS



commit 4a509a57057014a3a6b0ea940305961305058303
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Feb 19 14:17:12 2010 +0200

    core: Implement StopTransferResource action of CDS

 data/xml/ContentDirectory.xml          |   24 ++++++++++++------------
 src/rygel/rygel-content-directory.vala |   26 ++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/data/xml/ContentDirectory.xml b/data/xml/ContentDirectory.xml
index 728cfe3..0e1cd4b 100644
--- a/data/xml/ContentDirectory.xml
+++ b/data/xml/ContentDirectory.xml
@@ -404,6 +404,18 @@ feature provided by your editor.
 			</argumentList>
 		</action>
 
+		<action>
+			<Optional/>
+			<name>StopTransferResource</name>
+			<argumentList>
+				<argument>
+					<name>TransferID</name>
+					<direction>in</direction>
+					<relatedStateVariable>A_ARG_TYPE_TransferID</relatedStateVariable>
+				</argument>
+			</argumentList>
+		</action>
+
 <!-- Optional actions that are not implemented yet
                 <action>
 			<Optional/>
@@ -509,18 +521,6 @@ feature provided by your editor.
 
 		<action>
 			<Optional/>
-			<name>StopTransferResource</name>
-			<argumentList>
-				<argument>
-					<name>TransferID</name>
-					<direction>in</direction>
-					<relatedStateVariable>A_ARG_TYPE_TransferID</relatedStateVariable>
-				</argument>
-			</argumentList>
-		</action>
-
-		<action>
-			<Optional/>
 			<name>CreateReference</name>
 			<argumentList>
 				<argument>
diff --git a/src/rygel/rygel-content-directory.vala b/src/rygel/rygel-content-directory.vala
index 049b7cd..4484fc8 100644
--- a/src/rygel/rygel-content-directory.vala
+++ b/src/rygel/rygel-content-directory.vala
@@ -105,6 +105,8 @@ public class Rygel.ContentDirectory: Service {
         this.action_invoked["ImportResource"] += this.import_resource_cb;
         this.action_invoked["GetTransferProgress"] +=
                                         this.get_transfer_progress_cb;
+        this.action_invoked["StopTransferResource"] +=
+                                        this.stop_transfer_resource_cb;
 
         this.query_variable["TransferIDs"] += this.query_transfer_ids;
 
@@ -217,6 +219,30 @@ public class Rygel.ContentDirectory: Service {
         action.return_error (717, "No such file transfer");
     }
 
+    /* StopTransferResource action implementation */
+    private virtual void stop_transfer_resource_cb (
+                                        ContentDirectory    content_dir,
+                                        owned ServiceAction action) {
+        uint32 transfer_id;
+
+        action.get ("TransferID",
+                        typeof (uint32),
+                        out transfer_id);
+
+        foreach (var import in this.active_imports) {
+            if (import.transfer_id == transfer_id) {
+                import.cancellable.cancel ();
+
+                action.return ();
+
+                return;
+            }
+        }
+
+        // Reaching here means we didn't find the transfer of interest
+        action.return_error (717, "No such file transfer");
+    }
+
     /* GetSystemUpdateID action implementation */
     private void get_system_update_id_cb (ContentDirectory    content_dir,
                                           owned ServiceAction action) {



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