[Spice-devel] [PATCH] Basic SPICE port implementation

Oliver Gutierrez ogutierrez at redhat.com
Mon Oct 3 12:10:22 UTC 2016


Forget this one. Missing one file.

On Mon, Oct 3, 2016 at 2:02 PM, Oliver Gutierrez <ogutierrez at redhat.com>
wrote:

> ---
>  enums.js        |  9 +++++++++
>  main.js         |  3 +++
>  spice.html      | 13 +++++++++++++
>  spice_auto.html | 13 +++++++++++++
>  spicemsg.js     | 18 ++++++++++++++++++
>  utils.js        |  7 +++++++
>  6 files changed, 63 insertions(+)
>
> diff --git a/enums.js b/enums.js
> index 301fea0..b6e013c 100644
> --- a/enums.js
> +++ b/enums.js
> @@ -166,6 +166,15 @@ var SPICE_MSG_PLAYBACK_VOLUME           = 105;
>  var SPICE_MSG_PLAYBACK_MUTE             = 106;
>  var SPICE_MSG_PLAYBACK_LATENCY          = 107;
>
> +var SPICE_MSG_SPICEVMC_DATA             = 101;
> +var SPICE_MSG_PORT_INIT                 = 201;
> +var SPICE_MSG_PORT_EVENT                = 202;
> +var SPICE_MSG_END_PORT                  = 203;
> +
> +var SPICE_MSGC_SPICEVMC_DATA            = 101;
> +var SPICE_MSGC_PORT_EVENT               = 201;
> +var SPICE_MSGC_END_PORT                 = 202;
> +
>  var SPICE_PLAYBACK_CAP_CELT_0_5_1       = 0;
>  var SPICE_PLAYBACK_CAP_VOLUME           = 1;
>  var SPICE_PLAYBACK_CAP_LATENCY          = 2;
> diff --git a/main.js b/main.js
> index 874a038..2d8a1ff 100644
> --- a/main.js
> +++ b/main.js
> @@ -59,6 +59,7 @@ function SpiceMainConn()
>      this.file_xfer_tasks = {};
>      this.file_xfer_task_id = 0;
>      this.file_xfer_read_queue = [];
> +    this.ports = [];
>  }
>
>  SpiceMainConn.prototype = Object.create(SpiceConn.prototype);
> @@ -154,6 +155,8 @@ SpiceMainConn.prototype.process_channel_message =
> function(msg)
>                  this.cursor = new SpiceCursorConn(conn);
>              else if (chans.channels[i].type == SPICE_CHANNEL_PLAYBACK)
>                  this.cursor = new SpicePlaybackConn(conn);
> +            else if (chans.channels[i].type == SPICE_CHANNEL_PORT)
> +                this.ports.push(new SpicePortConn(conn));
>              else
>              {
>                  if (! ("extra_channels" in this))
> diff --git a/spice.html b/spice.html
> index c473678..d4c9962 100644
> --- a/spice.html
> +++ b/spice.html
> @@ -42,6 +42,7 @@
>          <script src="wire.js"></script>
>          <script src="spiceconn.js"></script>
>          <script src="display.js"></script>
> +        <script src="port.js"></script>
>          <script src="main.js"></script>
>          <script src="inputs.js"></script>
>          <script src="webm.js"></script>
> @@ -142,6 +143,18 @@
>                  }
>              }
>
> +            /* SPICE port event listeners
> +            window.addEventListener('spice-port-data', function(event) {
> +                // Here we convert data to text, but really we can obtain
> binary data also
> +                var msg_text = arraybuffer_to_str(new
> Uint8Array(event.detail.data));
> +                DEBUG > 0 && console.log('SPICE port',
> event.detail.channel.portName, 'message text:', msg_text);
> +            });
> +
> +            window.addEventListener('spice-port-event', function(event) {
> +                DEBUG > 0 && console.log('SPICE port',
> event.detail.channel.portName, 'event data:', event.detail.spiceEvent);
> +            });
> +            */
> +
>          </script>
>
>      </head>
> diff --git a/spice_auto.html b/spice_auto.html
> index 1179ebe..2f04fc9 100644
> --- a/spice_auto.html
> +++ b/spice_auto.html
> @@ -42,6 +42,7 @@
>          <script src="wire.js"></script>
>          <script src="spiceconn.js"></script>
>          <script src="display.js"></script>
> +        <script src="port.js"></script>
>          <script src="main.js"></script>
>          <script src="inputs.js"></script>
>          <script src="webm.js"></script>
> @@ -182,6 +183,18 @@
>                  }
>              }
>
> +            /* SPICE port event listeners
> +            window.addEventListener('spice-port-data', function(event) {
> +                // Here we convert data to text, but really we can obtain
> binary data also
> +                var msg_text = arraybuffer_to_str(new
> Uint8Array(event.detail.data));
> +                DEBUG > 0 && console.log('SPICE port',
> event.detail.channel.portName, 'message text:', msg_text);
> +            });
> +
> +            window.addEventListener('spice-port-event', function(event) {
> +                DEBUG > 0 && console.log('SPICE port',
> event.detail.channel.portName, 'event data:', event.detail.spiceEvent);
> +            });
> +            */
> +
>              connect();
>          </script>
>
> diff --git a/spicemsg.js b/spicemsg.js
> index 0321cc7..3619996 100644
> --- a/spicemsg.js
> +++ b/spicemsg.js
> @@ -1278,3 +1278,21 @@ SpiceMsgDisplayInvalList.prototype =
>          }
>      },
>  }
> +
> +function SpiceMsgPortInit(a, at)
> +{
> +    this.from_buffer(a,at);
> +};
> +
> +SpiceMsgPortInit.prototype =
> +{
> +    from_buffer: function (a, at)
> +    {
> +        at = at || 0;
> +        var dv = new SpiceDataView(a);
> +        var namesize = dv.getUint32(at, true); at += 4;
> +        var offset = dv.getUint32(at, true); at += 4;
> +        this.opened = dv.getUint8(at, true); at += 1;
> +        this.name = a.slice(offset, offset + namesize - 1);
> +    }
> +}
> diff --git a/utils.js b/utils.js
> index 9093a24..a22d0ae 100644
> --- a/utils.js
> +++ b/utils.js
> @@ -100,6 +100,13 @@ function hexdump_buffer(a)
>  }
>
>  /*----------------------------------------------------------
> ------------------
> +**  Convert arraybuffer to string
> +**---------------------------------------------------------
> -----------------*/
> +function arraybuffer_to_str(buf) {
> +  return String.fromCharCode.apply(null, new Uint16Array(buf));
> +}
> +
> +/*---------------------------------------------------------
> -------------------
>  ** Converting keycodes to AT scancodes is very hard.
>  ** luckly there are some resources on the web and in the Xorg driver that
> help
>  ** us figure out what browser dependent keycodes match to what scancodes.
> --
> 2.9.3
>
>


-- 
Oliver Gutierrez
Associate Software Engineer - Desktop Management tools
Red Hat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161003/ae91be22/attachment-0001.html>


More information about the Spice-devel mailing list