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.

1375 lines
29 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. RCScripts.js
  5. Abstract:
  6. Helper End javascript that drives the RCTOOL
  7. Author:
  8. Rajesh Soy 07/00
  9. Revision History:
  10. Modified:
  11. Sudha Srinivasan 08/00 to accomodate Remote Data Collection.
  12. --*/
  13. //
  14. // ParseIncident: Basic XML parse to parse the Incident
  15. //
  16. function ParseIncident()
  17. {
  18. var IncidentDoc = new ActiveXObject("microsoft.XMLDOM");
  19. try
  20. {
  21. IncidentDoc.load( g_szIncidentFile );
  22. if ( IncidentDoc.parseError.reason != "")
  23. {
  24. alert( IncidentDoc.parseError.reason);
  25. }
  26. //
  27. // Fetch the Upload data
  28. //
  29. var UploadData = IncidentDoc.documentElement.firstChild;
  30. //
  31. // Fetch the attributes of the upload data
  32. //
  33. var Attributes = UploadData.attributes;
  34. //
  35. // UserName
  36. //
  37. try
  38. {
  39. g_szUserName = Attributes.getNamedItem("USERNAME").nodeValue;
  40. }
  41. catch(error)
  42. {
  43. g_szUserName = "Unknown";
  44. }
  45. //
  46. // ProblemDescription
  47. //
  48. try
  49. {
  50. g_szProblemDescription = Attributes.getNamedItem("PROBLEMDESCRIPTION").nodeValue;
  51. }
  52. catch(error)
  53. {
  54. g_szProblemDescription = "";
  55. }
  56. //
  57. // SALEM ticket
  58. //
  59. try
  60. {
  61. g_szRCTicketEncrypted = Attributes.getNamedItem("SalemID").nodeValue;
  62. }
  63. catch(error)
  64. {
  65. g_szRCTicketEncrypted = null;
  66. }
  67. }
  68. catch(error)
  69. {
  70. alert("Failed to load: " + g_szIncidentFile + " Error: " + error);
  71. }
  72. }
  73. //
  74. // ValidateIncident: Validates the incident information loaded from XML
  75. //
  76. function ValidateIncident()
  77. {
  78. var bRetVal = true;
  79. if("" == g_oCurrentIncident.UserName)
  80. {
  81. alert( L_ERRLOADINGUSERNAME_MSG );
  82. bRetVal = false;
  83. }
  84. if("" == g_oCurrentIncident.RCTicket)
  85. {
  86. alert( L_ERRLOADINGRCTICKET_MSG );
  87. bRetVal = false;
  88. }
  89. return bRetVal;
  90. }
  91. //
  92. // InitializeRCTool: Stuff done when the RCTool page is loaded in the helpctr
  93. //
  94. function InitializeRCTool()
  95. {
  96. try
  97. {
  98. //
  99. // Create an instance of the SAF Incident Object
  100. //
  101. g_oCurrentIncident = oSAFClassFactory.CreateObject_Incident();
  102. //
  103. // Create an instance of the SAF Encryption Object
  104. //
  105. g_oEncryption = oSAFClassFactory.CreateObject_Encryption();
  106. }
  107. catch(error)
  108. {
  109. alert("Problem in initialising " +error);
  110. //
  111. // Todo: Handle Error
  112. //
  113. }
  114. //
  115. // Parse the document URL to Get the location of the Incident file
  116. //
  117. //
  118. // Location the position of "?"
  119. //
  120. var i = document.URL.indexOf("?", 1);
  121. if (i > 0)
  122. {
  123. //
  124. // Go past "?"
  125. //
  126. var g_szIncidentFileURL = document.URL.slice(i+2);
  127. //
  128. // Go past "IncidentFile="
  129. //
  130. var j = g_szIncidentFileURL.indexOf("=", 1);
  131. //
  132. // Split g_szIncidentFileURL to obtain the path to incident XML blob
  133. //
  134. g_szIncidentFile = g_szIncidentFileURL.slice(j+1);
  135. }
  136. else
  137. {
  138. alert ("Unable to locate Incident File");
  139. //
  140. // Todo: Add code to handle this error here
  141. //
  142. }
  143. //
  144. // Populate the incident object from the XML
  145. // representation of the incident (call LoadXML)
  146. //
  147. try
  148. {
  149. //
  150. // Load the incident from the XML blob
  151. //
  152. g_oCurrentIncident.LoadFromXMLFile( g_szIncidentFile );
  153. //
  154. // Validate the information loaded
  155. //
  156. if( false == ValidateIncident())
  157. {
  158. alert(L_ERRLOADINGINCIDENT_MSG);
  159. //
  160. // If incident loaded from XML is invalid
  161. // Use my XML parser to load the incident data
  162. //
  163. ParseIncident();
  164. }
  165. else
  166. {
  167. //
  168. // Incident loaded from XML blob is valid
  169. //
  170. //
  171. // Get the UserName of the person requesting support
  172. //
  173. g_szUserName = g_oCurrentIncident.UserName;
  174. //
  175. // Get the Description of the problem
  176. //
  177. g_szProblemDescription = g_oCurrentIncident.ProblemDescription;
  178. //
  179. // Get the RC Ticket
  180. //
  181. g_szRCTicketEncrypted = g_oCurrentIncident.RCTicket;
  182. }
  183. }
  184. catch(error)
  185. {
  186. alert( L_UNABLETOLOAD_MESSAGE + "\n" + error );
  187. //
  188. // Use my XML parser to load the incident data
  189. //
  190. ParseIncident();
  191. }
  192. //
  193. // Set the UI elements to be displayed from the data
  194. // contained in the incident object
  195. //
  196. window.InviteSent.innerHTML = "<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#333333\"> \
  197. <font size=\"2\" face=\"Courier New, Courier, mono\"> \
  198. <font face=\"Arial, Helvetica, sans-serif\">" + g_szUserName + "</font> </font></font>";
  199. window.SenderMessage.innerHTML = "<font face=\"Arial, Helvetica, sans-serif\" color=\"#333333\"> \
  200. <font face=\"Verdana, Arial, Helvetica, sans-serif\"> \
  201. <font size=\"2\">" + g_szProblemDescription +
  202. "</font></font></font>";
  203. window.InviteExpires.innerHTML = "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" color=\"#333333\">"
  204. + g_szExpiryTime +
  205. "</font>";
  206. //
  207. // Check to see if we need to ask for password
  208. //
  209. if(true == g_oCurrentIncident.RCTicketEncrypted)
  210. {
  211. //
  212. // RCTicket is encrypted. We need to ask for the password
  213. //
  214. PasswordTbl.style.visibility = "visible";
  215. //alert("Encrypted RCTicket: " + g_szRCTicketEncrypted);
  216. }
  217. else
  218. {
  219. //
  220. // RCTicket is not encrypted. Dont need to ask for the password
  221. //
  222. PasswordTbl.style.visibility = "hidden";
  223. g_szRCTicket = g_szRCTicketEncrypted;
  224. }
  225. return;
  226. }
  227. //
  228. // DecryptRCTicket: Calls into the SAF Encryption/Decryption API to decrypt
  229. // RCTicket
  230. //
  231. function DecryptRCTicket()
  232. {
  233. try
  234. {
  235. if(false == g_bPasswordSet)
  236. {
  237. //
  238. // Get the password
  239. //
  240. g_szPassword = PasswordBox.value;
  241. //
  242. // Use g_szPassword to decrypt the g_szRCTicketEncrypted.
  243. //
  244. g_szRCTicket = g_oEncryption.DecryptString( g_szPassword, g_szRCTicketEncrypted );
  245. //alert("Decrypted RCTicket: " + g_szRCTicket);
  246. //
  247. // Password has been set
  248. //
  249. g_bPasswordSet = true;
  250. }
  251. }
  252. catch(error)
  253. {
  254. alert( L_ERRPWD_MSG );
  255. PasswordBox.value = "";
  256. }
  257. return g_bPasswordSet;
  258. }
  259. //
  260. // PasswordSet: Use password as key to decrypt RCTicket on data entry.
  261. //
  262. function PasswordSet()
  263. {
  264. if (window.event.keyCode == 13)
  265. {
  266. //
  267. // Decrypt the RCTicket
  268. //
  269. DecryptRCTicket();
  270. }
  271. return;
  272. }
  273. //
  274. // Display_Screen2: Launches the actual RCTool
  275. //
  276. function Display_Screen2()
  277. {
  278. //
  279. // Check if Password needs to be set
  280. //
  281. if(true == g_oCurrentIncident.RCTicketEncrypted)
  282. {
  283. //
  284. // Decrypt RCTicket
  285. //
  286. if(false == DecryptRCTicket())
  287. {
  288. //
  289. // Invalid password. Re-enter
  290. //
  291. return;
  292. }
  293. }
  294. //
  295. // Go To HC Home Page
  296. //
  297. navigate(c_szHomePage);
  298. var vArgs = new Array(2);
  299. vArgs[0] = g_szRCTicket; // Remote Control Ticket
  300. vArgs[1] = g_szUserName; // UserName of Helpee
  301. //
  302. // Launch the actual RCTool in a seperate window
  303. //
  304. window.showModalDialog("RCToolScreen2.htm", vArgs, "dialogwidth:" + Screen2Width + "px;dialogHeight:" + Screen2Height + "px;status:no;resizable:yes");
  305. }
  306. //
  307. // InitScreen2: Initializes Screen 2
  308. //
  309. function InitScreen2()
  310. {
  311. //
  312. // Set status to not connected
  313. //
  314. StatusId.innerText = L_NOTCONNECTION_MSG;
  315. //
  316. // Hide all the divs, except the one that displays connection status
  317. //
  318. div1.style.visibility = "hidden";
  319. div2.style.visibility = "hidden";
  320. group1.style.visibility = "hidden";
  321. connecting.style.visibility = "visible";
  322. ConnectStarted = 0;
  323. g_bConnected = true;
  324. //
  325. // Set the text for the quit session button
  326. //
  327. ConnectionId.innerText = L_QUITSESSION;
  328. //
  329. // Check if the RemoteClientDesktopHost object is loaded
  330. // if loaded, connected
  331. //
  332. checkLoadx();
  333. return;
  334. }
  335. //
  336. // This checks to see if the Remote desktop client host object is loaded. if not wait 3 sec and try again
  337. //
  338. function checkLoadx()
  339. {
  340. //
  341. // Check if DesktopClientHost object loaded
  342. //
  343. if(L_COMPLETE != RemoteDesktopClientHost.readyState)
  344. {
  345. //
  346. // Not loaded yet
  347. //
  348. setTimeout('checkLoadx()', 3000);
  349. alert("Here in checkload");
  350. }
  351. else
  352. {
  353. //
  354. // Object loaded: Make a connection to the helpee's machine using SALEM API
  355. //
  356. RCConnect();
  357. }
  358. }
  359. //
  360. // Count down method for the connect two minute count down
  361. //
  362. function TwoMinuteCountDown()
  363. {
  364. if (NotConnected == 1)
  365. {
  366. //
  367. // Connection not established yet
  368. //
  369. if ((minutes + seconds)> 0)
  370. {
  371. //
  372. // If timeout not expired
  373. //
  374. if (seconds == 0)
  375. {
  376. minutes = minutes - 1;
  377. seconds = 60;
  378. }
  379. setTimeout('TwoMinuteCountDown()', 2000);
  380. seconds = seconds - 2;
  381. if (minutes > 0)
  382. {
  383. window.TwoMinutesText.innerHTML ="" + minutes + " Minute " + seconds + " Seconds";
  384. }
  385. else
  386. {
  387. if (seconds > 0)
  388. {
  389. window.TwoMinutesText.innerHTML ="" + seconds + " Seconds";
  390. }
  391. else
  392. {
  393. window.TwoMinutesText.innerHTML ="Time out";
  394. }
  395. }
  396. }
  397. else
  398. {
  399. window.ConnectMessage.innerHTML ="<font color=\"#333333\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><br>No Answer From...</font></font>";
  400. window.FailedRetry.style.visibility = "visible";
  401. g_bConnected = false;
  402. }
  403. }
  404. }
  405. //
  406. // setupFirstScreen: Sets up the helper screen
  407. //
  408. function setupFirstScreen()
  409. {
  410. // put screen size of 730 by 500 here
  411. if (640 >= window.screen.availWidth)
  412. {
  413. window.group1.style.width = "640px";
  414. window.screen2.style.width = "640px";
  415. window.dialogWidth = "640px";
  416. window.dialogHeight = "480px";
  417. }
  418. else
  419. {
  420. window.group1.style.width = "700px";
  421. window.screen2.style.width = "700px";
  422. window.dialogWidth = " 730px";
  423. window.dialogHeight = "500px";
  424. }
  425. //
  426. // Hide the desktop client host object
  427. //
  428. div2.style.visibility = "hidden";
  429. //
  430. // Enable chat controls on the screen
  431. //
  432. //div3.style.visibility = "visible";
  433. //div4.style.visibility = "visible";
  434. //div5.style.visibility = "visible";
  435. window.ConnectMessage.innerHTML ="<font color=\"#333333\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><br>Attempting to Connect with ...</font></font>";
  436. window.ConnectHelpee.innerHTML = "<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#333333\"> \
  437. <font size=\"2\" face=\"Courier New, Courier, mono\"> \
  438. <font face=\"Arial, Helvetica, sans-serif\">" + g_szUserName + "</font> </font></font>";
  439. window.FailedRetry.style.visibility = "hidden";
  440. }
  441. //
  442. // RCConnect connects to the user's terminal
  443. //
  444. function RCConnect()
  445. {
  446. var vArgs = window.dialogArguments;
  447. g_szRCTicket = vArgs[0];
  448. g_szUserName = vArgs[1];
  449. //alert("RCTicket: " + g_szRCTicket);
  450. //alert("UserName: " + g_szUserName);
  451. if(null != RemoteDesktopClientHost)
  452. {
  453. g_bNewBinaries = true;
  454. try
  455. {
  456. //
  457. // set screen up for the connect anouncement screen size.
  458. //
  459. setupFirstScreen();
  460. //alert( L_ATTEMPTCONNECTION_MSG );
  461. StatusId.innerText = L_ATTEMPTCONNECTION_MSG;
  462. NotConnected = 1;// set connect shut down boolean
  463. minutes=2;// initialize the two minute countdown timer
  464. seconds=2;
  465. TwoMinuteCountDown(); // START the two minute countdown timer.
  466. //
  467. // Obtain the RDSClient object
  468. //
  469. g_oSAFRemoteDesktopClient = RemoteDesktopClientHost.GetRemoteDesktopClient();
  470. //StatusId.innerText = "Binding Events";
  471. if(null != g_oSAFRemoteDesktopClient)
  472. {
  473. //
  474. // Bind the event handlers for this object.
  475. //
  476. g_oSAFRemoteDesktopClient.OnConnected = function()
  477. { ConnectedHandler(); }
  478. g_oSAFRemoteDesktopClient.OnDisconnected = function(reason)
  479. { DisconnectedHandler(reason); }
  480. if (false == g_bNewBinaries)
  481. {
  482. //
  483. // Using the Old SALEM interfaces
  484. //
  485. g_oSAFRemoteDesktopClient.OnChannelDataReady = function(channelID)
  486. { ChannelDataReadyHandler(channelID); }
  487. g_oSAFRemoteDesktopClient.ConnectToServer(g_szRCTicket);
  488. }
  489. else
  490. {
  491. //
  492. // Using the NEW Salem interfaces
  493. //
  494. g_oSAFRemoteDesktopClient.OnRemoteControlRequestComplete = function(status)
  495. { RemoteControlRequestCompleteHandler( status ); }
  496. //alert("RCTicket: " + g_szRCTicket);
  497. g_oSAFRemoteDesktopClient.ConnectParms = g_szRCTicket;
  498. //alert("Calling ConnectToServer");
  499. g_oSAFRemoteDesktopClient.ConnectToServer();
  500. }
  501. //
  502. // ToDo: Handle connection failure conditions
  503. //
  504. }
  505. else
  506. {
  507. window.ConnectMessage.innerHTML ="<font color=\"#333333\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><br>No Answer From...</font></font>";
  508. alert( L_ERRRDSCLIENT_MSG );
  509. }
  510. }
  511. catch(error)
  512. {
  513. alert( L_ERRCONNECT_MSG + "\n" + error );
  514. window.ConnectMessage.innerHTML ="<font color=\"#333333\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><br>No Answer From...</font></font>";
  515. }
  516. }
  517. else
  518. {
  519. window.ConnectMessage.innerHTML ="<font color=\"#333333\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><br>No Answer From...</font></font>";
  520. alert( L_ERRRDSCLIENTHOST_MSG );
  521. }
  522. return;
  523. }
  524. //
  525. // RemoteControlRequestCompleteHandler: Fired when Remote Control request completes
  526. //
  527. function RemoteControlRequestCompleteHandler( status )
  528. {
  529. alert("RCStatus: " + status);
  530. }
  531. //
  532. // HideChatBox: Toggles the chat box controls
  533. //
  534. function HideChatBox()
  535. {
  536. if(false == g_bChatBoxHidden)
  537. {
  538. //
  539. // Chatbox is visible. Hide it
  540. //
  541. chatText.style.visibility = "hidden";
  542. sendChatButton.style.visibility = "hidden";
  543. incomingChatText.style.visibility = "hidden";
  544. g_bChatBoxHidden = true;
  545. //HideChatBoxId.value = L_SHOWCHAT;
  546. }
  547. else
  548. {
  549. //
  550. // Chatbox is Hidden. Show it
  551. //
  552. chatText.style.visibility = "visible";
  553. sendChatButton.style.visibility = "visible";
  554. incomingChatText.style.visibility = "visible";
  555. g_bChatBoxHidden = false;
  556. //HideChatBoxId.value = L_HIDECHAT;
  557. }
  558. }
  559. //
  560. // ToggleConnection: Toggles between Quit Session and Connect
  561. //
  562. function ToggleConnection()
  563. {
  564. if(false == g_bConnected)
  565. {
  566. //
  567. // Establish Connection
  568. //
  569. RCConnect();
  570. g_bConnected = true;
  571. ConnectionId.innerText = L_QUITSESSION;
  572. }
  573. else
  574. {
  575. //
  576. // Disconnect
  577. //
  578. RCDisconnect();
  579. g_bConnected = false;
  580. ConnectionId.innerText = L_CONNECT;
  581. }
  582. return;
  583. }
  584. //
  585. // Routine to enable Remote Control
  586. //
  587. function ControlRemotePCHandler()
  588. {
  589. var Doc = null;
  590. var RCCommand = null;
  591. try
  592. {
  593. if(null != g_oSAFRemoteDesktopClient)
  594. {
  595. //
  596. // If RemoteControl is not ON already, Enable it
  597. //
  598. if( false == g_bRCEnabled )
  599. {
  600. //
  601. // Disable chat controls on the screen
  602. //
  603. div2.style.visibility = "visible";
  604. div3.style.visibility = "visible";
  605. div4.style.visibility = "hidden";
  606. div5.style.visibility = "hidden";
  607. //
  608. // Create an XML document
  609. //
  610. Doc = new ActiveXObject("microsoft.XMLDOM");
  611. //
  612. // Create the RCCOMMAND root node
  613. //
  614. RCCommand = Doc.createElement( c_szRCCommand );
  615. //
  616. // Set the NAME attribute to REMOTECTRLSTART
  617. //
  618. RCCommand.setAttribute( c_szRCCommandName, c_szRemoteCtrlStart );
  619. //
  620. // Send control message to other end to signal Remote control start
  621. //
  622. g_oControlChannel.SendChannelData( RCCommand.xml );
  623. //
  624. // ToDo: We should wait for an ack from the helpee here
  625. //
  626. //
  627. // Resize the helper's screen using the helpee's screen
  628. // resolution obtained during connection handshake
  629. //
  630. if (UserWidth <= window.screen.availWidth)
  631. {
  632. window.dialogWidth = " " + (parseInt(UserWidth) + 20) + "px";
  633. window.dialogHeight = " " + (parseInt(UserHeight)+145) + "px";
  634. window.group1.style.width = " " + (parseInt(UserWidth)) + "px";
  635. window.screen2.style.width = " " + (parseInt(UserWidth)) + "px";
  636. window.RemoteDesktopClientHost.style.width = " " + (parseInt(UserWidth)) + "px";
  637. window.RemoteDesktopClientHost.style.height = " " + (parseInt(UserHeight)) + "px";
  638. }
  639. else
  640. {
  641. window.dialogWidth = window.screen.availWidth;
  642. window.dialogHeight = " " + parseInt(window.screen.availHeight) + "px";
  643. window.group1.style.width = " " + (parseInt(window.screen.availWidth) - 20) + "px";
  644. window.screen2.style.width = " " + (parseInt(window.screen.availWidth) - 20) + "px";
  645. window.RemoteDesktopClientHost.style.width = " " + (parseInt(UserWidth)) + "px";
  646. window.RemoteDesktopClientHost.style.height = " " + (parseInt(UserHeight)) + "px";
  647. }
  648. //
  649. // Enable Remote Control
  650. //
  651. g_oSAFRemoteDesktopClient.ConnectRemoteDesktop();
  652. //
  653. // Hide the Chat Boxes control button
  654. //
  655. HideChatBox();
  656. //HideChatBoxId.style.visibility = "hidden";
  657. //
  658. // Hide the File XFer button
  659. //
  660. FileXferId.disabled = true;
  661. //
  662. // Change Mode
  663. //
  664. StatusId.innerText = c_szRCMODE;
  665. g_bRCEnabled = true;
  666. ControlRemotePC.value = L_ENDRC;
  667. }
  668. else
  669. {
  670. //
  671. // Disable Remote Control
  672. //
  673. g_oSAFRemoteDesktopClient.DisConnectRemoteDesktop();
  674. //
  675. // put screen size of 730 by 500 here
  676. //
  677. if (640 >= window.screen.availWidth)
  678. {
  679. window.group1.style.width = "640px";
  680. window.screen2.style.width = "640px";
  681. window.dialogWidth = "640px";
  682. window.dialogHeight = "480px";
  683. }
  684. else
  685. {
  686. window.group1.style.width = " 730px";
  687. window.screen2.style.width = " 730px";
  688. window.dialogWidth = " 730px";
  689. window.dialogHeight = "500px";
  690. }
  691. //
  692. // Hide the desktop client host object
  693. //
  694. div2.style.visibility = "hidden";
  695. //
  696. // Enable chat controls on the screen
  697. //
  698. div3.style.visibility = "visible";
  699. div4.style.visibility = "visible";
  700. div5.style.visibility = "visible";
  701. //
  702. // Show the Chat Boxes control button
  703. //
  704. HideChatBox();
  705. //HideChatBoxId.style.visibility = "visible";
  706. FileXferId.disabled = false;
  707. g_bRCEnabled = false;
  708. ControlRemotePC.value = L_STARTRC;
  709. //
  710. // Create an XML document
  711. //
  712. Doc = new ActiveXObject("microsoft.XMLDOM");
  713. //
  714. // Create the RCCOMMAND root node
  715. //
  716. RCCommand = Doc.createElement( c_szRCCommand );
  717. //
  718. // Set the NAME attribute to REMOTECTRLEND
  719. //
  720. RCCommand.setAttribute( c_szRCCommandName, c_szRemoteCtrlEnd );
  721. //
  722. // Send control message to other end to signal Remote control end
  723. //
  724. //
  725. // Wait for SALEM to allow data transfer on channels
  726. //
  727. alert( L_RCSUCCESS_MSG );
  728. g_oControlChannel.SendChannelData( RCCommand.xml );
  729. //
  730. // Change Mode
  731. //
  732. StatusId.innerText = c_szCHATMODE;
  733. }
  734. }
  735. }
  736. catch(error)
  737. {
  738. alert( L_ERRRCTOGGLEFAILED_MSG );
  739. }
  740. }
  741. //
  742. // Routine to disable Remote Control
  743. //
  744. function CloseConnectionHandler()
  745. {
  746. if(null != g_oSAFRemoteDesktopClient)
  747. {
  748. g_oSAFRemoteDesktopClient.DisConnectRemoteDesktop();
  749. }
  750. }
  751. //
  752. // ConnectedHandler: Triggered on connection establishment
  753. //
  754. function ConnectedHandler()
  755. {
  756. var x;
  757. StatusId.innerText = L_WAITFORHELPEE_MSG;
  758. try {
  759. if (false == g_bNewBinaries)
  760. {
  761. //
  762. // Using Old interface
  763. //
  764. //
  765. // Add the chat channel
  766. //
  767. g_oSAFRemoteDesktopClient.AddChannels(c_szChatChannelID);
  768. //
  769. // Add the control channel
  770. //
  771. g_oSAFRemoteDesktopClient.AddChannels( c_szControlChannelID );
  772. }
  773. else
  774. {
  775. //
  776. // Use new interface
  777. //
  778. //
  779. // Get the Channel Manager
  780. //
  781. g_oSAFRemoteDesktopChannelMgr = g_oSAFRemoteDesktopClient.ChannelManager;
  782. //
  783. // Open the Chat channel
  784. //
  785. g_oChatChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szChatChannelID );
  786. //
  787. // Open the Control Channel
  788. //
  789. g_oControlChannel = g_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szControlChannelID );
  790. //
  791. // Setup the ChannelDataReady handlers
  792. //
  793. g_oChatChannel.OnChannelDataReady = function()
  794. { ChatChannelDataReadyHandler(); }
  795. g_oControlChannel.OnChannelDataReady = function()
  796. { ControlChannelDataReadyHandler(); }
  797. }
  798. }
  799. catch(x)
  800. {
  801. //
  802. // Todo: Add handler here
  803. //
  804. }
  805. }
  806. //
  807. // SendChatData sends chat data to remote machine
  808. //
  809. function SendChatData()
  810. {
  811. if (g_oSAFRemoteDesktopClient != null)
  812. {
  813. if (false == g_bNewBinaries)
  814. {
  815. //
  816. // Send chat data to user (using Old interfaces)
  817. //
  818. g_oSAFRemoteDesktopClient.SendChannelData(c_szChatChannelID, chatText.value);
  819. }
  820. else
  821. {
  822. //
  823. // Send chat data to user (using New interfaces)
  824. //
  825. g_oChatChannel.SendChannelData( chatText.value );
  826. }
  827. //
  828. // Update chat history window
  829. //
  830. incomingChatText.value = incomingChatText.value + L_cszExpertID + chatText.value;
  831. //
  832. // Clear chat msg window
  833. //
  834. chatText.value="";
  835. //
  836. // Scroll down
  837. //
  838. incomingChatText.doScroll("scrollbarPageDown");
  839. }
  840. }
  841. //
  842. // RCDisconnect: Disconnects remote connection
  843. //
  844. function RCDisconnect()
  845. {
  846. if (g_oSAFRemoteDesktopClient != null)
  847. {
  848. if (false == g_bNewBinaries)
  849. {
  850. //
  851. // Using the old interface
  852. //
  853. //
  854. // Remove the chat channel
  855. //
  856. g_oSAFRemoteDesktopClient.RemoveChannels( c_szChatChannelID );
  857. //
  858. // Remove the control channel
  859. //
  860. g_oSAFRemoteDesktopClient.RemoveChannels( c_szControlChannelID );
  861. }
  862. if(false == g_bUserDisconnect)
  863. {
  864. //
  865. // Disconnect from Server (only if helper initiated)
  866. //
  867. g_oSAFRemoteDesktopClient.DisconnectFromServer();
  868. }
  869. window.close();
  870. //alert( L_DISCONNECTED_MSG );
  871. }
  872. }
  873. //
  874. // DisconnectedHandler: Fired when Session disconnected
  875. //
  876. function DisconnectedHandler(reason)
  877. {
  878. //
  879. // Close down RC Connection
  880. //
  881. RCDisconnect();
  882. }
  883. //
  884. // ParseControlData: Parse the data sent on the control channel
  885. //
  886. function ParseControlData ( str )
  887. {
  888. var Doc = new ActiveXObject("microsoft.XMLDOM");
  889. var RCCommand = null;
  890. var szCommandName = null;
  891. try
  892. {
  893. if( false == Doc.loadXML( str ))
  894. {
  895. alert ( L_ERRLOADXMLFAIL_MSG );
  896. }
  897. if ( Doc.parseError.reason != "")
  898. {
  899. alert( Doc.parseError.reason);
  900. }
  901. //
  902. // Get the RCCOMMAND node
  903. //
  904. RCCommand = Doc.documentElement;
  905. //
  906. // Get the NAME of the command
  907. //
  908. szCommandName = RCCommand.getAttribute( c_szRCCommandName );
  909. if( szCommandName == c_szScreenInfo )
  910. {
  911. //
  912. // SCREENINFO: Contains width/height/colordepth of user's machine
  913. //
  914. UserWidth = RCCommand.getAttribute( c_szWidth );
  915. UserHeight = RCCommand.getAttribute( c_szHeight );
  916. UserColorDepth = RCCommand.getAttribute( c_szColorDepth );
  917. //
  918. // put screen size of 730 by 500 here
  919. //
  920. if (640 >= window.screen.availWidth)
  921. {
  922. window.group1.style.width = "610px";
  923. window.screen2.style.width = "610px";
  924. window.dialogWidth = "640px";
  925. window.dialogHeight = "480px";
  926. }
  927. else
  928. {
  929. window.group1.style.width = "700px";
  930. window.screen2.style.width = "700px";
  931. window.dialogWidth = " 730px";
  932. window.dialogHeight = "500px";
  933. }
  934. //
  935. // Enable controls on the screen
  936. //
  937. div1.style.visibility = "visible";
  938. div2.style.visibility = "hidden";
  939. div3.style.visibility = "visible";
  940. div4.style.visibility = "visible";
  941. div5.style.visibility = "visible";
  942. connecting.style.visibility = "hidden";
  943. //ControlRemotePC.disabled = false;
  944. //chatText.disabled = false;
  945. //sendChatButton.disabled = false;
  946. NotConnected = 0;
  947. ConnectStarted = 1
  948. //
  949. // Update status
  950. //
  951. StatusId.innerText = c_szCHATMODE;
  952. }
  953. else if( szCommandName == c_szDisconnectRC )
  954. {
  955. //
  956. // DISCONNECTRC: Disconnect the connection
  957. //
  958. g_bUserDisconnect = true;
  959. RCDisconnect();
  960. }
  961. else if( szCommandName == c_szFileXfer )
  962. {
  963. //
  964. // File Transfer Initiation
  965. //
  966. var vArgs = new Array(6);
  967. var FileXferWidth = "600";
  968. var FileXferHeight = "500";
  969. vArgs[0] = 1; // Destination Mode
  970. vArgs[1] = g_oControlChannel; // Control Channel
  971. vArgs[2] = g_oSAFRemoteDesktopChannelMgr; // Channel Manager
  972. vArgs[3] = RCCommand.getAttribute( c_szFileName ); // FILENAME
  973. vArgs[4] = RCCommand.getAttribute( c_szFileSize ); // FILESIZE
  974. vArgs[5] = RCCommand.getAttribute( c_szChannelId ); // CHANNELID
  975. //alert("launching RCFileXfer.htm");
  976. window.showModelessDialog("RCFileXfer.htm", vArgs, "dialogwidth:" + FileXferWidth + "px;dialogHeight:" + FileXferHeight + "px;status:no;resizable:yes");
  977. }
  978. else if ( szCommandName == c_szRemoteDataCollection )
  979. {
  980. // alert("Inside the remote data collection");
  981. //
  982. // File Transfer Initiation
  983. //
  984. var vArgs = new Array(6);
  985. var FileXferWidth = "600";
  986. var FileXferHeight = "500";
  987. var Mode = RCCommand.getAttribute( c_szRemoteDataCollectMode ); // DATA COLLECTION MODE
  988. vArgs[1] = g_oControlChannel; // Control Channel
  989. vArgs[2] = g_oSAFRemoteDesktopChannelMgr; // Channel Manager
  990. vArgs[3] = RCCommand.getAttribute( c_szFileName ); // FILENAME
  991. vArgs[4] = RCCommand.getAttribute( c_szFileSize ); // FILESIZE
  992. vArgs[5] = RCCommand.getAttribute( c_szChannelId ); // CHANNELID
  993. g_szFileName = RCCommand.getAttribute( c_szFileName ); // FILENAME
  994. g_szChannelId = RCCommand.getAttribute( c_szChannelId ); // CHANNELID
  995. // alert("The channel id is : "+ g_szChannelId );
  996. if ( "DATARESPONSE" == Mode )
  997. {
  998. vArgs[0] = 1; // Destination Mode
  999. }
  1000. // alert("launching RemoteDataCollection.htm");
  1001. window.showModelessDialog("RemoteDataCollection.htm", vArgs, "dialogwidth:" + FileXferWidth + "px;dialogHeight:" + FileXferHeight + "px;status:no;resizable:yes");
  1002. }
  1003. }
  1004. catch(error)
  1005. {
  1006. alert( error );
  1007. }
  1008. }
  1009. //
  1010. // ChannelDataReadyHandler: Fired when there is data available on any channel
  1011. //
  1012. function ChannelDataReadyHandler(channelID)
  1013. {
  1014. var str = null;
  1015. if (channelID == c_szChatChannelID)
  1016. {
  1017. if (false == g_bNewBinaries)
  1018. {
  1019. //
  1020. // Using the old interface
  1021. //
  1022. //
  1023. // Incoming data on the chat channel
  1024. //
  1025. str = g_oSAFRemoteDesktopClient.ReceiveChannelData(channelID);
  1026. }
  1027. else
  1028. {
  1029. //
  1030. // Using the new interface
  1031. //
  1032. str = g_oChatChannel.ReceiveChannelData();
  1033. }
  1034. //
  1035. // Update chat history window
  1036. //
  1037. incomingChatText.value = incomingChatText.value + L_cszUserID + str;
  1038. incomingChatText.doScroll("scrollbarPageDown");
  1039. }
  1040. else if (channelID == c_szControlChannelID)
  1041. {
  1042. //
  1043. // Incoming data on the control channel. Data on this
  1044. // channel will be in XML.
  1045. // This channel will be used to support the following:
  1046. // 1. Server side (user end) disconnect
  1047. // 2. File transfer
  1048. //
  1049. if (false == g_bNewBinaries)
  1050. {
  1051. //
  1052. // Using the old interface
  1053. //
  1054. str = g_oSAFRemoteDesktopClient.ReceiveChannelData(channelID);
  1055. }
  1056. else
  1057. {
  1058. //
  1059. // Using the new interface
  1060. //
  1061. str = g_oControlChannel.ReceiveChannelData();
  1062. }
  1063. //
  1064. // Parse the data sent on the control channel
  1065. //
  1066. ParseControlData ( str );
  1067. }
  1068. return;
  1069. }
  1070. //
  1071. // ChatChannelDataReadyHandler: Fired when there is data available on Chat channel
  1072. //
  1073. function ChatChannelDataReadyHandler()
  1074. {
  1075. var str = null;
  1076. //
  1077. // Incoming data on the chat channel
  1078. //
  1079. str = g_oChatChannel.ReceiveChannelData();
  1080. //
  1081. // Update chat history window
  1082. //
  1083. incomingChatText.value = incomingChatText.value + L_cszUserID + str;
  1084. incomingChatText.doScroll("scrollbarPageDown");
  1085. return;
  1086. }
  1087. //
  1088. // ControlChannelDataReadyHandler: Fired when there is data available on Control channel
  1089. //
  1090. function ControlChannelDataReadyHandler()
  1091. {
  1092. var str = null;
  1093. //
  1094. // Incoming data on the control channel. Data on this
  1095. // channel will be in XML.
  1096. // This channel will be used to support the following:
  1097. // 1. Server side (user end) disconnect
  1098. // 2. File transfer
  1099. //
  1100. str = g_oControlChannel.ReceiveChannelData();
  1101. //
  1102. // Parse the data sent on the control channel
  1103. //
  1104. ParseControlData ( str );
  1105. return;
  1106. }
  1107. //
  1108. // OnEnter: This is fired when Expert hits <ENTER> in the chat message window
  1109. //
  1110. function OnEnter()
  1111. {
  1112. if (window.event.keyCode == 13)
  1113. {
  1114. //
  1115. // Send chat data to user
  1116. //
  1117. SendChatData();
  1118. }
  1119. }
  1120. var g_iChannelId = 1000;
  1121. //
  1122. // LaunchFileXfer: Launches the File Xfer UI
  1123. //
  1124. function LaunchFileXfer( mode )
  1125. {
  1126. var vArgs = new Array(4);
  1127. var FileXferWidth = "600";
  1128. var FileXferHeight = "500";
  1129. vArgs[0] = mode; // Source Mode
  1130. vArgs[1] = g_oControlChannel; // Control Channel
  1131. vArgs[2] = g_oSAFRemoteDesktopChannelMgr; // Channel Manager
  1132. vArgs[3] = g_iChannelId++;
  1133. // alert("mode :" + mode);
  1134. // alert("g_oControlChannel :" + g_oControlChannel);
  1135. // alert("g_oSAFRemoteDesktopChannelMgr :" + g_oSAFRemoteDesktopChannelMgr);
  1136. // alert("g_iChannelId :" + g_iChannelId);
  1137. window.showModelessDialog("RCFileXfer.htm", vArgs, "dialogwidth:" + FileXferWidth + "px;dialogHeight:" + FileXferHeight + "px;status:no;resizable:yes");
  1138. return;
  1139. }
  1140. //
  1141. // LaunchRemoteDataCollection: Launches the Remote Data Transfer
  1142. //
  1143. function LaunchRemoteDataCollection( mode )
  1144. {
  1145. var vArgs = new Array(4);
  1146. var FileXferWidth = "600";
  1147. var FileXferHeight = "500";
  1148. vArgs[0] = mode; // Source Mode
  1149. vArgs[1] = g_oControlChannel; // Control Channel
  1150. vArgs[2] = g_oSAFRemoteDesktopChannelMgr; // Channel Manager
  1151. vArgs[3] = g_iChannelId++;
  1152. window.showModelessDialog("RemoteDataCollection.htm", vArgs, "dialogwidth:" + FileXferWidth + "px;dialogHeight:" + FileXferHeight + "px;status:no;resizable:yes");
  1153. return;
  1154. }