[Spice-devel] [PATCH spice-html5 2/2] main: Add event to alert file transfer error messages
Tomáš Bohdálek
tom.bohdalek at gmail.com
Wed Sep 6 08:52:42 UTC 2017
---
main.js | 15 +++++++++++++++
spice.html | 5 +++++
spice_auto.html | 5 +++++
3 files changed, 25 insertions(+)
diff --git a/main.js b/main.js
index 0237f0e..447177b 100644
--- a/main.js
+++ b/main.js
@@ -385,20 +385,25 @@ SpiceMainConn.prototype.handle_file_xfer_status = function(file_xfer_status)
break;
case VD_AGENT_FILE_XFER_STATUS_ERROR:
xfer_error = "some errors occurred in the spice agent";
+ this.file_xfer_detailed_errors(xfer_error);
break;
case VD_AGENT_FILE_XFER_STATUS_SUCCESS:
break;
case VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE:
xfer_error = "not enough space in the remote system";
+ this.file_xfer_detailed_errors(xfer_error);
break;
case VD_AGENT_FILE_XFER_STATUS_SESSION_LOCKED:
xfer_error = "remote system is locked";
+ this.file_xfer_detailed_errors(xfer_error);
break;
case VD_AGENT_FILE_XFER_STATUS_AGENT_NOT_CONNECTED:
xfer_error = "spice angent is not connected";
+ this.file_xfer_detailed_errors(xfer_error);
break;
case VD_AGENT_FILE_XFER_STATUS_DISABLED:
xfer_error = "file transfer is disabled on the remote system";
+ this.file_xfer_detailed_errors(xfer_error);
break;
default:
xfer_error = "unhandled status type: " + file_xfer_status.result;
@@ -506,3 +511,13 @@ SpiceMainConn.prototype.relative_now = function()
var ret = (Date.now() - this.our_mm_time) + this.mm_time;
return ret;
}
+
+SpiceMainConn.prototype.file_xfer_detailed_errors = function(status)
+{
+ var event = new CustomEvent('xfer-error', {
+ detail: {
+ data: "File transfer: " + status
+ }
+ });
+ window.dispatchEvent(event);
+}
diff --git a/spice.html b/spice.html
index 8c43dcb..3709b9c 100644
--- a/spice.html
+++ b/spice.html
@@ -156,6 +156,11 @@
});
*/
+ window.addEventListener('xfer-error', function(event)
+ {
+ alert(event.detail.data);
+ });
+
</script>
</head>
diff --git a/spice_auto.html b/spice_auto.html
index 10f5508..92e75f1 100644
--- a/spice_auto.html
+++ b/spice_auto.html
@@ -196,6 +196,11 @@
});
*/
+ window.addEventListener('xfer-error', function(event)
+ {
+ alert(event.detail.data);
+ });
+
connect();
</script>
--
2.9.4
More information about the Spice-devel
mailing list