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.

2008 lines
61 KiB

  1. /*******************************************************************************
  2. *
  3. * mainfrm.cpp
  4. *
  5. * implementation of the CMainFrame class
  6. *
  7. * copyright notice: Copyright 1997, Citrix Systems Inc.
  8. * Copyright (c) 1998 - 1999 Microsoft Corporation
  9. *
  10. * $Author: donm $ Don Messerli
  11. *
  12. *******************************************************************************/
  13. #include "stdafx.h"
  14. #include "afxpriv.h"
  15. #include "afxcview.h"
  16. #include "winadmin.h"
  17. #include "admindoc.h"
  18. #include "treeview.h"
  19. #include "rtpane.h"
  20. #include "dialogs.h"
  21. #include "htmlhelp.h"
  22. #include "mainfrm.h"
  23. #include <winsock2.h>
  24. #include <dsrole.h>
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. #ifdef _STRESS_BUILD
  31. DWORD RunStress( PVOID pv );
  32. DWORD RunStressLite( PVOID pv );
  33. BOOL g_fWaitForAllServersToDisconnect = 1;
  34. #endif
  35. INT_PTR CALLBACK FWarnDlg( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp );
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CMainFrame
  38. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  39. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  40. //{{AFX_MSG_MAP(CMainFrame)
  41. ON_WM_CREATE()
  42. ON_MESSAGE(WM_ADMIN_CHANGEVIEW, OnAdminChangeView)
  43. ON_MESSAGE(WM_ADMIN_ADD_SERVER, OnAdminAddServer)
  44. ON_MESSAGE(WM_ADMIN_REMOVE_SERVER, OnAdminRemoveServer)
  45. ON_MESSAGE(WM_ADMIN_UPDATE_SERVER, OnAdminUpdateServer)
  46. ON_MESSAGE(WM_ADMIN_UPDATE_PROCESSES, OnAdminUpdateProcesses)
  47. ON_MESSAGE(WM_ADMIN_REMOVE_PROCESS, OnAdminRemoveProcess)
  48. ON_MESSAGE(WM_ADMIN_ADD_WINSTATION, OnAdminAddWinStation)
  49. ON_MESSAGE(WM_ADMIN_UPDATE_WINSTATION, OnAdminUpdateWinStation)
  50. ON_MESSAGE(WM_ADMIN_REMOVE_WINSTATION, OnAdminRemoveWinStation)
  51. ON_MESSAGE(WM_ADMIN_UPDATE_SERVER_INFO, OnAdminUpdateServerInfo)
  52. ON_MESSAGE(WM_ADMIN_REDISPLAY_LICENSES, OnAdminRedisplayLicenses)
  53. ON_MESSAGE(WM_ADMIN_UPDATE_WINSTATIONS, OnAdminUpdateWinStations)
  54. ON_MESSAGE(WM_ADMIN_UPDATE_DOMAIN, OnAdminUpdateDomain)
  55. ON_MESSAGE(WM_ADMIN_ADD_DOMAIN, OnAdminAddDomain)
  56. ON_MESSAGE(WM_ADMIN_VIEWS_READY, OnAdminViewsReady)
  57. ON_MESSAGE(WM_FORCE_TREEVIEW_FOCUS , OnForceTreeViewFocus )
  58. ON_MESSAGE( WM_ADMIN_ADDSERVERTOFAV , OnAdminAddServerToFavorites )
  59. ON_MESSAGE( WM_ADMIN_REMOVESERVERFROMFAV , OnAdminRemoveServerFromFavs )
  60. ON_MESSAGE( WM_ADMIN_GET_TV_STATES , OnAdminGetTVStates )
  61. ON_MESSAGE( WM_ADMIN_UPDATE_TVSTATE , OnAdminUpdateTVStates )
  62. ON_COMMAND(IDM_EXPAND_ALL, OnExpandAll)
  63. ON_COMMAND(IDM_REFRESH, OnRefresh)
  64. ON_COMMAND(IDM_CONNECT, OnConnect)
  65. ON_COMMAND(IDM_DISCONNECT, OnDisconnect)
  66. ON_COMMAND(IDM_MESSAGE, OnSendMessage)
  67. ON_COMMAND(IDM_SHADOW, OnShadow)
  68. ON_COMMAND(IDM_RESET, OnReset)
  69. ON_COMMAND(IDM_STATUS, OnStatus)
  70. ON_COMMAND(IDTM_CONNECT, OnTreeConnect)
  71. ON_COMMAND(IDTM_DISCONNECT, OnTreeDisconnect)
  72. ON_COMMAND(IDTM_MESSAGE, OnTreeSendMessage)
  73. ON_COMMAND(IDTM_SHADOW, OnTreeShadow)
  74. ON_COMMAND(IDTM_RESET, OnTreeReset)
  75. ON_COMMAND(IDTM_STATUS, OnTreeStatus)
  76. ON_COMMAND(IDM_LOGOFF, OnLogoff)
  77. ON_COMMAND(IDM_TERMINATE, OnTerminate)
  78. ON_COMMAND(IDM_PREFERENCES, OnPreferences)
  79. ON_COMMAND(IDM_COLLAPSE_ALL, OnCollapseAll)
  80. ON_COMMAND(IDM_COLLAPSE_TOSERVERS, OnCollapseToServers)
  81. ON_COMMAND(IDM_COLLAPSE_TODOMAINS, OnCollapseToDomains)
  82. ON_COMMAND(IDM_SHOW_SYSTEM_PROCESSES, OnShowSystemProcesses)
  83. ON_COMMAND(IDM_SERVER_CONNECT, OnServerConnect)
  84. ON_COMMAND(IDM_SERVER_DISCONNECT, OnServerDisconnect)
  85. ON_COMMAND( IDTM_DOMAIN_FIND_SERVER , OnFindServer )
  86. ON_COMMAND(IDM_SERVER_ADDTOFAV , OnAddToFavorites )
  87. ON_COMMAND(IDM_SERVER_REMOVEFAV , OnRemoveFromFavs )
  88. ON_COMMAND( IDM_ALLSERVERS_EMPTYFAVORITES , OnEmptyFavorites )
  89. ON_COMMAND(IDTM_DOMAIN_CONNECT_ALL, OnTreeDomainConnectAllServers)
  90. ON_COMMAND(IDTM_DOMAIN_DISCONNECT_ALL, OnTreeDomainDisconnectAllServers)
  91. ON_COMMAND(IDTM_DOMAIN_FIND_SERVERS, OnTreeDomainFindServers)
  92. ON_COMMAND(IDM_DOMAIN_CONNECT_ALL, OnDomainConnectAllServers)
  93. ON_COMMAND(IDM_DOMAIN_DISCONNECT_ALL, OnDomainDisconnectAllServers)
  94. ON_COMMAND(IDM_ALLSERVERS_CONNECT, OnAllServersConnect)
  95. ON_COMMAND(IDM_ALLSERVERS_DISCONNECT, OnAllServersDisconnect)
  96. ON_COMMAND(IDM_ALLSERVERS_FIND, OnAllServersFind)
  97. ON_UPDATE_COMMAND_UI(IDM_CONNECT, OnUpdateConnect)
  98. ON_UPDATE_COMMAND_UI(IDM_DISCONNECT, OnUpdateDisconnect)
  99. ON_UPDATE_COMMAND_UI(IDM_LOGOFF, OnUpdateLogoff)
  100. ON_UPDATE_COMMAND_UI(IDM_MESSAGE, OnUpdateMessage)
  101. ON_UPDATE_COMMAND_UI(IDM_RESET, OnUpdateReset)
  102. ON_UPDATE_COMMAND_UI(IDM_SHADOW, OnUpdateShadow)
  103. ON_UPDATE_COMMAND_UI(IDM_STATUS, OnUpdateStatus)
  104. ON_UPDATE_COMMAND_UI(IDM_TERMINATE, OnUpdateTerminate)
  105. ON_UPDATE_COMMAND_UI(IDM_SERVER_CONNECT, OnUpdateServerConnect)
  106. ON_UPDATE_COMMAND_UI(IDM_SERVER_DISCONNECT, OnUpdateServerDisconnect)
  107. ON_UPDATE_COMMAND_UI( IDM_SERVER_ADDTOFAV , OnUpdateServerAddToFavorite )
  108. ON_UPDATE_COMMAND_UI( IDM_SERVER_REMOVEFAV , OnUpdateServerRemoveFromFavorite )
  109. ON_UPDATE_COMMAND_UI(IDTM_CONNECT, OnUpdateTreeConnect)
  110. ON_UPDATE_COMMAND_UI(IDTM_DISCONNECT, OnUpdateTreeDisconnect)
  111. ON_UPDATE_COMMAND_UI(IDTM_MESSAGE, OnUpdateTreeMessage)
  112. ON_UPDATE_COMMAND_UI(IDTM_RESET, OnUpdateTreeReset)
  113. ON_UPDATE_COMMAND_UI(IDTM_SHADOW, OnUpdateTreeShadow)
  114. ON_UPDATE_COMMAND_UI(IDTM_STATUS, OnUpdateTreeStatus)
  115. ON_UPDATE_COMMAND_UI(IDM_SHOW_SYSTEM_PROCESSES, OnUpdateShowSystemProcesses)
  116. ON_UPDATE_COMMAND_UI_RANGE(IDM_DOMAIN_CONNECT_ALL, IDM_DOMAIN_DISCONNECT_ALL, OnUpdateDomainMenu)
  117. ON_UPDATE_COMMAND_UI_RANGE(IDTM_DOMAIN_CONNECT_ALL, IDTM_DOMAIN_DISCONNECT_ALL, OnUpdateDomainPopupMenu)
  118. ON_UPDATE_COMMAND_UI(IDTM_DOMAIN_FIND_SERVERS, OnUpdateDomainPopupFind)
  119. ON_UPDATE_COMMAND_UI(IDM_REFRESH, OnUpdateRefresh)
  120. ON_UPDATE_COMMAND_UI( IDM_ALLSERVERS_EMPTYFAVORITES , OnUpdateEmptyFavs )
  121. ON_COMMAND( ID_TAB , OnTab )
  122. ON_COMMAND( ID_SHIFTTAB , OnShiftTab )
  123. ON_COMMAND( ID_CTRLTAB , OnCtrlTab )
  124. ON_COMMAND( ID_CTRLSHIFTTAB , OnCtrlShiftTab )
  125. ON_COMMAND( ID_NEXTPANE , OnNextPane )
  126. ON_COMMAND( ID_PREVPANE , OnNextPane )
  127. ON_COMMAND( ID_DELKEY , OnDelFavNode )
  128. #ifdef _STRESS_BUILD
  129. ON_COMMAND( IDM_ALLSERVERS_FAVALLADD , OnAddAllServersToFavorites )
  130. ON_COMMAND( IDM_ALLSERVERS_RUNSTRESS , OnRunStress )
  131. ON_COMMAND( IDM_ALLSERVERS_RUNSTRESSLITE, OnRunStressLite )
  132. #endif
  133. ON_WM_CLOSE()
  134. //}}AFX_MSG_MAP
  135. // Global help commands
  136. ON_COMMAND(ID_HELP_FINDER, OnHtmlHelp)
  137. ON_COMMAND(ID_HELP, OnHtmlHelp)
  138. // ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
  139. // ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpFinder)
  140. END_MESSAGE_MAP()
  141. static UINT indicators[] =
  142. {
  143. ID_SEPARATOR, // status line indicator
  144. ID_INDICATOR_CAPS,
  145. ID_INDICATOR_NUM,
  146. ID_INDICATOR_SCRL,
  147. };
  148. /////////////////////////////////////////////////////////////////////////////
  149. // CMainFrame construction/destruction
  150. CMainFrame::CMainFrame()
  151. {
  152. m_pLeftPane = NULL;
  153. m_pRightPane = NULL;
  154. }
  155. CMainFrame::~CMainFrame()
  156. {
  157. }
  158. void CMainFrame::OnHtmlHelp()
  159. {
  160. TCHAR * pTsAdminHelp = L"ts_adm_topnode.htm";
  161. HtmlHelp(AfxGetMainWnd()->m_hWnd,L"TermSrv.Chm",HH_DISPLAY_TOPIC,(DWORD_PTR)pTsAdminHelp);
  162. }
  163. /*LRESULT CMainFrame::OnHelp(WPARAM wParam, LPARAM lParam)
  164. {
  165. CFrameWnd::WinHelp(0L, HELP_FINDER);
  166. return TRUE;
  167. }
  168. */
  169. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  170. {
  171. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  172. return -1;
  173. if (!m_wndToolBar.Create(this) ||
  174. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  175. {
  176. // TRACE0("Failed to create toolbar\n");
  177. return -1; // fail to create
  178. }
  179. if (!m_wndStatusBar.Create(this) ||
  180. !m_wndStatusBar.SetIndicators(indicators,
  181. sizeof(indicators)/sizeof(UINT)))
  182. {
  183. // TRACE0("Failed to create status bar\n");
  184. return -1; // fail to create
  185. }
  186. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  187. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  188. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  189. // TODO: Delete these three lines if you don't want the toolbar to
  190. // be dockable
  191. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  192. EnableDocking(CBRS_ALIGN_ANY);
  193. DockControlBar(&m_wndToolBar);
  194. // If there is an extension DLL, call it's startup function
  195. LPFNEXSTARTUPPROC StartupProc = ((CWinAdminApp*)AfxGetApp())->GetExtStartupProc();
  196. if(StartupProc) {
  197. (*StartupProc)(this->GetSafeHwnd());
  198. }
  199. DWORD dwTid;
  200. HANDLE hThread = CreateThread( NULL , 0 , ( LPTHREAD_START_ROUTINE )CMainFrame::InitWarningThread, GetSafeHwnd() , 0 , &dwTid );
  201. CloseHandle( hThread );
  202. return 0;
  203. } // end CMainFrame::OnCreate
  204. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  205. CCreateContext* pContext)
  206. {
  207. BOOL rtn;
  208. rtn = m_wndSplitter.CreateStatic(this, 1, 2);
  209. #ifdef PUBLISHED_APPS
  210. if(((CWinAdminApp*)AfxGetApp())->IsPicasso()) {
  211. rtn |= m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftPane),
  212. CSize(((CWinAdminApp *)AfxGetApp())->GetTreeWidth(), 300), pContext);
  213. } else {
  214. #else
  215. {
  216. #endif
  217. rtn |= m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CAdminTreeView),
  218. CSize(((CWinAdminApp *)AfxGetApp())->GetTreeWidth(), 300), pContext);
  219. }
  220. rtn |= m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightPane),
  221. CSize(0, 0), pContext);
  222. m_pLeftPane = m_wndSplitter.GetPane(0, 0);
  223. m_pRightPane = m_wndSplitter.GetPane(0, 1);
  224. return rtn;
  225. } // end CMainFrame::OnCreateClient
  226. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  227. {
  228. // TODO: Modify the Window class or styles here by modifying
  229. // the CREATESTRUCT cs
  230. cs.x = 3;
  231. cs.y = 3;
  232. cs.cx = 635;
  233. cs.cy = 444;
  234. return CFrameWnd::PreCreateWindow(cs);
  235. } // end CMainFrame::PreCreateWindow
  236. /////////////////////////////////////////////////////////////////////////////
  237. // CMainFrame diagnostics
  238. #ifdef _DEBUG
  239. void CMainFrame::AssertValid() const
  240. {
  241. CFrameWnd::AssertValid();
  242. }
  243. void CMainFrame::Dump(CDumpContext& dc) const
  244. {
  245. CFrameWnd::Dump(dc);
  246. }
  247. #endif //_DEBUG
  248. /////////////////////////////////////////////////////////////////////////////
  249. // CMainFrame message handlers
  250. /////////////////////////////////////
  251. // F'N: CMainFrame::OnAdminChangeView
  252. //
  253. // - handles the custom message WM_ADMIN_CHANGEVIEW
  254. // - this message is sent to the mainframe by CAdminTreeView when a new tree
  255. // item is selected
  256. // - lParam holds the info structure for the newly selected tree node
  257. // and is handed along to CRightPane as the lParam of another
  258. // WM_WA_CHANGEVIEW message, which CRightPane then handles as it
  259. // sees fit
  260. //
  261. LRESULT CMainFrame::OnAdminChangeView(WPARAM wParam, LPARAM lParam)
  262. {
  263. ASSERT(lParam);
  264. // tell the right pane to change his view
  265. m_pRightPane->SendMessage(WM_ADMIN_CHANGEVIEW, wParam, lParam);
  266. return 0;
  267. } // end CMainFrame::OnAdminChangeView
  268. /////////////////////////////////////
  269. // F'N: CMainFrame::OnAdminAddServer
  270. //
  271. LRESULT CMainFrame::OnAdminAddServer(WPARAM wParam, LPARAM lParam)
  272. {
  273. ASSERT(lParam);
  274. // tell the tree view to add server
  275. m_pLeftPane->SendMessage(WM_ADMIN_ADD_SERVER, wParam, lParam);
  276. // tell the right pane to add server
  277. m_pRightPane->SendMessage(WM_ADMIN_ADD_SERVER, wParam, lParam);
  278. return 0;
  279. } // end CMainFrame::OnAdminAddServer
  280. /////////////////////////////////////
  281. // F'N: CMainFrame::OnAdminRemoveServer
  282. //
  283. // wParam - TRUE if server disappeared, FALSE if via Server Filtering
  284. // lParam - CServer to remove
  285. LRESULT CMainFrame::OnAdminRemoveServer(WPARAM wParam, LPARAM lParam)
  286. {
  287. ASSERT(lParam);
  288. ODS( L"CMainFrame!OnAdminRemoveServer\n" );
  289. #if 0
  290. if(wParam) {
  291. // Is this the currently selected server?
  292. CWinAdminDoc *doc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  293. if((CObject*)lParam == doc->GetCurrentSelectedNode()) {
  294. CString TitleString;
  295. CString MessageString;
  296. TitleString.LoadString(AFX_IDS_APP_TITLE);
  297. MessageString.Format(IDS_SERVER_DISAPPEARED, ((CServer*)lParam)->GetName());
  298. MessageBox(MessageString, TitleString, MB_ICONEXCLAMATION | MB_OK);
  299. }
  300. }
  301. #endif
  302. // tell the tree view to remove server
  303. m_pLeftPane->SendMessage(WM_ADMIN_REMOVE_SERVER, wParam, lParam);
  304. // tell the right pane to remove server
  305. m_pRightPane->SendMessage(WM_ADMIN_REMOVE_SERVER, wParam, lParam);
  306. return 0;
  307. } // end CMainFrame::OnAdminRemoveServer
  308. //----------------------------------------------------------------------------
  309. LRESULT CMainFrame::OnAdminAddServerToFavorites( WPARAM wp , LPARAM lp )
  310. {
  311. ODS( L"CMainFrame::OnAdminAddServerToFavorites\n" );
  312. m_pLeftPane->SendMessage( WM_ADMIN_ADDSERVERTOFAV , wp , lp );
  313. return 0;
  314. }
  315. LRESULT CMainFrame::OnAdminRemoveServerFromFavs( WPARAM wp , LPARAM lp )
  316. {
  317. ODS( L"CMainFrame::OnAdminRemoveServerFromFavs\n" );
  318. return m_pLeftPane->SendMessage( WM_ADMIN_REMOVESERVERFROMFAV , wp , lp );
  319. }
  320. /////////////////////////////////////
  321. // F'N: CMainFrame::OnAdminUpdateServer
  322. //
  323. LRESULT CMainFrame::OnAdminUpdateServer(WPARAM wParam, LPARAM lParam)
  324. {
  325. ASSERT(lParam);
  326. // tell the tree view to update server
  327. m_pLeftPane->SendMessage(WM_ADMIN_UPDATE_SERVER, wParam, lParam);
  328. // tell the right pane to update server
  329. m_pRightPane->SendMessage(WM_ADMIN_UPDATE_SERVER, wParam, lParam);
  330. return 0;
  331. } // end CMainFrame::OnAdminUpdateServer
  332. /////////////////////////////////////
  333. // F'N: CMainFrame::OnAdminUpdateProcesses
  334. //
  335. LRESULT CMainFrame::OnAdminUpdateProcesses(WPARAM wParam, LPARAM lParam)
  336. {
  337. ASSERT(lParam);
  338. // tell the right pane to update processes
  339. m_pRightPane->SendMessage(WM_ADMIN_UPDATE_PROCESSES, wParam, lParam);
  340. return 0;
  341. } // end CMainFrame::OnAdminUpdateProcesses
  342. /////////////////////////////////////
  343. // F'N: CMainFrame::OnAdminRemoveProcess
  344. //
  345. LRESULT CMainFrame::OnAdminRemoveProcess(WPARAM wParam, LPARAM lParam)
  346. {
  347. ASSERT(lParam);
  348. // tell the right pane to remove a process
  349. m_pRightPane->SendMessage(WM_ADMIN_REMOVE_PROCESS, wParam, lParam);
  350. return 0;
  351. } // end CMainFrame::OnAdminUpdateProcesses
  352. /////////////////////////////////////
  353. // F'N: CMainFrame::OnAdminAddWinStation
  354. //
  355. LRESULT CMainFrame::OnAdminAddWinStation(WPARAM wParam, LPARAM lParam)
  356. {
  357. ASSERT(lParam);
  358. // tell the tree view to add a WinStation
  359. m_pLeftPane->SendMessage(WM_ADMIN_ADD_WINSTATION, wParam, lParam);
  360. return 0;
  361. } // end CMainFrame::OnAdminAddWinStation
  362. /////////////////////////////////////
  363. // F'N: CMainFrame::OnAdminUpdateWinStation
  364. //
  365. LRESULT CMainFrame::OnAdminUpdateWinStation(WPARAM wParam, LPARAM lParam)
  366. {
  367. ASSERT(lParam);
  368. // tell the tree view to update WinStation
  369. m_pLeftPane->SendMessage(WM_ADMIN_UPDATE_WINSTATION, wParam, lParam);
  370. return 0;
  371. } // end CMainFrame::OnAdminUpdateWinStation
  372. /////////////////////////////////////
  373. // F'N: CMainFrame::OnAdminUpdateWinStations
  374. //
  375. LRESULT CMainFrame::OnAdminUpdateWinStations(WPARAM wParam, LPARAM lParam)
  376. {
  377. ASSERT(lParam);
  378. // tell the right pane to update WinStations
  379. m_pRightPane->SendMessage(WM_ADMIN_UPDATE_WINSTATIONS, wParam, lParam);
  380. return 0;
  381. } // end CMainFrame::OnAdminUpdateWinStations
  382. /////////////////////////////////////
  383. // F'N: CMainFrame::OnAdminRemoveWinStation
  384. //
  385. LRESULT CMainFrame::OnAdminRemoveWinStation(WPARAM wParam, LPARAM lParam)
  386. {
  387. ASSERT(lParam);
  388. // tell the tree view to remove a WinStation
  389. m_pLeftPane->SendMessage(WM_ADMIN_REMOVE_WINSTATION, wParam, lParam);
  390. return 0;
  391. } // end CMainFrame::OnAdminRemoveWinStation
  392. /////////////////////////////////////
  393. // F'N: CMainFrame::OnAdminUpdateDomain
  394. //
  395. LRESULT CMainFrame::OnAdminUpdateDomain(WPARAM wParam, LPARAM lParam)
  396. {
  397. ASSERT(lParam);
  398. // tell the tree view to update the domain
  399. m_pLeftPane->SendMessage(WM_ADMIN_UPDATE_DOMAIN, wParam, lParam);
  400. return 0;
  401. } // end CMainFrame::OnAdminUpdateDomain
  402. /////////////////////////////////////
  403. // F'N: CMainFrame::OnAdminAddDomain
  404. //
  405. LRESULT CMainFrame::OnAdminAddDomain(WPARAM wParam, LPARAM lParam)
  406. {
  407. ASSERT(lParam);
  408. return m_pLeftPane->SendMessage(WM_ADMIN_ADD_DOMAIN, wParam, lParam);
  409. } // end CMainFrame::OnAdminAddDomain
  410. /////////////////////////////////////
  411. // F'N: CMainFrame::OnAdminUpdateServerInfo
  412. //
  413. LRESULT CMainFrame::OnAdminUpdateServerInfo(WPARAM wParam, LPARAM lParam)
  414. {
  415. ASSERT(lParam);
  416. // tell the right pane to update server info
  417. m_pRightPane->SendMessage(WM_ADMIN_UPDATE_SERVER_INFO, wParam, lParam);
  418. return 0;
  419. } // end CMainFrame::OnAdminUpdateServerInfo
  420. /////////////////////////////////////
  421. // F'N: CMainFrame::OnAdminRedisplayLicenses
  422. //
  423. LRESULT CMainFrame::OnAdminRedisplayLicenses(WPARAM wParam, LPARAM lParam)
  424. {
  425. ASSERT(lParam);
  426. // tell the right pane to redisplay licenses
  427. m_pRightPane->SendMessage(WM_ADMIN_REDISPLAY_LICENSES, wParam, lParam);
  428. return 0;
  429. } // end CMainFrame::OnAdminRedisplayLicenses
  430. /////////////////////////////////////
  431. // F'N: CMainFrame::OnAdminViewsReady
  432. //
  433. LRESULT CMainFrame::OnAdminViewsReady(WPARAM wParam, LPARAM lParam)
  434. {
  435. // tell the left pane that all views are ready
  436. m_pLeftPane->SendMessage(WM_ADMIN_VIEWS_READY, wParam, lParam);
  437. return 0;
  438. } // end CMainFrame::OnAdminViewsReady
  439. /////////////////////////////////////
  440. // F'N: CMainFrame::OnExpandAll
  441. //
  442. void CMainFrame::OnExpandAll()
  443. {
  444. // tell the tree view to expand all
  445. m_pLeftPane->SendMessage(WM_ADMIN_EXPANDALL, 0, 0);
  446. } // end CMainFrame::OnExpandAll
  447. /////////////////////////////////////
  448. // F'N: CMainFrame::OnCollapseAll
  449. //
  450. void CMainFrame::OnCollapseAll()
  451. {
  452. // tell the tree view to collapse all
  453. m_pLeftPane->SendMessage(WM_ADMIN_COLLAPSEALL, 0, 0);
  454. } // end CMainFrame::OnCollapseAll
  455. /////////////////////////////////////
  456. // F'N: CMainFrame::OnCollapseToServers
  457. //
  458. void CMainFrame::OnCollapseToServers()
  459. {
  460. // tell the tree view to collapse to servers
  461. m_pLeftPane->SendMessage(WM_ADMIN_COLLAPSETOSERVERS, 0, 0);
  462. } // end CMainFrame::OnCollapseToServers
  463. /////////////////////////////////////
  464. // F'N: CMainFrame::OnCollapseToDomains
  465. //
  466. void CMainFrame::OnCollapseToDomains()
  467. {
  468. // tell the tree view to collapse to domains
  469. m_pLeftPane->SendMessage(WM_ADMIN_COLLAPSETODOMAINS, 0, 0);
  470. } // end CMainFrame::OnCollapseToDomains
  471. /////////////////////////////////////
  472. // F'N: CMainFrame::OnRefresh
  473. //
  474. void CMainFrame::OnRefresh()
  475. {
  476. // tell the document to do a refresh
  477. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->Refresh();
  478. } // end CMainFrame::OnRefresh
  479. /////////////////////////////////////
  480. // F'N: CMainFrame::OnConnect
  481. //
  482. void CMainFrame::OnConnect()
  483. {
  484. // We don't ask for confirmation, should we?
  485. CWinAdminDoc* pDoc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  486. int view = pDoc->GetCurrentView();
  487. int page = pDoc->GetCurrentPage();
  488. // tell the document
  489. BOOL user = FALSE;
  490. if((view == VIEW_SERVER && page == PAGE_USERS)
  491. || (view == VIEW_ALL_SERVERS && page == PAGE_AS_USERS)
  492. || (view == VIEW_DOMAIN && page == PAGE_DOMAIN_USERS))
  493. user = TRUE;
  494. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ConnectWinStation(FALSE, user);
  495. } // end CMainFrame::OnConnect
  496. /////////////////////////////////////
  497. // F'N: CMainFrame::OnTreeConnect
  498. //
  499. void CMainFrame::OnTreeConnect()
  500. {
  501. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ConnectWinStation(TRUE, FALSE);
  502. } // end CMainFrame::OnTreeConnect
  503. /////////////////////////////////////
  504. // F'N: CMainFrame::OnDisconnect
  505. //
  506. void CMainFrame::OnDisconnect()
  507. {
  508. DisconnectHelper(FALSE);
  509. } // end CMainFrame::OnDisconnect
  510. /////////////////////////////////////
  511. // F'N: CMainFrame::OnTreeDisconnect
  512. //
  513. void CMainFrame::OnTreeDisconnect()
  514. {
  515. DisconnectHelper(TRUE);
  516. } // end CMainFrame::OnTreeDisconnect
  517. /////////////////////////////////////
  518. // F'N: CMainFrame::OnTreeDisconnect
  519. //
  520. void CMainFrame::DisconnectHelper(BOOL bTree)
  521. {
  522. CString TitleString;
  523. CString MessageString;
  524. // Only bother the user if Confirmation is set
  525. if(((CWinAdminApp*)AfxGetApp())->AskConfirmation()) {
  526. TitleString.LoadString(AFX_IDS_APP_TITLE);
  527. MessageString.LoadString(IDS_WARN_DISCONNECT);
  528. if(IDOK != MessageBox(MessageString, TitleString, MB_ICONEXCLAMATION | MB_OKCANCEL)) {
  529. return;
  530. }
  531. }
  532. // tell the document
  533. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->DisconnectWinStation(bTree);
  534. } // end CMainFrame::DisconnectHelper
  535. /////////////////////////////////////
  536. // F'N: CMainFrame::OnSendMessage
  537. //
  538. void CMainFrame::OnSendMessage()
  539. {
  540. SendMessageHelper(FALSE);
  541. } // end CMainFrame::OnSendMessage
  542. /////////////////////////////////////
  543. // F'N: CMainFrame::OnTreeSendMessage
  544. //
  545. void CMainFrame::OnTreeSendMessage()
  546. {
  547. SendMessageHelper(TRUE);
  548. } // end CMainFrame::OnTreeSendMessage
  549. /////////////////////////////////////
  550. // F'N: CMainFrame::SendMessageHelper
  551. //
  552. void CMainFrame::SendMessageHelper(BOOL bTree)
  553. {
  554. CSendMessageDlg dlg; //AfxGetMainWnd());
  555. if(dlg.DoModal() != IDOK || !(*dlg.m_szMessage))
  556. return;
  557. MessageParms *pParms = new MessageParms;
  558. wcscpy(pParms->MessageTitle, dlg.m_szTitle);
  559. wcscpy(pParms->MessageBody, dlg.m_szMessage);
  560. // tell the document
  561. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->SendWinStationMessage(bTree, pParms);
  562. } // end CMainFrame::SendMessageHelper
  563. /////////////////////////////////////
  564. // F'N: CMainFrame::OnShadow
  565. //
  566. void CMainFrame::OnShadow()
  567. {
  568. // tell the document to Shadow the WinStation(s)
  569. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ShadowWinStation(FALSE);
  570. } // end CMainFrame::OnShadow
  571. /////////////////////////////////////
  572. // F'N: CMainFrame::OnTreeShadow
  573. //
  574. void CMainFrame::OnTreeShadow()
  575. {
  576. // tell the document to Shadow the WinStation(s)
  577. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ShadowWinStation(TRUE);
  578. } // end CMainFrame::OnTreeShadow
  579. /////////////////////////////////////
  580. // F'N: CMainFrame::OnReset
  581. //
  582. void CMainFrame::OnReset()
  583. {
  584. ResetHelper(FALSE);
  585. } // end CMainFrame::OnReset
  586. /////////////////////////////////////
  587. // F'N: CMainFrame::OnTreeReset
  588. //
  589. void CMainFrame::OnTreeReset()
  590. {
  591. ResetHelper(TRUE);
  592. } // end CMainFrame::OnTreeReset
  593. /////////////////////////////////////
  594. // F'N: CMainFrame::ResetHelper
  595. //
  596. void CMainFrame::ResetHelper(BOOL bTree)
  597. {
  598. CString TitleString;
  599. CString MessageString;
  600. // Only bother the user if Confirmation is set
  601. if(((CWinAdminApp*)AfxGetApp())->AskConfirmation()) {
  602. TitleString.LoadString(AFX_IDS_APP_TITLE);
  603. MessageString.LoadString(IDS_WARN_RESET);
  604. if(IDOK != MessageBox(MessageString, TitleString, MB_ICONEXCLAMATION | MB_OKCANCEL)) {
  605. return;
  606. }
  607. }
  608. // tell the document to reset the WinStation(s)
  609. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ResetWinStation(bTree, TRUE);
  610. } // end CMainFrame::ResetHelper
  611. /////////////////////////////////////
  612. // F'N: CMainFrame::OnStatus
  613. //
  614. void CMainFrame::OnStatus()
  615. {
  616. // tell the document to reset the WinStation(s)
  617. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->StatusWinStation(FALSE);
  618. } // end CMainFrame::OnStatus
  619. /////////////////////////////////////
  620. // F'N: CMainFrame::OnTreeStatus
  621. //
  622. void CMainFrame::OnTreeStatus()
  623. {
  624. // tell the document to reset the WinStation(s)
  625. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->StatusWinStation(TRUE);
  626. } // end CMainFrame::OnTreeStatus
  627. /////////////////////////////////////
  628. // F'N: CMainFrame::OnLogoff
  629. //
  630. void CMainFrame::OnLogoff()
  631. {
  632. CString TitleString;
  633. CString MessageString;
  634. // Only bother the user if Confirmation is set
  635. if(((CWinAdminApp*)AfxGetApp())->AskConfirmation()) {
  636. TitleString.LoadString(AFX_IDS_APP_TITLE);
  637. MessageString.LoadString(IDS_WARN_LOGOFF);
  638. if(IDOK != MessageBox(MessageString, TitleString, MB_ICONEXCLAMATION | MB_OKCANCEL)) {
  639. return;
  640. }
  641. }
  642. // tell the document to reset the WinStation(s)
  643. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ResetWinStation(FALSE, TRUE);
  644. } // end CMainFrame::OnLogoff
  645. /////////////////////////////////////
  646. // F'N: CMainFrame::OnTerminate
  647. //
  648. void CMainFrame::OnTerminate()
  649. {
  650. CString TitleString;
  651. CString MessageString;
  652. // Only bother the user if Confirmation is set
  653. if(((CWinAdminApp*)AfxGetApp())->AskConfirmation()) {
  654. TitleString.LoadString(AFX_IDS_APP_TITLE);
  655. MessageString.LoadString(IDS_WARN_TERMINATE);
  656. if(IDOK != MessageBox(MessageString, TitleString, MB_ICONEXCLAMATION | MB_OKCANCEL)) {
  657. return;
  658. }
  659. }
  660. // tell the document to terminate the processes
  661. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->TerminateProcess();
  662. } // end CMainFrame::OnTerminate
  663. /////////////////////////////////////
  664. // F'N: CMainFrame::OnServerConnect
  665. //
  666. void CMainFrame::OnServerConnect()
  667. {
  668. // tell the document to connect to the server(s)
  669. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ServerConnect();
  670. } // end CMainFrame::OnServerConnect
  671. //------------------------------------------------------------
  672. void CMainFrame::OnAddToFavorites( )
  673. {
  674. // ok try following me
  675. // I'm going to call a method in CWinAdminDoc to determine the current server
  676. // and view. This will then be forwarded back here via sendmsg and then
  677. // towards the treeview.
  678. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ServerAddToFavorites( TRUE );
  679. }
  680. //=-----------------------------------------------------------
  681. void CMainFrame::OnRemoveFromFavs( )
  682. {
  683. ODS( L"CMainFrame::OnRemoveFromFavs\n" );
  684. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ServerAddToFavorites( FALSE );
  685. }
  686. /////////////////////////////////////
  687. // F'N: CMainFrame::OnServerDisconnect
  688. //
  689. void CMainFrame::OnServerDisconnect()
  690. {
  691. // tell the document to connect to the server(s)
  692. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ServerDisconnect();
  693. } // end CMainFrame::OnServerDisconnect
  694. /////////////////////////////////////
  695. // F'N: CMainFrame::OnTreeDomainConnectAllServers
  696. //
  697. void CMainFrame::OnTreeDomainConnectAllServers()
  698. {
  699. // tell the document to connect to the server(s)
  700. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->TempDomainConnectAllServers();
  701. } // end CMainFrame::OnTreeDomainConnectAllServers
  702. /////////////////////////////////////
  703. // F'N: CMainFrame::OnTreeDomainDisconnectAllServers
  704. //
  705. void CMainFrame::OnTreeDomainDisconnectAllServers()
  706. {
  707. // tell the document to connect to the server(s)
  708. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->TempDomainDisconnectAllServers();
  709. } // end CMainFrame::OnTreeDomainDisconnectAllServers
  710. /////////////////////////////////////
  711. // F'N: CMainFrame::OnTreeDomainFindServers
  712. //
  713. void CMainFrame::OnTreeDomainFindServers()
  714. {
  715. // tell the document to find servers in the domain
  716. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->DomainFindServers();
  717. } // end CMainFrame::OnTreeDomainFindServers
  718. /////////////////////////////////////
  719. // F'N: CMainFrame::OnDomainConnectAllServers
  720. //
  721. void CMainFrame::OnDomainConnectAllServers()
  722. {
  723. // tell the document to connect to the server(s)
  724. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CurrentDomainConnectAllServers();
  725. } // end CMainFrame::OnDomainConnectAllServers
  726. /////////////////////////////////////
  727. // F'N: CMainFrame::OnDomainDisconnectAllServers
  728. //
  729. void CMainFrame::OnDomainDisconnectAllServers()
  730. {
  731. // tell the document to connect to the server(s)
  732. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CurrentDomainDisconnectAllServers();
  733. } // end CMainFrame::OnDomainDisconnectAllServers
  734. /////////////////////////////////////
  735. // F'N: CMainFrame::OnAllServersConnect
  736. //
  737. void CMainFrame::OnAllServersConnect()
  738. {
  739. // tell the document to connect to all servers
  740. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->ConnectToAllServers();
  741. } // end CMainFrame::OnAllServersConnect
  742. /////////////////////////////////////
  743. // F'N: CMainFrame::OnAllServersDisconnect
  744. //
  745. void CMainFrame::OnAllServersDisconnect()
  746. {
  747. // tell the document to disconnect from all servers
  748. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->DisconnectFromAllServers();
  749. } // end CMainFrame::OnAllServersDisconnect
  750. /////////////////////////////////////
  751. // F'N: CMainFrame::OnAllServersFind
  752. //
  753. void CMainFrame::OnAllServersFind()
  754. {
  755. // tell the document to find all servers in all domains
  756. ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->FindAllServers();
  757. } // end CMainFrame::OnAllServersFind
  758. /////////////////////////////////////
  759. // F'N: CMainFrame::OnPreferences
  760. //
  761. void CMainFrame::OnPreferences()
  762. {
  763. CPreferencesDlg dlg;
  764. dlg.DoModal();
  765. } // end CMainFrame::OnPreferences
  766. /////////////////////////////////////
  767. // F'N: CMainFrame::OnUpdateConnect
  768. //
  769. void CMainFrame::OnUpdateConnect(CCmdUI* pCmdUI)
  770. {
  771. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanConnect());
  772. } // end CMainFrame::OnUpdateConnect
  773. /////////////////////////////////////
  774. // F'N: CMainFrame::OnUpdateDisconnect
  775. //
  776. void CMainFrame::OnUpdateDisconnect(CCmdUI* pCmdUI)
  777. {
  778. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanDisconnect());
  779. } // end CMainFrame::OnUpdateDisconnect
  780. /////////////////////////////////////
  781. // F'N: CMainFrame::OnUpdateLogoff
  782. //
  783. void CMainFrame::OnUpdateLogoff(CCmdUI* pCmdUI)
  784. {
  785. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanLogoff());
  786. } // end CMainFrame::OnUpdateLogoff
  787. /////////////////////////////////////
  788. // F'N: CMainFrame::OnUpdateMessage
  789. //
  790. void CMainFrame::OnUpdateMessage(CCmdUI* pCmdUI)
  791. {
  792. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanSendMessage());
  793. }
  794. /////////////////////////////////////
  795. // F'N: CMainFrame::OnUpdateRefresh
  796. //
  797. void CMainFrame::OnUpdateRefresh(CCmdUI* pCmdUI)
  798. {
  799. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanRefresh());
  800. }
  801. /////////////////////////////////////
  802. // F'N: CMainFrame::OnUpdateReset
  803. //
  804. void CMainFrame::OnUpdateReset(CCmdUI* pCmdUI)
  805. {
  806. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanReset());
  807. }
  808. /////////////////////////////////////
  809. // F'N: CMainFrame::OnUpdateShadow
  810. //
  811. void CMainFrame::OnUpdateShadow(CCmdUI* pCmdUI)
  812. {
  813. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanShadow());
  814. }
  815. /////////////////////////////////////
  816. // F'N: CMainFrame::OnUpdateStatus
  817. //
  818. void CMainFrame::OnUpdateStatus(CCmdUI* pCmdUI)
  819. {
  820. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanStatus());
  821. }
  822. /////////////////////////////////////
  823. // F'N: CMainFrame::OnUpdateTerminate
  824. //
  825. void CMainFrame::OnUpdateTerminate(CCmdUI* pCmdUI)
  826. {
  827. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTerminate());
  828. }
  829. /////////////////////////////////////
  830. // F'N: CMainFrame::OnUpdateServerConnect
  831. //
  832. void CMainFrame::OnUpdateServerConnect(CCmdUI* pCmdUI)
  833. {
  834. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanServerConnect());
  835. }
  836. /////////////////////////////////////
  837. // F'N: CMainFrame::OnUpdateServerDisconnect
  838. //
  839. void CMainFrame::OnUpdateServerDisconnect(CCmdUI* pCmdUI)
  840. {
  841. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanServerDisconnect());
  842. }
  843. void CMainFrame::OnUpdateServerAddToFavorite( CCmdUI *pCmdUI )
  844. {
  845. pCmdUI->Enable( !( ( CWinAdminDoc* )( ( CWinAdminApp* )AfxGetApp() )->GetDocument() )->IsAlreadyFavorite() );
  846. }
  847. void CMainFrame::OnUpdateServerRemoveFromFavorite( CCmdUI *pCmdUI )
  848. {
  849. pCmdUI->Enable( ( ( CWinAdminDoc* )( ( CWinAdminApp* )AfxGetApp() )->GetDocument() )->IsAlreadyFavorite() );
  850. }
  851. /////////////////////////////////////
  852. // F'N: CMainFrame::OnUpdateTreeConnect
  853. //
  854. void CMainFrame::OnUpdateTreeConnect(CCmdUI* pCmdUI)
  855. {
  856. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTempConnect());
  857. } // end CMainFrame::OnUpdateTreeConnect
  858. /////////////////////////////////////
  859. // F'N: CMainFrame::OnUpdateTreeDisconnect
  860. //
  861. void CMainFrame::OnUpdateTreeDisconnect(CCmdUI* pCmdUI)
  862. {
  863. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTempDisconnect());
  864. } // end CMainFrame::OnUpdateTreeDisconnect
  865. /////////////////////////////////////
  866. // F'N: CMainFrame::OnUpdateTreeMessage
  867. //
  868. void CMainFrame::OnUpdateTreeMessage(CCmdUI* pCmdUI)
  869. {
  870. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTempSendMessage());
  871. } // end CMainFrame::OnUpdateTreeMessage
  872. /////////////////////////////////////
  873. // F'N: CMainFrame::OnUpdateTreeReset
  874. //
  875. void CMainFrame::OnUpdateTreeReset(CCmdUI* pCmdUI)
  876. {
  877. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTempReset());
  878. } // end CMainFrame::OnUpdateTreeReset
  879. /////////////////////////////////////
  880. // F'N: CMainFrame::OnUpdateTreeShadow
  881. //
  882. void CMainFrame::OnUpdateTreeShadow(CCmdUI* pCmdUI)
  883. {
  884. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTempShadow());
  885. } // end CMainFrame::OnUpdateTreeShadow
  886. /////////////////////////////////////
  887. // F'N: CMainFrame::OnUpdateTreeStatus
  888. //
  889. void CMainFrame::OnUpdateTreeStatus(CCmdUI* pCmdUI)
  890. {
  891. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTempStatus());
  892. } // end CMainFrame::OnUpdateTreeStatus
  893. /////////////////////////////////////
  894. // F'N: CMainFrame::OnShowSystemProcesses
  895. //
  896. void CMainFrame::OnShowSystemProcesses()
  897. {
  898. int state = ((CWinAdminApp*)AfxGetApp())->ShowSystemProcesses();
  899. ((CWinAdminApp*)AfxGetApp())->SetShowSystemProcesses(state^1);
  900. // tell the right pane to redisplay processes
  901. m_pRightPane->SendMessage(WM_ADMIN_REDISPLAY_PROCESSES, 0, 0);
  902. } // end CMainFrame::OnShowSystemProcesses()
  903. /////////////////////////////////////
  904. // F'N: CMainFrame::OnUpdateShowSystemProcesses
  905. //
  906. void CMainFrame::OnUpdateShowSystemProcesses(CCmdUI* pCmdUI)
  907. {
  908. pCmdUI->SetCheck(((CWinAdminApp*)AfxGetApp())->ShowSystemProcesses());
  909. } // end CMainFrame::OnUpdateShowSystemProcesses
  910. /////////////////////////////////////
  911. // F'N: CMainFrame::OnUpdateDomainPopupMenu
  912. //
  913. void CMainFrame::OnUpdateDomainPopupMenu(CCmdUI* pCmdUI)
  914. {
  915. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTempDomainConnect());
  916. } // end CMainFrame::OnUpdateDomainPopupMenu
  917. /////////////////////////////////////
  918. // F'N: CMainFrame::OnUpdateDomainPopupFind
  919. //
  920. void CMainFrame::OnUpdateDomainPopupFind(CCmdUI* pCmdUI)
  921. {
  922. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanTempDomainFindServers());
  923. } // end CMainFrame::OnUpdateDomainPopupFind
  924. /////////////////////////////////////
  925. // F'N: CMainFrame::OnUpdateDomainMenu
  926. //
  927. void CMainFrame::OnUpdateDomainMenu(CCmdUI* pCmdUI)
  928. {
  929. pCmdUI->Enable(((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->CanDomainConnect());
  930. } // end CMainFrame::OnUpdateDomainMenu
  931. /////////////////////////////////////
  932. // F'N: CMainFrame::OnClose
  933. //
  934. void CMainFrame::OnClose()
  935. {
  936. GetWindowPlacement(&((CWinAdminApp*)AfxGetApp())->m_Placement);
  937. RECT rect;
  938. m_pLeftPane->GetWindowRect(&rect);
  939. ((CWinAdminApp*)AfxGetApp())->SetTreeWidth(rect.right-rect.left);
  940. CFrameWnd::OnClose();
  941. } // end CMainFrame::OnClose
  942. /////////////////////////////////////
  943. // F'N: CMainFrame::ActivateFrame
  944. //
  945. void CMainFrame::ActivateFrame(int nCmdShow)
  946. {
  947. // TODO: Add your specialized code here and/or call the base class
  948. WINDOWPLACEMENT *pPlacement =
  949. ((CWinAdminApp *)AfxGetApp())->GetPlacement();
  950. if ( pPlacement->length == -1 ) {
  951. /*
  952. * This is the first time that this is called, set the window
  953. * placement and show state to the previously saved state.
  954. */
  955. pPlacement->length = sizeof(WINDOWPLACEMENT);
  956. /*
  957. * If we have a previously saved placement state: set it.
  958. */
  959. if ( pPlacement->rcNormalPosition.right != -1 ) {
  960. if ( nCmdShow != SW_SHOWNORMAL )
  961. pPlacement->showCmd = nCmdShow;
  962. else
  963. nCmdShow = pPlacement->showCmd;
  964. SetWindowPlacement(pPlacement);
  965. }
  966. }
  967. /*
  968. * Perform the parent classes' ActivateFrame().
  969. */
  970. CFrameWnd::ActivateFrame(nCmdShow);
  971. } // end CMainFrame::ActivateFrame
  972. //---------------------------------------------------------------------------
  973. // bugid352062
  974. // Splash message for people who hate to RTFM
  975. //---------------------------------------------------------------------------
  976. void CMainFrame::InitWarningThread( PVOID *pvParam )
  977. {
  978. // display messagebox
  979. HWND hwnd = ( HWND )pvParam;
  980. DWORD dwSessionId;
  981. if( ProcessIdToSessionId( GetCurrentProcessId( ) , &dwSessionId ) )
  982. {
  983. if( dwSessionId == WTSGetActiveConsoleSessionId() )
  984. {
  985. // check if we are to show the dialog box
  986. // a) if the key does not exist show the dialog
  987. // b) if the key exist and the value is zero show the dialog
  988. HKEY hKey;
  989. DWORD dwStatus = RegOpenKeyEx( HKEY_CURRENT_USER , TEXT( "Software\\Microsoft\\Windows NT\\CurrentVersion\\Terminal Server\\TSADMIN" ) , 0 , KEY_READ , &hKey );
  990. if( dwStatus == ERROR_SUCCESS )
  991. {
  992. DWORD dwData = 0;
  993. DWORD dwSizeofData;
  994. dwSizeofData = sizeof( DWORD );
  995. RegQueryValueEx( hKey , TEXT( "DisableConsoleWarning" ) , 0 , NULL , ( LPBYTE )&dwData , &dwSizeofData );
  996. RegCloseKey( hKey );
  997. if( dwData != 0 )
  998. {
  999. return;
  1000. }
  1001. }
  1002. ::DialogBox( NULL , MAKEINTRESOURCE( IDD_DIALOG_FEATUREWARN ) , hwnd , ( DLGPROC )FWarnDlg );
  1003. }
  1004. }
  1005. }
  1006. //---------------------------------------------------------------------------
  1007. // Sets regkey DisableConsoleWarning
  1008. //---------------------------------------------------------------------------
  1009. INT_PTR CALLBACK FWarnDlg( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  1010. {
  1011. switch( msg )
  1012. {
  1013. case WM_INITDIALOG:
  1014. {
  1015. HICON hIcon = LoadIcon( NULL , IDI_INFORMATION );
  1016. SendMessage( GetDlgItem( hwnd , IDC_FWICON ) , STM_SETIMAGE, IMAGE_ICON, (LPARAM) hIcon );
  1017. // center dialog
  1018. RECT rParent;
  1019. RECT rMe;
  1020. GetWindowRect( GetParent( hwnd ) , &rParent );
  1021. GetWindowRect( hwnd , &rMe );
  1022. int xDelta , yDelta;
  1023. xDelta = ( ( rParent.right - rParent.left ) - ( rMe.right - rMe.left ) ) / 2;
  1024. if( xDelta < 0 )
  1025. {
  1026. xDelta = 0;
  1027. }
  1028. yDelta = ( ( rParent.bottom - rParent.top ) - ( rMe.bottom - rMe.top ) ) / 2;
  1029. if( yDelta < 0 )
  1030. {
  1031. yDelta = 0;
  1032. }
  1033. SetWindowPos( hwnd , NULL , rParent.left + xDelta , rParent.top + yDelta , 0 , 0 , SWP_NOSIZE );
  1034. }
  1035. case WM_COMMAND:
  1036. if( LOWORD( wp ) == IDOK )
  1037. {
  1038. // check the button and save the settings
  1039. HKEY hKey;
  1040. DWORD dwDisp;
  1041. DWORD dwStatus = RegCreateKeyEx( HKEY_CURRENT_USER , TEXT( "Software\\Microsoft\\Windows NT\\CurrentVersion\\Terminal Server\\TSADMIN" ) ,
  1042. 0 , NULL , 0 , KEY_ALL_ACCESS , NULL , &hKey , &dwDisp );
  1043. if( dwStatus == ERROR_SUCCESS )
  1044. {
  1045. DWORD dwBool = 0;
  1046. if( IsDlgButtonChecked( hwnd , IDC_CHECK_NOMORE ) == BST_CHECKED )
  1047. {
  1048. dwBool = ( DWORD )-1;
  1049. }
  1050. RegSetValueEx( hKey , TEXT( "DisableConsoleWarning" ), 0 , REG_DWORD , ( LPBYTE )&dwBool , sizeof( dwBool ) );
  1051. RegCloseKey( hKey );
  1052. }
  1053. // HKCU\Software\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSADMIN\DisableConsoleWarning (REG_DWORD)
  1054. EndDialog( hwnd , 0 );
  1055. }
  1056. }
  1057. return 0;
  1058. }
  1059. //=----------------------------------------------------------------------------------------------
  1060. void CMainFrame::OnTab( )
  1061. {
  1062. ODS( L"CMainFrame::OnTab received\n");
  1063. // pre tabbing
  1064. // set this state so that we can distinguish how the tabs received focus
  1065. // we can rule out the tab key
  1066. CWinAdminDoc* pDoc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  1067. pDoc->SetOnTabFlag( );
  1068. m_pRightPane->SendMessage( WM_ADMIN_TABBED_VIEW , 0 , 0 );
  1069. pDoc->ResetOnTabFlag( );
  1070. // end tabbing
  1071. }
  1072. //=----------------------------------------------------------------------------------------------
  1073. void CMainFrame::OnShiftTab( )
  1074. {
  1075. ODS( L"CMainFrame::OnShiftTab received\n" );
  1076. CWinAdminDoc* pDoc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  1077. pDoc->SetOnTabFlag( );
  1078. m_pRightPane->SendMessage( WM_ADMIN_SHIFTTABBED_VIEW , 0 , 0 );
  1079. pDoc->ResetOnTabFlag( );
  1080. }
  1081. //=----------------------------------------------------------------------------------------------
  1082. //= this message is sent from the right pane item in the view
  1083. //
  1084. LRESULT CMainFrame::OnForceTreeViewFocus( WPARAM wp , LPARAM lp )
  1085. {
  1086. m_pLeftPane->SetFocus( );
  1087. return 0;
  1088. }
  1089. //=----------------------------------------------------------------------------------------------
  1090. // this is to rotate around the tabs and treeview
  1091. //
  1092. void CMainFrame::OnCtrlTab( )
  1093. {
  1094. ODS( L"CMainFrame::OnCtrlTab received\n" );
  1095. m_pRightPane->SendMessage( WM_ADMIN_CTRLTABBED_VIEW , 0 , 0 );
  1096. }
  1097. //=----------------------------------------------------------------------------------------------
  1098. // this is to rotate around the tabs and treeview in the "other" direction
  1099. //
  1100. void CMainFrame::OnCtrlShiftTab( )
  1101. {
  1102. ODS( L"CMainFrame::OnCtrlShiftTab\n" );
  1103. m_pRightPane->SendMessage( WM_ADMIN_CTRLSHIFTTABBED_VIEW , 0 , 0 );
  1104. }
  1105. //=-----------------------------------------------------------------------------------------
  1106. void CMainFrame::OnNextPane( )
  1107. {
  1108. ODS( L"CMainFrame::OnNextPane\n" );
  1109. m_pRightPane->SendMessage( WM_ADMIN_NEXTPANE_VIEW , 0 , 0 );
  1110. }
  1111. //=-----------------------------------------------------------------------------------------
  1112. void CMainFrame::OnDelFavNode( )
  1113. {
  1114. ODS( L"CMainFrame::OnDelFavNode\n" );
  1115. m_pLeftPane->SendMessage( WM_ADMIN_DELTREE_NODE , 0 , 0 );
  1116. }
  1117. //This will find the server with the given name
  1118. //and place the cursor on it. The server may be
  1119. //added to the list if it's not already there
  1120. bool CMainFrame::LocateServer(LPCTSTR sServerName)
  1121. {
  1122. TCHAR szServerName[ 256 ];
  1123. CString cstrTitle;
  1124. CString cstrMsg;
  1125. CWaitCursor wait;
  1126. DBGMSG( L"Server to connect to is %s\n" , sServerName );
  1127. CWinAdminDoc* pDoc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  1128. // resolve name
  1129. // check to see if its an ipv4 address
  1130. lstrcpy( szServerName , sServerName );
  1131. WSADATA wsaData;
  1132. if( WSAStartup( 0x202 , &wsaData ) == 0 )
  1133. {
  1134. char szAnsiServerName[ 256 ];
  1135. WideCharToMultiByte( CP_OEMCP ,
  1136. 0 ,
  1137. szServerName,
  1138. -1,
  1139. szAnsiServerName ,
  1140. sizeof( szAnsiServerName ),
  1141. NULL ,
  1142. NULL );
  1143. int nAddr = 0;
  1144. nAddr = inet_addr( szAnsiServerName );
  1145. // if this is a valid ipv4 address then lets get the host name
  1146. // otherwise lets fall through and see if its a valid server name
  1147. if( nAddr != 0 && nAddr != INADDR_NONE )
  1148. {
  1149. ODS( L"Server name is IPV4\n" );
  1150. struct hostent *pHostEnt;
  1151. pHostEnt = gethostbyaddr( ( char * )&nAddr , 4 , AF_INET );
  1152. if( pHostEnt != NULL )
  1153. {
  1154. DWORD dwSize;
  1155. TCHAR szDnsServerName[ 256 ];
  1156. MultiByteToWideChar( CP_OEMCP ,
  1157. 0 ,
  1158. pHostEnt->h_name ,
  1159. -1,
  1160. szDnsServerName,
  1161. sizeof( szDnsServerName ) / sizeof( TCHAR ) );
  1162. dwSize = sizeof( szServerName ) / sizeof( TCHAR );
  1163. DnsHostnameToComputerName( szDnsServerName , szServerName , &dwSize );
  1164. }
  1165. else
  1166. {
  1167. // there was an error ( ip addr was probably not valid )
  1168. // display error
  1169. cstrTitle.LoadString( AFX_IDS_APP_TITLE );
  1170. cstrMsg.LoadString( IDS_NO_SERVER );
  1171. MessageBox( cstrMsg , cstrTitle , MB_OK | MB_ICONINFORMATION );
  1172. WSACleanup();
  1173. return FALSE;
  1174. }
  1175. }
  1176. WSACleanup();
  1177. }
  1178. CServer *pServer = pDoc->FindServerByName( szServerName );
  1179. if( pServer == NULL )
  1180. {
  1181. TCHAR szDomainName[ 256 ];
  1182. // this means that the server is not in the list
  1183. // let's find out what domain this server belongs to
  1184. DBGMSG( L"%s could not be found in the server list\n" , szServerName );
  1185. // Verify it's a terminal server we can connect to.
  1186. HANDLE hTerminalServer = NULL;
  1187. hTerminalServer = WinStationOpenServer( szServerName );
  1188. if( hTerminalServer == NULL )
  1189. {
  1190. DBGMSG( L"WinstationOpenServer failed with %d\n" , GetLastError( ) );
  1191. cstrTitle.LoadString( AFX_IDS_APP_TITLE );
  1192. cstrMsg.LoadString( IDS_NO_SERVER );
  1193. MessageBox( cstrMsg , cstrTitle , MB_OK | MB_ICONINFORMATION );
  1194. return false;
  1195. }
  1196. WinStationCloseServer( hTerminalServer );
  1197. DSROLE_PRIMARY_DOMAIN_INFO_BASIC *pDsRPDIB = NULL;
  1198. DWORD dwStatus = DsRoleGetPrimaryDomainInformation(
  1199. szServerName ,
  1200. DsRolePrimaryDomainInfoBasic,
  1201. ( PBYTE * )&pDsRPDIB );
  1202. DBGMSG( L"DsRoleGetPrimaryDomainInformation returned 0x%x\n" , dwStatus );
  1203. if( dwStatus == ERROR_SUCCESS && pDsRPDIB != NULL )
  1204. {
  1205. lstrcpy( szDomainName , pDsRPDIB->DomainNameFlat );
  1206. DsRoleFreeMemory( pDsRPDIB );
  1207. }
  1208. if( dwStatus != ERROR_SUCCESS )
  1209. {
  1210. // otherwise the server probably does not exist or its on
  1211. // a non-trusted domain
  1212. LPTSTR pBuffer = NULL;
  1213. cstrTitle.LoadString( AFX_IDS_APP_TITLE );
  1214. // cstrMsg.LoadString( IDS_NO_SERVER );
  1215. ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
  1216. FORMAT_MESSAGE_FROM_SYSTEM,
  1217. NULL, //ignored
  1218. dwStatus , //message ID
  1219. MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ), //message language
  1220. (LPTSTR)&pBuffer, //address of buffer pointer
  1221. 0, //minimum buffer size
  1222. NULL );
  1223. if( pBuffer != NULL )
  1224. {
  1225. cstrMsg.Format( IDS_NOSERVER_REASON , pBuffer );
  1226. LocalFree( pBuffer );
  1227. }
  1228. else
  1229. {
  1230. cstrMsg.Format( IDS_NOSERVER_REASON , TEXT("" ) );
  1231. }
  1232. MessageBox( cstrMsg , cstrTitle , MB_OK | MB_ICONINFORMATION );
  1233. return false;
  1234. }
  1235. else
  1236. {
  1237. // find the domain
  1238. BOOL bFound = FALSE;
  1239. CObList *pDomainList = pDoc->GetDomainList();
  1240. POSITION pos = pDomainList->GetHeadPosition();
  1241. while( pos )
  1242. {
  1243. CDomain *pDomain = ( CDomain* )pDomainList->GetNext( pos );
  1244. if( lstrcmpi( pDomain->GetName( ) , szDomainName ) == 0 )
  1245. {
  1246. bFound = TRUE;
  1247. CServer *pServer = new CServer( pDomain , szServerName , FALSE , FALSE );
  1248. if( pServer == NULL )
  1249. {
  1250. break;
  1251. }
  1252. pServer->SetManualFind();
  1253. // add server to list
  1254. pDoc->AddServer( pServer );
  1255. SendMessage( WM_ADMIN_ADD_SERVER , ( WPARAM )TVI_SORT , ( LPARAM )pServer );
  1256. m_pLeftPane->SendMessage( WM_ADMIN_GOTO_SERVER , 0 , ( LPARAM )pServer );
  1257. break;
  1258. }
  1259. }
  1260. if( !bFound )
  1261. {
  1262. CDomain *pDomain = new CDomain( szDomainName );
  1263. if( pDomain == NULL )
  1264. return false;
  1265. pDoc->AddDomain( pDomain );
  1266. m_pLeftPane->SendMessage( WM_ADMIN_ADD_DOMAIN , (WPARAM)NULL , ( LPARAM )pDomain );
  1267. CServer *pServer = new CServer( pDomain , szServerName , FALSE , FALSE );
  1268. if( pServer == NULL )
  1269. return false;
  1270. pServer->SetManualFind();
  1271. // add server to list
  1272. pDoc->AddServer( pServer );
  1273. SendMessage( WM_ADMIN_ADD_SERVER , ( WPARAM )TVI_SORT , ( LPARAM )pServer );
  1274. m_pLeftPane->SendMessage( WM_ADMIN_GOTO_SERVER , 0 , ( LPARAM )pServer );
  1275. }
  1276. }
  1277. }
  1278. else
  1279. {
  1280. // scroll to server
  1281. DBGMSG( L"Server %s is in the list\n",szServerName );
  1282. if( pServer->IsState(SS_DISCONNECTING) )
  1283. {
  1284. TCHAR buf[ 256 ];
  1285. ODS( L"but it's gone away so we're not jumping to server\n" );
  1286. cstrTitle.LoadString( AFX_IDS_APP_TITLE );
  1287. cstrMsg.LoadString( IDS_CURRENT_DISCON );
  1288. wsprintf( buf , cstrMsg , szServerName );
  1289. MessageBox( buf , cstrTitle , MB_OK | MB_ICONINFORMATION );
  1290. return false;
  1291. }
  1292. if( pServer->GetTreeItem( ) == NULL )
  1293. {
  1294. ODS( L"this server has no association to the tree add it now\n" );
  1295. SendMessage( WM_ADMIN_ADD_SERVER , ( WPARAM )TVI_SORT , ( LPARAM )pServer );
  1296. }
  1297. m_pLeftPane->SendMessage( WM_ADMIN_GOTO_SERVER , 0 , ( LPARAM )pServer );
  1298. }
  1299. return true;
  1300. }
  1301. //=-----------------------------------------------------------------------------------------
  1302. void CMainFrame::OnFindServer( )
  1303. {
  1304. CMyDialog dlg;
  1305. if( dlg.DoModal( ) == IDOK )
  1306. {
  1307. if (LocateServer(dlg.m_cstrServerName));
  1308. m_pLeftPane->SendMessage(WM_ADMIN_CONNECT_TO_SERVER, 0, 0);
  1309. }
  1310. }
  1311. //=-----------------------------------------------------------------
  1312. LRESULT CMainFrame::OnAdminGetTVStates( WPARAM wp , LPARAM lp )
  1313. {
  1314. ODS( L"CMainFrame::OnAdminGetTVStates\n" );
  1315. return m_pLeftPane->SendMessage( WM_ADMIN_GET_TV_STATES , 0 , 0 );
  1316. }
  1317. //=-----------------------------------------------------------------
  1318. LRESULT CMainFrame::OnAdminUpdateTVStates( WPARAM , LPARAM )
  1319. {
  1320. ODS( L"CMainFrame::OnAdminUpdateTVStates\n" );
  1321. return m_pLeftPane->SendMessage( WM_ADMIN_UPDATE_TVSTATE , 0 , 0 );
  1322. }
  1323. //=-----------------------------------------------------------------
  1324. void CMainFrame::OnEmptyFavorites( )
  1325. {
  1326. ODS( L"CMainFrame!OnEmptyFavorites\n" );
  1327. m_pLeftPane->SendMessage( IDM_ALLSERVERS_EMPTYFAVORITES , 0 , 0 );
  1328. }
  1329. void CMainFrame::OnUpdateEmptyFavs( CCmdUI* pCmdUI )
  1330. {
  1331. BOOL b = ( BOOL )m_pLeftPane->SendMessage( WM_ISFAVLISTEMPTY , 0 , 0 );
  1332. pCmdUI->Enable( !b );
  1333. }
  1334. //=-----------------------------------------------------------------
  1335. #ifdef _STRESS_BUILD
  1336. void CMainFrame::OnAddAllServersToFavorites( )
  1337. {
  1338. ODS( L"!OnAddAllServersToFavorites -- if you're seeing this you're running a special stress build\n" );
  1339. // loop through every server and add to fav's
  1340. CWinAdminDoc* pDoc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  1341. CObList *pServerList = pDoc->GetServerList();
  1342. POSITION pos = pServerList->GetHeadPosition();
  1343. while( pos )
  1344. {
  1345. CServer *pServer = ( CServer* )pServerList->GetNext( pos );
  1346. if( pServer != NULL &&
  1347. !pServer->IsState( SS_DISCONNECTING ) &&
  1348. pServer->GetTreeItemFromFav() == NULL )
  1349. {
  1350. m_pLeftPane->SendMessage( WM_ADMIN_ADDSERVERTOFAV , 0 , ( LPARAM )pServer );
  1351. }
  1352. }
  1353. }
  1354. //=-----------------------------------------------------------------
  1355. void CMainFrame::OnRunStress( )
  1356. {
  1357. ODS( L"OnRunStress! Stress starting...\n" );
  1358. AfxBeginThread((AFX_THREADPROC)RunStress , ( PVOID )m_pLeftPane );
  1359. }
  1360. //=-----------------------------------------------------------------
  1361. void CMainFrame::OnRunStressLite( )
  1362. {
  1363. ODS( L"OnRunStressLite! Stress lite starting...\n" );
  1364. AfxBeginThread((AFX_THREADPROC)RunStressLite , ( PVOID )m_pLeftPane );
  1365. }
  1366. //=-----------------------------------------------------------------
  1367. DWORD RunStressLite( PVOID pv )
  1368. {
  1369. CWnd *pLeftPane = ( CWnd * )pv;
  1370. CWinAdminDoc* pDoc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  1371. CObList *pDomainList = pDoc->GetDomainList();
  1372. CFrameWnd *p = (CFrameWnd*)pDoc->GetMainWnd();
  1373. // get all domains to start enumerating
  1374. pDoc->FindAllServers( );
  1375. int nStress = 0;
  1376. while( 1 )
  1377. {
  1378. DBGMSG( L"Stress lite run #%d\n" , nStress );
  1379. Sleep( 2 * 1000 * 60 );
  1380. // add all servers to favorites
  1381. ODS( L"STRES RUN! Adding all servers to favorites\n" );
  1382. p->SendMessage( WM_COMMAND , ( WPARAM )IDM_ALLSERVERS_FAVALLADD , ( LPARAM )p->GetSafeHwnd( ) );
  1383. pLeftPane->SendMessage( WM_ADMIN_EXPANDALL , 0 , 0 );
  1384. // wait 1 minutes
  1385. Sleep( 1 * 1000 * 60 );
  1386. // remove all servers from favorites
  1387. ODS( L"STRESS RUN! emptying favorites\n" );
  1388. pLeftPane->SendMessage( IDM_ALLSERVERS_EMPTYFAVORITES , 1 , 0 );
  1389. nStress++;
  1390. // start over ( no end );
  1391. }
  1392. }
  1393. //=-----------------------------------------------------------------
  1394. DWORD RunStress( PVOID pv )
  1395. {
  1396. CWnd *pLeftPane = ( CWnd * )pv;
  1397. CWinAdminDoc* pDoc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  1398. CObList *pDomainList = pDoc->GetDomainList();
  1399. CFrameWnd *p = (CFrameWnd*)pDoc->GetMainWnd();
  1400. // select each domain connect to each domain
  1401. POSITION pos = pDomainList->GetHeadPosition();
  1402. while( pos )
  1403. {
  1404. // Get a pointer to the domain
  1405. CDomain *pDomain = (CDomain*)pDomainList->GetNext(pos);
  1406. // If this domain isn't currently enumerating servers, tell it to
  1407. if( !pDomain->GetThreadPointer( ) )
  1408. {
  1409. // refresh server
  1410. if( lstrcmpi( pDomain->GetName( ) , L"ASIA" ) == 0 ||
  1411. lstrcmpi( pDomain->GetName( ) , L"HAIFA" ) == 0 )
  1412. {
  1413. DBGMSG( L"STRESS RUN! Enumerating %s\n", pDomain->GetName( ) );
  1414. pDomain->StartEnumerating();
  1415. }
  1416. }
  1417. }
  1418. while( 1 )
  1419. {
  1420. // wait a half a second.
  1421. Sleep( 1 * 10 * 1000 );
  1422. // pLeftPane->SendMessage( WM_ADMIN_COLLAPSEALL , 0 , 0 );
  1423. // connect to them all
  1424. ODS( L"\nSTRESS RUN! Connecting to all servers\n\n" );
  1425. p->SendMessage( WM_COMMAND , ( WPARAM )IDM_ALLSERVERS_CONNECT,( LPARAM )p->GetSafeHwnd( ) );
  1426. // pDoc->ConnectToAllServers();
  1427. Sleep( 1 * 30 * 1000 );
  1428. // pLeftPane->SendMessage( WM_ADMIN_EXPANDALL , 0 , 0 );
  1429. // disconnect them all
  1430. ODS( L"\nSTRESS RUN! Disconnecting from all servers\n\n" );
  1431. p->SendMessage( WM_COMMAND , ( WPARAM )IDM_ALLSERVERS_DISCONNECT,( LPARAM )p->GetSafeHwnd( ) );
  1432. // pDoc->DisconnectFromAllServers( );
  1433. ODS( L"\nSTRESS RUN! waiting for completion\n\n" );
  1434. while( g_fWaitForAllServersToDisconnect );
  1435. ODS( L"\nSTRESS RUN! done completing\n\n" );
  1436. // pLeftPane->SendMessage( WM_ADMIN_COLLAPSEALL , 0 , 0 );
  1437. // add all to favorites
  1438. ODS( L"\nSTRESS RUN! Adding all servers to favorites\n\n" );
  1439. p->SendMessage( WM_COMMAND , ( WPARAM )IDM_ALLSERVERS_FAVALLADD , ( LPARAM )p->GetSafeHwnd( ) );
  1440. // pLeftPane->SendMessage( WM_ADMIN_EXPANDALL , 0 , 0 );
  1441. // connect to them all
  1442. Sleep( 1 * 60 * 1000 );
  1443. ODS( L"\nSTRESS RUN! Connecting phase 2 to all servers\n\n" );
  1444. // pDoc->ConnectToAllServers();
  1445. p->SendMessage( WM_COMMAND , ( WPARAM )IDM_ALLSERVERS_CONNECT,( LPARAM )p->GetSafeHwnd( ) );
  1446. Sleep( 1 * 30 * 1000 );
  1447. ODS( L"\nSTRESS RUN! Disconnecting phase 2 from all servers\n\n" );
  1448. // pDoc->DisconnectFromAllServers( );
  1449. p->SendMessage( WM_COMMAND , ( WPARAM )IDM_ALLSERVERS_DISCONNECT,( LPARAM )p->GetSafeHwnd( ) );
  1450. while( g_fWaitForAllServersToDisconnect );
  1451. // remove from favs
  1452. ODS( L"STRESS RUN! emptying favorites\n" );
  1453. pLeftPane->SendMessage( IDM_ALLSERVERS_EMPTYFAVORITES , 1 , 0 );
  1454. }
  1455. return 0;
  1456. }
  1457. #endif