- make the form pass w3 validator,

- add serial port output, available as a telnet: url,
- add untested support for passing through a usb device like a webcam,
- add disabled SMP option,
- change port assignations
- lower sleep time for applet


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29833 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol
2009-03-31 17:08:00 +00:00
parent d30acbf30b
commit f0cbfcafbe
+161 -30
View File
@@ -37,7 +37,12 @@ define("APPLET_HEIGHT", "768");
define("VNCPORTBASE", 5900); define("VNCPORTBASE", 5900);
// base port for audio streams // base port for audio streams
define("AUDIOPORTBASE", 8080); //define("AUDIOPORTBASE", 8080);
define("AUDIOPORTBASE", (VNCPORTBASE + MAX_QEMUS));
// base port for serial output
//define("SERIALPORTBASE", 9000);
define("SERIALPORTBASE", (VNCPORTBASE + MAX_QEMUS * 2));
// timeout before the demo session is killed, as argument to /bin/sleep // timeout before the demo session is killed, as argument to /bin/sleep
define("SESSION_TIMEOUT", "20m"); define("SESSION_TIMEOUT", "20m");
@@ -70,10 +75,19 @@ define("QEMU_PIDFILE_TMPL", "qemu-haiku-pid-");
// name of session variable holding the qemu slot; not yet used correctly // name of session variable holding the qemu slot; not yet used correctly
define("QEMU_IDX_VAR", "QEMU_HAIKU_SESSION_VAR"); define("QEMU_IDX_VAR", "QEMU_HAIKU_SESSION_VAR");
// uncomment if you want to pass your Sonix webcam device through
// migth need to update VID:PID
//define("QEMU_USB_PASSTHROUGH", "-usbdevice host:0c45:6005");
define("BGCOLOR", "#336698"); define("BGCOLOR", "#336698");
$vnckeymap = "en-us"; $vnckeymap = "en-us";
$cpucount = 1;
// statics // statics
$count = $_SESSION['compteur']; $count = $_SESSION['compteur'];
//$count = $GLOBALS['compteur']; //$count = $GLOBALS['compteur'];
@@ -99,9 +113,9 @@ session_start();
//echo "do_kill: " . $do_kill . "<br>\n"; //echo "do_kill: " . $do_kill . "<br>\n";
?> ?>
<html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta name="robots" content="noindex, nofollow, noarchive"> <meta name="robots" content="noindex, nofollow, noarchive" />
<title>Haiku Online Demo</title> <title>Haiku Online Demo</title>
<link rel="shortcut icon" href="http://www.haiku-os.org/themes/shijin/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="http://www.haiku-os.org/themes/shijin/favicon.ico" type="image/x-icon" />
<style type="text/css"> <style type="text/css">
@@ -119,12 +133,12 @@ a:hover { color:pink; }
.haiku_online_applet { background-color: <?php echo BGCOLOR; ?>; } .haiku_online_applet { background-color: <?php echo BGCOLOR; ?>; }
--> -->
</style> </style>
</head> <script type="text/javascript">
<script>
function onPageUnload() { function onPageUnload() {
//window.open("<?php echo $_SERVER["SCRIPT_NAME"] . "?close"; ?>", "closing", "width=100,height=30,location=no,menubar=no,toolbar=no,scrollbars=no"); //window.open("<?php echo $_SERVER["SCRIPT_NAME"] . "?close"; ?>", "closing", "width=100,height=30,location=no,menubar=no,toolbar=no,scrollbars=no");
} }
</script> </script>
</head>
<?php <?php
@@ -304,6 +318,18 @@ function probe_keymap()
} }
function probe_options_form()
{
global $cpucount;
$cpucount = 1;
if (isset($_GET['cpucount']))
$cpucount = (int)$_GET['cpucount'];
$cpucount = max(min($cpucount, 8), 1);
//dbg("cpucount $cpucount");
$cpucount = 1; // force for now
}
function output_options_form() function output_options_form()
{ {
global $vnckeymap; global $vnckeymap;
@@ -311,15 +337,15 @@ function output_options_form()
echo "<form method=\"get\" action=\"" . $_SERVER['PHP_SELF'] . "\">"; echo "<form method=\"get\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
echo "<table border=\"0\" class=\"haiku_online_form\">\n"; echo "<table border=\"0\" class=\"haiku_online_form\">\n";
$keymaps = list_keymaps();
echo "<tr>\n<td align=\"right\">\n"; echo "<tr>\n<td align=\"right\">\n";
echo "Select your keymap:"; echo "Select your keymap:";
echo "</td>\n<td>\n"; echo "</td>\n<td>\n";
echo "<select name=\"keymap\">"; echo "<select name=\"keymap\">";
$keymaps = list_keymaps();
foreach ($keymaps as $keymap) { foreach ($keymaps as $keymap) {
echo "<option name=\"keymap\" value=\"$keymap\" "; echo "<option value=\"$keymap\" ";
if ($keymap == $vnckeymap) if ($keymap == $vnckeymap)
echo "selected "; echo "selected=\"selected\" ";
echo ">$keymap</option>"; echo ">$keymap</option>";
//echo "<option name=\"keymap\" "; //echo "<option name=\"keymap\" ";
//echo "value=\"$keymap\">" . locale_get_display_name($keymap); //echo "value=\"$keymap\">" . locale_get_display_name($keymap);
@@ -328,6 +354,7 @@ function output_options_form()
echo "</select>"; echo "</select>";
echo "</td>\n</tr>\n"; echo "</td>\n</tr>\n";
$modes = array("1024x768"/*, "800x600"*/); $modes = array("1024x768"/*, "800x600"*/);
echo "<tr "; echo "<tr ";
if (count($modes) < 2) if (count($modes) < 2)
@@ -338,18 +365,41 @@ function output_options_form()
echo "</td>\n<td>\n"; echo "</td>\n<td>\n";
echo "<select name=\"videomode\" "; echo "<select name=\"videomode\" ";
if (count($modes) < 2) if (count($modes) < 2)
echo "disabled"; echo "disabled=\"disabled\"";
echo ">"; echo ">";
foreach ($modes as $mode) { foreach ($modes as $mode) {
echo "<option name=\"videomode\" value=\"$mode\" "; echo "<option value=\"$mode\" ";
if ($mode == $videomode) if ($mode == $videomode)
echo "selected "; echo "selected=\"selected\" ";
echo ">$mode</option>"; echo ">$mode</option>";
} }
echo "</select>"; echo "</select>";
echo "</td>\n</tr>\n"; echo "</td>\n</tr>\n";
$maxcpus = 8;
echo "<tr ";
if (!$enable_cpus)
echo "class=\"haiku_online_disabled\"";
echo ">\n";
echo "<td align=\"right\">\n";
echo "Select cpu count:";
echo "</td>\n<td>\n";
echo "<select name=\"cpucount\" ";
if (!$enable_cpus)
echo "disabled=\"disabled\"";
echo ">";
for ($ncpu = 1; $ncpu <= $maxcpus; $ncpu++) {
echo "<option value=\"$ncpu\" ";
if ($ncpu == 1)
echo "selected=\"selected\" ";
echo ">$ncpu</option>";
}
echo "</select>";
echo "</td>\n</tr>\n";
$enable_sound = 0;
echo "<tr "; echo "<tr ";
if (!$enable_sound) if (!$enable_sound)
echo "class=\"haiku_online_disabled\""; echo "class=\"haiku_online_disabled\"";
@@ -357,19 +407,66 @@ function output_options_form()
echo "<td align=\"right\">\n"; echo "<td align=\"right\">\n";
echo "Check to enable sound:"; echo "Check to enable sound:";
echo "</td>\n<td>\n"; echo "</td>\n<td>\n";
echo "<input type=\"checkbox\" name=\"sound\" id=\"sound_cb\""; echo "<input type=\"checkbox\" name=\"sound\" id=\"sound_cb\" ";
echo "value=\"1\" disabled "; echo "value=\"1\" ";
if ($enable_sound) { if ($enable_sound) {
echo "checked "; echo "checked=\"checked\" ";
echo "><a onClick=\"o=window.document.getElementById('"; echo "/><a onclick=\"o=window.document.getElementById('";
echo "sound_cb'); o.checked = !o.checked;\""; echo "sound_cb'); o.checked = !o.checked;\"";
} } else
echo "disabled=\"disabled\" /";
echo ">Sound"; echo ">Sound";
if ($enable_sound) if ($enable_sound)
echo "</a>"; echo "</a>";
echo "</input>"; //echo "</input>";
echo "</td>\n</tr>\n"; echo "</td>\n</tr>\n";
$enable_serial = 1;
echo "<tr ";
if (!$enable_serial)
echo "class=\"haiku_online_disabled\"";
echo ">\n";
echo "<td align=\"right\">\n";
echo "Check to enable serial output:";
echo "</td>\n<td>\n";
echo "<input type=\"checkbox\" name=\"serial\" id=\"serial_cb\" ";
echo "value=\"1\" "/*"disabled "*/;
if ($enable_serial) {
//echo "checked ";
echo "/><a onclick=\"o=window.document.getElementById('";
echo "serial_cb'); o.checked = !o.checked;\"";
} else
echo "/";
echo ">Serial";
if ($enable_serial)
echo "</a>";
//echo "</input>";
echo "</td>\n</tr>\n";
if (defined("QEMU_USB_PASSTHROUGH")) {
$enable_webcam = 1;
echo "<tr ";
if (!$enable_webcam)
echo "class=\"haiku_online_disabled\"";
echo ">\n";
echo "<td align=\"right\">\n";
echo "Check to enable webcam:";
echo "</td>\n<td>\n";
echo "<input type=\"checkbox\" name=\"webcam\" id=\"webcam_cb\" ";
echo "value=\"1\" "/*"disabled "*/;
if ($enable_webcam) {
//echo "checked ";
echo "/><a onclick=\"o=window.document.getElementById('";
echo "webcam_cb'); o.checked = !o.checked;\"";
} else
echo "/";
echo ">Webcam";
if ($enable_webcam)
echo "</a>";
//echo "</input>";
echo "</td>\n</tr>\n";
}
/* /*
echo "<tr>\n<td align=\"right\">\n"; echo "<tr>\n<td align=\"right\">\n";
//out("Click here to enable sound:"); //out("Click here to enable sound:");
@@ -423,17 +520,28 @@ function output_kill_form()
function start_qemu() function start_qemu()
{ {
global $vnckeymap; global $vnckeymap;
global $cpucount;
$idx = find_qemu_slot(); $idx = find_qemu_slot();
if ($idx < 0) { if ($idx < 0) {
err("No available qemu slot, please try later."); err("No available qemu slot, please try later.");
return $idx; return $idx;
} }
$pidfile = make_qemu_pidfile_name($idx); $pidfile = make_qemu_pidfile_name($idx);
$cmd = QEMU_BIN . " " . QEMU_ARGS . $cmd = QEMU_BIN . " " . QEMU_ARGS;
" -k " . $vnckeymap . if ($cpucount > 1)
" -vnc " . QEMU_VNC_PREFIX . vnc_display() . $cmd .= " -smp " . $cpucount;
" -pidfile " . $pidfile . if (isset($_GET['serial'])) {
" " . QEMU_IMAGE_PATH; $cmd .= " -serial telnet::";
$cmd .= (SERIALPORTBASE + qemu_slot());
$cmd .= ",server,nowait,nodelay";
}
if (isset($_GET['webcam']) && defined("QEMU_USB_PASSTHROUGH")) {
$cmd .= " " . QEMU_USB_PASSTHROUGH;
}
$cmd .= " -k " . $vnckeymap .
" -vnc " . QEMU_VNC_PREFIX . vnc_display() .
" -pidfile " . $pidfile .
" " . QEMU_IMAGE_PATH;
if (file_exists($pidfile)) if (file_exists($pidfile))
unlink($pidfile); unlink($pidfile);
@@ -501,8 +609,8 @@ function output_vnc_info()
"or enter <tt>" . vnc_addr_display() . "</tt> in your " . "or enter <tt>" . vnc_addr_display() . "</tt> in your " .
"<a href=\"http://fr.wikipedia.org/wiki/Virtual_Network_" . "<a href=\"http://fr.wikipedia.org/wiki/Virtual_Network_" .
"Computing\"" . "Computing\"" .
">VNC viewer</a>.<br />"); ">VNC viewer</a>.");
echo "<br />\n"; //echo "<br />\n";
} }
function output_audio_player_code($external_only=false) function output_audio_player_code($external_only=false)
@@ -532,7 +640,7 @@ function output_applet_code($external_only=false)
$class = VNCCLASS; $class = VNCCLASS;
if ($external_only) if ($external_only)
return; return;
echo "<a name=\"haiku_online_applet\">"; echo "<a name=\"haiku_online_applet\"></a>";
echo "<center>"; echo "<center>";
echo "<applet code=$class codebase=\"$vncjpath/\" "; echo "<applet code=$class codebase=\"$vncjpath/\" ";
echo "archive=\"$vncjpath/$jar\" width=$w height=$h "; echo "archive=\"$vncjpath/$jar\" width=$w height=$h ";
@@ -564,13 +672,33 @@ function output_applet_code($external_only=false)
flush(); flush();
} }
out("<div align=\"right\">Available displays: " . function output_serial_output_code($external_only=false)
{
if (!isset($_GET['serial']))
return;
$url = "telnet://" . $_SERVER['HTTP_HOST'] . ":";
$url .= (SERIALPORTBASE + qemu_slot()) . "/";
out("You can get serial output at <a href=\"$url\">$url</a>");
return;
// not really http...
$url = "http://" . $_SERVER['HTTP_HOST'] . ":";
$url .= (SERIALPORTBASE + qemu_slot()) . "/";
echo "<center>";
echo "<iframe src=\"$url/\" type=\"text/plain\" width=\"100%\" ";
echo "height=\"200\"></iframe>";
echo "</center>";
}
out("<div style=\"text-align:right;\">Available displays: " .
available_qemu_slots() . "/" . total_qemu_slots() . available_qemu_slots() . "/" . total_qemu_slots() .
"</div>"); "</div>");
probe_keymap(); probe_keymap();
probe_options_form();
dbg("Checking if session is running..."); dbg("Checking if session is running...");
@@ -587,15 +715,18 @@ if (is_my_session_valid()) {
dbg("Need to start qemu."); dbg("Need to start qemu.");
$qemuidx = start_qemu(); $qemuidx = start_qemu();
out("Waiting for vnc server..."); //out("Waiting for vnc server...");
sleep(5); //sleep(5);
} }
if ($qemuidx >= 0 && !$do_kill) { if ($qemuidx >= 0 && !$do_kill) {
output_kill_form(); output_kill_form();
output_serial_output_code();
output_audio_player_code(); output_audio_player_code();
output_vnc_info(); output_vnc_info();
out("Waiting for vnc server...");
sleep(1);
output_applet_code(); output_applet_code();
} else { } else {
output_options_form(); output_options_form();