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.
 
 
 
 
 
 

1875 lines
43 KiB

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Remote Control Chat Server</TITLE>
<OBJECT ID=pchealth classid=CLSID:FC7D9E02-3F9E-11d3-93C0-00C04F72DAF7></OBJECT>
</HEAD>
<!--
Test
<BODY id="ChatServerId" onload=TransmitScreenInfo()>
-->
<BODY id="ChatServerId" onload=InitiateRCSession() bgcolor="#4a8ece" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!--
<BODY onUnload=cleanUp() id="ChatServerId" onload=InitiateRCSession() bgcolor="#4a8ece" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
-->
<!--
Title and control panel
-->
<div id=ChatServer STYLE="LEFT: 50px; POSITION: absolute; TOP: 50px; VISIBILITY: hidden">
<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="RemoteDataCollectionId" value="Remote Data Collection" onclick=LaunchRemoteDataCollection(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>
</div><!-- End of Chat Server div -->
<!--
//************************************************************************************
// Screens of Remote Data Collection
//************************************************************************************
-->
<div id=RemoteDataCollectionSrc STYLE="LEFT: 50px; POSITION: absolute; TOP: 50px; VISIBILITY: hidden">
<table id="table1" width="495" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#ffffff" height="400">
<tr>
<td align="middle" bgcolor="#99ccff"><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000"> Remote Data
Collection</font>
</td>
</tr>
<tr>
<td>
<table id="table2" border="0">
<tr>
<td>
<ol>
<LI>Click the <B>Browse</B> button to select the file that you want to transfer, or type the path to the file in the box below.<BR>
<center>
<nobr>
Attach File: <input name="attfile" type="file" LANGUAGE=javascript>
</nobr>
</center>
<p></p>
<LI>Click the <B>Send File</B> button to transfer the file.<BR>
The transfer of an attached file may require 30 seconds to up to 10 minutes.<BR>
<center>
<input type="button" id="btnSendFileId" value="Send File" style="HEIGHT: 24px; WIDTH: 100px" onclick=onSend()></button>
</center></LI>
</ol>
</td>
</tr>
<tr>
<td>
<div id="FileSizeSrcId" align="center" style="visibility: hidden">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<OBJECT classid=clsid:0713E8D2-850A-101B-AFC0-4210102A8DA7 id=ProgressBar2
style="HEIGHT: 25px; LEFT: 173px; TOP: 2px; WIDTH: 144px" VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="3810">
<PARAM NAME="_ExtentY" VALUE="661">
<PARAM NAME="_Version" VALUE="327682">
<PARAM NAME="BorderStyle" VALUE="0">
<PARAM NAME="Appearance" VALUE="1">
<PARAM NAME="MousePointer" VALUE="0">
<PARAM NAME="Enabled" VALUE="1">
<PARAM NAME="OLEDropMode" VALUE="0">
<PARAM NAME="Min" VALUE="0">
<PARAM NAME="Max" VALUE="100">
</OBJECT>
</div>
</td>
</tr>
</table> <!-- End of table2 -->
</td>
</tr>
</table>
</div><!-- End of RemoteDataCollectionSrc div --><!--
File Transfer Destination
-->
<div id=RemoteDataCollectionDestn STYLE="LEFT: 50px; POSITION: absolute; TOP: 50px; VISIBILITY: hidden">
<table width="495" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#ffffff" height="400">
<tr>
<td align="middle" bgcolor="#99ccff"><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000"> Remote Data
Collection </font>
</td>
</tr>
<tr>
<td align="middle">
<table border="0">
<tr>
<td align="middle"> <div id="Action"> </div> <div id="FileNameId"> &nbsp; </div> </td>
</tr>
<tr>
<td align="middle">
<div id="FileSizeDestnId">
<OBJECT classid=clsid:0713E8D2-850A-101B-AFC0-4210102A8DA7 id=ProgressBar3
style="HEIGHT: 26px; LEFT: 171px; TOP: -3px; WIDTH: 148px" VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="3916">
<PARAM NAME="_ExtentY" VALUE="688">
<PARAM NAME="_Version" VALUE="327682">
<PARAM NAME="BorderStyle" VALUE="0">
<PARAM NAME="Appearance" VALUE="1">
<PARAM NAME="MousePointer" VALUE="0">
<PARAM NAME="Enabled" VALUE="1">
<PARAM NAME="OLEDropMode" VALUE="0">
<PARAM NAME="Min" VALUE="0">
<PARAM NAME="Max" VALUE="100">
</OBJECT>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div><!-- End of RemoteDataCollectionDestn div -->
<!--
File Transfer Destination of the Data Collected RemoteDataCollectedDestn
-->
<div id=RemoteDataCollectedDestn STYLE="LEFT: 50px; POSITION: absolute; TOP: 50px; VISIBILITY: hidden">
<table width="495" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#ffffff" height="400">
<tr>
<td align="middle" bgcolor="#99ccff"><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000"> Remote Data
Collection </font>
</td>
</tr>
<tr>
<td align="middle">
<table border="0">
<tr>
<td align="middle"> Sending File: <div id="RDCFileNameId"> &nbsp; </div> </td>
</tr>
<tr>
<td align="middle">
<div id="FileSizeColDestnId">
<OBJECT classid=clsid:0713E8D2-850A-101B-AFC0-4210102A8DA7 id=ProgressBar1
style="HEIGHT: 26px; LEFT: 171px; TOP: -3px; WIDTH: 148px" VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="3916">
<PARAM NAME="_ExtentY" VALUE="688">
<PARAM NAME="_Version" VALUE="327682">
<PARAM NAME="BorderStyle" VALUE="0">
<PARAM NAME="Appearance" VALUE="1">
<PARAM NAME="MousePointer" VALUE="0">
<PARAM NAME="Enabled" VALUE="1">
<PARAM NAME="OLEDropMode" VALUE="0">
<PARAM NAME="Min" VALUE="0">
<PARAM NAME="Max" VALUE="100">
</OBJECT>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div><!-- End of RemoteDataCollectedDestn div -->
<!--
//************************************************************************************
// End of Remote Data Collection
//************************************************************************************
-->
<SCRIPT Language="JScript">
//
// Salem objects.
//
var vArgs = null;
var g_oSAFRemoteDesktopSession = null;
var g_oSAFRemoteDesktopChannelMgr = null;
var g_oChatChannel = null;
var g_oControlChannel = null;
var g_oDataChannel = null;
var g_oDataChannelRDC = 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";
var c_szRemoteDataCollection = "REMOTEDATACOLLECTION";
var c_szRemoteDataCollectMode = "REMOTEDATACOLLECTIONMODE";
var c_szRDCResponse = "DATARESPONSE";
var c_szRDCRequest = "DATAREQUEST";
var c_MAXFILEXFERSIZE = 10240;
var c_szFileXferACK = "FILEXFERACK";
var c_szFileEND = "FILEXFEREND";
//
// 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";
//********************************************************************
//*****************************************************************************
// constants for the data collection
//*****************************************************************************
// variables to track event notification and other tasks
//
var iMessageCount = 0;
var strTestReport = "Data Collection results\n"; // string containig the test results
// Data Collection Object (DC OBj) related variables.
//
var objDataColl; // The Data Collection object.
var strDataSpecFile; // The dataspec.xml file.
// constant declarations according to DC Obj Status property
//
var DC_NOTACTIVE = 0;
var DC_COLLECTING = 1;
var DC_FAILED = 2;
var DC_COMPLETED = 3;
var DC_NODELTA = 4;
var DC_COMPARING = 5;
// System Folders.
//
var strWindowsTempDir;
var strMachineFileName;
var strLogFile;
var g_iFileSize = 0;
var g_iSentCtr = 0;
var g_iRecvdCtr = 0;
var g_szFileName = null;
var g_szChannelId = null;
var fso = null;
var fileHandle = null;
var file = null;
var tFileName = null;
var tProgBarCounter = 0;
var tFileSize = 0;
//*****************************************************************************
//
// InitiateRCSession: Initiates the RC Session
//
function InitiateRCSession()
{
SetUIForChat();
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;
}
else if ( szCommandName == c_szRemoteDataCollection )
{
//
// File Transfer for remote data collection Initiation
//
var RDCMode = RCCommand.getAttribute( c_szRemoteDataCollectMode ) ;
//alert(" the mode received is : " + RDCMode);
g_szFileName = RCCommand.getAttribute( c_szFileName ); // FILENAME
//alert( "filename :"+ g_szFileName );
g_iFileSize = RCCommand.getAttribute( c_szFileSize ); // FILESIZE
//alert( "filesize :"+ g_iFileSize );
g_szChannelId = RCCommand.getAttribute( c_szChannelId ); // CHANNELID
//alert( "ChannelId :"+ g_szChannelId );
if ( c_szRDCRequest == RDCMode )
{
//alert("Creating the pchealth object from chatserver.htm");
try {
objDataColl = pchealth.CreateObject_DataCollection(); // data collection object
}
catch(err)
{
alert("Unable to create Data Collection object: " + err );
}
//
// File Transfer destination mode UI
//
ChatServer.style.visibility = "hidden";
RemoteDataCollectionSrc.style.visibility = "hidden";
RemoteDataCollectionDestn.style.visibility = "visible";
Action.innerText = "Receiving File :";
RemoteDataCollectedDestn.style.visibility = "hidden";
FileSizeSrcId.style.visibility = "hidden";
FileSizeDestnId.style.visibility = "visible";
//
// Update filename and filesize in UI
//
//alert("FileNameId.innerText = g_szFileName");
FileNameId.innerText = g_szFileName;
g_iRecvdCtr = 0;
FileSizeDestnId.style.visibility = "visible";
tProgBarCounter = Math.ceil(g_iFileSize/c_MAXFILEXFERSIZE);
try
{
//
// Create the data channel for file transfer if necessary
//
if(null == g_oDataChannel)
{
//alert(" Initialising the data channel if necessary");
g_oDataChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( g_szChannelId );
//alert(" Created the data channel");
//
// Bind the OnChannelDataReady event handler
//
g_oDataChannel.OnChannelDataReady = function()
{ DestnDataChannelDataCollectHandler(); }
//alert(" Associated a func. with the channeldataready event");
}
}
catch(error)
{
alert( L_ERRFAILDATACHANNELCREATION_MSG );
//
// Todo: Add code to handle error here
//
}
//
// Create temp file for staging while file is XFered
//
alert(" Creation of file object");
fso = new ActiveXObject("Scripting.FileSystemObject");
var tFolder = fso.GetSpecialFolder(0); // Get Path to system config directory.
tFileName = tFolder + "\\temp\\" + g_szFileName;
//alert( "Create text file tFileName: " + tFileName );
try {
fileHandle = fso.CreateTextFile( tFileName );
}
catch(err)
{
alert("In mode 1, " + err );
}
//
// Send ACK to source to make it begin pumping data on the data channel
//
//alert(" Sending ACK");
if ( null != g_oDataChannel )
{
g_oDataChannel.SendChannelData( c_szFileXferACK );
}
else
{
alert("Problem in initialising the datachannel");
}
}
}
}
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;
}
//********************************************************************************
// For data collection.
//********************************************************************************
//*****************************************************************************//
// creates a DC Obj and initialize its members.
//
function constructor()
{
if ( null != fso )
{
// if BVT success notification file exists, delete it.
//
//alert("Inside the constructor");
if ( null != objDataColl )
{
//alert("Creation of Data Collection Object already done");
}
//alert("Setup of Machine Data property ");
objDataColl.MachineData_DataSpec = strDataSpecFile;
//alert("Registering For Event Notification ");
objDataColl.onStatusChange = dc_onStatusChange;
objDataColl.onProgress = dc_onProgress;
objDataColl.onComplete = dc_onComplete;
}
}
function dc_onStatusChange( dcObj, Status )
{
}
function dc_onProgress( dcObj, lDone, lTotal )
{
}
function dc_onComplete( dcObj, hResult )
{
// Print the asynchronous execution result
// if succeeded, try to save the data
//
if ( hResult == 0 )
{
var strmMachine; // file streams
// Asynchronous Data Collection Execution PASSed
//
// get dataspec file name
//
strMachineFileName = strWindowsTempDir + "\\machineDATA.xml";
alert("The file to look out for is : " + strMachineFileName);
// alert("Getting file stream for machine data ");
strmMachine = dcObj.MachineData_GetStream();
if( strmMachine == null )
{
alert("file stream for machine data FAIL");
}
else
{
//alert("file stream for machine data PASS");
if( fso.FileExists( strMachineFileName ) )
{
alert("delete the file if it exist");
fso.DeleteFile( strMachineFileName );
}
alert("Attempting to save machine data ");
try {
pchealth.CopyStreamToFile( strMachineFileName , strmMachine );
}
catch(error)
{
alert("Unablr to copy to the file :" + error );
}
if( fso.FileExists(strMachineFileName) )
{
//alert("Data saved!");
}
else
{
}
}
// Reset UI for sending the data collected.
//
// File Transfer destination mode
//
ResetUIForRDC();
// send the data across.
alert("Sending the " + strMachineFileName + "across");
SendDataCollected( strMachineFileName );
}
else
{
// Asynchronous Data Collection Execution FAILed
//
alert("Asynchronous Data Collection Execution FAILed");
}
// Lets clean up the system (remove temporary files) but don't unload the page
//
cleanUp();
}
// get the HelpCtr System subdirectories to store temporarily this htm page for the BVT
// and also get the Config subdir to get the dataspec.xml file from.
//
function getHelpCtrDirs()
{
var WindowsDir = fso.GetSpecialFolder(0);
//alert("WindowsDir is " + WindowsDir);
strWindowsTempDir = WindowsDir + "\\temp";
strLogFile = strWindowsTempDir + "\\DCObjRDC.log";
}
// Prints a message in the html page and update the log file
//
function Print( line )
{
var strTemp = line.toUpperCase(); // temporary string
var iStringMaxLength = 42;
// if not a end line message like "PASS<BR>" add dots at the end of message
//
if( strTemp.search("<BR>") == -1 )
{
var iAddDots = iStringMaxLength - line.length;
iMessageCount++;
for( i = 0; i < iAddDots; i++ )
{
line += ".";
}
line = iMessageCount + ". " + line;
}
var regExpression = /<BR>/g;
strTestReport += line;
strTestReport = strTestReport.replace(regExpression, "\n");
// create the log file, if already done, overwrite it
//
var strmLogFile = fso.CreateTextFile( strLogFile , true ); // A stream to the log file.
strmLogFile.WriteLine(strTestReport);
strmLogFile.Close();
out.innerHTML += line;
}
// delete data collection files
//
function cleanUp()
{
// stops data collection if in progress and release the DC Obj.
//
if( objDataColl != null && objDataColl.Satus != DC_COLLECTING )
{ objDataColl.Abort(); }
}
// close this page and clens up any garbagr the script has generated
//
function closeWindow()
{
try
{
// Print( "<BR>Closing window<BR>" );
pchealth.Close();
}
catch(exception)
{
//Print( "Caught exception " + exception + " in closing window<BR>" );
}
}
function ResetUIForRDC()
{
//alert("Reseting the UI for sending the data collected");
RemoteDataCollectionSrc.style.visibility = "hidden";
RemoteDataCollectionDestn.style.visibility = "hidden";
RemoteDataCollectedDestn.style.visibility = "visible";
FileSizeColDestnId.style.visibility = "visible";
tProgBarCounter = Math.ceil(g_iFileSize/c_MAXFILEXFERSIZE);
}
function SetUIForChat()
{
ChatServer.style.visibility = "visible";
RemoteDataCollectionSrc.style.visibility = "hidden";
RemoteDataCollectionDestn.style.visibility = "hidden";
RemoteDataCollectedDestn.style.visibility = "hidden";
FileSizeSrcId.style.visibility = "hidden";
FileSizeDestnId.style.visibility = "hidden";
FileSizeColDestnId.style.visibility = "hidden";
}
//**************************************************************************
// the data collection.
//**************************************************************************
function CollectData()
{
// alert("Getting the helpctr directories");
getHelpCtrDirs();
// alert("Getting the dataspec.xml file");
var tFolder = fso.GetSpecialFolder(0); // Get Path to system config directory.
tFileName = tFolder + "\\temp\\" + g_szFileName;
strDataSpecFile = tFileName;
// alert("strDataSpecFile : " + strDataSpecFile);
constructor(); // initialize object and properties.
alert("Executing Asynchronous Data Collection ");
try {
Action.innerText = "Executing the following script to collect data :";
objDataColl.ExecuteAsync();
}
catch(err) {
alert("executeaync as usual fails" + err);
}
}
//********************************************************************************
//
// onSend: This routine is fired when the "Send File" button is clicked
//
function onSend()
{
var fileName = attfile.value;
var ForReading = 1, ForWriting = 2, ForAppending = 8;
var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
var Doc = null;
var RCCommand = null;
//
// Open the File for reading
//
try
{
//
// Create the filesystem object
//
fso = new ActiveXObject("Scripting.FileSystemObject");
//
// Open the file
//
file = fso.GetFile(fileName);
fileHandle = file.OpenAsTextStream(ForReading,TristateUseDefault);
}
catch(error)
{
alert( L_ERROPENINGFILEFORREAD_MSG + fileName );
}
//
// Initiate File Xfer
//
try
{
//
// Create an XML document
//
Doc = new ActiveXObject("microsoft.XMLDOM");
}
catch (err)
{
alert("new object: " + err);
}
try {
//
// Create the RCCOMMAND root node
//
RCCommand = Doc.createElement( c_szRCCommand );
}
catch (err)
{
alert("create element :" + err);
}
try {
//
// Set the NAME attribute to FILEXFER
//
RCCommand.setAttribute( c_szRCCommandName, c_szRemoteDataCollection );
}
catch (err)
{
alert("setAttribute for datacollection :" + err);
}
try {
//
// Set the DATA COLLECTION MODE attribute
//
RCCommand.setAttribute( c_szRemoteDataCollectMode, c_szRDCRequest );
}
catch (err)
{
alert("set attribute for RDCRequest: " + err );
}
try {
//
// Set the FILENAME attribute
//
RCCommand.setAttribute( c_szFileName, file.Name );
}
catch(err)
{
alert("set attribute file name :" + err);
}
try {
//
// Set the FILESIZE attribute
//
RCCommand.setAttribute( c_szFileSize, file.size );
}
catch(err)
{
alert("set attribute for file size : " + err );
}
try {
//
// Set the CHANNELID attribute
//
// alert( " channel id is : " + g_iChannelId );
RCCommand.setAttribute( c_szChannelId, g_iChannelId );
}
catch(err)
{
alert("set attribute channel id: " + err);
}
try {
//
// Send the XML across
//
// alert("the xml sent across is :" + RCCommand.xml);
g_oControlChannel.SendChannelData( RCCommand.xml );
}
catch(error)
{
alert ( L_ERRFILEXFERINITFAILED_MSG );
}
//
// Create the data channel for Filetransfer
//
try
{
if(null == g_oDataChannel)
{
// alert("The data channel is null");
}
if ( null == g_oDataChannel )
{
g_oDataChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( g_iChannelId );
}
}
catch(error)
{
alert( L_ERRFAILDATACHANNELCREATION_MSG );
}
try
{
if(null != g_oDataChannel)
{
//
// Bind the OnChannelDataReady event handler
//
g_oDataChannel.OnChannelDataReady = function()
{ SrcDataChannelDataReadyHandler(); }
}
}
catch(error)
{
alert( "Problem in binding the handler");
}
//
// Enable progress bar
//
FileSizeSrcId.style.visibility = "visible";
return;
}
//
// SrcDataChannelDataReadyHandler: Fired when file Xfer src receives data from
// the file Xfer destn on the data channel
//
function SrcDataChannelDataReadyHandler()
{
//alert("Start sending data");
//
// Start sending data
//
SendFileData();
//
// We are done. Close the window
//
window.close();
//
// Create the data channel for Data transfer
//
try
{
if(null == g_oDataChannelRDC)
{
// g_szChannelId;
Mode = 2;
g_oDataChannelRDC = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( g_szChannelId );
//
// Bind the OnChannelDataReady event handler
//
g_oDataChannelRDC.OnChannelDataReady = function()
{ DestnDataChannelDataReadyHandler(); }
}
}
catch(error)
{
alert( L_ERRFAILDATACHANNELCREATION_MSG );
}
return;
}
//
// SendFileData: Sends currently open file to destination
//
function SendFileData()
{
var stream = null;
if ( fileHandle!= null )
{
//
// Enable display of file xfer status in the UI
//
FileSizeSrcId.style.visibility = "visible";
g_iSentCtr = 0;
//
// While there is data to send
//
tProgBarCounter = Math.ceil((file.size)/c_MAXFILEXFERSIZE);
tFileSize = file.size;
while (!fileHandle.AtEndOfStream)
{
try
{
stream = null;
//
// Read File
//
stream = fileHandle.Read( c_MAXFILEXFERSIZE );
//
// Update UI
//
g_iSentCtr+= stream.length;
//
// Send data over the data channel
//
g_oDataChannel.SendChannelData( stream );
//alert("Sent data");
if ( tProgBarCounter > 0 )
{
ProgressBar2.Value = (100/tProgBarCounter);
tProgBarCounter--;
}
}
catch(error)
{
alert( L_ERRDATACHANNELSEND_MSG );
}
}
alert("The End of file has been reached with size " + g_iSentCtr);
if ( g_iSentCtr != tFileSize )
{
g_oDataChannel.SendChannelData( c_szFileEND );
}
//
// Close the file
//
fileHandle.Close();
}
else
{
alert( L_ERRINVALIDFILEHANDLE_MSG );
}
return;
}
function DestnDataChannelDataCollectHandler()
{
var str = null;
// alert("Recvd data");
//
// receiving incoming data
//
str = g_oDataChannel.ReceiveChannelData();
// alert(str);
if ( c_szFileXferACK != str )
{
//
// Update UI
//
g_iRecvdCtr += str.length;
//
// Write str to open temp file
//
fileHandle.Write( str );
// alert("g_iRecvdCtr :" + g_iRecvdCtr );
if ( tProgBarCounter > 0 )
{
ProgressBar1.Value = (100/tProgBarCounter);
tProgBarCounter--;
}
//
// If g_iRecvdCtr == g_iFileSize;
// - launch File Open/Save dialog
// - close data connection
if( g_iRecvdCtr == g_iFileSize )
{
// alert( "File received" );
//
// Close open temp file handle
//
fileHandle.Close();
// run the script. collect data in a file.
CollectData();
}
}
else
{
// alert("Sending the data file");
SendFileData();
SetUIForChat();
}
return;
}
//
// SendDataCollected: This routine is fired when the "Send File" button is clicked
//
function SendDataCollected( filename )
{
var fileName = filename;
var ForReading = 1, ForWriting = 2, ForAppending = 8;
var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
var Doc = null;
var RCCommand = null;
// alert("Inside the SendDataCollected func.");
//
// Open the File for reading
//
try
{
//
// Create the filesystem object
//
if ( null == fso )
{
fso = new ActiveXObject("Scripting.FileSystemObject");
}
//
// Open the file
//
// BUG:: The file size varies with the type of file being UNICODE or not.
// The type needs to be checked before opening it in any particular mode.
file = fso.GetFile(fileName);
fileHandle = file.OpenAsTextStream(ForReading,TristateTrue);
}
catch(error)
{
alert( L_ERROPENINGFILEFORREAD_MSG + fileName );
}
//
// Initiate File Xfer
//
try
{
//
// Create an XML document
//
Doc = new ActiveXObject("microsoft.XMLDOM");
//
// Create the RCCOMMAND root node
//
// alert("creating the RCCommand");
RCCommand = Doc.createElement( c_szRCCommand );
//
// Set the NAME attribute to FILEXFER
//
// alert("Set the attribute for command name :" + c_szRemoteDataCollection);
RCCommand.setAttribute( c_szRCCommandName, c_szRemoteDataCollection );
//
// Set the FILENAME attribute
//
// alert("Set the attribute filename name :" + file.Name);
RCCommand.setAttribute( c_szFileName, file.Name );
//
// Set the FILESIZE attribute
//
alert("Set the attribute filename size :" + file.size);
RCCommand.setAttribute( c_szFileSize, file.size );
//
// Set the CHANNELID attribute
//
// alert("Set the attribute channel id :" + g_szChannelId);
RCCommand.setAttribute( c_szChannelId, g_szChannelId );
//
// Set the RDC Mode
//
// alert("Set the attribute mode :" + c_szRDCResponse);
RCCommand.setAttribute( c_szRemoteDataCollectMode, c_szRDCResponse);
//
// Send the XML across
//
// alert("the text that's sent across: " + RCCommand.xml );
g_oControlChannel.SendChannelData( RCCommand.xml );
}
catch(error)
{
alert ( L_ERRFILEXFERINITFAILED_MSG );
}
//
// Create the data channel for Filetransfer
//
try
{
if(null == g_oDataChannel)
{
g_oDataChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( g_szChannelId );
//
// Bind the OnChannelDataReady event handler
//
g_oDataChannel.OnChannelDataReady = function()
{ SrcDataChannelDataReadyHandler(); }
}
}
catch(error)
{
alert( L_ERRFAILDATACHANNELCREATION_MSG );
}
//
// Enable progress bar
//
FileSizeSrcId.style.visibility = "visible";
return;
}
//
// SrcDataChannelDataReadyHandler: Fired when file Xfer src receives data from
// the file Xfer destn on the data channel
//
function SrcDataChannelDataReadyHandler()
{
//alert("Start sending data");
//
// Start sending data
//
SendFileData();
return;
}
</SCRIPT>
</BODY>
</HTML>