Re: [Spice-devel] [PATCH] Added needed import of function arraybuffer_to_str

2020-05-28 Thread Oliver Gutierrez
This is a patch to fix the SPICE port feature not being working since the
change made to use module imports instead of inline loading of scripts.

Right now works with only this change.

On Thu, May 28, 2020 at 1:31 PM Oliver Gutierrez  wrote:

> ---
>  src/port.js | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/port.js b/src/port.js
> index 74523ae..b254131 100644
> --- a/src/port.js
> +++ b/src/port.js
> @@ -20,7 +20,7 @@
>  */
>
>  import { Constants } from './enums.js';
> -import { DEBUG } from './utils.js';
> +import { DEBUG, arraybuffer_to_str } from './utils.js';
>  import { SpiceConn } from './spiceconn.js';
>  import { SpiceMsgPortInit } from './spicemsg.js';
>
> --
> 2.25.1
>
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
>
>

-- 
Oliver Gutierrez
Software Engineer - Desktop Management tools
Red Hat
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH] Added needed import of function arraybuffer_to_str

2020-05-28 Thread Oliver Gutierrez
---
 src/port.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/port.js b/src/port.js
index 74523ae..b254131 100644
--- a/src/port.js
+++ b/src/port.js
@@ -20,7 +20,7 @@
 */
 
 import { Constants } from './enums.js';
-import { DEBUG } from './utils.js';
+import { DEBUG, arraybuffer_to_str } from './utils.js';
 import { SpiceConn } from './spiceconn.js';
 import { SpiceMsgPortInit } from './spicemsg.js';
 
-- 
2.25.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


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

2016-10-10 Thread Oliver Gutierrez
THanks :) No problem. Just were asking :)

On Mon, Oct 10, 2016 at 1:55 PM, Pavel Grunt <pgr...@redhat.com> wrote:

> On Mon, 2016-10-10 at 13:14 +0200, Oliver Gutierrez wrote:
> > This patch has not been pushed yet. Is there any problem?
>
> Sorry for the delay Oliver
> It is pushed
> Pavel
>
>
> > On Wed, Oct 5, 2016 at 8:06 AM, Pavel Grunt <pgr...@redhat.com>
> > wrote:
> > > Hi Oliver,
> > >
> > > it looks good to me :)
> > >
> > > Acked-by: Pavel Grunt <pgr...@redhat.com>
> > >
> > > Thanks,
> > > Pavel
> > >
> > > On Mon, 2016-10-03 at 14:09 +0200, Oliver Gutierrez wrote:
> > > > ---
> > > >  enums.js|  9 ++
> > > >  main.js |  3 ++
> > > >  port.js | 85
> > > > +
> > > >  spice.html  | 13 +
> > > >  spice_auto.html | 13 +
> > > >  spicemsg.js | 18 
> > > >  utils.js|  7 +
> > > >  7 files changed, 148 insertions(+)
> > > >  create mode 100644 port.js
> > > >
> > > > 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/port.js b/port.js
> > > > new file mode 100644
> > > > index 000..ee22073
> > > > --- /dev/null
> > > > +++ b/port.js
> > > > @@ -0,0 +1,85 @@
> > > > +"use strict";
> > > > +/*
> > > > +   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
> > > > + Miroslav Chodil <mcho...@redhat.com>
> > > > +
> > > > +   This file is part of spice-html5.
> > > > +
> > > > +   spice-html5 is free software: you can redistribute it and/or
> > > > modify
> > > > +   it under the terms of the GNU Lesser General Public License
> > > as
> > > > published by
> > > > +   the Free Software Foundation, either version 3 of the
> > > License,
> > > > or
> > > > +   (at your option) any later version.
> > > > +
> > > > +   spice-html5 is distributed in the hope that it will be
> > > useful,
> > > > +   but WITHOUT ANY WARRAN

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

2016-10-10 Thread Oliver Gutierrez
This patch has not been pushed yet. Is there any problem?

On Wed, Oct 5, 2016 at 8:06 AM, Pavel Grunt <pgr...@redhat.com> wrote:

> Hi Oliver,
>
> it looks good to me :)
>
> Acked-by: Pavel Grunt <pgr...@redhat.com>
>
> Thanks,
> Pavel
>
> On Mon, 2016-10-03 at 14:09 +0200, Oliver Gutierrez wrote:
> > ---
> >  enums.js|  9 ++
> >  main.js |  3 ++
> >  port.js | 85
> > +
> >  spice.html  | 13 +
> >  spice_auto.html | 13 +
> >  spicemsg.js | 18 
> >  utils.js|  7 +
> >  7 files changed, 148 insertions(+)
> >  create mode 100644 port.js
> >
> > 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/port.js b/port.js
> > new file mode 100644
> > index 000..ee22073
> > --- /dev/null
> > +++ b/port.js
> > @@ -0,0 +1,85 @@
> > +"use strict";
> > +/*
> > +   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
> > + Miroslav Chodil <mcho...@redhat.com>
> > +
> > +   This file is part of spice-html5.
> > +
> > +   spice-html5 is free software: you can redistribute it and/or
> > modify
> > +   it under the terms of the GNU Lesser General Public License as
> > published by
> > +   the Free Software Foundation, either version 3 of the License,
> > or
> > +   (at your option) any later version.
> > +
> > +   spice-html5 is distributed in the hope that it will be useful,
> > +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > +   GNU Lesser General Public License for more details.
> > +
> > +   You should have received a copy of the GNU Lesser General Public
> > License
> > +   along with spice-html5.  If not, see <http://www.gnu.org/license
> > s/>.
> > +*/
> > +
> > +/*-
> > ---
> > +**  SpicePortConn
> > +**  Drive the Spice Port Channel
> > +**-
> > -*/
> > +function SpicePortConn()
> > +{
> > +DEBUG > 0 && console.log('SPICE port: created SPICE port
> > channel. Args:', arguments);
> > +SpiceConn.apply(this, arguments);
> > +this.port_name = null;
> > +}
> > +
> > +SpicePortConn.prototype = Object.create(SpiceConn.prototype);
> > +
> > +SpicePortConn.prototype.process_channel_message = function(msg)
> > +{
> > +if (msg.type == SPICE_MSG_PORT_INIT)
> > +{
> > +if (this.port_name === null)
> &

Re: [Spice-devel] [spice-html5 audio 0/4] Audio tuneup patch set

2016-10-03 Thread Oliver Gutierrez
I've tested both this patch series and the video ones.

In Firefox works without any problems. In Chrome I have no audio at all,
but I do not have it also with master.

Cheers

On Mon, Oct 3, 2016 at 10:21 AM, Pavel Grunt <pgr...@redhat.com> wrote:

> Hi,
>
> looks good to me, ACK
>
> Pavel
>
> On Wed, 2016-09-28 at 15:25 -0500, Jeremy White wrote:
> > Firefox and Chrome have both drifted somewhat over the past
> > few years, and audio playback is no longer as robust in spice-html5
> > as it once was.
> >
> > Further, the MediaSource specification is a bit more stable than
> > it was when the initial implementation was written.
> >
> > This patch set tunes the spice-html5 implementation to play back
> > sound effectively in both Chrome 53 and Firefox 45.
> >
> > Jeremy White (4):
> >   Use modern brower information to detect underrun.
>typo ^
> >   Revise sound packet time sequencing for a more recent Firefox.
> >   Rely on the auto play attribute.
> >   Implement support for the playback stop message.
> >
> >  playback.js | 82 
> > -
> >  webm.js |  1 +
> >  2 files changed, 50 insertions(+), 33 deletions(-)
> >
> >
> _______
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
>



-- 
Oliver Gutierrez
Associate Software Engineer - Desktop Management tools
Red Hat
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


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

2016-10-03 Thread Oliver Gutierrez
OMG. THe patch attached to same thread. Now is Ok

On Mon, Oct 3, 2016 at 2:10 PM, Oliver Gutierrez <ogutier...@redhat.com>
wrote:

> Forget this one. Missing one file.
>
> On Mon, Oct 3, 2016 at 2:02 PM, Oliver Gutierrez <ogutier...@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 @@
>>  
>>  
>>  
>> +
>>  
>>  
>>  
>> @@ -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);
>> +});
>> +*/
>> +
>>  
>>
>>  
>> 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 @@
>>  
>>  
>>  
>> +
>>  
>>  
>>  
>> @@ -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);

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

2016-10-03 Thread Oliver Gutierrez
Forget this one. Missing one file.

On Mon, Oct 3, 2016 at 2:02 PM, Oliver Gutierrez <ogutier...@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 @@
>  
>  
>  
> +
>  
>  
>  
> @@ -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);
> +});
> +*/
> +
>  
>
>  
> 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 @@
>  
>  
>  
> +
>  
>  
>  
> @@ -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();
>  
>
> 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.getU

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

2016-10-03 Thread Oliver Gutierrez
---
 enums.js|  9 ++
 main.js |  3 ++
 port.js | 85 +
 spice.html  | 13 +
 spice_auto.html | 13 +
 spicemsg.js | 18 
 utils.js|  7 +
 7 files changed, 148 insertions(+)
 create mode 100644 port.js

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/port.js b/port.js
new file mode 100644
index 000..ee22073
--- /dev/null
+++ b/port.js
@@ -0,0 +1,85 @@
+"use strict";
+/*
+   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
+ Miroslav Chodil <mcho...@redhat.com>
+
+   This file is part of spice-html5.
+
+   spice-html5 is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   spice-html5 is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with spice-html5.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+**  SpicePortConn
+**  Drive the Spice Port Channel
+**--*/
+function SpicePortConn()
+{
+DEBUG > 0 && console.log('SPICE port: created SPICE port channel. Args:', 
arguments);
+SpiceConn.apply(this, arguments);
+this.port_name = null;
+}
+
+SpicePortConn.prototype = Object.create(SpiceConn.prototype);
+
+SpicePortConn.prototype.process_channel_message = function(msg)
+{
+if (msg.type == SPICE_MSG_PORT_INIT)
+{
+if (this.port_name === null)
+{
+var m = new SpiceMsgPortInit(msg.data);
+this.portName = arraybuffer_to_str(new Uint8Array(m.name));
+this.portOpened = m.opened
+DEBUG > 0 && console.log('SPICE port: Port', this.portName, 
'initialized');
+return true;
+}
+
+DEBUG > 0 && console.log('SPICE port: Port', this.port_name, 'is 
already initialized.');
+}
+else if (msg.type == SPICE_MSG_PORT_EVENT)
+{
+DEBUG > 0 && console.log('SPICE port: Port event received for', 
this.portName, msg);
+var event = new CustomEvent('spice-port-event', {
+detail: {
+channel: this,
+spiceEvent: new Uint8Array(msg.data)
+},
+bubbles: true,
+cancelable: true
+});
+
+window.dispatchEvent(event);
+return true;
+}
+else if (msg.type == SPICE_MSG_SPICEVMC_DATA)
+{
+DEBUG > 0 && console.log('SPICE port: Data received in port', 
this.portName, msg);
+var event = new CustomEvent('spice-port-data', {
+detail: {
+channel: this,
+data: msg.data
+},
+bubbles: true,
+cancelable: true
+});
+window.dispatchEvent(event);
+return true;
+}
+else
+{
+DEBUG > 0 && console.log('SPICE po

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

2016-10-03 Thread Oliver Gutierrez
---
 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 @@
 
 
 
+
 
 
 
@@ -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);
+});
+*/
+
 
 
 
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 @@
 
 
 
+
 
 
 
@@ -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();
 
 
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
 

Re: [Spice-devel] [PATCH 2/2] SPICE port basic implementation

2016-10-03 Thread Oliver Gutierrez
Hi Pavel,

The Uint8Array is an event. i don't know if there are more events than port
opened or port closed. The value 0 is sent when the port device file is
opened in the VM side and the 1 is sent when in the VM side you close
device file, so I left it as is because I don't know if there are other
possible events that can be handled by the user.

About the format for the data arriving in the port you're right. We can
leave it "as-is".

I will change the console messages for printing just the events and that we
received data to avoid browser locking. Also will add a DEBUG > 0 && for
showing them only when debugging.

Finally I will put the code as a coment then. :)

Thanks. Will send the last commit again in a few.

Cheers!

On Fri, Sep 30, 2016 at 10:51 AM, Pavel Grunt <pgr...@redhat.com> wrote:

> Hi Oliver,
>
> I tested it (in FF) and it works nicely, I just have minor comments:
> in the console:
> SPICE port com.spice.fc.1 event data: Uint8Array { 0=0}
> SPICE port com.spice.fc.1 message text: CHILI
> SPICE port com.spice.fc.1 event data: Uint8Array { 0=1}
>
> 1) what is the Uint8Array - it has just one value (port opened ?), a
> boolean could be more clear
>
> 2) there is no guarantee that data are text, i think it would be
> better to have it as Uint8Array
>
> 3) not sure if it is a good idea to print to console by default,
> consider someone does:
> dd=if=/dev/urandom of=/dev/virtio-ports/port ...
> it could block the browser
>
>
> The code handling the event in the html files could be just an comment
> (to server as an example for somebody implementing something on top of
> the port channel)
>
> Thanks for the contribution,
> Pavel
>
>
> On Thu, 2016-09-29 at 08:59 +0200, Oliver Gutierrez wrote:
> > Here is an small guide to test this for the ones that want to check
> > it faster:
> >
> > Add a spiceport to a virtual machine adding this under devices in
> > the XML
> >
> > 
> >   
> >> name='org.freedesktop.FleetCommander.0'/>
> >> port='2'/>
> > 
> >
> >
> > Boot machine, Connect to it as usual using spice-html5 and as root:
> >
> > echo "CHILI" > /dev/virtio-ports/org.freedesktop.FleetCommander.0
> >
> > In the browser console yo sould see the events for opening the port,
> > the message and the port closing.
> >
> > If in a week or so there is no other feedback then I will contact
> > you Jeremy.
> >
> > Thanks and cheers!
> >
> > On Wed, Sep 28, 2016 at 10:10 PM, Jeremy White <jwhite@codeweavers.c
> > om> wrote:
> > > Looks good to me.  I don't have the time to test this myself, so
> > > I'll
> > > leave this open for others to kibitz for now.
> > >
> > > I don't think it will do harm, so if no one else expresses an
> > > opinion
> > > after a while, you can probably nudge me into pushing it.
> > >
> > > Reviewed-by: Jeremy White <jwh...@codeweavers.com>
> > >
> > > Cheers,
> > >
> > > Jeremy
> > >
> > > On 09/27/2016 10:29 AM, Oliver Gutierrez wrote:
> > > > ---
> > > >  enums.js|  9 ++
> > > >  main.js |  3 ++
> > > >  port.js | 85
> > > +
> > > >  spice.html  | 10 +++
> > > >  spice_auto.html | 10 +++
> > > >  spicemsg.js | 18 
> > > >  utils.js|  7 +
> > > >  7 files changed, 142 insertions(+)
> > > >  create mode 100644 port.js
> > > >
> > > > 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 SP

Re: [Spice-devel] [PATCH 2/2] SPICE port basic implementation

2016-09-29 Thread Oliver Gutierrez
Here is an small guide to test this for the ones that want to check it
faster:

Add a spiceport to a virtual machine adding this under devices in the XML


  
  
  



Boot machine, Connect to it as usual using spice-html5 and as root:

echo "CHILI" > /dev/virtio-ports/org.freedesktop.FleetCommander.0

In the browser console yo sould see the events for opening the port, the
message and the port closing.

If in a week or so there is no other feedback then I will contact you
Jeremy.

Thanks and cheers!

On Wed, Sep 28, 2016 at 10:10 PM, Jeremy White <jwh...@codeweavers.com>
wrote:

> Looks good to me.  I don't have the time to test this myself, so I'll
> leave this open for others to kibitz for now.
>
> I don't think it will do harm, so if no one else expresses an opinion
> after a while, you can probably nudge me into pushing it.
>
> Reviewed-by: Jeremy White <jwh...@codeweavers.com>
>
> Cheers,
>
> Jeremy
>
> On 09/27/2016 10:29 AM, Oliver Gutierrez wrote:
> > ---
> >  enums.js|  9 ++
> >  main.js |  3 ++
> >  port.js | 85 ++
> +++
> >  spice.html  | 10 +++
> >  spice_auto.html | 10 +++
> >  spicemsg.js | 18 
> >  utils.js|  7 +
> >  7 files changed, 142 insertions(+)
> >  create mode 100644 port.js
> >
> > 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/port.js b/port.js
> > new file mode 100644
> > index 000..ee22073
> > --- /dev/null
> > +++ b/port.js
> > @@ -0,0 +1,85 @@
> > +"use strict";
> > +/*
> > +   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
> > + Miroslav Chodil <mcho...@redhat.com>
> > +
> > +   This file is part of spice-html5.
> > +
> > +   spice-html5 is free software: you can redistribute it and/or modify
> > +   it under the terms of the GNU Lesser General Public License as
> published by
> > +   the Free Software Foundation, either version 3 of the License, or
> > +   (at your option) any later version.
> > +
> > +   spice-html5 is distributed in the hope that it will be useful,
> > +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > +   GNU Lesser General Public License for more details.
> > +
> > +   You should have received a copy of the GNU Lesser General Public
> License
> > +   along with spice-html5.  If not, see <http://www.gnu.org/licenses/>.
> > +*/
> > +
> > +/*-
> ---
> > +**  SpicePortConn
> > +**  Drive the Spice Port Channel
> > +**-

[Spice-devel] [PATCH 1/2] Fixed trailing whitespaces in several files

2016-09-27 Thread Oliver Gutierrez
---
 README  |  4 ++--
 TODO|  2 +-
 cursor.js   |  2 +-
 display.js  | 36 ++--
 enums.js|  2 +-
 main.js |  2 +-
 playback.js |  2 +-
 simulatecursor.js   |  6 +++---
 spice.css   |  1 -
 spice.html  | 40 
 spice_auto.html |  2 +-
 spicedataview.js|  8 
 spicemsg.js |  6 +++---
 spicetype.js|  2 +-
 thirdparty/jsbn.js  |  6 +++---
 thirdparty/prng4.js |  6 +++---
 thirdparty/rng.js   |  8 
 thirdparty/rsa.js   |  6 +++---
 wire.js |  2 +-
 19 files changed, 71 insertions(+), 72 deletions(-)

diff --git a/README b/README
index 89d3747..6443000 100644
--- a/README
+++ b/README
@@ -5,7 +5,7 @@ Instructions and status as of August, 2016.
 Requirements:
 
   1.  Modern Firefox or Chrome (IE will work, but badly)
-  
+
   2.  A WebSocket proxy
 
   websockify:
@@ -24,7 +24,7 @@ Optional:
 
   With firefox, you can just open file:///your-path-to-spice.html-here
 
-  With Chrome, you have to set a secret config flag to do that, or 
+  With Chrome, you have to set a secret config flag to do that, or
   serve the files from a web server.
 
 
diff --git a/TODO b/TODO
index 4d4b115..64fc326 100644
--- a/TODO
+++ b/TODO
@@ -6,7 +6,7 @@ Medium Tasks:
 *only* about messages)
 
   . Change the message processing to be able to handle
-an array of ArrayBuffers so we don't have to 
+an array of ArrayBuffers so we don't have to
 use the combine function, which is presumed slow.
 
   . Use the 'real' DataView if we have it
diff --git a/cursor.js b/cursor.js
index 296fbde..d3f4d55 100644
--- a/cursor.js
+++ b/cursor.js
@@ -118,7 +118,7 @@ SpiceCursorConn.prototype.process_channel_message = 
function(msg)
 SpiceCursorConn.prototype.set_cursor = function(cursor)
 {
 var pngstr = create_rgba_png(cursor.header.height, cursor.header.width, 
cursor.data);
-var curstr = 'url(data:image/png,' + pngstr + ') ' + 
+var curstr = 'url(data:image/png,' + pngstr + ') ' +
 cursor.header.hot_spot_x + ' ' + cursor.header.hot_spot_y + ", 
default";
 var screen = document.getElementById(this.parent.screen_id);
 screen.style.cursor = 'auto';
diff --git a/display.js b/display.js
index 12fbab0..d8239c2 100644
--- a/display.js
+++ b/display.js
@@ -142,7 +142,7 @@ SpiceDisplayConn.prototype.process_channel_message = 
function(msg)
 { base: draw_copy.base,
   src_area: draw_copy.data.src_area,
   image_data: 
this.cache[draw_copy.data.src_bitmap.descriptor.id],
-  tag: "copycache." + 
draw_copy.data.src_bitmap.descriptor.id, 
+  tag: "copycache." + 
draw_copy.data.src_bitmap.descriptor.id,
   has_alpha: true, /* FIXME - may want this to be false... 
*/
   descriptor : draw_copy.data.src_bitmap.descriptor
 });
@@ -200,7 +200,7 @@ SpiceDisplayConn.prototype.process_channel_message = 
function(msg)
 tmpstr += qdv[i].toString(16);
 }
 
-img.o = 
+img.o =
 { base: draw_copy.base,
   tag: "jpeg." + draw_copy.data.src_bitmap.surface_id,
   descriptor : draw_copy.data.src_bitmap.descriptor,
@@ -233,7 +233,7 @@ SpiceDisplayConn.prototype.process_channel_message = 
function(msg)
 tmpstr += qdv[i].toString(16);
 }
 
-img.o = 
+img.o =
 { base: draw_copy.base,
   tag: "jpeg." + draw_copy.data.src_bitmap.surface_id,
   descriptor : draw_copy.data.src_bitmap.descriptor,
@@ -265,7 +265,7 @@ SpiceDisplayConn.prototype.process_channel_message = 
function(msg)
 draw_copy.data.src_bitmap.bitmap);
 if (! source_img)
 {
-this.log_warn("FIXME: Unable to interpret bitmap of 
format: " + 
+this.log_warn("FIXME: Unable to interpret bitmap of 
format: " +
 draw_copy.data.src_bitmap.bitmap.format);
 return false;
 }
@@ -295,7 +295,7 @@ SpiceDisplayConn.prototype.process_channel_message = 
function(msg)
 draw_copy.data.src_bitmap.lz_rgb);
 if (! source_img)
 {
-this.log_warn("FIXME: Unable to interpret bitmap of type: 
" + 
+this.log_warn("FIXME: Unable to interpret bitmap of type: 
" +
 draw_copy.data.src_bitmap.lz_rgb.type);
 return false;
 }
@@ -359,7 +359,7 @@ SpiceDisplayConn.prototype.process_channel_message = 
function(msg)
 

[Spice-devel] [PATCH 2/2] SPICE port basic implementation

2016-09-27 Thread Oliver Gutierrez
---
 enums.js|  9 ++
 main.js |  3 ++
 port.js | 85 +
 spice.html  | 10 +++
 spice_auto.html | 10 +++
 spicemsg.js | 18 
 utils.js|  7 +
 7 files changed, 142 insertions(+)
 create mode 100644 port.js

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/port.js b/port.js
new file mode 100644
index 000..ee22073
--- /dev/null
+++ b/port.js
@@ -0,0 +1,85 @@
+"use strict";
+/*
+   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
+ Miroslav Chodil <mcho...@redhat.com>
+
+   This file is part of spice-html5.
+
+   spice-html5 is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   spice-html5 is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with spice-html5.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+**  SpicePortConn
+**  Drive the Spice Port Channel
+**--*/
+function SpicePortConn()
+{
+DEBUG > 0 && console.log('SPICE port: created SPICE port channel. Args:', 
arguments);
+SpiceConn.apply(this, arguments);
+this.port_name = null;
+}
+
+SpicePortConn.prototype = Object.create(SpiceConn.prototype);
+
+SpicePortConn.prototype.process_channel_message = function(msg)
+{
+if (msg.type == SPICE_MSG_PORT_INIT)
+{
+if (this.port_name === null)
+{
+var m = new SpiceMsgPortInit(msg.data);
+this.portName = arraybuffer_to_str(new Uint8Array(m.name));
+this.portOpened = m.opened
+DEBUG > 0 && console.log('SPICE port: Port', this.portName, 
'initialized');
+return true;
+}
+
+DEBUG > 0 && console.log('SPICE port: Port', this.port_name, 'is 
already initialized.');
+}
+else if (msg.type == SPICE_MSG_PORT_EVENT)
+{
+DEBUG > 0 && console.log('SPICE port: Port event received for', 
this.portName, msg);
+var event = new CustomEvent('spice-port-event', {
+detail: {
+channel: this,
+spiceEvent: new Uint8Array(msg.data)
+},
+bubbles: true,
+cancelable: true
+});
+
+window.dispatchEvent(event);
+return true;
+}
+else if (msg.type == SPICE_MSG_SPICEVMC_DATA)
+{
+DEBUG > 0 && console.log('SPICE port: Data received in port', 
this.portName, msg);
+var event = new CustomEvent('spice-port-data', {
+detail: {
+channel: this,
+data: msg.data
+},
+bubbles: true,
+cancelable: true
+});
+window.dispatchEvent(event);
+return true;
+}
+else
+{
+DEBUG > 0 && console.log('SPICE po

Re: [Spice-devel] [PATCH] SPICE port basic implementation

2016-09-27 Thread Oliver Gutierrez
Ok. Sending.

On Mon, Sep 26, 2016 at 2:54 PM, Frediano Ziglio <fzig...@redhat.com> wrote:

> >
> > ---
> >  enums.js| 11 +++-
> >  main.js |  5 +++-
> >  port.js | 85
> >  +
> >  spice.html  | 50 +++--
> >  spice_auto.html | 12 +++-
> >  spicemsg.js | 24 ++--
> >  utils.js|  7 +
> >  7 files changed, 168 insertions(+), 26 deletions(-)
> >  create mode 100644 port.js
> >
> > diff --git a/enums.js b/enums.js
> > index 3ef36dc..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;
> > @@ -264,7 +273,7 @@ var SPICE_MOUSE_BUTTON_MASK_LEFT = (1 << 0),
> >  SPICE_MOUSE_BUTTON_MASK_MIDDLE = (1 << 1),
> >  SPICE_MOUSE_BUTTON_MASK_RIGHT = (1 << 2),
> >  SPICE_MOUSE_BUTTON_MASK_MASK = 0x7;
> > -
> > +
> >  var SPICE_MOUSE_BUTTON_INVALID  = 0;
> >  var SPICE_MOUSE_BUTTON_LEFT = 1;
> >  var SPICE_MOUSE_BUTTON_MIDDLE   = 2;
>
> Could you split the styles/spaces changes into a separate patch ?
>
> Frediano
>



-- 
Oliver Gutierrez
Associate Software Engineer - Desktop Management tools
Red Hat
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] SPICE port basic implementation

2016-09-26 Thread Oliver Gutierrez
I finally put all in the same patch with the Textdecoder part removed. Just
added an utility function to do that in utils.js


On Mon, Sep 26, 2016 at 1:02 PM, Oliver Gutierrez <ogutier...@redhat.com>
wrote:

> ---
>  enums.js| 11 +++-
>  main.js |  5 +++-
>  port.js | 85 ++
> +++
>  spice.html  | 50 +++--
>  spice_auto.html | 12 +++-
>  spicemsg.js | 24 ++--
>  utils.js|  7 +
>  7 files changed, 168 insertions(+), 26 deletions(-)
>  create mode 100644 port.js
>
> diff --git a/enums.js b/enums.js
> index 3ef36dc..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;
> @@ -264,7 +273,7 @@ var SPICE_MOUSE_BUTTON_MASK_LEFT = (1 << 0),
>  SPICE_MOUSE_BUTTON_MASK_MIDDLE = (1 << 1),
>  SPICE_MOUSE_BUTTON_MASK_RIGHT = (1 << 2),
>  SPICE_MOUSE_BUTTON_MASK_MASK = 0x7;
> -
> +
>  var SPICE_MOUSE_BUTTON_INVALID  = 0;
>  var SPICE_MOUSE_BUTTON_LEFT = 1;
>  var SPICE_MOUSE_BUTTON_MIDDLE   = 2;
> diff --git a/main.js b/main.js
> index afe69bf..2d8a1ff 100644
> --- a/main.js
> +++ b/main.js
> @@ -22,7 +22,7 @@
>  **  SpiceMainConn
>  **  This is the master Javascript class for establishing and
>  **  managing a connection to a Spice Server.
> -**
> +**
>  **  Invocation:  You must pass an object with properties as follows:
>  **  uri (required)  Uri of a WebSocket listener that is
>  **  connected to a spice server.
> @@ -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/port.js b/port.js
> new file mode 100644
> index 000..ee22073
> --- /dev/null
> +++ b/port.js
> @@ -0,0 +1,85 @@
> +"use strict";
> +/*
> +   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
> + Miroslav Chodil <mcho...@redhat.com>
> +
> +   This file is part of spice-html5.
> +
> +   spice-html5 is free software: you can redistribute it and/or modify
> +   it under the terms of the GNU Lesser General Public License as
> published by
> +   the Free Software Foundation, either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   spice-html5 is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> License
> +   along with spice-html5.  If not, see <http://www.gnu.org/licenses/>.
> +*/
> +
> +/*-
> ---
> +**  SpicePortConn
> +**  Drive the Spice Port Channel
> +**-
> -*/
> +function SpicePortConn()
> +{
> +DEBUG > 0 && console.log('SPICE port: created SPICE port channel.
> Args:', arguments);
> +SpiceConn.apply(this, arguments);
> +this.port_name = null;
> +}
> +
> +SpicePortConn.prototype = Object.create(SpiceConn.prototype);
> +
> +SpicePortConn.prototype.process_channel

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

2016-09-26 Thread Oliver Gutierrez
---
 enums.js| 11 +++-
 main.js |  5 +++-
 port.js | 85 +
 spice.html  | 50 +++--
 spice_auto.html | 12 +++-
 spicemsg.js | 24 ++--
 utils.js|  7 +
 7 files changed, 168 insertions(+), 26 deletions(-)
 create mode 100644 port.js

diff --git a/enums.js b/enums.js
index 3ef36dc..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;
@@ -264,7 +273,7 @@ var SPICE_MOUSE_BUTTON_MASK_LEFT = (1 << 0),
 SPICE_MOUSE_BUTTON_MASK_MIDDLE = (1 << 1),
 SPICE_MOUSE_BUTTON_MASK_RIGHT = (1 << 2),
 SPICE_MOUSE_BUTTON_MASK_MASK = 0x7;
-
+
 var SPICE_MOUSE_BUTTON_INVALID  = 0;
 var SPICE_MOUSE_BUTTON_LEFT = 1;
 var SPICE_MOUSE_BUTTON_MIDDLE   = 2;
diff --git a/main.js b/main.js
index afe69bf..2d8a1ff 100644
--- a/main.js
+++ b/main.js
@@ -22,7 +22,7 @@
 **  SpiceMainConn
 **  This is the master Javascript class for establishing and
 **  managing a connection to a Spice Server.
-**  
+**
 **  Invocation:  You must pass an object with properties as follows:
 **  uri (required)  Uri of a WebSocket listener that is
 **  connected to a spice server.
@@ -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/port.js b/port.js
new file mode 100644
index 000..ee22073
--- /dev/null
+++ b/port.js
@@ -0,0 +1,85 @@
+"use strict";
+/*
+   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
+ Miroslav Chodil <mcho...@redhat.com>
+
+   This file is part of spice-html5.
+
+   spice-html5 is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   spice-html5 is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with spice-html5.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+**  SpicePortConn
+**  Drive the Spice Port Channel
+**--*/
+function SpicePortConn()
+{
+DEBUG > 0 && console.log('SPICE port: created SPICE port channel. Args:', 
arguments);
+SpiceConn.apply(this, arguments);
+this.port_name = null;
+}
+
+SpicePortConn.prototype = Object.create(SpiceConn.prototype);
+
+SpicePortConn.prototype.process_channel_message = function(msg)
+{
+if (msg.type == SPICE_MSG_PORT_INIT)
+{
+if (this.port_name === null)
+{
+var m = new SpiceMsgPortInit(msg.data);
+this.portName = arraybuffer_to_str(new Uint8Array(m.name));
+this.portOpened = m.opened
+DEBUG > 0 && console.log('SPICE port: Port', this.portName, 
'initialized');
+return true;
+}
+
+DEBUG > 0 && console.log('SPICE port: Port', this.port_name, 'is 
already initialized.');
+}
+else if (msg.type == SPICE_MSG_PORT_EVENT)
+{
+DEBUG > 0 && console.log('SPICE port: Port event received for', 
this.portName, msg);
+var event = new CustomEvent('spice-port-event', {
+  

[Spice-devel] [PATCH 3/3] Updated example files with SPICE port event listeners

2016-09-20 Thread Oliver Gutierrez
---
 spice.html  | 10 ++
 spice_auto.html | 10 ++
 2 files changed, 20 insertions(+)

diff --git a/spice.html b/spice.html
index c473678..f9a91c0 100644
--- a/spice.html
+++ b/spice.html
@@ -42,6 +42,7 @@
 
 
 
+
 
 
 
@@ -142,6 +143,15 @@
 }
 }
 
+window.addEventListener('spice-port-data', function(event) {
+var msg_text = new TextDecoder('utf-8').decode(new 
Uint8Array(event.detail.data));
+console.log('SPICE port', event.detail.channel.portName, 
'message text:', msg_text);
+});
+
+window.addEventListener('spice-port-event', function(event) {
+console.log('SPICE port', event.detail.channel.portName, 
'event data:', event.detail.spiceEvent);
+});
+
 
 
 
diff --git a/spice_auto.html b/spice_auto.html
index 1179ebe..48a6bda 100644
--- a/spice_auto.html
+++ b/spice_auto.html
@@ -42,6 +42,7 @@
 
 
 
+
 
 
 
@@ -182,6 +183,15 @@
 }
 }
 
+window.addEventListener('spice-port-data', function(event) {
+var msg_text = new TextDecoder('utf-8').decode(new 
Uint8Array(event.detail.data));
+console.log('SPICE port', event.detail.channel.portName, 
'message text:', msg_text);
+});
+
+window.addEventListener('spice-port-event', function(event) {
+console.log('SPICE port', event.detail.channel.portName, 
'event data:', event.detail.spiceEvent);
+});
+
 connect();
 
 
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH 1/3] Cleaning of trailing whitespaces

2016-09-20 Thread Oliver Gutierrez
---
 enums.js|  2 +-
 main.js |  2 +-
 spice.html  | 40 
 spice_auto.html |  2 +-
 spicemsg.js |  6 +++---
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/enums.js b/enums.js
index 3ef36dc..301fea0 100644
--- a/enums.js
+++ b/enums.js
@@ -264,7 +264,7 @@ var SPICE_MOUSE_BUTTON_MASK_LEFT = (1 << 0),
 SPICE_MOUSE_BUTTON_MASK_MIDDLE = (1 << 1),
 SPICE_MOUSE_BUTTON_MASK_RIGHT = (1 << 2),
 SPICE_MOUSE_BUTTON_MASK_MASK = 0x7;
-
+
 var SPICE_MOUSE_BUTTON_INVALID  = 0;
 var SPICE_MOUSE_BUTTON_LEFT = 1;
 var SPICE_MOUSE_BUTTON_MIDDLE   = 2;
diff --git a/main.js b/main.js
index afe69bf..874a038 100644
--- a/main.js
+++ b/main.js
@@ -22,7 +22,7 @@
 **  SpiceMainConn
 **  This is the master Javascript class for establishing and
 **  managing a connection to a Spice Server.
-**  
+**
 **  Invocation:  You must pass an object with properties as follows:
 **  uri (required)  Uri of a WebSocket listener that is
 **  connected to a spice server.
diff --git a/spice.html b/spice.html
index f2f9ed0..c473678 100644
--- a/spice.html
+++ b/spice.html
@@ -28,26 +28,26 @@
 
 
 Spice Javascript client
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 
- 
+
 
 
 
@@ -71,8 +71,8 @@
 {
 var host, port, password, scheme = "ws://", uri;
 
-host = document.getElementById("host").value; 
-port = document.getElementById("port").value; 
+host = document.getElementById("host").value;
+port = document.getElementById("port").value;
 password = document.getElementById("password").value;
 
 
@@ -92,7 +92,7 @@
 
 try
 {
-sc = new SpiceMainConn({uri: uri, screen_id: 
"spice-screen", dump_id: "debug-div", 
+sc = new SpiceMainConn({uri: uri, screen_id: 
"spice-screen", dump_id: "debug-div",
 message_id: "message-div", password: password, 
onerror: spice_error, onagent: agent_connected });
 }
 catch (e)
diff --git a/spice_auto.html b/spice_auto.html
index 9aae118..1179ebe 100644
--- a/spice_auto.html
+++ b/spice_auto.html
@@ -28,7 +28,7 @@
 
 
 Spice Javascript client
- 
+
 
 
 
diff --git a/spicemsg.js b/spicemsg.js
index db6625a..0321cc7 100644
--- a/spicemsg.js
+++ b/spicemsg.js
@@ -21,7 +21,7 @@
 /*
 **  Spice messages
 **  This file contains classes for passing messages to and from
-**  a spice server.  This file should arguably be generated from 
+**  a spice server.  This file should arguably be generated from
 **  spice.proto, but it was instead put together by hand.
 **--*/
 function SpiceLinkHeader(a, at)
@@ -63,7 +63,7 @@ SpiceLinkHeader.prototype =
 dv.setUint32(at, this.size, true); at += 4;
 },
 buffer_size: function()
-{ 
+{
 return 16;
 },
 }
@@ -938,7 +938,7 @@ function SpiceMsgcMousePosition(sc, e)
 this.x = e.clientX - 
sc.display.surfaces[sc.display.primary_surface].canvas.offsetLeft + scrollLeft;
 this.y = e.clientY - 
sc.display.surfaces[sc.display.primary_surface].canvas.offsetTop + scrollTop;
 sc.mousex = this.x;
-sc.mousey = this.y; 
+sc.mousey = this.y;
 }
 else
 {
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH 2/3] SPICE port implementation

2016-09-20 Thread Oliver Gutierrez
---
 enums.js|  9 +++
 main.js |  3 +++
 port.js | 85 +
 spicemsg.js | 18 +
 4 files changed, 115 insertions(+)
 create mode 100644 port.js

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/port.js b/port.js
new file mode 100644
index 000..d61ef7e
--- /dev/null
+++ b/port.js
@@ -0,0 +1,85 @@
+"use strict";
+/*
+   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
+ Miroslav Chodil <mcho...@redhat.com>
+
+   This file is part of spice-html5.
+
+   spice-html5 is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   spice-html5 is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with spice-html5.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+**  SpicePortConn
+**  Drive the Spice Port Channel
+**--*/
+function SpicePortConn()
+{
+DEBUG > 0 && console.log('SPICE port: created SPICE port channel. Args:', 
arguments);
+SpiceConn.apply(this, arguments);
+this.port_name = null;
+}
+
+SpicePortConn.prototype = Object.create(SpiceConn.prototype);
+
+SpicePortConn.prototype.process_channel_message = function(msg)
+{
+if (msg.type == SPICE_MSG_PORT_INIT)
+{
+if (this.port_name === null)
+{
+var m = new SpiceMsgPortInit(msg.data);
+this.portName = new TextDecoder('utf-8').decode(new 
Uint8Array(m.name));
+this.portOpened = m.opened
+DEBUG > 0 && console.log('SPICE port: Port', this.portName, 
'initialized');
+return true;
+}
+
+DEBUG > 0 && console.log('SPICE port: Port', this.port_name, 'is 
already initialized.');
+}
+else if (msg.type == SPICE_MSG_PORT_EVENT)
+{
+DEBUG > 0 && console.log('SPICE port: Port event received for', 
this.portName, msg);
+var event = new CustomEvent('spice-port-event', {
+detail: {
+channel: this,
+spiceEvent: new Uint8Array(msg.data)
+},
+bubbles: true,
+cancelable: true
+});
+
+window.dispatchEvent(event);
+return true;
+}
+else if (msg.type == SPICE_MSG_SPICEVMC_DATA)
+{
+DEBUG > 0 && console.log('SPICE port: Data received in port', 
this.portName, msg);
+var event = new CustomEvent('spice-port-data', {
+detail: {
+channel: this,
+data: msg.data
+},
+bubbles: true,
+cancelable: true
+});
+window.dispatchEvent(event);
+return true;
+}
+else
+{
+DEBUG > 0 && console.log('SPICE port: SPICE message type not 
recognized:', msg)
+}
+
+return false;
+};
diff --git 

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

2016-09-12 Thread Oliver Gutierrez
---
 enums.js|  11 -
 main.js |   7 +++-
 port.js | 125 
 spice.html  |   1 +
 spice_auto.html |   3 +-
 5 files changed, 143 insertions(+), 4 deletions(-)
 create mode 100644 port.js

diff --git a/enums.js b/enums.js
index 3ef36dc..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;
@@ -264,7 +273,7 @@ var SPICE_MOUSE_BUTTON_MASK_LEFT = (1 << 0),
 SPICE_MOUSE_BUTTON_MASK_MIDDLE = (1 << 1),
 SPICE_MOUSE_BUTTON_MASK_RIGHT = (1 << 2),
 SPICE_MOUSE_BUTTON_MASK_MASK = 0x7;
-
+
 var SPICE_MOUSE_BUTTON_INVALID  = 0;
 var SPICE_MOUSE_BUTTON_LEFT = 1;
 var SPICE_MOUSE_BUTTON_MIDDLE   = 2;
diff --git a/main.js b/main.js
index afe69bf..ba5a737 100644
--- a/main.js
+++ b/main.js
@@ -22,7 +22,7 @@
 **  SpiceMainConn
 **  This is the master Javascript class for establishing and
 **  managing a connection to a Spice Server.
-**  
+**
 **  Invocation:  You must pass an object with properties as follows:
 **  uri (required)  Uri of a WebSocket listener that is
 **  connected to a spice server.
@@ -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);
@@ -153,7 +154,9 @@ SpiceMainConn.prototype.process_channel_message = 
function(msg)
 else if (chans.channels[i].type == SPICE_CHANNEL_CURSOR)
 this.cursor = new SpiceCursorConn(conn);
 else if (chans.channels[i].type == SPICE_CHANNEL_PLAYBACK)
-this.cursor = new SpicePlaybackConn(conn);
+this.playback = 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/port.js b/port.js
new file mode 100644
index 000..2c96724
--- /dev/null
+++ b/port.js
@@ -0,0 +1,125 @@
+"use strict";
+/*
+   Copyright (C) 2016 by Oliver Gutierrez <ogut...@gmail.com>
+
+   This file is part of spice-html5.
+
+   spice-html5 is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   spice-html5 is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with spice-html5.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+**  SpiceCursorConn
+**  Drive the Spice Cursor Channel
+**--*/
+function SpicePortConn()
+{
+DEBUG > 0 && console.log(
+  'SPICE port: created SPICE port channel. Args:', arguments);
+
+SpiceConn.apply(this, arguments);
+this.port_name = null;
+}
+
+SpicePortConn.prototype = Object.create(SpiceConn.prototype);
+
+SpicePortConn.prototype.process_channel_message = function(msg)
+{
+  if (msg.type == SPICE_MSG_PORT_INIT)
+  {
+if (this.port_name === null) {
+  var m = new SpiceMsgPortInit(msg.data);
+  this.portName = new TextDecoder('utf-8').decode(new Uint8Array(m.name));
+  this.portOpened = m.opened
+
+  DEBUG > 0 && console.log(
+'SPICE port: Port', this.portName, 'initialized');
+
+  return true;
+}
+
+DEBUG > 0 && console.log(
+  'SPICE port: Port', this.port_name, 'is already initialized.');
+  }
+  else if (msg.type == SPICE_MSG_PORT_EVENT)
+  {
+DEBUG > 0 && console.log(
+  'SPICE port: Port event received for', this.portName, msg);
+
+var event = new CustomEvent("spice-port-event", {
+   detail: {
+channel: this,
+

[Spice-devel] RFC - SPICE port draft implementation

2016-09-12 Thread Oliver Gutierrez

This is a fist draft of the SPICE port feature in spice-html5

There is only support for receiving messages right now.

The port-event and port-data callbacks are set just like other javascript event 
listeners in the window object (Maybe we can move this to the main channel)

Also we need to move code chunks to places its intended to be (remove the 
examples of event listeners, moving the SPICE_MSG_PORT_INIT message class to 
the mesages file, etc.)

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH] Fixed syntax error in debugger command.

2016-09-08 Thread Oliver Gutierrez
Debugger is not an object or command. It is a reserved word and DEBUG > 0 && 
syntax does not work with it
---
 spiceconn.js | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/spiceconn.js b/spiceconn.js
index 010a446..796f954 100644
--- a/spiceconn.js
+++ b/spiceconn.js
@@ -189,8 +189,10 @@ SpiceConn.prototype =
 
 if (msg.type > 500)
 {
-DEBUG > 0 && alert("Something has gone very wrong; we 
think we have message of type " + msg.type);
-DEBUG > 0 && debugger;
+if (DEBUG > 0) {
+  alert("Something has gone very wrong; we think we have 
message of type " + msg.type);
+  debugger;
+}
 }
 
 if (msg.size == 0)
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] Fixed syntax error. Debugger is not an object or command. It is a reserved word and DEBUG > 0 && syntax does not work with it

2016-09-08 Thread Oliver Gutierrez
Ok. Thanks for the tips :D

On Thu, Sep 8, 2016 at 2:26 PM, Pavel Grunt <pgr...@redhat.com> wrote:

> Ah, I didn't realized before pushing /o\
>
> Please make the summary shorter - you can put the other sentence to
> the commit body.
>
> On Thu, 2016-09-08 at 13:21 +0200, Oliver Gutierrez wrote:
> > ---
> >  spiceconn.js | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/spiceconn.js b/spiceconn.js
> > index 010a446..796f954 100644
> > --- a/spiceconn.js
> > +++ b/spiceconn.js
> > @@ -189,8 +189,10 @@ SpiceConn.prototype =
> >
> >  if (msg.type > 500)
> >  {
> > -DEBUG > 0 && alert("Something has gone very
> > wrong; we think we have message of type " + msg.type);
> > -DEBUG > 0 && debugger;
> > +if (DEBUG > 0) {
> Please align to our brackets & indentation style
> > +  alert("Something has gone very wrong; we
> > think we have message of type " + msg.type);
> > +      debugger;
> > +}
> >  }
> >
> >  if (msg.size == 0)
> Besides that it works & looks good to me
>
> Thanks,
> Pavel
>



-- 
Oliver Gutierrez
Associate Software Engineer - Desktop Management tools
Red Hat
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH] Fixed syntax error. Debugger is not an object or command. It is a reserved word and DEBUG > 0 && syntax does not work with it

2016-09-08 Thread Oliver Gutierrez
---
 spiceconn.js | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/spiceconn.js b/spiceconn.js
index 010a446..796f954 100644
--- a/spiceconn.js
+++ b/spiceconn.js
@@ -189,8 +189,10 @@ SpiceConn.prototype =
 
 if (msg.type > 500)
 {
-DEBUG > 0 && alert("Something has gone very wrong; we 
think we have message of type " + msg.type);
-DEBUG > 0 && debugger;
+if (DEBUG > 0) {
+  alert("Something has gone very wrong; we think we have 
message of type " + msg.type);
+  debugger;
+}
 }
 
 if (msg.size == 0)
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] Added debug filtering to avoid debugger to start when using in production

2016-09-05 Thread Oliver Gutierrez
This change:

-**  display, inputs, and cursor channels.  See main.js for
+**  display, inputs, and cursor channels.  See main.js for

Is because file in repository has a trailing whitespace.

It happened before in another patch I sent but now is when I finally found
the reason.

On Mon, Sep 5, 2016 at 10:48 AM, Oliver Gutierrez <ogutier...@redhat.com>
wrote:

> ---
>  spiceconn.js | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/spiceconn.js b/spiceconn.js
> index 903f3b0..5123e04 100644
> --- a/spiceconn.js
> +++ b/spiceconn.js
> @@ -23,7 +23,7 @@
>  **  This is the base Javascript class for establishing and
>  **  managing a connection to a Spice Server.
>  **  It is used to provide core functionality to the Spice main,
> -**  display, inputs, and cursor channels.  See main.js for
> +**  display, inputs, and cursor channels.  See main.js for
>  **  usage.
>  **--
> */
>  function SpiceConn(o)
> @@ -185,8 +185,8 @@ SpiceConn.prototype =
>
>  if (msg.type > 500)
>  {
> -alert("Something has gone very wrong; we think we
> have message of type " + msg.type);
> -debugger;
> +DEBUG > 0 && alert("Something has gone very wrong; we
> think we have message of type " + msg.type);
> +        DEBUG > 0 && debugger;
>  }
>
>  if (msg.size == 0)
> --
> 2.7.4
>
>


-- 
Oliver Gutierrez
Associate Software Engineer - Desktop Management tools
Red Hat
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH] Added debug filtering to avoid debugger to start when using in production

2016-09-05 Thread Oliver Gutierrez
---
 spiceconn.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/spiceconn.js b/spiceconn.js
index 903f3b0..5123e04 100644
--- a/spiceconn.js
+++ b/spiceconn.js
@@ -23,7 +23,7 @@
 **  This is the base Javascript class for establishing and
 **  managing a connection to a Spice Server.
 **  It is used to provide core functionality to the Spice main,
-**  display, inputs, and cursor channels.  See main.js for 
+**  display, inputs, and cursor channels.  See main.js for
 **  usage.
 **--*/
 function SpiceConn(o)
@@ -185,8 +185,8 @@ SpiceConn.prototype =
 
 if (msg.type > 500)
 {
-alert("Something has gone very wrong; we think we have 
message of type " + msg.type);
-debugger;
+DEBUG > 0 && alert("Something has gone very wrong; we 
think we have message of type " + msg.type);
+DEBUG > 0 && debugger;
 }
 
 if (msg.size == 0)
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] Fixed error when trying to access undefined source buffer without checking it first

2016-07-28 Thread Oliver Gutierrez
AFAIK My setup is very basic. I'm using a gnome-boxes machine, and
modifying the xml for libvirt machine to setup a spice graphics adapter
with autoport enabled.

Then I run websockify and connect with spice-html5 client. Nothing strange.

If you want to look to implementation I do for setting up the client you
can see it at
https://github.com/fleet-commander/fc-admin/blob/master/admin/cockpit/fleet-commander-admin/js/fcspiceclient.js

There is a workaround I did to spice code to avoid client send alerts and
start debugger in file:
https://github.com/fleet-commander/fc-admin/blob/master/admin/cockpit/fleet-commander-admin/js/spice_debug_bypass.js

This are the only modifications I've done

On Thu, Jul 28, 2016 at 2:00 PM, Christophe Fergeau <cferg...@redhat.com>
wrote:

> On Thu, Jul 28, 2016 at 12:59:05PM +0100, Oliver Gutierrez wrote:
> > The problem I was having was the spice-html5 client was throwing
> exceptions
> > for trying to access that property in cases where it is not a valid
> value.
> >
> > I got to the error because I'm developing a plugin for cockpit that makes
> > use of spice-html5 for connecting to VMs, and when spice-html5 starts
> > displaying graphics, it throws this error repeatedly, causing cockpit to
> > show an awfull "Oops" message.
> >
> > It just failed throwing exceptions to console. It stopped the playback
> when
> > failed, so with the change it stops anyway but without throwing errors.
> >
> > I hope this answer your questions. My knowledge about spice-html5 or
> spice
> > is limited, so I don't know if this info is enough for you.
>
> Any idea what is different in your setup compared to 'traditional'
> setups? I expect this bug is not always happening or it would have been
> noticed earlier?
>
> Christophe
>



-- 
Oliver Gutierrez
Associate Software Engineer - Desktop Management tools
Red Hat
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] Fixed error when trying to access undefined source buffer without checking it first

2016-07-28 Thread Oliver Gutierrez
The problem I was having was the spice-html5 client was throwing exceptions
for trying to access that property in cases where it is not a valid value.

I got to the error because I'm developing a plugin for cockpit that makes
use of spice-html5 for connecting to VMs, and when spice-html5 starts
displaying graphics, it throws this error repeatedly, causing cockpit to
show an awfull "Oops" message.

It just failed throwing exceptions to console. It stopped the playback when
failed, so with the change it stops anyway but without throwing errors.

I hope this answer your questions. My knowledge about spice-html5 or spice
is limited, so I don't know if this info is enough for you.

On Thu, Jul 28, 2016 at 12:47 PM, Christophe Fergeau <cferg...@redhat.com>
wrote:

> Hey,
>
> Thanks for the patch!
>
> I'd expand a bit in the commit log, that this.source_buffer can be used
> before being checked for null, and that this commit moves the check
> before the first use of this.source_buffer.
> You could also describe what happens when this triggers/how this
> triggers (I assume playback stops?)
>
> On Thu, Jul 28, 2016 at 10:50:05AM +0100, Oliver Gutierrez wrote:
> > ---
> >  playback.js | 9 -
> >  1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/playback.js b/playback.js
> > index 9659381..b5954da 100644
> > --- a/playback.js
> > +++ b/playback.js
> > @@ -107,21 +107,20 @@
> SpicePlaybackConn.prototype.process_channel_message = function(msg)
> >   So we do two things.  First, we seek forward.  Second, we
> compute how much of a gap
> >   there would have been, and essentially eliminate it.
> >  */
> > +if (! this.source_buffer)
> > +return true;
> > +
> >  if (this.last_data_time && data.time >= (this.last_data_time +
> GAP_DETECTION_THRESHOLD))
> >  {
> >  this.skip_until = data.time;
> > -this.gap_time = (data.time - this.start_time) -
> > +this.gap_time = (data.time - this.start_time) -
>
> This looks like an unrelated whitespace change
>
>
> Looks good otherwise!
>
> Reviewed-by: Christophe Fergeau <cferg...@redhat.com>
>
> Christophe
>



-- 
Oliver Gutierrez
Associate Software Engineer - Desktop Management tools
Red Hat
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH] Fixed error when trying to access undefined source buffer without checking it first

2016-07-28 Thread Oliver Gutierrez
---
 playback.js | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/playback.js b/playback.js
index 9659381..b5954da 100644
--- a/playback.js
+++ b/playback.js
@@ -107,21 +107,20 @@ SpicePlaybackConn.prototype.process_channel_message = 
function(msg)
  So we do two things.  First, we seek forward.  Second, we compute 
how much of a gap
  there would have been, and essentially eliminate it.
 */
+if (! this.source_buffer)
+return true;
+
 if (this.last_data_time && data.time >= (this.last_data_time + 
GAP_DETECTION_THRESHOLD))
 {
 this.skip_until = data.time;
-this.gap_time = (data.time - this.start_time) - 
+this.gap_time = (data.time - this.start_time) -
   
(this.source_buffer.buffered.end(this.source_buffer.buffered.end.length - 1) * 
1000.0).toFixed(0);
 }
 
 this.last_data_time = data.time;
 
-
 DEBUG > 1 && console.log("PlaybackData; time " + data.time + "; length 
" + data.data.byteLength);
 
-if (! this.source_buffer)
-return true;
-
 if (this.start_time == 0)
 this.start_playback(data);
 
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel