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.

826 lines
17 KiB

  1. <HTML>
  2. <!--
  3. ChatServer.htm: Implementation of the helpee chat window and controls
  4. Rajesh Soy (nsoy) - updated for new UI 08/18/2000
  5. -->
  6. <HEAD>
  7. <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
  8. <TITLE>Remote Control Help Session</TITLE>
  9. <LINK id="UI_StyleSheet" REL="stylesheet" TYPE="text/css" HREF="rc.css">
  10. </HEAD>
  11. <BODY onload=InitiateRCSession()>
  12. <div id="ChatServerId" class="styHelpBackGround">
  13. <!--
  14. Title and control panel
  15. -->
  16. <table>
  17. <tr>
  18. <td>
  19. <table width="100%" cellspacing="0" cellpadding="0">
  20. <tr>
  21. <table align="left" >
  22. <tr>
  23. <td><FONT class=styHeader>Help Session
  24. </FONT>
  25. </td>
  26. <td align=left>
  27. <div id=idHelperName> &nbsp;&nbsp; </div>
  28. </td>
  29. </tr>
  30. </table>
  31. </tr>
  32. <tr>
  33. <td valign="center">
  34. <table align="right" >
  35. <tr>
  36. <td> <BUTTON align="center" CLASS="styButton" id="FileXferId" onclick=LaunchFileXfer(0)> Send a File... </BUTTON> </td>
  37. <td> <BUTTON align="center" CLASS="styButton" id=btnAbortConnection onclick=AbortConnection()
  38. > Quit </BUTTON> </td>
  39. <td> <BUTTON align="center" CLASS="styButton" id=btnHelp onclick=LaunchHelp()> Help </BUTTON> </td>
  40. </tr>
  41. </table>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td colspan=4> <hr class="styHorzLine" style="LEFT: 0px; TOP: 8px"
  46. > </td>
  47. </tr>
  48. <tr>
  49. <td colspan=3>
  50. <div id=idStatus> </div>
  51. </td>
  52. <td align=right>
  53. <div id=idtogglechat onclick=HideChatBox()> </div>
  54. </td>
  55. </tr>
  56. </table>
  57. </td>
  58. </tr>
  59. <TR><!--
  60. Incoming chat display area
  61. -->
  62. <TD><TEXTAREA cols=40 id=incomingChatText name=incomingChatText readOnly rows=3 wrap=VIRTUAL multiline="true"></TEXTAREA>
  63. </TD>
  64. </TR>
  65. <TR><!--
  66. Chat text box
  67. -->
  68. <TD><TEXTAREA cols=27 id=chatText name=chatText onkeypress=OnEnter() rows=1 wrap=VIRTUAL></TEXTAREA>&nbsp;&nbsp;&nbsp;
  69. <input class="styButton" type="submit" id=sendChatButton name=sendChatButton onclick=SendChatButtonHandler() value="Submit"></TD>
  70. </TR>
  71. </table>
  72. </div>
  73. <SCRIPT Language="JScript">
  74. //
  75. // Salem objects.
  76. //
  77. var vArgs = null;
  78. var g_oSAFRemoteDesktopSession = null;
  79. var g_oSAFRemoteDesktopChannelMgr = null;
  80. var g_oChatChannel = null;
  81. var g_oControlChannel = null;
  82. if(null == parent.oRCSession)
  83. {
  84. //alert("Dialog");
  85. vArgs = window.dialogArguments;
  86. g_oSAFRemoteDesktopSession = vArgs;
  87. }
  88. else
  89. {
  90. //alert("not a dialog");
  91. g_oSAFRemoteDesktopSession = parent.oRCSession;
  92. }
  93. //
  94. // Globals
  95. //
  96. var g_bChatBoxHidden = false;
  97. var g_bNewBinaries = false;
  98. var g_bUserDisconnect = true;
  99. var g_bChatMode = true;
  100. var g_FileXferWidth = "400";
  101. var g_FileXferHeight = "140";
  102. //
  103. // Constants
  104. //
  105. var c_szChatChannelID = "70";
  106. var c_szControlChannelID = "71";
  107. var c_szHomePage = "hcp://system/HomePage.htm";
  108. var c_szRCCommand = "RCCOMMAND";
  109. var c_szRCCommandName = "NAME";
  110. var c_szScreenInfo = "SCREENINFO";
  111. var c_szWidth = "WIDTH";
  112. var c_szHeight = "HEIGHT";
  113. var c_szColorDepth = "COLORDEPTH";
  114. var c_szDisconnectRC = "DISCONNECTRC";
  115. var c_szFileXfer = "FILEXFER";
  116. var c_szFileName = "FILENAME";
  117. var c_szFileSize = "FILESIZE";
  118. var c_szChannelId = "CHANNELID";
  119. var c_szRemoteCtrlStart = "REMOTECTRLSTART";
  120. var c_szRemoteCtrlEnd = "REMOTECTRLEND";
  121. var c_szRCMODE = "REMOTE CONTROL";
  122. var c_szCHATMODE = "CHAT";
  123. var c_szFileXferURL = "../RCExpert/RCFileXfer.htm";
  124. //
  125. // Desktop Control Permissions
  126. //
  127. var DESKTOPSHARING_DEFAULT = 0x0000;
  128. var NO_DESKTOP_SHARING = 0x0001;
  129. var VIEWDESKTOP_PERMISSION_REQUIRE = 0x0002;
  130. var VIEWDESKTOP_PERMISSION_NOT_REQUIRE = 0x0004;
  131. var CONTROLDESKTOP_PERMISSION_REQUIRE = 0x0008;
  132. var CONTROLDESKTOP_PERMISSION_NOT_REQUIRE = 0x00010;
  133. //
  134. // Localizable contants
  135. //
  136. var L_cszExpertID = "\n Helper> ";
  137. var L_cszUserID = "\n Helpee> ";
  138. var L_HIDECHAT = "Hide Chat Boxes";
  139. var L_SHOWCHAT = "Show Chat Boxes";
  140. //
  141. // Messages
  142. //
  143. var L_EXPERTDISCONNECT_MSG = "Helper disconnected.";
  144. var L_EXPERTCONNECTED_MSG = "Helper connected.";
  145. var L_ABORTINGCONNECTION_MSG = "Terminating Remote control connection from Helper";
  146. 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";
  147. //
  148. // Error Messages
  149. //
  150. var L_ERRNULLRCSESSION = "RCSession object is not defined";
  151. //
  152. // InitiateRCSession: Initiates the RC Session
  153. //
  154. function InitiateRCSession()
  155. {
  156. //
  157. // Initialization
  158. //
  159. idtogglechat.innerHTML = "<div class=styText> Hide Chat <img src=\"hide-chat.gif\"> </div>";
  160. g_bNewBinaries = true;
  161. //
  162. // To Do: File the Helper's name
  163. //
  164. idHelperName.innerText = "( Place Holder )";
  165. idStatus.innerHTML = "<div class=styText> <IMG src=\"status_connected.gif\"> <STRONG>Status</STRONG> :Connected </div>";
  166. if(null == g_oSAFRemoteDesktopSession)
  167. {
  168. alert( L_ERRNULLRCSESSION );
  169. }
  170. else
  171. {
  172. var x;
  173. try
  174. {
  175. if (false == g_bNewBinaries)
  176. {
  177. //
  178. // Using Old interface
  179. //
  180. //
  181. // Add the chat channel
  182. //
  183. g_oSAFRemoteDesktopSession.AddChannels( c_szChatChannelID );
  184. //
  185. // Add the control channel
  186. //
  187. g_oSAFRemoteDesktopSession.AddChannels( c_szControlChannelID );
  188. //
  189. // Bind OnChannelDataReady callback
  190. //
  191. g_oSAFRemoteDesktopSession.OnChannelDataReady = function(channelID)
  192. { OnChannelDataReadyEvent(channelID); }
  193. }
  194. else
  195. {
  196. //
  197. // Use new interface
  198. //
  199. //
  200. // Get the Channel Manager
  201. //
  202. //alert("Getting ChannelManager");
  203. g_oSAFRemoteDesktopChannelMgr = g_oSAFRemoteDesktopSession.ChannelManager;
  204. //
  205. // Open the Chat channel
  206. //
  207. //alert("Opening ChatChannel");
  208. g_oChatChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szChatChannelID );
  209. //
  210. // Open the Control Channel
  211. //
  212. //alert("Opening Control Channel");
  213. g_oControlChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szControlChannelID );
  214. //
  215. // Setup the ChannelDataReady handlers
  216. //
  217. //alert("Binding Events");
  218. g_oChatChannel.OnChannelDataReady = function()
  219. { ChatChannelDataReadyEvent(); }
  220. g_oControlChannel.OnChannelDataReady = function()
  221. { ControlChannelDataReadyEvent(); }
  222. HideChat.value = L_HIDECHAT;
  223. }
  224. }
  225. catch(x)
  226. {
  227. // no big deal ... it just means that the channel was added
  228. // by a previous instance.
  229. }
  230. //
  231. // Setup the OnDisconnected event callback
  232. //
  233. g_oSAFRemoteDesktopSession.OnDisconnected = function()
  234. { OnClientDisconnected(); }
  235. }
  236. try
  237. {
  238. //
  239. // Also, Enable Remote Control
  240. //
  241. //alert("Enabling Remote Control");
  242. EnableRemoteControl();
  243. //
  244. // Transmit screen resolution to Expert, so that
  245. // he has the right screen size to see in the RC Tool
  246. //
  247. //alert("Transmitting screen info");
  248. TransmitScreenInfo();
  249. //StatusID.innerText = c_szCHATMODE;
  250. }
  251. catch(error)
  252. {
  253. alert(error);
  254. }
  255. }
  256. //
  257. // TransmitScreenInfo: Sends the user's screen resolution to the expert
  258. //
  259. function TransmitScreenInfo()
  260. {
  261. var Doc = null;
  262. var RCCommand = null;
  263. try
  264. {
  265. //
  266. // Create an XML document
  267. //
  268. Doc = new ActiveXObject("microsoft.XMLDOM");
  269. //
  270. // Create the RCCOMMAND root node
  271. //
  272. RCCommand = Doc.createElement( c_szRCCommand );
  273. //
  274. // Set the NAME attribute to SCREENINFO
  275. //
  276. RCCommand.setAttribute( c_szRCCommandName, c_szScreenInfo );
  277. //
  278. // Set the WIDTH attribute
  279. //
  280. RCCommand.setAttribute( c_szWidth, screen.width );
  281. //
  282. // Set the HEIGHT attribute
  283. //
  284. RCCommand.setAttribute( c_szHeight, screen.height );
  285. //
  286. // Set the COLORDEPTH attribute
  287. //
  288. RCCommand.setAttribute( c_szColorDepth, screen.colorDepth );
  289. //
  290. // Send the XML across
  291. //
  292. if (false == g_bNewBinaries)
  293. {
  294. //
  295. // Using Old interface
  296. //
  297. g_oSAFRemoteDesktopSession.SendChannelData( c_szControlChannelID, RCCommand.xml );
  298. }
  299. else
  300. {
  301. //
  302. // Use new interface
  303. //
  304. g_oControlChannel.SendChannelData( RCCommand.xml );
  305. }
  306. }
  307. catch(error)
  308. {
  309. alert( error );
  310. }
  311. }
  312. //
  313. // EnableRemoteControl: This routine enables remote control
  314. //
  315. function EnableRemoteControl()
  316. {
  317. if(null != g_oSAFRemoteDesktopSession)
  318. {
  319. if (false == g_bNewBinaries)
  320. {
  321. //
  322. // Using Old interface
  323. //
  324. g_oSAFRemoteDesktopSession.EnableRemoteControl( "" );
  325. }
  326. else
  327. {
  328. //
  329. // Use the new interface
  330. //
  331. //alert("remote control permissions: ");
  332. //alert("Existing: " + g_oSAFRemoteDesktopSession.SharingClass);
  333. g_oSAFRemoteDesktopSession.SharingClass = CONTROLDESKTOP_PERMISSION_NOT_REQUIRE;
  334. }
  335. }
  336. }
  337. //
  338. // DisableRemoteControl: Routine to disable Remote Control
  339. //
  340. function DisableRemoteControl()
  341. {
  342. if(null != g_oSAFRemoteDesktopSession)
  343. {
  344. if (false == g_bNewBinaries)
  345. {
  346. //
  347. // Using Old interface
  348. //
  349. g_oSAFRemoteDesktopSession.DisableRemoteControl( "" );
  350. }
  351. else
  352. {
  353. //
  354. // Use the new interface
  355. //
  356. g_oSAFRemoteDesktopSession.RemoteControlPermissions = NO_DESKTOP_SHARING;
  357. }
  358. }
  359. }
  360. //
  361. // AbortConnection: Routine that disconnects the session
  362. //
  363. function AbortConnection()
  364. {
  365. if (false == g_bNewBinaries)
  366. {
  367. //
  368. // Using Old interface
  369. //
  370. if (g_oSAFRemoteDesktopSession != null)
  371. {
  372. g_oSAFRemoteDesktopSession.StopListening();
  373. }
  374. //
  375. // Remove the chat channel
  376. //
  377. g_oSAFRemoteDesktopSession.RemoveChannels( c_szChatChannelID );
  378. //
  379. // Remove the control channel
  380. //
  381. g_oSAFRemoteDesktopSession.RemoveChannels( c_szControlChannelID );
  382. }
  383. else
  384. {
  385. //
  386. // Using New interfaces
  387. //
  388. //
  389. // Disconnect the connection to Helper, if the connection is broken by the Helpee
  390. //
  391. if(true == g_bUserDisconnect)
  392. {
  393. DisconnectRC();
  394. }
  395. }
  396. //
  397. // Close this window
  398. //
  399. //window.close();
  400. //
  401. // Close the session
  402. //
  403. //alert("Closing Session");
  404. try
  405. {
  406. g_oSAFRemoteDesktopSession.CloseRemoteDesktopSession();
  407. }
  408. catch(error)
  409. {
  410. alert(error);
  411. }
  412. parent.navigate( c_szHomePage );
  413. return;
  414. }
  415. //
  416. // SendChatButtonHandler: Routine to send chat data
  417. //
  418. function SendChatButtonHandler()
  419. {
  420. if (g_oSAFRemoteDesktopSession != null)
  421. {
  422. if ( true == g_bChatMode)
  423. {
  424. //
  425. // If We are in Chat Mode. Only then send the data across
  426. //
  427. if (false == g_bNewBinaries)
  428. {
  429. //
  430. // Using Old interface
  431. //
  432. //
  433. // Send data on the chat channel
  434. //
  435. g_oSAFRemoteDesktopSession.SendChannelData(c_szChatChannelID, chatText.value);
  436. }
  437. else
  438. {
  439. //
  440. // Use the new interface
  441. //
  442. g_oChatChannel.SendChannelData( chatText.value );
  443. }
  444. //
  445. // Update user's chat history window
  446. //
  447. incomingChatText.value = incomingChatText.value + L_cszUserID + chatText.value;
  448. }
  449. else
  450. {
  451. //
  452. // This is remote control Mode
  453. //
  454. //
  455. // Update user's chat history window
  456. //
  457. incomingChatText.value = incomingChatText.value + "\n> " + chatText.value;
  458. }
  459. //
  460. // Clear up the chat message window
  461. //
  462. chatText.value="";
  463. incomingChatText.doScroll("scrollbarPageDown");
  464. }
  465. }
  466. //
  467. // OnChannelDataReadyEvent: Call back to handle data from expert
  468. //
  469. function OnChannelDataReadyEvent(channelID)
  470. {
  471. var str = null;
  472. if (channelID == c_szChatChannelID)
  473. {
  474. //
  475. // Data on chat channel
  476. //
  477. str = g_oSAFRemoteDesktopSession.ReceiveChannelData(channelID)
  478. //
  479. // Update chat history window with incoming data
  480. //
  481. incomingChatText.value = incomingChatText.value + L_cszExpertID + str;
  482. incomingChatText.doScroll("scrollbarPageDown");
  483. }
  484. else if (channelID == c_szControlChannelID)
  485. {
  486. //
  487. // Incoming data on the control channel
  488. //
  489. }
  490. }
  491. //
  492. // ChatChannelDataReadyEvent: Call back to handle data from expert
  493. //
  494. function ChatChannelDataReadyEvent()
  495. {
  496. var str = null;
  497. //
  498. // Data on chat channel
  499. //
  500. str = g_oChatChannel.ReceiveChannelData();
  501. //
  502. // Update chat history window with incoming data
  503. //
  504. incomingChatText.value = incomingChatText.value + L_cszExpertID + str;
  505. incomingChatText.doScroll("scrollbarPageDown");
  506. return;
  507. }
  508. //
  509. // ControlChannelDataReadyEvent: Call back to handle data from expert
  510. //
  511. function ControlChannelDataReadyEvent()
  512. {
  513. var str = null;
  514. //
  515. // Data on control channel
  516. //
  517. str = g_oControlChannel.ReceiveChannelData();
  518. //
  519. // Parse the data sent on the control channel
  520. //
  521. ParseControlData ( str );
  522. return;
  523. }
  524. //
  525. // ParseControlData: Parse the data sent on the control channel
  526. //
  527. function ParseControlData ( str )
  528. {
  529. var Doc = new ActiveXObject("microsoft.XMLDOM");
  530. var RCCommand = null;
  531. var szCommandName = null;
  532. try
  533. {
  534. if( false == Doc.loadXML( str ))
  535. {
  536. alert ( L_ERRLOADXMLFAIL_MSG );
  537. }
  538. if ( Doc.parseError.reason != "")
  539. {
  540. alert( Doc.parseError.reason);
  541. }
  542. //
  543. // Get the RCCOMMAND node
  544. //
  545. RCCommand = Doc.documentElement;
  546. //
  547. // Get the NAME of the command
  548. //
  549. szCommandName = RCCommand.getAttribute( c_szRCCommandName );
  550. if( szCommandName == c_szFileXfer )
  551. {
  552. //
  553. // File Transfer Initiation
  554. //
  555. var vArgs = new Array(6);
  556. vArgs[0] = 1; // Destination Mode
  557. vArgs[1] = g_oControlChannel; // Control Channel
  558. vArgs[2] = g_oSAFRemoteDesktopChannelMgr; // Channel Manager
  559. vArgs[3] = RCCommand.getAttribute( c_szFileName ); // FILENAME
  560. vArgs[4] = RCCommand.getAttribute( c_szFileSize ); // FILESIZE
  561. vArgs[5] = RCCommand.getAttribute( c_szChannelId ); // CHANNELID
  562. window.showModelessDialog( c_szFileXferURL, vArgs, "dialogwidth:600px;dialogHeight:500px;status:no;resizable:yes");
  563. }
  564. else if ( szCommandName == c_szRemoteCtrlStart )
  565. {
  566. //
  567. // Remote Control initiation
  568. //
  569. //
  570. // Change mode display to "Remote control"
  571. //
  572. //StatusID.innerText = c_szRCMODE;
  573. incomingChatText.value = L_USECHATBOX_MSG;
  574. FileXferId.disabled = true;
  575. //AbortConnection.disabled = true;
  576. g_bChatMode = false;
  577. }
  578. else if ( szCommandName == c_szRemoteCtrlEnd )
  579. {
  580. //
  581. // End of Remote Control
  582. //
  583. //
  584. // Change mode display to "chat"
  585. //
  586. //StatusID.innerText = c_szCHATMODE;
  587. incomingChatText.value = "";
  588. FileXferId.disabled = false;
  589. //AbortConnection.disabled = false;
  590. g_bChatMode = true;
  591. }
  592. }
  593. catch(error)
  594. {
  595. alert( error );
  596. }
  597. }
  598. function OnClientConnected() {
  599. //StatusID.innerText = c_szCHATMODE;
  600. }
  601. function OnClientDisconnected() {
  602. //StatusID.innerText = L_EXPERTDISCONNECT_MSG ;
  603. g_bUserDisconnect = false;
  604. AbortConnection();
  605. }
  606. function OnEnter()
  607. {
  608. if (window.event.keyCode == 13)
  609. {
  610. SendChatButtonHandler();
  611. }
  612. }
  613. //
  614. // HideChatBox: Toggles the chat box controls
  615. //
  616. function HideChatBox()
  617. {
  618. if(false == g_bChatBoxHidden)
  619. {
  620. //
  621. // Chatbox is visible. Hide it
  622. //
  623. chatText.style.visibility = "hidden";
  624. sendChatButton.style.visibility = "hidden";
  625. incomingChatText.style.visibility = "hidden";
  626. g_bChatBoxHidden = true;
  627. idtogglechat.innerHTML = "<div class=styText> Show Chat <img src=\"show-chat.gif\"> </div>";
  628. //HideChat.value = L_SHOWCHAT;
  629. }
  630. else
  631. {
  632. //
  633. // Chatbox is Hidden. Show it
  634. //
  635. chatText.style.visibility = "visible";
  636. sendChatButton.style.visibility = "visible";
  637. incomingChatText.style.visibility = "visible";
  638. g_bChatBoxHidden = false;
  639. //HideChat.value = L_HIDECHAT;
  640. idtogglechat.innerHTML = "<div class=styText> Hide Chat <img src=\"hide-chat.gif\"> </div>";
  641. }
  642. }
  643. //
  644. // Disconnect: Disconnects the RC Connection made by Expert
  645. //
  646. function DisconnectRC()
  647. {
  648. var Doc = null;
  649. var RCCommand = null;
  650. try
  651. {
  652. //
  653. // Create an XML document
  654. //
  655. Doc = new ActiveXObject("microsoft.XMLDOM");
  656. //
  657. // Create the RCCOMMAND root node
  658. //
  659. RCCommand = Doc.createElement( c_szRCCommand );
  660. //
  661. // Set the NAME attribute to DISCONNECTRC
  662. //
  663. RCCommand.setAttribute( c_szRCCommandName, c_szDisconnectRC );
  664. //
  665. // Send the XML across
  666. //
  667. if (false == g_bNewBinaries)
  668. {
  669. //
  670. // Using Old interface
  671. //
  672. g_oSAFRemoteDesktopSession.SendChannelData( c_szControlChannelID, RCCommand.xml );
  673. }
  674. else
  675. {
  676. //
  677. // Use new interface
  678. //
  679. g_oControlChannel.SendChannelData( RCCommand.xml );
  680. }
  681. }
  682. catch(error)
  683. {
  684. alert( error );
  685. }
  686. }
  687. var g_iChannelId = 1000;
  688. //
  689. // LaunchFileXfer: Launches the File Xfer UI
  690. //
  691. function LaunchFileXfer( mode )
  692. {
  693. var vArgs = new Array(4);
  694. if(0 == mode)
  695. {
  696. vArgs[0] = mode; // Source Mode
  697. vArgs[1] = g_oControlChannel; // Control Channel
  698. vArgs[2] = g_oSAFRemoteDesktopChannelMgr; // Channel Manager
  699. vArgs[3] = g_iChannelId++; // Channel ID
  700. window.showModelessDialog( c_szFileXferURL, vArgs, "dialogwidth:" + g_FileXferWidth + "px;dialogHeight:" + g_FileXferHeight + "px;status:no;resizable:no");
  701. }
  702. return;
  703. }
  704. //
  705. // LaunchHelp: Launches Help
  706. //
  707. function LaunchHelp()
  708. {
  709. //
  710. // Place holder
  711. //
  712. return;
  713. }
  714. </SCRIPT>
  715. </BODY>
  716. </HTML>