[PATCH spice-html5 2/2] Add button for cancelling file transfer

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

 



---
 filexfer.js | 12 ++++++++++++
 main.js     |  9 +++++++++
 2 files changed, 21 insertions(+)

diff --git a/filexfer.js b/filexfer.js
index 2887e14..beabfd8 100644
--- a/filexfer.js
+++ b/filexfer.js
@@ -26,9 +26,20 @@ function SpiceFileXferTask(id, file)
 
 SpiceFileXferTask.prototype.create_progressbar = function()
 {
+    var _this = this;
+    var cancel = document.createElement("input");
     this.progressbar_container = document.createElement("div");
     this.progressbar = document.createElement("progress");
 
+    cancel.type = 'button';
+    cancel.value = 'Cancel';
+    cancel.style.float = 'right';
+    cancel.onclick = function()
+    {
+        _this.cancelled = true;
+        _this.remove_progressbar();
+    };
+
     this.progressbar.setAttribute('max', this.file.size);
     this.progressbar.setAttribute('value', 0);
     this.progressbar.style.width = '100%';
@@ -38,6 +49,7 @@ SpiceFileXferTask.prototype.create_progressbar = function()
     this.progressbar_container.style.margin = 'auto';
     this.progressbar_container.style.padding = '4px';
     this.progressbar_container.textContent = this.file.name;
+    this.progressbar_container.appendChild(cancel);
     this.progressbar_container.appendChild(this.progressbar);
     document.getElementById('spice-xfer-area').appendChild(this.progressbar_container);
 }
diff --git a/main.js b/main.js
index f9a463b..bfc102a 100644
--- a/main.js
+++ b/main.js
@@ -338,6 +338,15 @@ SpiceMainConn.prototype.file_xfer_read = function(file_xfer_task, start_byte)
         return;
     }
 
+    if (file_xfer_task.cancelled)
+    {
+        var xfer_status = new VDAgentFileXferStatusMessage(file_xfer_task.id,
+                                                           VD_AGENT_FILE_XFER_STATUS_CANCELLED);
+        this.send_agent_message(VD_AGENT_FILE_XFER_STATUS, xfer_status);
+        delete this.file_xfer_tasks[file_xfer_task.id];
+        return;
+    }
+
     sb = start_byte || 0,
     eb = Math.min(sb + FILE_XFER_CHUNK_SIZE, file_xfer_task.file.size);
 
-- 
1.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]