Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

785 lines
17 KiB

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Remote Control Chat Server</TITLE>
</HEAD>
<!--
Test
<BODY id="ChatServerId" onload=TransmitScreenInfo()>
-->
<BODY id="ChatServerId" onload=InitiateRCSession() bgcolor="#4a8ece" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!--
Title and control panel
-->
<table width="700" border="0" cellspacing="0" cellpadding="2" bgcolor="#4a8ece">
<tr bgcolor="#4a8ece">
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="42%" height="30"><img src="WinRCTitleChat.gif" width="290" height="33"></td>
<td width="9%" valign="middle" height="30">
<table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF">
<tr bgcolor="#4a8ece">
<td><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>MODE:</b><br>
<font size="1"> <div id=StatusID> </div></font></font></td>
</tr>
</table>
<font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">
</font></td>
<td width="49%" valign="middle" height="30">
<div align="right">
<input type="button" id=AbortConnection value="Quit Session" onclick=AbortConnection()>
<input type="button" id="FileXferId" value="File Transfer" onclick=LaunchFileXfer(0)>
<!--input type="button" id=HideChat onclick=HideChatBox()-->
&nbsp;&nbsp;&nbsp; </div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<TABLE>
<TR>
<!--
Incoming chat display area
-->
<TD>
<TEXTAREA wrap="VIRTUAL" cols="85" rows="15" id=incomingChatText name=incomingChatText readOnly multiline="true"></TEXTAREA>
</TD>
</TR>
<TR>
<!--
Chat text box
-->
<TD><TEXTAREA id=chatText name=chatText cols="60" wrap="VIRTUAL" rows="4" onkeypress=OnEnter()></TEXTAREA>&nbsp;&nbsp;&nbsp;
<input type="submit" id=sendChatButton name=sendChatButton onclick=SendChatButtonHandler() value="Submit Message ^">
</TR>
</TABLE>
</tr>
</table>
<SCRIPT Language="JScript">
//
// Salem objects.
//
var vArgs = null;
var g_oSAFRemoteDesktopSession = null;
var g_oSAFRemoteDesktopChannelMgr = null;
var g_oChatChannel = null;
var g_oControlChannel = null;
if(null == parent.oRCSession)
{
//alert("Dialog");
vArgs = window.dialogArguments;
g_oSAFRemoteDesktopSession = vArgs;
}
else
{
//alert("not a dialog");
g_oSAFRemoteDesktopSession = parent.oRCSession;
}
//
// Globals
//
var g_bChatBoxHidden = false;
var g_bNewBinaries = false;
var g_bUserDisconnect = true;
//
// Constants
//
var c_szChatChannelID = "70";
var c_szControlChannelID = "71";
var c_szHomePage = "hcp://system/HomePage.htm";
var c_szRCCommand = "RCCOMMAND";
var c_szRCCommandName = "NAME";
var c_szScreenInfo = "SCREENINFO";
var c_szWidth = "WIDTH";
var c_szHeight = "HEIGHT";
var c_szColorDepth = "COLORDEPTH";
var c_szDisconnectRC = "DISCONNECTRC";
var c_szFileXfer = "FILEXFER";
var c_szFileName = "FILENAME";
var c_szFileSize = "FILESIZE";
var c_szChannelId = "CHANNELID";
var c_szRemoteCtrlStart = "REMOTECTRLSTART";
var c_szRemoteCtrlEnd = "REMOTECTRLEND";
var c_szRCMODE = "REMOTE CONTROL";
var c_szCHATMODE = "CHAT";
//
// Desktop Control Permissions
//
var DESKTOPSHARING_DEFAULT = 0x0000;
var NO_DESKTOP_SHARING = 0x0001;
var VIEWDESKTOP_PERMISSION_REQUIRE = 0x0002;
var VIEWDESKTOP_PERMISSION_NOT_REQUIRE = 0x0004;
var CONTROLDESKTOP_PERMISSION_REQUIRE = 0x0008;
var CONTROLDESKTOP_PERMISSION_NOT_REQUIRE = 0x00010;
//
// Localizable contants
//
var L_cszExpertID = "\n Helper> ";
var L_cszUserID = "\n Helpee> ";
var L_HIDECHAT = "Hide Chat Boxes";
var L_SHOWCHAT = "Show Chat Boxes";
//
// Messages
//
var L_EXPERTDISCONNECT_MSG = "Helper disconnected.";
var L_EXPERTCONNECTED_MSG = "Helper connected.";
var L_ABORTINGCONNECTION_MSG = "Terminating Remote control connection from Helper";
var L_USECHATBOX_MSG = "1. Your Helper will now taken Remote control of your Computer.\n2. Both you and your helper can control your computer at the same time.\n3. You can still use your chat window to communicate with your helper. \n4. However, your helper would need to use your chat window to communicate with you. \n";
//
// Error Messages
//
var L_ERRNULLRCSESSION = "RCSession object is not defined";
//
// InitiateRCSession: Initiates the RC Session
//
function InitiateRCSession()
{
g_bNewBinaries = true;
if(null == g_oSAFRemoteDesktopSession)
{
alert( L_ERRNULLRCSESSION );
}
else
{
var x;
try
{
if (false == g_bNewBinaries)
{
//
// Using Old interface
//
//
// Add the chat channel
//
g_oSAFRemoteDesktopSession.AddChannels( c_szChatChannelID );
//
// Add the control channel
//
g_oSAFRemoteDesktopSession.AddChannels( c_szControlChannelID );
//
// Bind OnChannelDataReady callback
//
g_oSAFRemoteDesktopSession.OnChannelDataReady = function(channelID)
{ OnChannelDataReadyEvent(channelID); }
}
else
{
//
// Use new interface
//
//
// Get the Channel Manager
//
//alert("Getting ChannelManager");
g_oSAFRemoteDesktopChannelMgr = g_oSAFRemoteDesktopSession.ChannelManager;
//
// Open the Chat channel
//
//alert("Opening ChatChannel");
g_oChatChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szChatChannelID );
//
// Open the Control Channel
//
//alert("Opening Control Channel");
g_oControlChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szControlChannelID );
//
// Setup the ChannelDataReady handlers
//
//alert("Binding Events");
g_oChatChannel.OnChannelDataReady = function()
{ ChatChannelDataReadyEvent(); }
g_oControlChannel.OnChannelDataReady = function()
{ ControlChannelDataReadyEvent(); }
HideChat.value = L_HIDECHAT;
}
}
catch(x)
{
// no big deal ... it just means that the channel was added
// by a previous instance.
}
//
// Setup the OnDisconnected event callback
//
g_oSAFRemoteDesktopSession.OnDisconnected = function()
{ OnClientDisconnected(); }
}
try
{
//
// Also, Enable Remote Control
//
//alert("Enabling Remote Control");
EnableRemoteControl();
//
// Transmit screen resolution to Expert, so that
// he has the right screen size to see in the RC Tool
//
//alert("Transmitting screen info");
TransmitScreenInfo();
StatusID.innerText = c_szCHATMODE;
}
catch(error)
{
alert(error);
}
}
//
// TransmitScreenInfo: Sends the user's screen resolution to the expert
//
function TransmitScreenInfo()
{
var Doc = null;
var RCCommand = null;
try
{
//
// Create an XML document
//
Doc = new ActiveXObject("microsoft.XMLDOM");
//
// Create the RCCOMMAND root node
//
RCCommand = Doc.createElement( c_szRCCommand );
//
// Set the NAME attribute to SCREENINFO
//
RCCommand.setAttribute( c_szRCCommandName, c_szScreenInfo );
//
// Set the WIDTH attribute
//
RCCommand.setAttribute( c_szWidth, screen.width );
//
// Set the HEIGHT attribute
//
RCCommand.setAttribute( c_szHeight, screen.height );
//
// Set the COLORDEPTH attribute
//
RCCommand.setAttribute( c_szColorDepth, screen.colorDepth );
//
// Send the XML across
//
if (false == g_bNewBinaries)
{
//
// Using Old interface
//
g_oSAFRemoteDesktopSession.SendChannelData( c_szControlChannelID, RCCommand.xml );
}
else
{
//
// Use new interface
//
g_oControlChannel.SendChannelData( RCCommand.xml );
}
}
catch(error)
{
alert( error );
}
}
//
// EnableRemoteControl: This routine enables remote control
//
function EnableRemoteControl()
{
if(null != g_oSAFRemoteDesktopSession)
{
if (false == g_bNewBinaries)
{
//
// Using Old interface
//
g_oSAFRemoteDesktopSession.EnableRemoteControl( "" );
}
else
{
//
// Use the new interface
//
//alert("remote control permissions: ");
//alert("Existing: " + g_oSAFRemoteDesktopSession.SharingClass);
g_oSAFRemoteDesktopSession.SharingClass = CONTROLDESKTOP_PERMISSION_NOT_REQUIRE;
}
}
}
//
// DisableRemoteControl: Routine to disable Remote Control
//
function DisableRemoteControl()
{
if(null != g_oSAFRemoteDesktopSession)
{
if (false == g_bNewBinaries)
{
//
// Using Old interface
//
g_oSAFRemoteDesktopSession.DisableRemoteControl( "" );
}
else
{
//
// Use the new interface
//
g_oSAFRemoteDesktopSession.RemoteControlPermissions = NO_DESKTOP_SHARING;
}
}
}
//
// AbortConnection: Routine that disconnects the session
//
function AbortConnection()
{
if (false == g_bNewBinaries)
{
//
// Using Old interface
//
if (g_oSAFRemoteDesktopSession != null)
{
g_oSAFRemoteDesktopSession.StopListening();
}
//
// Remove the chat channel
//
g_oSAFRemoteDesktopSession.RemoveChannels( c_szChatChannelID );
//
// Remove the control channel
//
g_oSAFRemoteDesktopSession.RemoveChannels( c_szControlChannelID );
}
else
{
//
// Using New interfaces
//
//
// Disconnect the connection to Helper, if the connection is broken by the Helpee
//
if(true == g_bUserDisconnect)
{
DisconnectRC();
}
}
//
// Close this window
//
//window.close();
//
// Close the session
//
//alert("Closing Session");
try
{
g_oSAFRemoteDesktopSession.CloseRemoteDesktopSession();
}
catch(error)
{
alert(error);
}
parent.navigate( c_szHomePage );
return;
}
//
// SendChatButtonHandler: Routine to send chat data
//
function SendChatButtonHandler()
{
if (g_oSAFRemoteDesktopSession != null)
{
if (StatusID.innerText == c_szCHATMODE)
{
//
// If We are in Chat Mode. Only then send the data across
//
if (false == g_bNewBinaries)
{
//
// Using Old interface
//
//
// Send data on the chat channel
//
g_oSAFRemoteDesktopSession.SendChannelData(c_szChatChannelID, chatText.value);
}
else
{
//
// Use the new interface
//
g_oChatChannel.SendChannelData( chatText.value );
}
//
// Update user's chat history window
//
incomingChatText.value = incomingChatText.value + L_cszUserID + chatText.value;
}
else
{
//
// This is remote control Mode
//
//
// Update user's chat history window
//
incomingChatText.value = incomingChatText.value + "\n> " + chatText.value;
}
//
// Clear up the chat message window
//
chatText.value="";
incomingChatText.doScroll("scrollbarPageDown");
}
}
//
// OnChannelDataReadyEvent: Call back to handle data from expert
//
function OnChannelDataReadyEvent(channelID)
{
var str = null;
if (channelID == c_szChatChannelID)
{
//
// Data on chat channel
//
str = g_oSAFRemoteDesktopSession.ReceiveChannelData(channelID)
//
// Update chat history window with incoming data
//
incomingChatText.value = incomingChatText.value + L_cszExpertID + str;
incomingChatText.doScroll("scrollbarPageDown");
}
else if (channelID == c_szControlChannelID)
{
//
// Incoming data on the control channel
//
}
}
//
// ChatChannelDataReadyEvent: Call back to handle data from expert
//
function ChatChannelDataReadyEvent()
{
var str = null;
//
// Data on chat channel
//
str = g_oChatChannel.ReceiveChannelData();
//
// Update chat history window with incoming data
//
incomingChatText.value = incomingChatText.value + L_cszExpertID + str;
incomingChatText.doScroll("scrollbarPageDown");
return;
}
//
// ControlChannelDataReadyEvent: Call back to handle data from expert
//
function ControlChannelDataReadyEvent()
{
var str = null;
//
// Data on control channel
//
str = g_oControlChannel.ReceiveChannelData();
//
// Parse the data sent on the control channel
//
ParseControlData ( str );
return;
}
//
// ParseControlData: Parse the data sent on the control channel
//
function ParseControlData ( str )
{
var Doc = new ActiveXObject("microsoft.XMLDOM");
var RCCommand = null;
var szCommandName = null;
try
{
if( false == Doc.loadXML( str ))
{
alert ( L_ERRLOADXMLFAIL_MSG );
}
if ( Doc.parseError.reason != "")
{
alert( Doc.parseError.reason);
}
//
// Get the RCCOMMAND node
//
RCCommand = Doc.documentElement;
//
// Get the NAME of the command
//
szCommandName = RCCommand.getAttribute( c_szRCCommandName );
if( szCommandName == c_szFileXfer )
{
//
// File Transfer Initiation
//
var vArgs = new Array(6);
var FileXferWidth = "600";
var FileXferHeight = "500";
vArgs[0] = 1; // Destination Mode
vArgs[1] = g_oControlChannel; // Control Channel
vArgs[2] = g_oSAFRemoteDesktopChannelMgr; // Channel Manager
vArgs[3] = RCCommand.getAttribute( c_szFileName ); // FILENAME
vArgs[4] = RCCommand.getAttribute( c_szFileSize ); // FILESIZE
vArgs[5] = RCCommand.getAttribute( c_szChannelId ); // CHANNELID
window.showModelessDialog("../RCExpert/RCFileXfer.htm", vArgs, "dialogwidth:" + FileXferWidth + "px;dialogHeight:" + FileXferHeight + "px;status:no;resizable:yes");
}
else if ( szCommandName == c_szRemoteCtrlStart )
{
//
// Remote Control initiation
//
//
// Change mode display to "Remote control"
//
StatusID.innerText = c_szRCMODE;
incomingChatText.value = L_USECHATBOX_MSG;
FileXferId.disabled = true;
//AbortConnection.disabled = true;
}
else if ( szCommandName == c_szRemoteCtrlEnd )
{
//
// End of Remote Control
//
//
// Change mode display to "chat"
//
StatusID.innerText = c_szCHATMODE;
incomingChatText.value = "";
FileXferId.disabled = false;
//AbortConnection.disabled = false;
}
}
catch(error)
{
alert( error );
}
}
function OnClientConnected() {
StatusID.innerText = c_szCHATMODE;
}
function OnClientDisconnected() {
StatusID.innerText = L_EXPERTDISCONNECT_MSG ;
g_bUserDisconnect = false;
AbortConnection();
}
function OnEnter()
{
if (window.event.keyCode == 13)
{
SendChatButtonHandler();
}
}
//
// HideChatBox: Toggles the chat box controls
//
function HideChatBox()
{
if(false == g_bChatBoxHidden)
{
//
// Chatbox is visible. Hide it
//
chatText.style.visibility = "hidden";
sendChatButton.style.visibility = "hidden";
incomingChatText.style.visibility = "hidden";
g_bChatBoxHidden = true;
HideChat.value = L_SHOWCHAT;
}
else
{
//
// Chatbox is Hidden. Show it
//
chatText.style.visibility = "visible";
sendChatButton.style.visibility = "visible";
incomingChatText.style.visibility = "visible";
g_bChatBoxHidden = false;
HideChat.value = L_HIDECHAT;
}
}
//
// Disconnect: Disconnects the RC Connection made by Expert
//
function DisconnectRC()
{
var Doc = null;
var RCCommand = null;
try
{
//
// Create an XML document
//
Doc = new ActiveXObject("microsoft.XMLDOM");
//
// Create the RCCOMMAND root node
//
RCCommand = Doc.createElement( c_szRCCommand );
//
// Set the NAME attribute to DISCONNECTRC
//
RCCommand.setAttribute( c_szRCCommandName, c_szDisconnectRC );
//
// Send the XML across
//
if (false == g_bNewBinaries)
{
//
// Using Old interface
//
g_oSAFRemoteDesktopSession.SendChannelData( c_szControlChannelID, RCCommand.xml );
}
else
{
//
// Use new interface
//
g_oControlChannel.SendChannelData( RCCommand.xml );
}
}
catch(error)
{
alert( error );
}
}
var g_iChannelId = 1000;
//
// LaunchFileXfer: Launches the File Xfer UI
//
function LaunchFileXfer( mode )
{
var vArgs = new Array(4);
var FileXferWidth = "600";
var FileXferHeight = "500";
if(0 == mode)
{
vArgs[0] = mode; // Source Mode
vArgs[1] = g_oControlChannel; // Control Channel
vArgs[2] = g_oSAFRemoteDesktopChannelMgr; // Channel Manager
vArgs[3] = g_iChannelId++; // Channel ID
window.showModelessDialog("../RCExpert/RCFileXfer.htm", vArgs, "dialogwidth:" + FileXferWidth + "px;dialogHeight:" + FileXferHeight + "px;status:no;resizable:yes");
}
return;
}
</SCRIPT>
</BODY>
</HTML>