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.

489 lines
11 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. RAServer.js
  5. Abstract:
  6. Contains Javascript code to handle control of the Server side (Helpee) UI
  7. Author:
  8. Rajesh Soy 10/00
  9. Revision History:
  10. Rajesh Soy - created 10/24/2000
  11. --*/
  12. #include "debug_decl.inc"
  13. #include "constants.inc"
  14. /*
  15. * Localizable constants, text and messages
  16. */
  17. var L_STOPTALKING_Text = "Stop <U>T</U>alking";
  18. var L_STARTTALKING_Text = "Start <u>T</u>alking";
  19. var L_LASTCHAT_Text = "Last message received at ";
  20. var L_ERRRCSESSION_Text = "Failed to destroy RCSession";
  21. var L_ERRNULLRCSESSION_Text = c_szError1;
  22. var L_RCCTL_Text = "Remote Assistance failed. Please try again. ";
  23. //
  24. // VOIP Messages
  25. //
  26. var L_ERRVOIP2_Text = c_szVoiceError;
  27. /*++
  28. Helpee End utility routines and globals
  29. --*/
  30. //
  31. // Salem objects.
  32. //
  33. var g_Helpee_oSAFRemoteDesktopSession = null;
  34. var g_Helpee_oSAFRemoteDesktopChannelMgr = null;
  35. var g_Helpee_oChatChannel = null;
  36. var g_Helpee_oControlChannel = null;
  37. var g_Helpee_oSAFIntercomServer = null;
  38. #ifdef _VOIPENABLED
  39. var g_bVoIPEnabled = true; // JPEREZ: Enabled March 1, 2001 - // ADHOC, Disabling VoIP for the moment.
  40. #else
  41. var g_bVoIPEnabled = false;
  42. #endif
  43. var g_objPanic = null;
  44. //
  45. // InitVoIP
  46. //
  47. function InitVoIP()
  48. {
  49. //
  50. // If VoIP is enabled
  51. //
  52. if( true == g_bVoIPEnabled )
  53. {
  54. // Point the g_oSAFRemoteAssistanceHelpee to it's parent
  55. // NOTE: It will be null
  56. // alert("Creating CreateObject_IntercomServer...");
  57. g_Helpee_oSAFIntercomServer = oSAFClassFactory.CreateObject_IntercomServer();
  58. g_Helpee_oSAFIntercomServer.onVoiceDisconnected = Helpee_onVoiceDisconnected;
  59. g_Helpee_oSAFIntercomServer.onVoiceConnected = Helpee_onVoiceConnected;
  60. g_Helpee_oSAFIntercomServer.onVoiceDisabled = Helpee_onVoiceDisabled;
  61. }
  62. }
  63. //
  64. // Initialize the Helpee End SALEM Objects
  65. //
  66. function Init_Helpee_SALEM()
  67. {
  68. TraceFunctEnter("Init_Helpee_SALEM");
  69. if(null == g_Helpee_oSAFRemoteDesktopSession)
  70. {
  71. //alert("This is not good");
  72. FatalError( L_ERRNULLRCSESSION_Text );
  73. }
  74. else
  75. {
  76. try
  77. {
  78. //
  79. // Get the Channel Manager
  80. //
  81. //alert("Getting ChannelManager");
  82. g_Helpee_oSAFRemoteDesktopChannelMgr = g_Helpee_oSAFRemoteDesktopSession.ChannelManager;
  83. //
  84. // Open the Chat channel
  85. //
  86. //alert("Opening ChatChannel");
  87. g_Helpee_oChatChannel = g_Helpee_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szChatChannelID );
  88. //
  89. // Open the Control Channel
  90. //
  91. //alert("Opening Control Channel");
  92. g_Helpee_oControlChannel = g_Helpee_oSAFRemoteDesktopChannelMgr.OpenDataChannel( c_szControlChannelID );
  93. //
  94. // Setup the ChannelDataReady handlers
  95. //
  96. // alert("Binding Events");
  97. g_Helpee_oChatChannel.OnChannelDataReady = function()
  98. { Helpee_ChatChannelDataReadyEventHandler(); }
  99. g_Helpee_oControlChannel.OnChannelDataReady = function()
  100. { Helpee_ControlChannelDataReadyEventHandler(); }
  101. //
  102. // Setup the OnDisconnected event callback
  103. //
  104. g_Helpee_oSAFRemoteDesktopSession.OnDisconnected = function()
  105. { Helpee_OnClientDisconnectedEventHandler(); }
  106. }
  107. catch(error)
  108. {
  109. //
  110. // Fatal Error initializing SALEM. Close down
  111. //
  112. FatalError( L_ERRFATAL_Text, error );
  113. }
  114. }
  115. TraceFunctLeave();
  116. return;
  117. }
  118. //
  119. // This function gets called when the onVoiceDisconnected event gets fired on the helpee/server
  120. //
  121. function Helpee_onVoiceDisconnected()
  122. {
  123. TraceFunctEnter("Helpee_onVoiceDisconnected");
  124. try
  125. {
  126. if (true == g_bConnected)
  127. {
  128. // alert("in onVoiceDisconnected!");
  129. // Persist state for VoIP connection
  130. g_bVoipConnected = false;
  131. g_bStartEnabled = true;
  132. // Ungray the voice button only if voice is enabled
  133. if (g_bVoIPEnabled == true)
  134. {
  135. #ifndef _HSSTOOLBAR
  136. frames.idFrameTools.btnVoice.disabled = false;
  137. frames.idFrameTools.txtVoice.disabled = false;
  138. // DO NOT Set the not connected image
  139. // frames.idFrameTools.imgVoicePic.src = "../Common/SendVoice.gif";
  140. frames.idFrameTools.txtVoice.innerHTML = L_STARTTALKING_Text;
  141. #else
  142. frames.idFrameTools.HideButton( "btnVoiceStop" );
  143. frames.idFrameTools.EnableButton( "btnVoice" );
  144. frames.idFrameTools.ShowButton( "btnVoice" );
  145. #endif
  146. }
  147. }
  148. }
  149. catch (error)
  150. {
  151. // This should never happen as there are no calls to objects
  152. // DO NOTHING
  153. }
  154. TraceFunctLeave();
  155. }
  156. //
  157. // This function gets called when the onVoiceConnected event gets fired on the helpee/server
  158. //
  159. function Helpee_onVoiceConnected()
  160. {
  161. TraceFunctEnter("Helpee_onVoiceConnected");
  162. try
  163. {
  164. // alert("in onVoiceConnected!");
  165. // alert("Setting g_bVoipConnected = TRUE");
  166. // Persist state for VoIP connection
  167. g_bVoipConnected = true;
  168. g_bStartEnabled = true;
  169. // Ungray the voice button
  170. #ifndef _HSSTOOLBAR
  171. frames.idFrameTools.txtVoice.innerHTML = L_STOPTALKING_Text;
  172. frames.idFrameTools.btnVoice.disabled = false;
  173. frames.idFrameTools.txtVoice.disabled = false;
  174. // Do not change the image
  175. // frames.idFrameTools.imgVoicePic.src = "../Common/SendVoiceOn.gif";
  176. #else
  177. frames.idFrameTools.HideButton( "btnVoice" );
  178. frames.idFrameTools.ShowButton( "btnVoiceStop" );
  179. frames.idFrameTools.EnableButton( "btnVoiceStop" );
  180. #endif
  181. }
  182. catch (error)
  183. {
  184. // This should never happen as there are no calls to objects
  185. // DO NOTHING
  186. }
  187. TraceFunctLeave();
  188. }
  189. function Helpee_onVoiceDisabled()
  190. {
  191. TraceFunctEnter("Helpee_onVoiceDisabled");
  192. try
  193. {
  194. if (g_bVoIPEnabled == true)
  195. {
  196. // Disable the voice on this machine
  197. g_bVoIPEnabled = false;
  198. g_bVoipConnected = false;
  199. DisplayMessage(L_ERRVOIP2_Text);
  200. // Gray the voice button
  201. #ifndef _HSSTOOLBAR
  202. frames.idFrameTools.btnVoice.disabled = true;
  203. frames.idFrameTools.txtVoice.disabled = true;
  204. #else
  205. frames.idFrameTools.DisableButton( "btnVoice" );
  206. #endif
  207. // set me to bad
  208. g_stateVoipMe = 2;
  209. // Send a message to the Helper to disable it's voice also
  210. Helpee_SendControlCommand( c_szVoipDisable );
  211. }
  212. }
  213. catch (error)
  214. {
  215. FatalError( L_RCCTL_Text, error );
  216. }
  217. TraceFunctLeave();
  218. }
  219. //
  220. // Helpee_ChatChannelDataReadyEventHandler: Call back to handle data from expert
  221. //
  222. function Helpee_ChatChannelDataReadyEventHandler()
  223. {
  224. TraceFunctEnter("Helpee_ChatChannelDataReadyEventHandler");
  225. var data = null;
  226. try
  227. {
  228. //
  229. // Data on chat channel
  230. //
  231. data = g_Helpee_oChatChannel.ReceiveChannelData();
  232. idCtx.minimized = false;
  233. idCtx.bringToForeground();
  234. SoundBeep();
  235. //
  236. // Open Chat window if necessary
  237. //
  238. if(true == g_bChatBoxHidden)
  239. {
  240. frames.idFrameTools.Helpee_HideChat();
  241. }
  242. //
  243. // Update chat history window with incoming data
  244. //
  245. frames.idFrameChatTop.UpdateChatHistory( data );
  246. frames.idFrameTools.UpdateChatStatus( L_LASTCHAT_Text );
  247. frames.idFrameChatTop.SetFocus();
  248. #ifdef _BVT
  249. if( data == c_szChatBVT )
  250. {
  251. g_Helpee_oChatChannel.SendChannelData( c_szBVTPASS );
  252. }
  253. #endif
  254. }
  255. catch(error)
  256. {
  257. FatalError( L_ERRFATAL_Text, error );
  258. }
  259. TraceFunctLeave();
  260. return;
  261. }
  262. function DisplayDisconnectStatus()
  263. {
  264. TraceFunctEnter("DisplayDisconnectStatus");
  265. try
  266. {
  267. frames.idFrameTools.UpdateStatus( L_HELPEEDISCONNECTED_Text );
  268. parent.gDisconnected = true;
  269. }
  270. catch(error)
  271. {
  272. FatalError( L_RCCTL_Text, error );
  273. }
  274. TraceFunctLeave();
  275. return;
  276. }
  277. function Helpee_OnClientDisconnectedEventHandler()
  278. {
  279. TraceFunctEnter("Helpee_OnClientDisconnectedEventHandler");
  280. try
  281. {
  282. SoundBeep();
  283. g_bConnected = false;
  284. try
  285. {
  286. // Disconnect the voice session if active
  287. if (g_bVoipConnected == true)
  288. {
  289. g_Helpee_oSAFIntercomServer.Disconnect();
  290. }
  291. if(null != parent.oRCSession)
  292. {
  293. parent.oRCSession.Disconnect();
  294. parent.oRCSession.onDisconnected = function()
  295. { }
  296. parent.oRCSession.onConnected = function( salemID, userSID, sessionID )
  297. { }
  298. }
  299. }
  300. catch(error)
  301. {
  302. // Ignore
  303. }
  304. DisplayDisconnectStatus();
  305. TraceFunctLeave();
  306. EndTrace();
  307. idBody.disabled = true;
  308. //frames.idFrameChatTop.idBody.disabled = true;
  309. frames.idFrameChatTop.idchatText.disabled = true;
  310. frames.idFrameChatTop.btnSendChat.disabled = true;
  311. frames.idFrameChatTop.idIncomingChatText.disabled = false;
  312. frames.idFrameTools.idBody.disabled = true;
  313. CloseOpenSubWin();
  314. if( false == g_bUserDisconnect )
  315. {
  316. if (null != g_objPanic)
  317. {
  318. g_objPanic.ClearPanicHook();
  319. }
  320. #ifdef _BVT
  321. if( false == parent.gBVT )
  322. {
  323. if ( (null == parent.gHelperName ) || ( parent.gHelperName.length == 0 ))
  324. {
  325. parent.gHelperName = L_DEFAULTUSER_Text;
  326. }
  327. var vArgs = new Array(1);
  328. vArgs[0] = L_ERRDISCONNECT1_Text + parent.gHelperName + L_ERRDISCONNECT2_Text + parent.gHelperName + "."; // Message
  329. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szMsgSpecs );
  330. }
  331. #else
  332. if ( (null == parent.gHelperName ) || ( parent.gHelperName.length == 0 ))
  333. {
  334. parent.gHelperName = L_DEFAULTUSER_Text;
  335. }
  336. var vArgs = new Array(1);
  337. vArgs[0] = L_ERRDISCONNECT1_Text + parent.gHelperName + L_ERRDISCONNECT2_Text + parent.gHelperName + "."; // Message
  338. var vRetVal = window.showModelessDialog( c_szMsgURL, vArgs, c_szMsgSpecs );
  339. #endif
  340. }
  341. #ifdef _HELPCNT
  342. //
  343. // Increment count of number of help requests
  344. //
  345. var sVendorID = "CN=Microsoft Corporation,L=Redmond,S=Washington,C=US";
  346. var sProductID = "Microsoft Remote Assistance";
  347. var chan = parent.pchealth.CreateObject_Channel( sVendorID, sProductID );
  348. var iTimes = 0;
  349. var sTimes = null;
  350. for(var e = new Enumerator( chan.Incidents( 2 ) ); !e.atEnd(); e.moveNext())
  351. {
  352. var inc = e.item();
  353. if (inc.URL == parent.sSalemID) // Find the correct incident
  354. {
  355. var XMLFile = inc.XMLDataFile;
  356. if (XMLFile == "")
  357. {
  358. continue;
  359. }
  360. var oInc = parent.pchealth.CreateObject_Incident();
  361. oInc.LoadFromXMLFile(XMLFile);
  362. try
  363. {
  364. sTimes = oInc.Misc("HelpCnt");
  365. if( (sTimes == null) || (sTimes.length == 0 ))
  366. {
  367. iTimes = 1;
  368. }
  369. else
  370. {
  371. iTimes = parseInt( sTimes ) + 1;
  372. }
  373. }
  374. catch(e)
  375. {
  376. iTimes = 1;
  377. }
  378. oInc.Misc("HelpCnt") = iTimes;
  379. oInc.GetXML(XMLFile);
  380. //alert("iTimes: " + iTimes);
  381. }
  382. }
  383. #endif // _HELPCNT
  384. #ifdef _BVT
  385. if( true == parent.gBVT )
  386. {
  387. parent.pchealth.close();
  388. }
  389. #endif
  390. }
  391. catch(error)
  392. {
  393. //FatalTrace( L_ERRRCSESSION_Text, error );
  394. }
  395. }