[Spice-devel] [PATCH] test page overhaul

Alon Levy alevy at redhat.com
Sun Mar 18 02:47:15 PDT 2012


On Fri, Mar 16, 2012 at 10:14:14AM +0100, David Jaša wrote:
> This patch
>       * gets the test page in sync with API defined in nsISpicec.idl
>       * cleans up HTML and JavaScript to more coherent & up-to-date
>         style
>       * improves page log: adds timestamps, structures it to table
>       * allows "disabling" of any value (well, setting it to empty
>         string, as undefining it or setting it to Null does not make the
>         spice-xpi plugin happy)
> 
> The only missing part is OnDisconnected event logging, i just couldn't
> make it work on my machine.
> 

It looks a hell of a lot better then the previous page :)
Disconnect doesn't work. And there is no Hide botton (but then again,
both of these are missing from the previous page too, just mentioning
the obvious).

> 
> ---
>  data/test.html |  319 ++++++++++++++++++++++++++++++++++++++++++++++----------
>  1 files changed, 264 insertions(+), 55 deletions(-)
> 
> diff --git a/data/test.html b/data/test.html
> index 929d096..1d8adaf 100644
> --- a/data/test.html
> +++ b/data/test.html
> @@ -1,86 +1,295 @@
> -<HTML>
> -<HEAD>
> -<TITLE>SPICE xpi test page</TITLE>
> -</HEAD>
> -<BODY onload='BodyLoad()' onunload='BodyUnload()'>
> +<html>
> +<head>
> +<title>Spice-XPI test page</title>
> +<style type="text/css">
> +
> +    caption {
> +	text-align: left;
> +	font-weight: bold;
> +    }
> +
> +    th {
> +	text-align: left;
> +    }
> +
> +</style>
> +</head>
> +<body onload='bodyLoad()' onunload='bodyUnload()'>
>  
>  <center>
>  <h1>SPICE xpi test page</h1>
>  </center>
>  
> -SPICE xpi test page.
> -<br><br>
> +SPICE xpi test page. Disabled (greyed out) values are passed to SPICE xpi as empty variables, asterisk-marked ones are passed when you press button marked in the same fashion.
> +<br />
>  
>  <center>
>  
> -<embed type="application/x-spice" width=0 height=0><br>
> +<embed type="application/x-spice" width="0" height="0" id="spice-xpi" /><br />
>  
> -<script>
> +<script type="text/javascript">
>  
> -var embed = document.embeds[0];
> +var embed = document.getElementById("spice-xpi");
>  
> -function BodyLoad() {
> -    document.getElementById("log").innerHTML += "BodyLoad<br>";
> +function bodyLoad() 
> +{
> +	log("BodyLoad");
>  }
>  
> -function BodyUnload() {
> -    document.getElementById("log").innerHTML += "BodyUnload<br>";
> +function bodyUnload() 
> +{
> +	log("BodyUnload");
>  }
>  
> -function Execute()
> +function connect()
>  {
> -    document.getElementById("log").innerHTML += "Execute<br>";
> -    embed.hostIP = document.all["Host"].value;
> -    embed.port = document.all["Port"].value;
> -    embed.SecurePort = document.all["SecurePort"].value;
> -    embed.Password = document.all["Password"].value;
> -    embed.HostSubject = document.all["HostSubject"].value;
> -    embed.TrustStore = document.all["TrustStore"].value;
> -    embed.fullScreen = false;
> -    embed.AdminConsole = (document.all["AdminConsole"].value == "1");
> -    embed.HotKeys = document.all["HotKeys"].value;
> -    embed.SendCtrlAltDelete = (document.all["SendCtrlAltDelete"].value == "1")
> -    embed.fAudio = true;
> -    embed.connect();
> +	setConnectVars();
> +	log("connect: host '" + embed.hostIP + "', port '" + embed.port + "', secure port '" + embed.SecurePort + "', USB port '" + embed.UsbListenPort + "'");
> +	embed.connect();
>  }
>  
> -function Status()
> +function disconnect()
>  {
> -    var status = embed.ConnectedStatus();
> -    document.getElementById("log").innerHTML += "ConnectedStatus = " + status + "<br>";
> +	embed.disconnect();
> +	log("disconnected by page");
>  }
>  
> -function Show()
> +/* FIXME
> +function OnDisconnected(msg)
>  {
> -    embed.show();
> -    document.getElementById("log").innerHTML += "Show was called<br>";
> +	log(msg);
> +}
> +*/
> +
> +function log(message)
> +{
> +	var log = document.getElementById("log");
> +	var ts = new Date().toString() + ": ";
> +	var newRow = document.createElement("tr");
> +	var tsCell = document.createElement("td");
> +	var msgCell = document.createElement("td");
> +
> +	tsCell.innerHTML = ts;
> +	msgCell.innerHTML = message;
> +
> +	newRow.appendChild(tsCell);
> +	newRow.appendChild(msgCell);
> +	log.appendChild(newRow);
> +}
> +
> +function setLanguageStrings()
> +{
> +	section = document.getElementById("LanguageStringsSectionToggled").checked == true ? document.getElementById("LanguageStringsSection").value : "";
> +	lang = document.getElementById("LanguageStringsLangToggled").checked == true ? document.getElementById("LanguageStringsLang").value : "";
> +	embed.SetLanguageStrings(section, lang)
> +	log("Language Strings were set to '" + section + "' '" + lang + "'");
> +}
> +
> +function setUsbFilter()
> +{
> +	filter = document.getElementById("UsbFilterToggled").checked == true ? document.getElementById("UsbFilter").value : "";
> +	embed.SetUsbFilter(filter);
> +	log("USB Filter String was set to: '" + filter + "'");
> +}
> +
> +function setConnectVars()
> +{
> +	if(document.getElementById("hostIPToggled").checked == true) { embed.hostIP = document.getElementById("hostIP").value; } else { embed.hostIP = ""; }
> +	if(document.getElementById("portToggled").checked == true) { embed.port = document.getElementById("port").value; } else { embed.port = ""; }
> +	if(document.getElementById("SecurePortToggled").checked == true) { embed.SecurePort = document.getElementById("SecurePort").value; } else { embed.SecurePort = ""; }
> +	if(document.getElementById("PasswordToggled").checked == true) { embed.Password = document.getElementById("Password").value; } else { embed.Password = ""; }
> +	if(document.getElementById("CipherSuiteToggled").checked == true) { embed.CipherSuite = document.getElementById("CipherSuite").value; } else { embed.CipherSuite = ""; }
> +	if(document.getElementById("SSLChannelsToggled").checked == true) { embed.SSLChannels = document.getElementById("SSLChannels").value; } else { embed.SSLChannels = ""; }
> +	if(document.getElementById("TrustStoreToggled").checked == true) { embed.TrustStore = document.getElementById("TrustStore").value; } else { embed.TrustStore = ""; }
> +	if(document.getElementById("HostSubjectToggled").checked == true) { embed.HostSubject = document.getElementById("HostSubject").value; } else { embed.HostSubject = ""; }
> +	if(document.getElementById("fullScreenToggled").checked == true) { embed.fullScreen = document.getElementById("fullScreen").checked; } else { embed.fullScreen = ""; }
> +	if(document.getElementById("AdminConsoleToggled").checked == true) { embed.AdminConsole = document.getElementById("AdminConsole").checked; } else { embed.AdminConsole = ""; }
> +	if(document.getElementById("TitleToggled").checked == true) { embed.Title = document.getElementById("Title").value; } else { embed.Title = ""; }
> +	if(document.getElementById("dynamicMenuToggled").checked == true) { embed.dynamicMenu = document.getElementById("dynamicMenu").value; } else { embed.dynamicMenu = ""; }
> +	if(document.getElementById("NumberOfMonitorsToggled").checked == true) { embed.NumberOfMonitors = document.getElementById("NumberOfMonitors").value; } else { embed.NumberOfMonitors = ""; }
> +	if(document.getElementById("GuestHostNameToggled").checked == true) { embed.GuestHostName = document.getElementById("GuestHostName").value; } else { embed.GuestHostName = ""; }
> +	if(document.getElementById("HotKeyToggled").checked == true) { embed.HotKey = document.getElementById("HotKey").value; } else { embed.HotKey = ""; }
> +	if(document.getElementById("NoTaskMgrExecutionToggled").checked == true) { embed.NoTaskMgrExecution = document.getElementById("NoTaskMgrExecution").checked; } else { embed.NoTaskMgrExecution = ""; }
> +	if(document.getElementById("SendCtrlAltdeleteToggled").checked == true) { embed.SendCtrlAltdelete = document.getElementById("SendCtrlAltdelete").checked; } else { embed.SendCtrlAltDelete = ""; }
> +	if(document.getElementById("UsbListenPortToggled").checked == true) { embed.UsbListenPort = parseInt( document.getElementById("UsbListenPort").value ); } else { embed.UsbListenPort = ""; }
> +	if(document.getElementById("UsbAutoShareToggled").checked == true) { embed.UsbAutoShare = document.getElementById("UsbAutoShare").checked; } else { embed.UsbAutoShare = ""; }
> +	if(document.getElementById("SmartcardToggled").checked == true) { embed.Smartcard = document.getElementById("Smartcard").checked; } else { embed.Smartcard = ""; }
> +}
> +
> +function show()
> +{
> +	embed.show();
> +	log("Show was called");
> +}
> +
> +function status()
> +{
> +	var status = embed.ConnectedStatus();
> +	log("ConnectedStatus = " + status);
> +}
> +
> +function toggle(checkboxID)
> +{
> +	var checkbox = document.getElementById(checkboxID);
> +	for (var i = 1; i < arguments.length; i++)
> +	{
> +		var toggle = document.getElementById(arguments[i]);
> +		var updateToggle = checkbox.checked ? toggle.disabled = false : toggle.disabled = true;
> +	}
>  }
>  
>  </script>
>  
>  
> -<br>
> -Host: <input id="Host" type="text" size="13"> </input>
> -Port: <input id="Port" type="text" size="13"> </input> <BR>
> -SecurePort: <input id="SecurePort" type="text" size="13"> </input> <BR>
> -Password: <input id="Password" type="text" size="13"> </input>
> -HotKeys: <input id="HotKeys" type="text" size="13" value="release-cursor=ctrl+alt"> </input>
> -AdminConsole: <input id="AdminConsole" type="text" size="5" value="1"> </input>
> -SendCtrlAltDelete: <input id="SendCtrlAltDelete" type="text" size="5" value="1"> </input>
> -<BR>
> -HostSubject: <input id="HostSubject" type="text" size="60"> </input></br>
> -TrustStore: <textarea id="TrustStore" type="text" cols="65" rows="15"> </textarea> <BR>
> +<table id="values">
> +<tr>
>  
> -<input type=button value="Exec" onclick='Execute()'/>
> -<input type=button value="Check Status" onclick='Status()'> </input>
> -<input type=button value="Show" onclick='Show()'> </input>
> +<td>
> +<table>
> +<tr>
> +<td><input type="checkbox" id="hostIPToggled" onclick="toggle('hostIPToggled', 'hostIP')" checked /></td>
> +<td>Host:</td>
> +<td> <input id="hostIP" type="text" size="30" /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="portToggled" onclick="toggle('portToggled', 'port')" checked /></td>
> +<td>Port:</td>
> +<td> <input id="port" type="text" size="30" /> </td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="SecurePortToggled" onclick="toggle('SecurePortToggled', 'SecurePort')" /></td>
> +<td>SecurePort:</td>
> +<td> <input id="SecurePort" type="text" size="30" disabled /> </td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="PasswordToggled" onclick="toggle('PasswordToggled', 'Password')" /></td>
> +<td>Password:</td>
> +<td> <input id="Password" type="text" size="30" disabled /><br />
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="CipherSuiteToggled" onclick="toggle('CipherSuiteToggled', 'CipherSuite')" /></td>
> +<td>Cipher Suite:</td>
> +<td> <input id="CipherSuite" type="text" size="30" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="SSLChannelsToggled" onclick="toggle('SSLChannelsToggled', 'SSLChannels')" /></td>
> +<td>Secure Channels:</td>
> +<td> <input id="SSLChannels" type="text" size="30" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="HostSubjectToggled" onclick="toggle('HostSubjectToggled', 'HostSubject')" /></td>
> +<td>Host Subject:</td>
> +<td> <input id="HostSubject" type="text" size="30" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="fullScreenToggled" onclick="toggle('fullScreenToggled', 'fullScreen')" /></td>
> +<td>Full Screen:</td>
> +<td> <input id="fullScreen" type="checkbox" disabled /> </td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="AdminConsoleToggled" onclick="toggle('AdminConsoleToggled', 'AdminConsole')" checked /></td>
> +<td>AdminConsole:</td>
> +<td> <input id="AdminConsole" type="checkbox" checked /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="TitleToggled" onclick="toggle('TitleToggled', 'Title')" /></td>
> +<td>Title:</td>
> +<td> <input id="Title" type="text" size="30" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="dynamicMenuToggled" onclick="toggle('dynamicMenuToggled', 'dynamicMenu')" /></td>
> +<td>Dynamic Menu:</td>
> +<td> <input id="dynamicMenu" type="text" size="30" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="NumberOfMonitorsToggled" onclick="toggle('NumberOfMonitorsToggled', 'NumberOfMonitors')" /></td>
> +<td>Number of Monitors:</td>
> +<td> <input id="NumberOfMonitors" type="text" size="30" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="GuestHostNameToggled" onclick="toggle('GuestHostNameToggled', 'GuestHostName')" /></td>
> +<td>GuestHostName:</td>
> +<td> <input id="GuestHostName" type="text" size="30" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="HotKeyToggled" onclick="toggle('HotKeyToggled', 'HotKey')" checked /></td>
> +<td>Hot Key:</td>
> +<td> <input id="HotKey" type="text" size="30" value="toggle-fullscreen=shift+f11,release-cursor=shift+f12,smartcard-insert=shift+f8,smartcard-remove=shift+f9" /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="NoTaskMgrExecutionToggled" onclick="toggle('NoTaskMgrExecutionToggled', 'NoTaskMgrExecution')" /></td>
> +<td title="Suppress launching of task manager when Ctrl+Alt+Del is pressed">NoTaskMgrExecution:</td>
> +<td> <input id="NoTaskMgrExecution" type="checkbox" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="SendCtrlAltdeleteToggled" onclick="toggle('SendCtrlAltdeleteToggled', 'SendCtrlAltdelete')" /></td>
> +<td>Send Ctrl+Alt+Delete:</td>
> +<td> <input id="SendCtrlAltdelete" type="checkbox" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="UsbListenPortToggled" onclick="toggle('UsbListenPortToggled', 'UsbListenPort')" /></td>
> +<td>USB listen port:</td>
> +<td> <input id="UsbListenPort" type="text" size="30" value="32023" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="UsbAutoShareToggled" onclick="toggle('UsbAutoShareToggled', 'UsbAutoShare')" /></td>
> +<td>USB Auto Share:</td>
> +<td> <input id="UsbAutoShare" type="checkbox" disabled /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="SmartcardToggled" onclick="toggle('SmartcardToggled', 'Smartcard')" checked /></td>
> +<td>Smartcard:</td>
> +<td> <input id="Smartcard" type="checkbox" /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="LanguageStringsSectionToggled" onclick="toggle('LanguageStringsSectionToggled', 'LanguageStringsSection')" checked /></td>
> +<td>*Language Strings - section:</td>
> +<td> <input id="LanguageStringsSection" type="input" size="30" /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="LanguageStringsLangToggled" onclick="toggle('LanguageStringsLangToggled', 'LanguageStringsLang')" checked /></td>
> +<td>*Language Strings - lang:</td>
> +<td> <input id="LanguageStringsLang" type="input" size="30" /></td>
> +</tr>
> +<tr>
> +<td><input type="checkbox" id="UsbFilterToggled" onclick="toggle('UsbFilterToggled', 'UsbFilter')" checked /></td>
> +<td>**Set USB Filter:</td>
> +<td><input id="UsbFilter" type="text" size="30" /></td>
> +</tr>
> +</table>
> +</td>
>  
> -</center>
> +<td rowspan="21" width="25px" > </td>
>  
> +<td>
> +<table>
> +<td>
> +<tr>
> +<td><input type="checkbox" id="TrustStoreToggled" onclick="toggle('TrustStoreToggled', 'TrustStore')" /></td>
> +<td title="CA Certificate in plain text. For RHEV-M, it can be found in 'http://rhev-m.example.com/ca.crt'">Trust Store:</td>
> +</tr>
> +<tr><td colspan="2"><textarea id="TrustStore" cols="66" rows="33" disabled ></textarea></td></tr>
> +</table>
> +</td>
> +
> +</tr>
> +</table>
> +
> +<input type="button" value="Connect" onclick='connect()' />
> +<input type="button" value="Check Status" onclick='status()' />
> +<input type="button" value="Show" onclick='show()' />
> +<input type="button" value="*Set Language Strings" onclick='setLanguageStrings()' id="LanguageStringsButton" />
> +<input type="button" value="**Set Usb Filter" onclick='setUsbFilter()' id="UsbFilterButton" />
> +<input type="button" value="Disconnect" onclick='disconnect()' />
> +
> +</center>
>  
> ----<br>
> -<div id="log">
> -</div>
> ----<br>
> -</BODY>
> -</HTML>
> +<hr />
> +<table style="border: 1px; border-color: black; " >
> +<caption  >log:</caption>
> +<thead><tr><th style="width: 22em; ">timestamp</th><th>message</th></tr></thead>
> +<tbody style="font-family: monospace; " id="log">
> +</tbody>
> +</table>
> +</body>
> +</html>
> -- 
> 1.7.1
> 
> 
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list