[Spice-devel] [PATCH spice-html5 1/4] spiceconn: Add function to test channel capabilities

Frediano Ziglio fziglio at redhat.com
Thu Sep 7 09:49:55 UTC 2017


> I agree, I will use your first suggestion.

> Tomáš

As a note, I'm not a Javascript expert as you, I just tested my suggestion with a small test 
script. 

Frediano 

> 2017-09-07 10:31 GMT+02:00 Frediano Ziglio < fziglio at redhat.com > :

> > >
> 
> > > This will be used in other commits.
> 
> > > ---
> 
> > > spiceconn.js | 19 +++++++++++++++++++
> 
> > > 1 file changed, 19 insertions(+)
> 
> > >
> 
> > > diff --git a/spiceconn.js b/spiceconn.js
> 
> > > index 33e7388..78d5820 100644
> 
> > > --- a/spiceconn.js
> 
> > > +++ b/spiceconn.js
> 
> > > @@ -243,6 +243,9 @@ SpiceConn.prototype =
> 
> > > else if (this.state == "link")
> 
> > > {
> 
> > > this.reply_link = new SpiceLinkReply(mb);
> 
> > > + this.common_caps = this.reply_link.common_caps;
> 
> > > + this.channel_caps = this.reply_link.channel_caps;
> 
> > > +
> 
> > > // FIXME - Screen the caps - require minihdr at least, right?
> 
> > > if (this.reply_link.error)
> 
> > > {
> 
> > > @@ -495,6 +498,22 @@ SpiceConn.prototype =
> 
> > > var e = new Error("Connection timed out.");
> 
> > > this.report_error(e);
> 
> > > },
> 
> > > +
> 
> > > + test_capability: function(caps, cap)
> 
> > > + {
> 
> > > + var ret = (caps >> cap) & 1;
> 
> > > + return ret;
> 
> > > + },
> 
> > > +
> 

> > This will work till cap is < 32, maybe safer to use a
> 

> > return (caps[cap >> 5] >> (cap & 31)) & 1;
> 

> > Or maybe put a comment where capabilities constants are defined
> 
> > to change this function when we reach 32.
> 

> > > + channel_test_capability: function(cap)
> 
> > > + {
> 
> > > + return this.test_capability(this.channel_caps, cap);
> 
> > > + },
> 
> > > +
> 
> > > + channel_test_common_capability: function(cap)
> 
> > > + {
> 
> > > + return this.test_capability(this.common_caps, cap);
> 
> > > + }
> 
> > > }
> 
> > >
> 
> > > function spiceconn_timeout(sc)
> 

> > Frediano
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170907/e3958aa7/attachment.html>


More information about the Spice-devel mailing list