State machine refactoring.

Add new states 'loaded', 'connect' and 'fatal':
- Loaded state is first page state. Pass WebSockets mode message using
  this state.
- Connect indicates that the user has issued a "connect" but we
  haven't gotten an WebSockets onopen yet.
- Fatal is a condition that indicates inability to continue on: right
  now, lack of WebSockets/Flash or non-working canvas.

Move much of the actual state transition code into updateState.

Handle 'password' state better in default_controls.js; instead of
disconnecting, prompt for password to send.

Add comments to updateState indicating possible states.
This commit is contained in:
Joel Martin
2010-07-15 19:38:25 -05:00
parent 53b112f2a6
commit f00b1e3776
3 changed files with 188 additions and 65 deletions
+16
View File
@@ -82,6 +82,12 @@ load: function(target) {
};
},
setPassword: function() {
console.log("setPassword");
RFB.sendPassword($('VNC_password').value);
return false;
},
sendCtrlAltDel: function() {
RFB.sendCtrlAltDel();
},
@@ -94,6 +100,7 @@ updateState: function(state, msg) {
cad = $('sendCtrlAltDelButton');
switch (state) {
case 'failed':
case 'fatal':
c.disabled = true;
cad.disabled = true;
klass = "VNC_status_error";
@@ -106,6 +113,7 @@ updateState: function(state, msg) {
klass = "VNC_status_normal";
break;
case 'disconnected':
case 'loaded':
c.value = "Connect";
c.onclick = DefaultControls.connect;
@@ -113,6 +121,14 @@ updateState: function(state, msg) {
cad.disabled = true;
klass = "VNC_status_normal";
break;
case 'password':
c.value = "Send Password";
c.onclick = DefaultControls.setPassword;
c.disabled = false;
cad.disabled = true;
klass = "VNC_status_warn";
break;
default:
c.disabled = true;
cad.disabled = true;