Leaked source code of windows server 2003
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.

939 lines
24 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. RAClient.js
  5. Abstract:
  6. Contains Javascript code to handle control of the Client side (Helper) UI
  7. Author:
  8. Rajesh Soy 10/00
  9. Revision History:
  10. Rajesh Soy - created 10/24/2000
  11. --*/
  12. /*++
  13. Helper end Utility functions and globals
  14. --*/
  15. #include "debug_decl.inc"
  16. #include "constants.inc"
  17. /*
  18. * Localizable constants, text and messages
  19. */
  20. var L_EXPIRED_Text = "Invitation has expired.";
  21. var L_UNABLETOLOCATEXML_Text = "The invitation was not found. It may have been deleted or corrupted. You can try and open the invitation again, or ask the sender for a new invitation.";
  22. var L_ERRLOADINGINCIDENT_Text = "There is a problem with the invitation and it cannot be opened. To use Remote Assistance, the sender of this invitation will have to send you a new invitation.";//"Error loading incident.";
  23. var L_ERRLOADINGRCTICKET_Text = "There is a problem with the invitation and it cannot be opened. To use Remote Assistance, the sender of this invitation will have to send you a new invitation.";//"Unable to load RCTicket from XML";
  24. var L_ERRQUIT_Text = "Failed to Disconnect from Server";
  25. var L_ERRLOADFROMXMLFILE_Text = "There is a problem with the invitation and it cannot be opened. To use Remote Assistance, the sender of this invitation will have to send you a new invitation.";
  26. var L_DOT_Text = ".";
  27. var L_AM_Text ="AM";
  28. var L_PM_Text ="PM";
  29. var L_JAN_Text = "Jan";
  30. var L_FEB_Text = "Feb";
  31. var L_MAR_Text = "Mar";
  32. var L_APR_Text = "Apr";
  33. var L_MAY_Text = "May";
  34. var L_JUN_Text = "Jun";
  35. var L_JUL_Text = "Jul";
  36. var L_AUG_Text = "Aug";
  37. var L_SEP_Text = "Sep";
  38. var L_OCT_Text = "Oct";
  39. var L_NOV_Text = "Nov";
  40. var L_DEC_Text = "Dec";
  41. var L_UNKNOWN_Text = "Unknown";
  42. //
  43. // SAFRemoteAssistanceHelper: Constructor for the SAFRemoteAssistanceHelper object
  44. //
  45. function SAFRemoteAssistanceHelper()
  46. {
  47. try
  48. {
  49. //
  50. // SALEM Objects
  51. //
  52. this.m_oSAFRemoteDesktopClient = null;
  53. this.m_oSAFRemoteDesktopChannelMgr = null;
  54. this.m_oChatChannel = null;
  55. this.m_oControlChannel = null;
  56. //
  57. // SAF Objects
  58. //
  59. this.m_oSAFClassFactory = null;
  60. this.m_idCtx = null;
  61. this.m_oCurrentIncident = null;
  62. this.m_oEncryption = null;
  63. this.m_oDict = null;
  64. this.m_oSAFIntercomClient = null;
  65. //
  66. // Other objects
  67. //
  68. this.m_oFso = null;
  69. this.m_oRCFileDlg = null;
  70. //
  71. // BOOLEANS
  72. //
  73. this.m_bChatBoxHidden = false;
  74. this.m_bPasswordSet = false;
  75. this.m_bRCEnabled = false;
  76. this.m_bConnected = false;
  77. this.m_bUserDisconnect = false;
  78. this.m_bLoadFromFile = true;
  79. this.m_bEnableSmartScaling = true;
  80. this.m_bPerfOptimize = false;
  81. this.m_bMSRA = true;
  82. this.m_bListen = false;
  83. this.m_bIsIM = false;
  84. this.m_bURA = false;
  85. this.m_bExpired = false;
  86. #ifdef _BVT
  87. this.m_bBVT = false;
  88. #endif
  89. //
  90. // Configuration stuff
  91. //
  92. this.m_bDeleteTicket = false;
  93. this.m_bNoPrompt = false;
  94. this.m_bNoChat = false;
  95. //
  96. // INTEGERS
  97. //
  98. this.m_iChannelId = 1000;
  99. this.m_UserWidth = window.screen.availWidth;
  100. this.m_UserHeight = window.screen.availHeight;
  101. this.m_UserColorDepth = window.screen.colorDepth;
  102. //
  103. // STRINGS
  104. //
  105. this.m_szURL = null;
  106. this.m_szCurrentIP = null;
  107. this.m_szLocalUser = null;
  108. this.m_szIncidentFile = null;
  109. this.m_szUserName = null;
  110. this.m_szExpiryTime = "1 HOUR";
  111. this.m_szPassword = null;
  112. this.m_szRCTicketEncrypted = null;
  113. this.m_szRCTicket = null;
  114. this.m_szHelpeeIP = null;
  115. this.m_szRCTicket = null;
  116. this.m_szUserName = null;
  117. this.m_szIncidentXML = null;
  118. this.m_szPassStub = "";
  119. this.m_szExpertTicket = null;
  120. this.m_szExpertBlob = null;
  121. //
  122. // Trace stuff
  123. //
  124. this.m_bDebug = true;
  125. this.m_szFuncName = null;
  126. this.m_TraceFso = null;
  127. this.m_TraceFileHandle = null;
  128. this.m_TraceFile = null;
  129. this.m_TracetFileName = null;
  130. }
  131. catch(error)
  132. {
  133. FatalError( L_ERRFATAL_Text, error );
  134. }
  135. }
  136. //
  137. // ParseURL: This function parses the document URL and extracts the location of the incident file
  138. // If we are launched from UnSolicitedRC, the IncidentFile will be called "URC".
  139. // This function returns the IncidentFile
  140. //
  141. #ifdef _STRUCT_ERR
  142. // Return Values: Path to incident file on success
  143. // null on error. This routine will display the appropriate error message to user.
  144. // Callers should handle the return call to cleanup and abort
  145. //
  146. #endif
  147. function ParseURL()
  148. {
  149. var szIncidentFileURL = null;
  150. var szTempstr = null;
  151. var szTempstr1 = null;
  152. var i = null;
  153. var j = null;
  154. var k = null;
  155. TraceFunctEnter("ParseURL");
  156. //
  157. // For normal invokation, the URL will be of the form:
  158. // "hcp://<vendorid>/rcexpert/rctoolscreen1.htm?IncidentFile=<path_to_incidentfile>"
  159. // Location the position of "?"
  160. //
  161. try
  162. {
  163. #ifndef _EXTRA_ARGUMENT
  164. i = g_oSAFRemoteAssistanceHelper.m_szURL.indexOf("?", 1);
  165. #else
  166. i = 1;
  167. #endif
  168. if (i > 0)
  169. {
  170. //
  171. // Go past "?"
  172. //
  173. #ifndef _EXTRA_ARGUMENT
  174. szIncidentFileURL = g_oSAFRemoteAssistanceHelper.m_szURL.slice(i+1);
  175. #else
  176. szIncidentFileURL = oSAFClassFactory.ExtraArgument;
  177. DebugTrace("szIncidentFileURL: " + szIncidentFileURL);
  178. #endif
  179. j = szIncidentFileURL.indexOf("IM=");
  180. //
  181. // check if it's IM
  182. //
  183. if (j == 0)
  184. {
  185. g_oSAFRemoteAssistanceHelper.m_bIsIM = true;
  186. g_oSAFRemoteAssistanceHelper.m_SessionID = szIncidentFileURL.slice(3);
  187. DebugTrace("ProcessID: " + g_oSAFRemoteAssistanceHelper.m_SessionID);
  188. g_oSAFRemoteAssistanceHelper.m_bLoadFromFile = false;
  189. #ifndef _STRUCT_ERR
  190. TraceFunctLeave();
  191. return;
  192. #else
  193. TraceFunctLeave();
  194. return g_oSAFRemoteAssistanceHelper.m_SessionID;
  195. #endif
  196. }
  197. //
  198. // Go past "IncidentFile="
  199. //
  200. j = szIncidentFileURL.indexOf("=", 1);
  201. //
  202. // Split g_szIncidentFileURL to obtain the path to incident XML blob
  203. //
  204. szTempstr = szIncidentFileURL.slice(j+1);
  205. #if 0
  206. //
  207. // TODO: Get rid of the code below. We can't special case like this.
  208. // Check if we were launched as UnsolicitedRC
  209. //
  210. if( 0 == szTempstr.indexOf( c_szNOIncidentFile ) )
  211. {
  212. //
  213. // The URL is of the form "hcp://<vendorid>/rcexpert/rctoolscreen1.htm?IncidentFile=NOFILE&IncidentXML=<XML_blob>"
  214. // Extract the RCTicket now
  215. //
  216. //
  217. // Go past "IncidentXML="
  218. //
  219. i = szTempstr.indexOf("=", 1);
  220. szTempstr1 = szTempstr.slice(i+1);
  221. //
  222. // Get everything after "IncidentXML="
  223. //
  224. j = szTempstr1.indexOf("&");
  225. g_oSAFRemoteAssistanceHelper.m_szIncidentXML = szTempstr1.slice(0, j);
  226. //
  227. // We need to load incident from XML string ...
  228. //
  229. g_oSAFRemoteAssistanceHelper.m_bLoadFromFile = false;
  230. }
  231. else if( 0 == szTempstr.indexOf( c_szLISTEN ))
  232. #endif
  233. if( 0 == szTempstr.indexOf( c_szLISTEN )) // Used by PSS for Reverse connection
  234. {
  235. g_oSAFRemoteAssistanceHelper.m_bListen = true;
  236. g_oSAFRemoteAssistanceHelper.m_szIncidentFile = szTempstr;
  237. }
  238. else
  239. {
  240. g_oSAFRemoteAssistanceHelper.m_szIncidentFile = szTempstr;
  241. }
  242. DebugTrace("g_szIncidentFile: " + g_oSAFRemoteAssistanceHelper.m_szIncidentFile);
  243. }
  244. else
  245. {
  246. //
  247. // Fatal Error
  248. //
  249. FatalError( L_UNABLETOLOCATEXML_Text );
  250. TraceFunctLeave();
  251. return null;
  252. }
  253. }
  254. catch(error)
  255. {
  256. FatalError( error.description, error );
  257. return null;
  258. }
  259. TraceFunctLeave();
  260. return g_oSAFRemoteAssistanceHelper.m_szIncidentFile;
  261. }
  262. //
  263. // LoadIncidentFromFile: Loads our SAF Incident object from the data file passed as argument in the URL
  264. // Return Values : On success, this routine returns the Path to the incident object
  265. // On error, the return value is null
  266. // This routine handles all exceptions and reports it to the user. Callers should
  267. // use the return value to cleanup.
  268. //
  269. function LoadIncidentFromFile()
  270. {
  271. TraceFunctEnter("LoadIncidentFromFile");
  272. try
  273. {
  274. //
  275. // Create an instance of the SAF Incident Object
  276. //
  277. g_oSAFRemoteAssistanceHelper.m_oCurrentIncident = oSAFClassFactory.CreateObject_Incident();
  278. //
  279. // Create an instance of the SAF Encryption Object
  280. //
  281. g_oSAFRemoteAssistanceHelper.m_oEncryption = oSAFClassFactory.CreateObject_Encryption();
  282. //
  283. // Load the incident from the XML blob
  284. //
  285. try
  286. {
  287. if(true == g_oSAFRemoteAssistanceHelper.m_bLoadFromFile )
  288. {
  289. //
  290. // Load from File
  291. //
  292. g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.LoadFromXMLFile( g_oSAFRemoteAssistanceHelper.m_szIncidentFile );
  293. }
  294. else
  295. {
  296. //
  297. // Load from string
  298. //
  299. g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.LoadFromXMLString( g_oSAFRemoteAssistanceHelper.m_szIncidentXML );
  300. }
  301. }
  302. catch(error)
  303. {
  304. // Log Event Log (event 2)
  305. try
  306. {
  307. var oLogger = new ActiveXObject("RACplDlg.RAEventLog");
  308. var args = new Array(1);
  309. args[0] = parent.EscapedName(parent.GetLocalUser());
  310. oLogger.LogRemoteAssistanceEvent(0,2,args);
  311. }
  312. catch(e)
  313. {
  314. // do nothing
  315. }
  316. FatalError( L_ERRLOADFROMXMLFILE_Text, error );
  317. TraceFunctLeave();
  318. return null;
  319. }
  320. //
  321. // Validate the information loaded
  322. //
  323. if( false == ValidateIncident())
  324. {
  325. // Log Event Log (event 2)
  326. try
  327. {
  328. var oLogger = new ActiveXObject("RACplDlg.RAEventLog");
  329. var args = new Array(1);
  330. args[0] = parent.EscapedName(parent.GetLocalUser());
  331. oLogger.LogRemoteAssistanceEvent(0,2,args);
  332. }
  333. catch(e)
  334. {
  335. // Do nothing
  336. }
  337. //
  338. // Fatal Error
  339. //
  340. FatalError(L_ERRLOADINGINCIDENT_Text);
  341. TraceFunctLeave();
  342. return null;
  343. }
  344. else
  345. {
  346. //
  347. // Incident loaded from XML blob is valid
  348. //
  349. //
  350. // Get the UserName of the person requesting support
  351. //
  352. g_oSAFRemoteAssistanceHelper.m_szUserName = EscapedName( g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.UserName );
  353. //
  354. // Get the RC Ticket
  355. //
  356. g_oSAFRemoteAssistanceHelper.m_szRCTicketEncrypted = g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.RCTicket;
  357. //
  358. // Get the Misc Items
  359. //
  360. g_oSAFRemoteAssistanceHelper.m_oDict = g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.Misc;
  361. //
  362. // Get the Expiry time.
  363. //
  364. var DtStart = g_oSAFRemoteAssistanceHelper.m_oDict.Item("DtStart");
  365. var DtLength = g_oSAFRemoteAssistanceHelper.m_oDict.Item("DtLength");
  366. DebugTrace( "DtStart: " + DtStart );
  367. DebugTrace( "DtLength: " + DtLength);
  368. //
  369. // Compute the expiry time based on the start time and the duration
  370. //
  371. var ms = DtStart*1000 + DtLength*60*1000;
  372. DebugTrace (ms );
  373. var ExpiryDate = new Date ( ms );
  374. var iNow = Date.parse(new Date());
  375. g_oSAFRemoteAssistanceHelper.m_iRemainingMins = parseInt(((ms - iNow)/1000)/60);
  376. //
  377. // If ticket has not expired, display the remaining time before expiry
  378. //
  379. if( 0 >= g_oSAFRemoteAssistanceHelper.m_iRemainingMins)
  380. {
  381. g_oSAFRemoteAssistanceHelper.m_bExpired = true;
  382. }
  383. g_oSAFRemoteAssistanceHelper.m_szExpiryTime = GetTime(ExpiryDate);
  384. DebugTrace("Expiry " + g_oSAFRemoteAssistanceHelper.m_szExpiryTime);
  385. //
  386. // Get the IP address(es) of helpee
  387. //
  388. g_oSAFRemoteAssistanceHelper.m_szHelpeeIP = g_oSAFRemoteAssistanceHelper.m_oDict.Item("IP");
  389. //
  390. // Get configuration information
  391. //
  392. //
  393. // DeleteTicket == 1; Delete Incident File
  394. //
  395. if(1 == g_oSAFRemoteAssistanceHelper.m_oDict.Item("DeleteTicket"))
  396. {
  397. g_oSAFRemoteAssistanceHelper.m_bDeleteTicket = true;
  398. }
  399. //
  400. // NoPrompt == 1 and ticket is not encrypted; Dont show 1st screen
  401. //
  402. if((1 == g_oSAFRemoteAssistanceHelper.m_oDict.Item("NoPrompt"))&&( false == g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.RCTicketEncrypted))
  403. {
  404. g_oSAFRemoteAssistanceHelper.m_bNoPrompt = true;
  405. }
  406. //
  407. // NoChat == 1; Dont show chat
  408. //
  409. if(1 == g_oSAFRemoteAssistanceHelper.m_oDict.Item("NoChat"))
  410. {
  411. g_oSAFRemoteAssistanceHelper.m_bNoChat = true;
  412. }
  413. //
  414. // Check for Unsolicited RA
  415. //
  416. if(1 == g_oSAFRemoteAssistanceHelper.m_oDict.Item("URA"))
  417. {
  418. g_oSAFRemoteAssistanceHelper.m_bURA = true;
  419. }
  420. #ifdef _BVT
  421. {
  422. g_oSAFRemoteAssistanceHelper.m_bBVT = false;
  423. try
  424. {
  425. var oShell = new ActiveXObject("WScript.Shell");
  426. var oEnv = oShell.Environment("process");
  427. var szBVT = oEnv( "RABVT" );
  428. DebugTrace("szBVT: " + szBVT + " szBVT.indexOf: " + szBVT.indexOf("1"));
  429. if( szBVT.indexOf("1") == 1 )
  430. {
  431. g_oSAFRemoteAssistanceHelper.m_bBVT = true;
  432. g_oSAFRemoteAssistanceHelper.m_bURA = true;
  433. InitBVT();
  434. }
  435. }
  436. catch(error)
  437. {
  438. alert( error.description, error );
  439. g_oSAFRemoteAssistanceHelper.m_bBVT = false;
  440. g_oSAFRemoteAssistanceHelper.m_bURA = false;
  441. }
  442. }
  443. DebugTrace("g_oSAFRemoteAssistanceHelper.m_bBVT: " + g_oSAFRemoteAssistanceHelper.m_bBVT);
  444. #endif
  445. //
  446. // Performance optimizations
  447. //
  448. try
  449. {
  450. if( (1 == g_oSAFRemoteAssistanceHelper.m_oDict.Item("L")) || (true == oSAFClassFactory.Connectivity.IsAModem ))
  451. {
  452. g_oSAFRemoteAssistanceHelper.m_bPerfOptimize = true;
  453. }
  454. }
  455. catch(error)
  456. {
  457. g_oSAFRemoteAssistanceHelper.m_bPerfOptimize = false;
  458. }
  459. DebugTrace("g_oSAFRemoteAssistanceHelper.m_bPerfOptimize: " + g_oSAFRemoteAssistanceHelper.m_bPerfOptimize);
  460. #ifdef _TESTMODEM
  461. g_oSAFRemoteAssistanceHelper.m_bPerfOptimize = true;
  462. #endif
  463. //
  464. // Delete the incident file if necessary
  465. //
  466. if(true == g_oSAFRemoteAssistanceHelper.m_bDeleteTicket)
  467. {
  468. //
  469. // Delete Incident File
  470. //
  471. //alert("Deleting: " + g_oSAFRemoteAssistanceHelper.m_szIncidentFile);
  472. try
  473. {
  474. g_oSAFRemoteAssistanceHelper.m_oFso.DeleteFile( g_oSAFRemoteAssistanceHelper.m_szIncidentFile );
  475. }
  476. catch(error)
  477. {
  478. FatalError( error.description + " (" + g_oSAFRemoteAssistanceHelper.m_szIncidentFile + ")" );
  479. TraceFunctLeave();
  480. return null;
  481. }
  482. }
  483. }
  484. }
  485. catch(error)
  486. {
  487. //
  488. // Fatal Error
  489. //
  490. FatalError(L_ERRLOADINGINCIDENT_Text, error);
  491. TraceFunctLeave();
  492. return null;
  493. }
  494. TraceFunctLeave();
  495. return g_oSAFRemoteAssistanceHelper.m_oCurrentIncident;
  496. }
  497. //
  498. // ValidateIncident: Validates the incident information loaded from XML
  499. // Return Values: TRUE on success
  500. // FALSE on failure
  501. //
  502. function ValidateIncident()
  503. {
  504. TraceFunctEnter("ValidateIncident");
  505. var bRetVal = true;
  506. if("" == g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.UserName)
  507. {
  508. g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.UserName = L_DEFAULTUSER_Text;
  509. }
  510. if("" == g_oSAFRemoteAssistanceHelper.m_oCurrentIncident.RCTicket)
  511. {
  512. bRetVal = false;
  513. }
  514. TraceFunctLeave();
  515. return bRetVal;
  516. }
  517. /*++
  518. Remote Connection handling routines
  519. --*/
  520. //
  521. // UserDisconnect
  522. //
  523. var g_bAlreadyDisconnected = false;
  524. function UserDisconnect()
  525. {
  526. try
  527. {
  528. if ( true == parent.g_ExpertDisconnected )
  529. {
  530. //
  531. // Expert disconnected, so we dont need to display
  532. // the message
  533. //
  534. return;
  535. }
  536. DebugTrace("g_bAlreadyDisconnected: " + g_bAlreadyDisconnected);
  537. if( false == g_bAlreadyDisconnected )
  538. {
  539. g_bAlreadyDisconnected = true;
  540. var vArgs = new Array(1);
  541. vArgs[0] = L_ERRDISCONNECT1_Text + g_oSAFRemoteAssistanceHelper.m_szUserName + L_ERRDISCONNECT2_Text + g_oSAFRemoteAssistanceHelper.m_szUserName + L_DOT_Text; // Message
  542. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szMsgSpecs );
  543. }
  544. }
  545. catch(error)
  546. {
  547. // not fatal
  548. }
  549. }
  550. //
  551. // RCDisconnect: Disconnects SALEM Connection
  552. //
  553. function RCDisconnect()
  554. {
  555. TraceFunctEnter("RCDisconnect");
  556. //
  557. // Tear Down the SALEM Connection
  558. //
  559. try
  560. {
  561. //
  562. // Use the Remote Assistant helper object context from the Tools page
  563. //
  564. if( null != parent.frames.idFrameTools.g_oSAFRemoteAssistanceHelper)
  565. {
  566. g_oSAFRemoteAssistanceHelper = parent.frames.idFrameTools.g_oSAFRemoteAssistanceHelper;
  567. }
  568. else if( null != parent.g_oSAFRemoteAssistanceHelper )
  569. {
  570. g_oSAFRemoteAssistanceHelper = parent.g_oSAFRemoteAssistanceHelper;
  571. }
  572. if ((g_oSAFRemoteAssistanceHelper.m_szUserName != null) && ( g_oSAFRemoteAssistanceHelper.m_szUserName.length == 0 ))
  573. {
  574. g_oSAFRemoteAssistanceHelper.m_szUserName = L_DEFAULTUSER_Text
  575. }
  576. // If we are connected for VoIP, disconnect the Client
  577. if (true == parent.g_bVoipOn)
  578. {
  579. // Call Disconnect() on the IntercomClient object
  580. try
  581. {
  582. if( null != g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient )
  583. {
  584. DebugTrace("Calling g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.Disconnect...");
  585. g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.Disconnect();
  586. DebugTrace("g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.Disconnect successful. ");
  587. }
  588. //alert("Call to Disconnect() succeeded!");
  589. parent.g_bVoipOn = false;
  590. // TODO: This may not be necessary
  591. #ifdef _OLDTOOLBAR
  592. parent.frames.idFrameTools.btnVoice.disabled = true;
  593. #else
  594. parent.frames.idFrameTools.idTB.SetState( "btnVoice", false );
  595. #endif
  596. }
  597. catch (e)
  598. {
  599. // Do nothing.
  600. // NOTE: In the future, we may think about putting up
  601. // a message if calling Disconnect() fails.
  602. return;
  603. }
  604. }
  605. if((false == g_oSAFRemoteAssistanceHelper.m_bUserDisconnect) && (true == g_oSAFRemoteAssistanceHelper.m_bConnected))
  606. {
  607. //
  608. // Helper initiated disconnect
  609. //
  610. g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopClient.DisconnectFromServer();
  611. TraceFunctLeave();
  612. EndTrace();
  613. }
  614. else if (true == g_oSAFRemoteAssistanceHelper.m_bConnected)
  615. {
  616. //
  617. // Helpee initiated disconnect
  618. //
  619. //
  620. // Close connection
  621. //
  622. if(null != g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopClient )
  623. {
  624. g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopClient.DisconnectFromServer();
  625. }
  626. g_oSAFRemoteAssistanceHelper.m_bConnected = false;
  627. //parent.frames.idFrameScreen.idRemoteControlObject.style.visibility = "hidden";
  628. UserDisconnect();
  629. TraceFunctLeave();
  630. EndTrace();
  631. }
  632. }
  633. catch(e)
  634. {
  635. FatalError( L_ERRQUIT_Text );
  636. }
  637. }
  638. //
  639. // Helper_SetupChatChannel: Sets up the Chat Channel and event handlers
  640. //
  641. function Helper_SetupChatChannel()
  642. {
  643. TraceFunctEnter("Helper_SetupChatChannel");
  644. try
  645. {
  646. //
  647. // Get the Channel Manager
  648. //
  649. //DebugTrace("Getting ChannelManager");
  650. if(null == g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopChannelMgr)
  651. {
  652. g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopChannelMgr = g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopClient.ChannelManager;
  653. }
  654. //
  655. // Open the Chat channel
  656. //
  657. //DebugTrace("Opening channels");
  658. //
  659. // Open the Chat Channel
  660. //
  661. g_oSAFRemoteAssistanceHelper.m_oChatChannel = g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szChatChannelID );
  662. //
  663. // Setup the ChannelDataReady handlers
  664. //
  665. g_oSAFRemoteAssistanceHelper.m_oChatChannel.OnChannelDataReady = function()
  666. { parent.Helper_ChatChannelDataReadyHandler(); }
  667. }
  668. catch(error)
  669. {
  670. //
  671. // Fatal Error
  672. //
  673. parent.FatalError( parent.L_ERRFATAL_Text, error );
  674. }
  675. TraceFunctLeave();
  676. return;
  677. }
  678. //
  679. // Helper_SetupDataChannels: Sets up the Data Channels and event handlers
  680. //
  681. function Helper_SetupDataChannels()
  682. {
  683. TraceFunctEnter("Helper_SetupDataChannels");
  684. try
  685. {
  686. //
  687. // Setup the Control Channel
  688. //
  689. Helper_SetupControlChannel();
  690. //
  691. // Setup the Chat Channel
  692. //
  693. Helper_SetupChatChannel();
  694. }
  695. catch(error)
  696. {
  697. //
  698. // Fatal Error
  699. //
  700. FatalError( L_ERRFATAL_Text, error );
  701. }
  702. TraceFunctLeave();
  703. return;
  704. }
  705. //
  706. // Helper_ChatChannelDataReadyHandler: Fired when there is data available on Chat channel
  707. //
  708. function Helper_ChatChannelDataReadyHandler()
  709. {
  710. TraceFunctEnter("Helper_ChatChannelDataReadyHandler");
  711. var Data = null;
  712. try
  713. {
  714. //
  715. // Open Chat window if necessary
  716. //
  717. if(true == parent.frames.idFrameTools.g_oSAFRemoteAssistanceHelper.m_bChatBoxHidden)
  718. {
  719. parent.frames.idFrameStatus.Helper_HideChat();
  720. }
  721. //
  722. // Bring window in focus
  723. //
  724. parent.idCtx.minimized = false;
  725. parent.idCtx.bringToForeground();
  726. SoundBeep();
  727. //
  728. // Incoming data on the chat channel
  729. //
  730. Data = g_oSAFRemoteAssistanceHelper.m_oChatChannel.ReceiveChannelData();
  731. //
  732. // Update the chat history pane
  733. //
  734. parent.frames.idFrameChat.Helper_UpdateChatHistory( Data );
  735. }
  736. catch(error)
  737. {
  738. FatalError( parent.L_ERRFATAL_Text, error );
  739. }
  740. TraceFunctLeave();
  741. return;
  742. }
  743. function GetTime(oDate)
  744. {
  745. TraceFunctEnter("GetTime");
  746. var DateTime;
  747. #if 0
  748. try
  749. {
  750. var DateTime;
  751. var Hr;
  752. var Min;
  753. var DayNight;
  754. var Month;
  755. var Date;
  756. DateTime = oDate;
  757. Hr = DateTime.getHours() % 12;
  758. if (Hr == 0)
  759. {
  760. Hr = 12;
  761. }
  762. if (Hr<10)
  763. {
  764. Hr=" "+Hr;
  765. }
  766. Min=DateTime.getMinutes();
  767. if(Min<10)
  768. {
  769. Min="0"+Min;
  770. }
  771. DayNight=(DateTime.getHours()>=12)? L_PM_Text : L_AM_Text ;
  772. var Month_Text = new Array(L_JAN_Text, L_FEB_Text, L_MAR_Text, L_APR_Text, L_MAY_Text, L_JUN_Text, L_JUL_Text, L_AUG_Text, L_SEP_Text, L_OCT_Text, L_NOV_Text, L_DEC_Text);
  773. Month = Month_Text[DateTime.getMonth()];
  774. Date=DateTime.getDate();
  775. if (Date<10)
  776. {
  777. Date="0"+Date;
  778. }
  779. DateTime = Month + " " + Date + ", " + Hr + ":"+Min+" "+DayNight + " (PST)";
  780. }
  781. catch(error)
  782. {
  783. alert(parent.L_RCCTL_Text);
  784. return;
  785. }
  786. #endif
  787. try
  788. {
  789. DateTime = oDate.toLocaleString();
  790. }
  791. catch(error)
  792. {
  793. DateTime = L_UNKNOWN_Text;
  794. }
  795. TraceFunctLeave();
  796. return(DateTime);
  797. }