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.

1086 lines
27 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. RAControl.js
  5. Abstract:
  6. Contains Javascript code to handle the control channel
  7. Author:
  8. Rajesh Soy 10/00
  9. Revision History:
  10. Rajesh Soy - created 10/25/2000
  11. --*/
  12. /*++
  13. HELPER End of the Control Channel
  14. --*/
  15. #include "debug_decl.inc"
  16. #include "constants.inc"
  17. /*
  18. * Localizable Constants, text and messages
  19. */
  20. var L_RELEASECONTROL_Text = "&nbsp;&nbsp;Release <U>C</U>ontrol";
  21. var L_HELPEEREJECTRC_Text = "Your request to take control of remote computer was rejected by ";
  22. var L_HELPEETAKECONTROL_Text = " has stopped control.";
  23. var L_CONTROL1_Text = "You now are sharing control of ";
  24. var L_CONTROL2_Text = "'s computer. Click in ";
  25. var L_CONTROL3_Text = "'s screen to get started.\n\nControl will return to ";
  26. var L_CONTROL4_Text = " if you press the ESC key, or any key sequence or combination including the ESC key (such as ESC+TAB)";
  27. var L_ERRRCPERMDENIED1_Text = "Control of remote computer is not allowed.";
  28. var L_ERRRCERROR_Text = "Request to take control of remote computer failed.";
  29. //
  30. // VOIP Error messages
  31. //
  32. var L_ERRVOIP1_Text = c_szVoiceConnError;
  33. var L_ERRVOIP2_Text = c_szVoiceError;
  34. //
  35. // Helper_SetupControlChannel: Sets up the Control Channel and event handlers
  36. //
  37. function Helper_SetupControlChannel()
  38. {
  39. TraceFunctEnter("Helper_SetupControlChannel");
  40. try
  41. {
  42. //
  43. // Get the Channel Manager
  44. //
  45. DebugTrace("Getting ChannelManager");
  46. if(null == g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopChannelMgr)
  47. {
  48. g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopChannelMgr = g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopClient.ChannelManager;
  49. }
  50. //
  51. // Open the Chat channel
  52. //
  53. DebugTrace("Opening channels");
  54. //
  55. // Open the Control Channel
  56. //
  57. g_oSAFRemoteAssistanceHelper.m_oControlChannel = g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szControlChannelID );
  58. // Send the IP Address of the Expert to the Novice now!
  59. var ip;
  60. var oSetting = new ActiveXObject("rcbdyctl.setting");
  61. ip = oSetting.GetIPAddress;
  62. // Now send it
  63. Helper_SendIPAddress(ip);
  64. //
  65. // Setup the ChannelDataReady handlers
  66. //
  67. g_oSAFRemoteAssistanceHelper.m_oControlChannel.OnChannelDataReady = function()
  68. { Helper_ControlChannelDataReadyHandler(); }
  69. }
  70. catch(error)
  71. {
  72. //
  73. // Fatal Error
  74. //
  75. FatalError( L_ERRFATAL_Text, error );
  76. }
  77. TraceFunctLeave();
  78. return;
  79. }
  80. //
  81. // Helper_ControlChannelDataReadyHandler: Fired when there is data available on Control channel at helper end
  82. //
  83. function Helper_ControlChannelDataReadyHandler()
  84. {
  85. TraceFunctEnter("Helper_ControlChannelDataReadyHandler");
  86. var ControlData = null;
  87. //
  88. // Incoming data on the control channel. Data on this
  89. // channel will be in XML.
  90. //
  91. try
  92. {
  93. ControlData = g_oSAFRemoteAssistanceHelper.m_oControlChannel.ReceiveChannelData();
  94. }
  95. catch(error)
  96. {
  97. FatalError(L_ERRFATAL_Text, error);
  98. }
  99. //
  100. // Parse the data sent on the control channel and handle the command
  101. //
  102. SoundBeep();
  103. Helper_ParseControlData ( ControlData );
  104. TraceFunctLeave();
  105. return;
  106. }
  107. //
  108. // Helper_ParseControlData: Parses the XML data sent on the control channel and handles the command at the helper end
  109. //
  110. function Helper_ParseControlData ( ControlData )
  111. {
  112. TraceFunctEnter("Helper_ParseControlData");
  113. var Doc = new ActiveXObject("microsoft.XMLDOM");
  114. var RCCommand = null;
  115. var szCommandName = null;
  116. try
  117. {
  118. if( false == Doc.loadXML( ControlData ))
  119. {
  120. FatalError ( Doc.parseError.reason );
  121. }
  122. //
  123. // Get the RCCOMMAND node
  124. //
  125. RCCommand = Doc.documentElement;
  126. //
  127. // Get the NAME of the command
  128. //
  129. szCommandName = RCCommand.getAttribute( c_szRCCommandName );
  130. idCtx.minimized = false;
  131. idCtx.bringToForeground();
  132. //alert("RCCOMMAND: " + szCommandName );
  133. if( szCommandName == c_szScreenInfo )
  134. {
  135. //
  136. // SCREENINFO: Contains width/height/colordepth of user's machine. This is the
  137. // First command received from the helpee. Unless this command is received,
  138. // the connection sequence is not considered complete.
  139. //
  140. g_oSAFRemoteAssistanceHelper.m_UserWidth = RCCommand.getAttribute( c_szWidth );
  141. g_oSAFRemoteAssistanceHelper.m_UserHeight = RCCommand.getAttribute( c_szHeight );
  142. g_oSAFRemoteAssistanceHelper.m_UserColorDepth = RCCommand.getAttribute( c_szColorDepth );
  143. if( true == g_bVersionCheckEnforced )
  144. {
  145. //
  146. // VERSION Check
  147. //
  148. var szSchemaVersion = null;
  149. var szControlChannelVersion = null;
  150. try
  151. {
  152. szSchemaVersion = RCCommand.getAttribute( c_szSchema );
  153. if( szSchemaVersion != c_szSchemaVersion )
  154. {
  155. //
  156. // Schema Versions differ.
  157. //
  158. alert(L_ERRSCHEMAVERSION_Text);
  159. }
  160. }
  161. catch(error)
  162. {
  163. //
  164. // Our Helpee has an older version
  165. //
  166. alert(L_ERRSCHEMAVERSION_Text);
  167. }
  168. try
  169. {
  170. szControlChannelVersion = RCCommand.getAttribute( c_szControlChannel );
  171. if( szControlChannelVersion != c_szControlChannelVersion )
  172. {
  173. //
  174. // Control Channel Versions differ.
  175. //
  176. alert(L_ERRCHANNELVERSION_Text);
  177. }
  178. }
  179. catch(error)
  180. {
  181. //
  182. // Our Helpee has an older version
  183. //
  184. alert(L_ERRSCHEMAVERSION_Text);
  185. }
  186. }
  187. //
  188. // Send our version across to the Helpee
  189. //
  190. Helper_SendVersionInfo();
  191. }
  192. else if( szCommandName == c_szDisconnectRC )
  193. {
  194. //
  195. // DISCONNECTRC: Helpee initiated a Disconnect.
  196. //
  197. g_oSAFRemoteAssistanceHelper.m_bUserDisconnect = true;
  198. //
  199. // Call the shutdown sequence
  200. //
  201. RCDisconnect();
  202. }
  203. else if( szCommandName == c_szFileXfer )
  204. {
  205. //
  206. // FILEXFER: Helpee is initiating a file transfer
  207. //
  208. var vArgs = new Array(13);
  209. vArgs[0] = 1; // Destination Mode
  210. vArgs[1] = g_oSAFRemoteAssistanceHelper.m_oControlChannel; // Control Channel
  211. vArgs[2] = g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopChannelMgr; // Channel Manager
  212. vArgs[3] = RCCommand.getAttribute( c_szFileName ); // FILENAME
  213. vArgs[4] = RCCommand.getAttribute( c_szFileSize ); // FILESIZE
  214. vArgs[5] = RCCommand.getAttribute( c_szChannelId ); // CHANNELID
  215. vArgs[6] = g_oSAFRemoteAssistanceHelper.m_oFso; // File system object
  216. vArgs[7] = g_oSAFRemoteAssistanceHelper.m_oRCFileDlg; // File SaveAs dialog object
  217. vArgs[8] = g_oSAFRemoteAssistanceHelper.m_oSAFClassFactory; // SAF ClassFactory object
  218. vArgs[9] = g_oSAFRemoteAssistanceHelper.m_szUserName; // Sender
  219. // Logging DCR - Sending in a reference to the RAEventLog object
  220. //
  221. vArgs[10] = new ActiveXObject("RACplDlg.RAEventLog");
  222. vArgs[11] = g_oSAFRemoteAssistanceHelper.m_szHelpeeIP; // Remote IP
  223. vArgs[12] = g_oSAFRemoteAssistanceHelper.m_szLocalUser; // Remote Username
  224. //
  225. // Launch the File xfer UI in it's own Modeless dialog
  226. //
  227. //DebugTrace("launching RCFileXfer.htm");
  228. var subWin = window.showModelessDialog( c_szFileXferURL, vArgs, "dialogwidth:" + c_FileXferWidth + "px;dialogHeight:" + c_FileXferHeight + "px;status:no;resizable:no;help:no");
  229. AddOpenSubWin( subWin );
  230. }
  231. else if (szCommandName == c_szAcceptRC)
  232. {
  233. //
  234. // ACCEPTRC: Helpee has accepted request for control of his desktop
  235. //
  236. #ifdef _OLDTOOLBAR
  237. parent.frames.idFrameTools.btnTakeControl_1.disabled = false;
  238. parent.frames.idFrameTools.btnTakeControl_1.innerHTML = L_RELEASECONTROL_Text;
  239. #else
  240. parent.frames.idFrameTools.idTB.SetVisibility( "btnTakeControl", false);
  241. parent.frames.idFrameTools.idTB.SetVisibility( "btnReleaseControl", true);
  242. #endif
  243. // Log to the event log (event 3)
  244. try
  245. {
  246. var oLogger = new ActiveXObject("RACplDlg.RAEventLog");
  247. var args = new Array(2);
  248. args[0] = g_oSAFRemoteAssistanceHelper.m_szLocalUser;
  249. args[1] = g_oSAFRemoteAssistanceHelper.m_szUserName;
  250. // Expert side
  251. oLogger.LogRemoteAssistanceEvent(0,5,args);
  252. }
  253. catch(e)
  254. {
  255. // do nothing
  256. }
  257. //
  258. // Change Mode from VIEW to CONTROL
  259. //
  260. parent.frames.idFrameStatus.Helper_UpdateStatus( L_INCONTROL_Text );
  261. #ifdef _BVT
  262. if( false == g_oSAFRemoteAssistanceHelper.m_bBVT )
  263. {
  264. var vArgs = new Array(1);
  265. vArgs[0] = L_CONTROL1_Text + g_oSAFRemoteAssistanceHelper.m_szUserName + L_CONTROL2_Text + g_oSAFRemoteAssistanceHelper.m_szUserName + L_CONTROL3_Text + g_oSAFRemoteAssistanceHelper.m_szUserName + L_CONTROL4_Text; // Message
  266. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szTCMsgSpecs );
  267. AddOpenSubWin( vRetVal );
  268. }
  269. #else
  270. var vArgs = new Array(1);
  271. vArgs[0] = L_CONTROL1_Text + g_oSAFRemoteAssistanceHelper.m_szUserName + L_CONTROL2_Text + g_oSAFRemoteAssistanceHelper.m_szUserName + L_CONTROL3_Text + g_oSAFRemoteAssistanceHelper.m_szUserName + L_CONTROL4_Text; // Message
  272. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szTCMsgSpecs );
  273. AddOpenSubWin( vRetVal );
  274. #endif
  275. g_oSAFRemoteAssistanceHelper.m_bRCEnabled = true;
  276. }
  277. else if (szCommandName == c_szRejectRC)
  278. {
  279. //
  280. // REJECTRC: Helpee rejected request for control of his desktop
  281. //
  282. var vArgs = new Array(1);
  283. vArgs[0] = L_HELPEEREJECTRC_Text + " " + g_oSAFRemoteAssistanceHelper.m_szUserName; // Message
  284. #ifdef _OLDTOOLBAR
  285. parent.frames.idFrameTools.btnTakeControl_1.disabled = false;
  286. #else
  287. parent.frames.idFrameTools.idTB.SetState( "btnTakeControl", true );
  288. parent.frames.idFrameTools.g_bTakeControlDisabled = false;
  289. #endif
  290. parent.frames.idFrameStatus.Helper_UpdateStatus( L_SCREENVIEWONLY_Text );
  291. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szMsgSpecs );
  292. AddOpenSubWin( vRetVal );
  293. }
  294. else if (szCommandName == c_szTakeControl)
  295. {
  296. //
  297. // TAKECONTROL: Helpee took back control
  298. //
  299. // Log event log (event 4)
  300. try
  301. {
  302. var oLogger = new ActiveXObject("RACplDlg.RAEventLog");
  303. var args = new Array(2);
  304. args[0] = g_oSAFRemoteAssistanceHelper.m_szLocalUser;
  305. args[1] = g_oSAFRemoteAssistanceHelper.m_szUserName;
  306. // expert
  307. oLogger.LogRemoteAssistanceEvent(0,6,args);
  308. }
  309. catch(e)
  310. {
  311. // do nothing
  312. }
  313. var vArgs = new Array(1);
  314. vArgs[0] = g_oSAFRemoteAssistanceHelper.m_szUserName + L_HELPEETAKECONTROL_Text; // Message
  315. #ifdef _OLDTOOLBAR
  316. parent.frames.idFrameTools.btnTakeControl_1.disabled = false;
  317. parent.frames.idFrameTools.btnTakeControl_1.innerHTML = L_TAKECONTROL_Text;
  318. #else
  319. parent.frames.idFrameTools.idTB.SetVisibility( "btnReleaseControl", false);
  320. parent.frames.idFrameTools.idTB.SetVisibility( "btnTakeControl", true);
  321. parent.frames.idFrameTools.idTB.SetState( "btnTakeControl", true );
  322. parent.frames.idFrameTools.g_bTakeControlDisabled = false;
  323. #endif
  324. g_oSAFRemoteAssistanceHelper.m_bRCEnabled = false;
  325. //
  326. // Change Mode from CONTROL to VIEW
  327. //
  328. parent.frames.idFrameStatus.Helper_UpdateStatus( L_SCREENVIEWONLY_Text );
  329. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szMsgSpecs );
  330. AddOpenSubWin( vRetVal );
  331. }
  332. else if (szCommandName == c_szEscRC)
  333. {
  334. //
  335. // ESCRC: Helpee took back control by pressing ESC
  336. //
  337. // Log event log (event 4)
  338. try
  339. {
  340. var oLogger = new ActiveXObject("RACplDlg.RAEventLog");
  341. var args = new Array(2);
  342. args[0] = g_oSAFRemoteAssistanceHelper.m_szLocalUser;
  343. args[1] = g_oSAFRemoteAssistanceHelper.m_szUserName;
  344. // expert
  345. oLogger.LogRemoteAssistanceEvent(0,6,args);
  346. }
  347. catch(e)
  348. {
  349. // do nothing
  350. }
  351. var vArgs = new Array(1);
  352. vArgs[0] = g_oSAFRemoteAssistanceHelper.m_szUserName + L_OR_Text + g_oSAFRemoteAssistanceHelper.m_szLocalUser + L_ESCHIT_Text; // Message
  353. #ifdef _OLDTOOLBAR
  354. parent.frames.idFrameTools.btnTakeControl_1.disabled = false;
  355. parent.frames.idFrameTools.btnTakeControl_1.innerHTML = L_TAKECONTROL_Text;
  356. #else
  357. parent.frames.idFrameTools.idTB.SetVisibility( "btnReleaseControl", false);
  358. parent.frames.idFrameTools.idTB.SetVisibility( "btnTakeControl", true);
  359. parent.frames.idFrameTools.idTB.SetState( "btnTakeControl", true );
  360. parent.frames.idFrameTools.g_bTakeControlDisabled = false;
  361. #endif
  362. g_oSAFRemoteAssistanceHelper.m_bRCEnabled = false;
  363. //
  364. // Change Mode from CONTROL to VIEW
  365. //
  366. parent.frames.idFrameStatus.Helper_UpdateStatus( L_SCREENVIEWONLY_Text );
  367. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szMsgSpecs );
  368. AddOpenSubWin( vRetVal );
  369. }
  370. else if ( szCommandName == c_szDeniedRC )
  371. {
  372. var vArgs = new Array(1);
  373. vArgs[0] = L_ERRRCPERMDENIED1_Text; // Message
  374. #ifdef _OLDTOOLBAR
  375. parent.frames.idFrameTools.btnTakeControl_1.disabled = false;
  376. #else
  377. parent.frames.idFrameTools.idTB.SetState( "btnTakeControl", true );
  378. #endif
  379. parent.frames.idFrameTools.g_bTakeControlDisabled = false;
  380. parent.frames.idFrameStatus.Helper_UpdateStatus( L_SCREENVIEWONLY_Text );
  381. var vRetVal = window.showModalDialog( c_szMsgURL, vArgs, c_szMsgSpecs );
  382. }
  383. else if ( szCommandName == c_szErrorRC )
  384. {
  385. var vArgs = new Array(1);
  386. vArgs[0] = L_ERRRCERROR_Text; // Message
  387. #ifdef _OLDTOOLBAR
  388. parent.frames.idFrameTools.btnTakeControl_1.disabled = false;
  389. #else
  390. parent.frames.idFrameTools.idTB.SetState( "btnTakeControl", true );
  391. #endif
  392. parent.frames.idFrameStatus.Helper_UpdateStatus( L_SCREENVIEWONLY_Text );
  393. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szMsgSpecs );
  394. }
  395. // PreStartYes
  396. else if (szCommandName == c_szVoipPreStartYes)
  397. {
  398. if (false == g_bVoIPEnabled)
  399. {
  400. return;
  401. }
  402. if (false == g_bVoipConnected)
  403. {
  404. // Start Voice and send a message to the Helpee(Server) so it also starts.
  405. //
  406. try
  407. {
  408. // Send a message to 1. Ask for Voip and 2. if yes, call Listen and continue
  409. Helper_SendControlCommand ( c_szVoipPreGo );
  410. }
  411. catch (e)
  412. {
  413. }
  414. }
  415. else
  416. {
  417. //
  418. // This is the case where Voice is active. Stop it.
  419. // No message needs to be sent because the onVoiceDisconnected event will fire
  420. try
  421. {
  422. g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.Disconnect();
  423. }
  424. catch (e)
  425. {
  426. // Ungray the voice button
  427. #ifdef _OLDTOOLBAR
  428. frames.idFrameTools.btnVoice.disabled = false;
  429. #else
  430. frames.idFrameTools.idTB.SetState( "btnVoice", true );
  431. #endif
  432. // start accepting StartPending messages
  433. g_bStartEnabled = true;
  434. }
  435. }
  436. }
  437. // PreGo - Helper
  438. else if (szCommandName == c_szVoipPreGo)
  439. {
  440. if (false == g_bVoIPEnabled)
  441. {
  442. return;
  443. }
  444. // alert("Helper: Got StartPending!");
  445. try
  446. {
  447. // This message means that the Helpee(Server) has called Start(). So we need to call start
  448. // and send an ack back to the Helpee
  449. // Put up a Dialog to see if the helpee wants to 'GO VOICE!'
  450. var vArgs = new Array(1);
  451. vArgs[0] = L_VOIPSTART_Text; // Message
  452. var vRetVal = window.showModalDialog( c_szVOIPMsgURL, vArgs, c_szMsgSpecs );
  453. if( 0 == vRetVal)
  454. {
  455. //
  456. // Helper accepts Voice request
  457. //
  458. try
  459. {
  460. // call Listen()
  461. // g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.Listen();
  462. // We succeeded so send a message to the Helpee/Server
  463. Helper_SendControlCommand( c_szVoipPreGo2 );
  464. }
  465. catch (e)
  466. {
  467. //
  468. // Helper_SendControlCommand( c_szVoipGoNo );
  469. }
  470. }
  471. else
  472. {
  473. //
  474. // Helpee rejects Voice request
  475. //
  476. Helper_SendControlCommand( c_szVoipQNo );
  477. // ungray the voice button
  478. #ifdef _OLDTOOLBAR
  479. frames.idFrameTools.btnVoice.disabled = false;
  480. #else
  481. frames.idFrameTools.idTB.SetState( "btnVoice", true );
  482. #endif
  483. g_bStartEnabled = true;
  484. }
  485. }
  486. catch (error)
  487. {
  488. FatalError( L_RCCTL_Text, error );
  489. }
  490. }
  491. // QNo
  492. else if (szCommandName == c_szVoipQNo)
  493. {
  494. if (false == g_bVoIPEnabled)
  495. {
  496. return;
  497. }
  498. try
  499. {
  500. DisplayMessage( L_ERRVOIP1_Text );
  501. // ungray the voice button
  502. #ifdef _OLDTOOLBAR
  503. frames.idFrameTools.btnVoice.disabled = false;
  504. #else
  505. frames.idFrameTools.idTB.SetState( "btnVoice", true );
  506. #endif
  507. g_bStartEnabled = true;
  508. }
  509. catch (error)
  510. {
  511. FatalError( L_RCCTL_Text, error );
  512. }
  513. }
  514. // GoNo
  515. else if (szCommandName == c_szVoipGoNo)
  516. {
  517. if (false == g_bVoIPEnabled)
  518. {
  519. return;
  520. }
  521. try
  522. {
  523. DisplayMessage( L_ERRVOIP1_Text );
  524. // ungray the voice button
  525. #ifdef _OLDTOOLBAR
  526. frames.idFrameTools.btnVoice.disabled = false;
  527. #else
  528. frames.idFrameTools.idTB.SetState( "btnVoice", true );
  529. #endif
  530. g_bStartEnabled = true;
  531. }
  532. catch (error)
  533. {
  534. FatalError( L_RCCTL_Text, error );
  535. }
  536. }
  537. // Go
  538. // TODO: Change this to receive the KEY!!!! JP 3.5.01
  539. else if (szCommandName == c_szVoipGo)
  540. {
  541. if (false == g_bVoIPEnabled)
  542. {
  543. return;
  544. }
  545. var szKey = null; // Used to store the Key that has been sent through this message
  546. var szIPPort = null;
  547. var szTemp = null;
  548. var szIP = null;
  549. var szRAIP = null;
  550. var i = 0;
  551. var j = 0;
  552. var bFoundIP = false;
  553. try
  554. {
  555. // Get the trasmitted Key from the XML
  556. szKey = RCCommand.getAttribute( c_szVoipGoKey );
  557. szTemp = RCCommand.getAttribute( c_szVoipIPList );
  558. // go through the list of IPs and when we find the right one
  559. // grab it and the respective port. Then use it to call connect(...)
  560. // The 'right one' is the one that matches the RA IP
  561. // If we didn't send an IP list, then we use m_szHelpeeIP to try to connect for Voice
  562. while ((szTemp != null) && (i != -1) && (!bFoundIP))
  563. {
  564. i = szTemp.indexOf(";"); // Grab pos of End of this IP
  565. if (i != -1)
  566. szIPPort = szTemp.slice(0,i); // Grab this IP:Port
  567. else
  568. szIPPort = szTemp;
  569. j = szIPPort.indexOf(":");
  570. if (j == -1)
  571. {
  572. // The IP doesn't have a port, just use the string
  573. szIP = szIPPort;
  574. }
  575. else
  576. szIP = szIPPort.slice(0,j);
  577. szRAIP = g_oSAFRemoteAssistanceHelper.m_szHelpeeIP;
  578. // Compare the two IPs
  579. if (szIP == szRAIP)
  580. {
  581. bFoundIP = true;
  582. }
  583. // Move to the next token in the string (if necessary)
  584. if (i != -1)
  585. {
  586. szTemp = szTemp.slice(i+1);
  587. }
  588. }
  589. if (!bFoundIP)
  590. {
  591. szIPPort = g_oSAFRemoteAssistanceHelper.m_szHelpeeIP;
  592. }
  593. g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.Connect(szIPPort, szKey);
  594. }
  595. catch (e)
  596. {
  597. // Call Helpee_onVoiceDisabled() -
  598. //
  599. // Disable voice in the case that Connect fails
  600. frames.idFrameTools.Helper_onVoiceDisabled();
  601. }
  602. }
  603. // PreStartNo
  604. else if (szCommandName == c_szVoipPreStartNo)
  605. {
  606. if (false == g_bVoIPEnabled)
  607. {
  608. return;
  609. }
  610. // This means, that a connection transaction has already been established the opposite direction
  611. try
  612. {
  613. // Enable Start
  614. g_bStartEnabled = true;
  615. // Ungray the voice button
  616. #ifdef _OLDTOOLBAR
  617. frames.idFrameTools.btnVoice.disabled = false;
  618. #else
  619. frames.idFrameTools.idTB.SetState( "btnVoice", true );
  620. #endif
  621. }
  622. catch (error)
  623. {
  624. FatalError( L_RCCTL_Text, error );
  625. }
  626. }
  627. // PreStart
  628. else if (szCommandName == c_szVoipPreStart)
  629. {
  630. if (false == g_bVoIPEnabled)
  631. {
  632. return;
  633. }
  634. try
  635. {
  636. // This message Starts the connection transaction
  637. // gray the voice button - so that we can't click on it also
  638. #ifdef _OLDTOOLBAR
  639. frames.idFrameTools.btnVoice.disabled = true;
  640. #else
  641. frames.idFrameTools.idTB.SetState( "btnVoice", false );
  642. #endif
  643. if (false == g_bStartEnabled )
  644. {
  645. // Start is not enables, send PreStartNo
  646. Helper_SendControlCommand ( c_szVoipPreStartNo );
  647. // Ungray the button
  648. #ifdef _OLDTOOLBAR
  649. frames.idFrameTools.btnVoice.disabled = false;
  650. #else
  651. frames.idFrameTools.idTB.SetState( "btnVoice", true );
  652. #endif
  653. }
  654. else
  655. {
  656. // it's ok - send PreStartYes
  657. Helper_SendControlCommand ( c_szVoipPreStartYes );
  658. }
  659. }
  660. catch (error)
  661. {
  662. FatalError( L_RCCTL_Text, error );
  663. }
  664. }
  665. // VoipDisable
  666. else if (szCommandName == c_szVoipDisable)
  667. {
  668. try
  669. {
  670. if (g_bVoIPEnabled == true)
  671. {
  672. DisplayMessage( L_ERRVOIP2_Text );
  673. // disable VoIP
  674. g_bVoIPEnabled = false;
  675. // set you to bad
  676. g_stateVoipYou = 2;
  677. // Gray the button
  678. #ifdef _OLDTOOLBAR
  679. frames.idFrameTools.btnVoice.disabled = true;
  680. #else
  681. frames.idFrameTools.idTB.SetState( "btnVoice", false );
  682. #endif
  683. }
  684. }
  685. catch (error)
  686. {
  687. FatalError( L_RCCTL_Text, error );
  688. }
  689. }
  690. // VoipWizardGood
  691. else if (szCommandName == c_szVoipWizardGood)
  692. {
  693. try
  694. {
  695. // set you to good
  696. g_stateVoipYou = 1;
  697. // check to see if we can enable voice
  698. if ( (g_stateVoipYou < 2) && (g_stateVoipMe < 2) )
  699. {
  700. // Ungray voice button
  701. g_bVoIPEnabled = true;
  702. #ifdef _OLDTOOLBAR
  703. frames.idFrameTools.btnVoice.disabled = false;
  704. #else
  705. frames.idFrameTools.idTB.SetState( "btnVoice", true );
  706. #endif
  707. }
  708. }
  709. catch (error)
  710. {
  711. FatalError( L_RCCTL_Text, error );
  712. }
  713. }
  714. // VoipWizardBad
  715. else if (szCommandName == c_szVoipWizardBad)
  716. {
  717. try
  718. {
  719. g_bVoIPEnabled = false;
  720. DisplayMessage( L_ERRVOIP2_Text );
  721. // set you to bad
  722. g_stateVoipYou = 2;
  723. // gray button
  724. #ifdef _OLDTOOLBAR
  725. frames.idFrameTools.btnVoice.disabled = true;
  726. #else
  727. frames.idFrameTools.idTB.SetState( "btnVoice", false );
  728. #endif
  729. }
  730. catch (error)
  731. {
  732. FatalError( L_RCCTL_Text, error );
  733. }
  734. }
  735. // VoipBandwidthToHigh
  736. else if (szCommandName == c_szVoipBandwidthToHigh)
  737. {
  738. //alert("Test");
  739. g_VoipBandwidth = 1;
  740. g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.SamplingRate = 2;
  741. }
  742. // VoipBandwidthToLow
  743. else if (szCommandName == c_szVoipBandwidthToLow)
  744. {
  745. g_VoipBandwidth = 0;
  746. g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.SamplingRate = 1;
  747. }
  748. #ifdef _BVT
  749. else if (( szCommandName == c_szBVTPASS )&&( true == g_oSAFRemoteAssistanceHelper.m_bBVT ))
  750. {
  751. frames.idFrameChat.Helper_UpdateChatHistory( c_szBVTPASS );
  752. }
  753. else if (( szCommandName == c_szBVTFAIL )&&( true == g_oSAFRemoteAssistanceHelper.m_bBVT ))
  754. {
  755. frames.idFrameChat.Helper_UpdateChatHistory( c_szBVTFAIL );
  756. }
  757. #endif
  758. }
  759. catch(error)
  760. {
  761. FatalError( L_ERRFATAL_Text, error );
  762. }
  763. TraceFunctLeave();
  764. return;
  765. }
  766. //
  767. // Helper_SendVersionInfo: Routine to send the helper version information across to the helpee
  768. //
  769. function Helper_SendVersionInfo()
  770. {
  771. TraceFunctEnter("Helper_SendControlCommand");
  772. var Doc = null;
  773. var RCCommand = null;
  774. try
  775. {
  776. //
  777. // Create an XML document
  778. //
  779. Doc = new ActiveXObject("microsoft.XMLDOM");
  780. //
  781. // Create the RCCOMMAND root node
  782. //
  783. RCCommand = Doc.createElement( c_szRCCommand );
  784. //
  785. // Set the NAME attribute to HELPERVERSION
  786. //
  787. RCCommand.setAttribute( c_szRCCommandName, c_szHelperVersion );
  788. //
  789. // Set the SCHEMAVERSION attribute
  790. //
  791. RCCommand.setAttribute( c_szSchema, c_szSchemaVersion );
  792. //
  793. // Set the CONTROLCHANNELVERSION attribute
  794. //
  795. RCCommand.setAttribute( c_szControlChannel, c_szControlChannelVersion );
  796. //
  797. // Send control message to other end
  798. //
  799. g_oSAFRemoteAssistanceHelper.m_oControlChannel.SendChannelData( RCCommand.xml );
  800. }
  801. catch(error)
  802. {
  803. FatalError( L_RCCTL_Text, error );
  804. }
  805. TraceFunctLeave();
  806. }
  807. //
  808. // Helper_SendControlCommand: Routine to send a control command across to the helpee
  809. //
  810. function Helper_SendControlCommand( szCommandName )
  811. {
  812. TraceFunctEnter("Helper_SendControlCommand");
  813. var Doc = null;
  814. var RCCommand = null;
  815. try
  816. {
  817. //
  818. // Create an XML document
  819. //
  820. Doc = new ActiveXObject("microsoft.XMLDOM");
  821. //
  822. // Create the RCCOMMAND root node
  823. //
  824. RCCommand = Doc.createElement( c_szRCCommand );
  825. //
  826. // Set the NAME attribute to szCommandName
  827. //
  828. RCCommand.setAttribute( c_szRCCommandName, szCommandName );
  829. //
  830. // Send control message to other end
  831. //
  832. g_oSAFRemoteAssistanceHelper.m_oControlChannel.SendChannelData( RCCommand.xml );
  833. }
  834. catch(error)
  835. {
  836. FatalError( L_RCCTL_Text, error );
  837. }
  838. TraceFunctLeave();
  839. return;
  840. }
  841. function Helper_SendIPAddress( szIP )
  842. {
  843. TraceFunctEnter("Helper_SendIPAddress");
  844. var Doc = null;
  845. var RCCommand = null;
  846. try
  847. {
  848. //
  849. // Create an XML document
  850. //
  851. Doc = new ActiveXObject("microsoft.XMLDOM");
  852. //
  853. // Create the RCCOMMAND root node
  854. //
  855. RCCommand = Doc.createElement( c_szRCCommand );
  856. //
  857. // Set the NAME attribute to szCommandName
  858. //
  859. RCCommand.setAttribute( c_szRCCommandName, c_szExpertIP );
  860. RCCommand.setAttribute( c_szExpertIPDATA, szIP );
  861. //
  862. // Send control message to other end
  863. //
  864. g_oSAFRemoteAssistanceHelper.m_oControlChannel.SendChannelData( RCCommand.xml );
  865. }
  866. catch(error)
  867. {
  868. FatalError( L_RCCTL_Text, error );
  869. }
  870. TraceFunctLeave();
  871. return;
  872. }
  873. //
  874. // Helper_ResetHelpee: Routine to reset Helpee after RC
  875. //
  876. function Helper_ResetHelpee()
  877. {
  878. TraceFunctEnter("Helper_ResetHelpee");
  879. //
  880. // Send control message to other end to signal Remote control end
  881. //
  882. Helper_SendControlCommand( c_szRemoteCtrlEnd );
  883. TraceFunctLeave();
  884. return;
  885. }