summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Grunt <pgrunt@redhat.com>2015-01-15 13:33:58 +0100
committerJeremy White <jwhite@codeweavers.com>2015-01-15 12:43:43 -0600
commit54ee82f004a85d99a742108bf63922be5c3f0800 (patch)
tree9ba3e1ca7b948c6b2c9373c31406a1596a51e441
parent566e4acc393c791f825f04b0874a62456e6c8c1b (diff)
Inform agent about client's capabilities
The client should inform the agent about capabilities when the connection is established. This avoid receiving unhandled agent messages.
-rw-r--r--enums.js13
-rw-r--r--main.js19
-rw-r--r--spicemsg.js34
3 files changed, 65 insertions, 1 deletions
diff --git a/enums.js b/enums.js
index 07aa343..17d77cb 100644
--- a/enums.js
+++ b/enums.js
@@ -329,6 +329,19 @@ var VD_AGENT_MOUSE_STATE = 1,
VD_AGENT_CLIENT_DISCONNECTED =13,
VD_AGENT_MAX_CLIPBOARD =14;
+var VD_AGENT_CAP_MOUSE_STATE = 0,
+ VD_AGENT_CAP_MONITORS_CONFIG = 1,
+ VD_AGENT_CAP_REPLY = 2,
+ VD_AGENT_CAP_CLIPBOARD = 3,
+ VD_AGENT_CAP_DISPLAY_CONFIG = 4,
+ VD_AGENT_CAP_CLIPBOARD_BY_DEMAND = 5,
+ VD_AGENT_CAP_CLIPBOARD_SELECTION = 6,
+ VD_AGENT_CAP_SPARSE_MONITORS_CONFIG = 7,
+ VD_AGENT_CAP_GUEST_LINEEND_LF = 8,
+ VD_AGENT_CAP_GUEST_LINEEND_CRLF = 9,
+ VD_AGENT_CAP_MAX_CLIPBOARD = 10,
+ VD_AGENT_END_CAP = 11;
+
var VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA = 0,
VD_AGENT_FILE_XFER_STATUS_CANCELLED = 1,
VD_AGENT_FILE_XFER_STATUS_ERROR = 2,
diff --git a/main.js b/main.js
index 24feb6d..f6006e6 100644
--- a/main.js
+++ b/main.js
@@ -185,7 +185,14 @@ SpiceMainConn.prototype.process_channel_message = function(msg)
if (msg.type == SPICE_MSG_MAIN_AGENT_DATA)
{
var agent_data = new SpiceMsgMainAgentData(msg.data);
- if (agent_data.type == VD_AGENT_FILE_XFER_STATUS)
+ if (agent_data.type == VD_AGENT_ANNOUNCE_CAPABILITIES)
+ {
+ var agent_caps = new VDAgentAnnounceCapabilities(agent_data.data);
+ if (agent_caps.request)
+ this.announce_agent_capabilities(0);
+ return true;
+ }
+ else if (agent_data.type == VD_AGENT_FILE_XFER_STATUS)
{
this.handle_file_xfer_status(new VDAgentFileXferStatusMessage(agent_data.data));
return true;
@@ -262,6 +269,14 @@ SpiceMainConn.prototype.send_agent_message = function(type, message)
}
}
+SpiceMainConn.prototype.announce_agent_capabilities = function(request)
+{
+ var caps = new VDAgentAnnounceCapabilities(request, (1 << VD_AGENT_CAP_MOUSE_STATE) |
+ (1 << VD_AGENT_CAP_MONITORS_CONFIG) |
+ (1 << VD_AGENT_CAP_REPLY));
+ this.send_agent_message(VD_AGENT_ANNOUNCE_CAPABILITIES, caps);
+}
+
SpiceMainConn.prototype.resize_window = function(flags, width, height, depth, x, y)
{
var monitors_config = new VDAgentMonitorsConfig(flags, width, height, depth, x, y);
@@ -365,6 +380,8 @@ SpiceMainConn.prototype.connect_agent = function()
mr.build_msg(SPICE_MSGC_MAIN_AGENT_START, agent_start);
this.send_msg(mr);
+ this.announce_agent_capabilities(1);
+
if (this.onagent !== undefined)
this.onagent(this);
diff --git a/spicemsg.js b/spicemsg.js
index ec2034c..e167b3d 100644
--- a/spicemsg.js
+++ b/spicemsg.js
@@ -486,6 +486,40 @@ SpiceMsgcMainAgentData.prototype =
}
}
+function VDAgentAnnounceCapabilities(request, caps)
+{
+ if (caps)
+ {
+ this.request = request;
+ this.caps = caps;
+ }
+ else
+ this.from_buffer(request);
+}
+
+VDAgentAnnounceCapabilities.prototype =
+{
+ to_buffer: function(a, at)
+ {
+ at = at || 0;
+ var dv = new SpiceDataView(a);
+ dv.setUint32(at, this.request, true); at += 4;
+ dv.setUint32(at, this.caps, true); at += 4;
+ },
+ from_buffer: function(a, at)
+ {
+ at = at || 0;
+ var dv = new SpiceDataView(a);
+ this.request = dv.getUint32(at, true); at += 4;
+ this.caps = dv.getUint32(at, true); at += 4;
+ return at;
+ },
+ buffer_size: function()
+ {
+ return 8;
+ }
+}
+
function VDAgentMonitorsConfig(flags, width, height, depth, x, y)
{
this.num_mon = 1;