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.

1809 lines
46 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. //
  3. // 08/13/98
  4. // alhen
  5. //
  6. #include "stdafx.h"
  7. #include "tscc.h"
  8. #include "compdata.h"
  9. #include "comp.h"
  10. #include "tsprsht.h"
  11. #include "sdlgs.h"
  12. INT_PTR CALLBACK RenameDlgProc( HWND , UINT , WPARAM , LPARAM );
  13. void ErrMessage( HWND hwndOwner , INT_PTR iResourceID );
  14. extern void xxxErrMessage( HWND hwnd , INT_PTR nResMessageId , INT_PTR nResTitleId , UINT nFlags );
  15. extern void TscAccessDeniedMsg( HWND hwnd );
  16. extern void TscGeneralErrMsg( HWND hwnd );
  17. BOOL IsValidConnectionName( LPTSTR szConName , PDWORD );
  18. extern void SnodeErrorHandler( HWND hParent , INT nObjectId , DWORD dwStatus );
  19. extern void ReportStatusError( HWND hwnd , DWORD dwStatus );
  20. extern BOOL g_bAppSrvMode;
  21. //extern BOOL g_bEditMode;
  22. //--------------------------------------------------------------------------
  23. CComp::CComp( CCompdata* pCompdata )
  24. {
  25. m_pConsole = NULL;
  26. m_pCompdata = pCompdata;
  27. m_pResultData = NULL;
  28. m_pHeaderCtrl = NULL;
  29. m_pConsoleVerb = NULL;
  30. m_pImageResult = NULL;
  31. m_pDisplayHelp = NULL;
  32. m_nSettingCol = 0;
  33. m_nAttribCol = 0;
  34. m_cRef = 1; // addref at ctor
  35. }
  36. //--------------------------------------------------------------------------
  37. CComp::~CComp( )
  38. {
  39. }
  40. //--------------------------------------------------------------------------
  41. STDMETHODIMP CComp::QueryInterface( REFIID riid , PVOID *ppv )
  42. {
  43. HRESULT hr = S_OK;
  44. if( riid == IID_IUnknown )
  45. {
  46. *ppv = ( LPUNKNOWN )( LPCOMPONENT )this;
  47. }
  48. else if( riid == IID_IComponent )
  49. {
  50. *ppv = ( LPCOMPONENT )this;
  51. }
  52. else if( riid == IID_IExtendContextMenu )
  53. {
  54. *ppv = ( LPEXTENDCONTEXTMENU )this;
  55. }
  56. else if( riid == IID_IExtendPropertySheet )
  57. {
  58. *ppv = ( LPEXTENDPROPERTYSHEET )this;
  59. }
  60. else
  61. {
  62. *ppv = 0;
  63. hr = E_NOINTERFACE;
  64. }
  65. AddRef( );
  66. return hr;
  67. }
  68. //--------------------------------------------------------------------------
  69. STDMETHODIMP_( ULONG ) CComp::AddRef( )
  70. {
  71. return InterlockedIncrement( ( LPLONG )&m_cRef );
  72. }
  73. //--------------------------------------------------------------------------
  74. STDMETHODIMP_( ULONG )CComp::Release( )
  75. {
  76. if( InterlockedDecrement( ( LPLONG )&m_cRef ) == 0 )
  77. {
  78. delete this;
  79. return 0;
  80. }
  81. return m_cRef;
  82. }
  83. //--------------------------------------------------------------------------
  84. STDMETHODIMP CComp::Initialize( LPCONSOLE lpConsole )
  85. {
  86. HRESULT hr;
  87. ASSERT( lpConsole != NULL );
  88. m_pConsole = lpConsole;
  89. m_pConsole->AddRef( );
  90. // VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_MAINFOLDERNAME , m_strDispName , sizeof( m_strDispName ) ) );
  91. do
  92. {
  93. if( FAILED( ( hr = m_pConsole->QueryInterface( IID_IResultData , ( LPVOID *)&m_pResultData ) ) ) )
  94. {
  95. break;
  96. }
  97. if( FAILED( ( hr = m_pConsole->QueryInterface( IID_IHeaderCtrl , ( LPVOID *)&m_pHeaderCtrl ) ) ) )
  98. {
  99. break;
  100. }
  101. if( FAILED( ( hr = m_pConsole->QueryConsoleVerb( &m_pConsoleVerb ) ) ) )
  102. {
  103. break;
  104. }
  105. if( FAILED( ( hr = m_pConsole->QueryInterface( IID_IDisplayHelp , ( LPVOID * )&m_pDisplayHelp ) ) ) )
  106. {
  107. break;
  108. }
  109. hr = m_pConsole->QueryResultImageList( &m_pImageResult );
  110. }while( 0 );
  111. return hr;
  112. }
  113. //--------------------------------------------------------------------------
  114. STDMETHODIMP CComp::Notify( LPDATAOBJECT pDataObj , MMC_NOTIFY_TYPE event , LPARAM arg , LPARAM )
  115. {
  116. switch( event )
  117. {
  118. case MMCN_ACTIVATE:
  119. ODS( L"IComponent -- MMCN_ACTIVATE\n" );
  120. break;
  121. case MMCN_ADD_IMAGES:
  122. ODS( L"IComponent -- MMCN_ADD_IMAGES\n" );
  123. OnAddImages( );
  124. break;
  125. case MMCN_BTN_CLICK:
  126. ODS( L"IComponent -- MMCN_BTN_CLICK\n" );
  127. break;
  128. case MMCN_CLICK:
  129. ODS( L"IComponent -- MMCN_CLICK\n" );
  130. break;
  131. case MMCN_DBLCLICK:
  132. ODS( L"IComponent -- MMCN_DBLCLICK\n" );
  133. // enables navigation to inner folders.
  134. // final item launches default verb
  135. OnDblClk( pDataObj );
  136. return S_FALSE;
  137. case MMCN_DELETE:
  138. ODS( L"IComponent -- MMCN_DELETE\n" );
  139. OnDelete( pDataObj );
  140. break;
  141. case MMCN_EXPAND:
  142. ODS( L"IComponent -- MMCN_EXPAND\n" );
  143. break;
  144. case MMCN_MINIMIZED:
  145. ODS( L"IComponent -- MMCN_MINIMIZED\n" );
  146. break;
  147. case MMCN_PROPERTY_CHANGE:
  148. ODS( L"IComponent -- MMCN_PROPERTY_CHANGE\n" );
  149. break;
  150. case MMCN_REMOVE_CHILDREN:
  151. ODS( L"IComponent -- MMCN_REMOVE_CHILDREN\n" );
  152. break;
  153. case MMCN_REFRESH:
  154. ODS( L"IComponent -- MMCN_REFRESH\n" );
  155. OnRefresh( pDataObj );
  156. break;
  157. case MMCN_RENAME:
  158. ODS( L"IComponent -- MMCN_RENAME\n" );
  159. break;
  160. case MMCN_SELECT:
  161. ODS( L"IComponent -- MMCN_SELECT\n" );
  162. OnSelect( pDataObj , ( BOOL )LOWORD( arg ) , ( BOOL )HIWORD( arg ) );
  163. break;
  164. case MMCN_SHOW:
  165. ODS( L"IComponent -- MMCN_SHOW\n" );
  166. OnShow( pDataObj , ( BOOL )arg );
  167. break;
  168. case MMCN_VIEW_CHANGE:
  169. ODS( L"IComponent -- MMCN_VIEW_CHANGE\n" );
  170. OnViewChange( );
  171. break;
  172. case MMCN_CONTEXTHELP:
  173. ODS( L"IComponent -- MMCN_CONTEXTHELP\n" );
  174. OnHelp( pDataObj );
  175. break;
  176. case MMCN_SNAPINHELP:
  177. ODS( L"IComponent -- MMCN_SNAPINHELP\n" );
  178. break;
  179. default:
  180. ODS( L"CComp::Notify - event not registered\n" );
  181. }
  182. return S_OK;
  183. }
  184. //--------------------------------------------------------------------------
  185. // pDataobject represents the current selected scope folder
  186. // this should only be our main folder in the scope pane
  187. //--------------------------------------------------------------------------
  188. HRESULT CComp::OnShow( LPDATAOBJECT pDataobject , BOOL bSelect )
  189. {
  190. TCHAR tchBuffer[ 256 ];
  191. HRESULT hr = S_FALSE;
  192. ASSERT( pDataobject != NULL );
  193. if( bSelect && m_pCompdata->IsSettingsFolder( pDataobject ) )
  194. {
  195. // set up columns for services folder
  196. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_SETTINGS_COLUMN1 , tchBuffer , SIZE_OF_BUFFER( tchBuffer ) ) );
  197. if( m_nSettingCol == 0 && m_nAttribCol == 0 )
  198. {
  199. SetColumnsForSettingsPane( );
  200. }
  201. ODS( L"TSCC:Comp@OnShow inserting columns\n" );
  202. if( m_nSettingCol == 0 )
  203. {
  204. hr = m_pHeaderCtrl->InsertColumn( 0 , tchBuffer , 0 , MMCLV_AUTO );
  205. }
  206. else
  207. {
  208. hr = m_pHeaderCtrl->InsertColumn( 0 , tchBuffer , 0 , m_nSettingCol );
  209. }
  210. if( SUCCEEDED( hr ) )
  211. {
  212. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ATTRIB_COLUMN2 , tchBuffer , SIZE_OF_BUFFER( tchBuffer ) ) );
  213. if( m_nAttribCol == 0 )
  214. {
  215. hr = m_pHeaderCtrl->InsertColumn( 1 , tchBuffer , 0 , MMCLV_AUTO );
  216. }
  217. else
  218. {
  219. hr = m_pHeaderCtrl->InsertColumn( 1 , tchBuffer , 0 , m_nAttribCol );
  220. }
  221. }
  222. AddSettingsinResultPane( );
  223. }
  224. else if( bSelect && m_pCompdata->IsConnectionFolder( pDataobject ) )
  225. {
  226. // set up column headers for connection folder
  227. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_COLCONNECT , tchBuffer , SIZE_OF_BUFFER( tchBuffer ) ) );
  228. hr = m_pHeaderCtrl->InsertColumn( 0 , tchBuffer , 0 , MMCLV_AUTO );
  229. if( SUCCEEDED( hr ) )
  230. {
  231. //SetColumnWidth( 0 );
  232. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_COLTRANSPORT , tchBuffer , SIZE_OF_BUFFER( tchBuffer ) ) );
  233. hr = m_pHeaderCtrl->InsertColumn( 1 , tchBuffer , 0 , MMCLV_AUTO );
  234. }
  235. if( SUCCEEDED( hr ) )
  236. {
  237. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_COLTYPE , tchBuffer , SIZE_OF_BUFFER( tchBuffer ) ) );
  238. // ui master dirty trick 120 equals fudge factor
  239. hr = m_pHeaderCtrl->InsertColumn( 2 , tchBuffer , 0 , 120/*MMCLV_AUTO*/ );
  240. }
  241. if( SUCCEEDED( hr ) )
  242. {
  243. //SetColumnWidth( 2 );
  244. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_COLCOMMENT , tchBuffer , SIZE_OF_BUFFER( tchBuffer ) ) );
  245. hr = m_pHeaderCtrl->InsertColumn( 3 , tchBuffer , 0 , MMCLV_AUTO );
  246. }
  247. // insert items
  248. if( SUCCEEDED( hr ) )
  249. {
  250. hr = InsertItemsinResultPane( );
  251. }
  252. }
  253. return hr;
  254. }
  255. //--------------------------------------------------------------------------
  256. BOOL CComp::OnAddImages( )
  257. {
  258. HICON hiconConnect = LoadIcon( _Module.GetResourceInstance( ) , MAKEINTRESOURCE( IDI_ICON_CON ) );
  259. HICON hiconDiscon = LoadIcon( _Module.GetResourceInstance( ) , MAKEINTRESOURCE( IDI_ICON_DISCON ) );
  260. HICON hiconBullet = LoadIcon( _Module.GetResourceInstance( ) , MAKEINTRESOURCE( IDI_ICON_BULLET ) );
  261. m_pImageResult->ImageListSetIcon( ( PLONG_PTR )hiconConnect , 1 );
  262. m_pImageResult->ImageListSetIcon( ( PLONG_PTR )hiconDiscon , 2 );
  263. m_pImageResult->ImageListSetIcon( ( PLONG_PTR )hiconBullet , 3 );
  264. return TRUE;
  265. }
  266. //--------------------------------------------------------------------------
  267. // update resultitems in result pane and note scopeitems
  268. //--------------------------------------------------------------------------
  269. BOOL CComp::OnViewChange( )
  270. {
  271. RESULTDATAITEM rdi;
  272. ZeroMemory( &rdi , sizeof( RESULTDATAITEM ) );
  273. rdi.mask = RDI_PARAM;
  274. m_pResultData->GetItem( &rdi );
  275. if( rdi.bScopeItem )
  276. {
  277. return FALSE;
  278. }
  279. if( SUCCEEDED( InsertItemsinResultPane( ) ) )
  280. {
  281. return TRUE;
  282. }
  283. return FALSE;
  284. }
  285. //--------------------------------------------------------------------------
  286. // Forced refreshed!!
  287. //--------------------------------------------------------------------------
  288. BOOL CComp::OnRefresh( LPDATAOBJECT pdo )
  289. {
  290. RESULTDATAITEM rdi;
  291. ZeroMemory( &rdi , sizeof( RESULTDATAITEM ) );
  292. CBaseNode *pNode = static_cast< CBaseNode * >( pdo );
  293. if( pNode->GetNodeType() == MAIN_NODE )
  294. {
  295. rdi.mask = RDI_PARAM;
  296. m_pResultData->GetItem( &rdi );
  297. if( rdi.bScopeItem )
  298. {
  299. return FALSE;
  300. }
  301. //NA 2/28/01 This has been moved to InsertItemsinResultPane because
  302. //it needs to be performed between its two operations, not before
  303. //if( FAILED( m_pCompdata->UpdateAllResultNodes( ) ) )
  304. //{
  305. // ODS( L"OnRefresh - UpdateAllResultNodes failed!!\n" ) ;
  306. // return FALSE;
  307. //}
  308. InsertItemsinResultPane( );
  309. }
  310. #if 0 // too late for this feature
  311. else if( pNode->GetNodeType() == SETTINGS_NODE )
  312. {
  313. HRESULT hr;
  314. ODS( L"OnRefresh - called for settings node\n" );
  315. rdi.mask = RDI_PARAM;
  316. rdi.itemID = 1;
  317. m_pResultData->GetItem( &rdi );
  318. if( rdi.bScopeItem )
  319. {
  320. return FALSE;
  321. }
  322. if( FAILED( hr = m_pResultData->DeleteAllRsltItems( ) ) )
  323. {
  324. DBGMSG( L"TSCC:OnRefresh DeleteAllRsltItems ( SNODES ) failed 0x%x\n" , hr );
  325. return FALSE;
  326. }
  327. SetColumnsForSettingsPane( );
  328. AddSettingsinResultPane( );
  329. }
  330. #endif
  331. return TRUE;
  332. }
  333. //--------------------------------------------------------------------------
  334. STDMETHODIMP CComp::Destroy( MMC_COOKIE /* reserved */ )
  335. {
  336. ODS( L"IComponent releasing interfaces\n" );
  337. if( m_pResultData != NULL )
  338. {
  339. m_pResultData->Release( );
  340. }
  341. if( m_pConsole != NULL )
  342. {
  343. m_pConsole->Release( );
  344. }
  345. if( m_pHeaderCtrl != NULL )
  346. {
  347. m_pHeaderCtrl->Release( );
  348. }
  349. if( m_pConsoleVerb != NULL )
  350. {
  351. m_pConsoleVerb->Release( );
  352. }
  353. if( m_pImageResult != NULL )
  354. {
  355. m_pImageResult->Release( );
  356. }
  357. if( m_pDisplayHelp != NULL )
  358. {
  359. m_pDisplayHelp->Release( );
  360. }
  361. return S_OK;
  362. }
  363. //--------------------------------------------------------------------------
  364. STDMETHODIMP CComp::GetResultViewType( MMC_COOKIE , LPOLESTR* , PLONG plView )
  365. {
  366. *plView = MMC_VIEW_OPTIONS_NONE;
  367. return S_FALSE;
  368. }
  369. //--------------------------------------------------------------------------
  370. STDMETHODIMP CComp::QueryDataObject( MMC_COOKIE ck , DATA_OBJECT_TYPES dtype , LPDATAOBJECT* ppDataObject )
  371. {
  372. if( dtype == CCT_RESULT )
  373. {
  374. *ppDataObject = ( LPDATAOBJECT )ck;
  375. ( ( LPDATAOBJECT )*ppDataObject)->AddRef( );
  376. }
  377. else if( m_pCompdata != NULL )
  378. {
  379. return m_pCompdata->QueryDataObject( ck , dtype , ppDataObject );
  380. }
  381. return S_OK;
  382. }
  383. //--------------------------------------------------------------------------
  384. STDMETHODIMP CComp::GetDisplayInfo( LPRESULTDATAITEM pRdi )
  385. {
  386. ASSERT( pRdi != NULL );
  387. if( pRdi == NULL )
  388. {
  389. return E_INVALIDARG;
  390. }
  391. if( pRdi->bScopeItem )
  392. {
  393. CBaseNode *pScopeNode = ( CBaseNode * )pRdi->lParam;
  394. if( pScopeNode != NULL )
  395. {
  396. if( pScopeNode->GetNodeType( ) == MAIN_NODE )
  397. {
  398. //
  399. if( pRdi->mask & RDI_STR )
  400. {
  401. if( pRdi->nCol == 0 )
  402. {
  403. // pRdi->str is NULL in this call
  404. pRdi->str = ( LPOLESTR )m_pCompdata->m_tchMainFolderName; //m_strDispName;
  405. }
  406. }
  407. }
  408. else if( pScopeNode->GetNodeType( ) == SETTINGS_NODE )
  409. {
  410. if( pRdi->mask & RDI_STR )
  411. {
  412. if( pRdi->nCol == 0 )
  413. {
  414. // pRdi->str is NULL in this call
  415. pRdi->str = ( LPOLESTR )m_pCompdata->m_tchSettingsFolderName; //L"Server Settings";
  416. }
  417. }
  418. }
  419. }
  420. if( pRdi->mask & RDI_IMAGE )
  421. {
  422. ODS( TEXT("RDI_IMAGE -- in CComponent::GetDisplayInfo\n") );
  423. pRdi->nImage = ( ( CBaseNode * )pRdi->lParam )->GetImageIdx( );
  424. }
  425. }
  426. else
  427. {
  428. // populate result pane
  429. CBaseNode *pItem = ( CBaseNode * )pRdi->lParam;
  430. if( pItem != NULL )
  431. {
  432. if( pItem->GetNodeType( ) == RESULT_NODE )
  433. {
  434. CResultNode *pNode = ( CResultNode * )pRdi->lParam;
  435. if( pRdi->mask & RDI_STR )
  436. {
  437. switch( pRdi->nCol )
  438. {
  439. case 0:
  440. pRdi->str = pNode->GetConName( );
  441. break;
  442. case 1:
  443. pRdi->str = pNode->GetTTName( );
  444. break;
  445. case 2:
  446. pRdi->str = pNode->GetTypeName( );
  447. break;
  448. case 3:
  449. pRdi->str = pNode->GetComment( );
  450. break;
  451. }
  452. }
  453. }
  454. else if( pItem->GetNodeType( ) == RSETTINGS_NODE )
  455. {
  456. CSettingNode *pNode = ( CSettingNode *)pRdi->lParam;
  457. if( pRdi->mask & RDI_STR )
  458. {
  459. switch( pRdi->nCol )
  460. {
  461. case 0:
  462. pRdi->str = pNode->GetAttributeName( );
  463. break;
  464. case 1:
  465. if( pNode->GetObjectId( ) >= CUSTOM_EXTENSION )
  466. {
  467. DWORD dwStatus;
  468. pNode->SetAttributeValue( 0 , &dwStatus );
  469. }
  470. pRdi->str = pNode->GetCachedValue( );
  471. break;
  472. }
  473. }
  474. }
  475. }
  476. }
  477. return S_OK;
  478. }
  479. //--------------------------------------------------------------------------
  480. // Returns S_OK if they are similar S_FALSE otherwise
  481. //--------------------------------------------------------------------------
  482. STDMETHODIMP CComp::CompareObjects( LPDATAOBJECT , LPDATAOBJECT )
  483. {
  484. return S_OK;
  485. }
  486. //--------------------------------------------------------------------------
  487. HRESULT CComp::InsertItemsinResultPane( )
  488. {
  489. HRESULT hr;
  490. //This removes the node information from the data in MMC
  491. if( FAILED( hr = m_pResultData->DeleteAllRsltItems( ) ) )
  492. {
  493. return hr;
  494. }
  495. if( m_pCompdata == NULL )
  496. {
  497. return E_UNEXPECTED;
  498. }
  499. //NA 3/2/01 This needs to be done to update the data held
  500. //in m_pCompdata before the nodes are put into its list
  501. if( FAILED( m_pCompdata->UpdateAllResultNodes( ) ) )
  502. {
  503. ODS( L"OnRefresh - UpdateAllResultNodes failed!!\n" ) ;
  504. return FALSE;
  505. }
  506. //This puts the data for the nodes into m_pCompdata and also
  507. //sends that same information to MMC
  508. if( FAILED( hr = m_pCompdata->InsertFolderItems( m_pResultData ) ) )
  509. {
  510. return hr;
  511. }
  512. return hr;
  513. }
  514. //--------------------------------------------------------------------------
  515. HRESULT CComp::AddSettingsinResultPane( )
  516. {
  517. HRESULT hr;
  518. if( m_pCompdata == NULL )
  519. {
  520. return E_UNEXPECTED;
  521. }
  522. if( FAILED( hr = m_pCompdata->InsertSettingItems( m_pResultData ) ) )
  523. {
  524. return hr;
  525. }
  526. return hr;
  527. }
  528. //--------------------------------------------------------------------------
  529. HRESULT CComp::OnSelect( LPDATAOBJECT pdo , BOOL bScope , BOOL bSelected )
  530. {
  531. CBaseNode *pNode = static_cast< CBaseNode * >( pdo );
  532. if( pNode == NULL )
  533. {
  534. return S_FALSE;
  535. }
  536. if( m_pConsoleVerb == NULL )
  537. {
  538. return E_UNEXPECTED;
  539. }
  540. // Item is being deselected and we're not interested currently
  541. if( !bSelected )
  542. {
  543. return S_OK;
  544. }
  545. // pNode == NULL if the folder item is being viewed in the result pane
  546. // settings node is ignored for this release
  547. if( bScope && pNode->GetNodeType( ) == MAIN_NODE )
  548. {
  549. m_pConsoleVerb->SetVerbState( MMC_VERB_REFRESH , ENABLED , TRUE );
  550. m_pConsoleVerb->SetDefaultVerb( MMC_VERB_OPEN );
  551. }
  552. else
  553. {
  554. if( pNode->GetNodeType() == RESULT_NODE )
  555. {
  556. m_pConsoleVerb->SetVerbState( MMC_VERB_DELETE , ENABLED , TRUE );
  557. //m_pConsoleVerb->SetVerbState( MMC_VERB_REFRESH , ENABLED , TRUE );
  558. m_pConsoleVerb->SetVerbState( MMC_VERB_PROPERTIES , ENABLED , TRUE );
  559. m_pConsoleVerb->SetDefaultVerb( MMC_VERB_PROPERTIES );
  560. }
  561. }
  562. return S_OK;
  563. }
  564. //--------------------------------------------------------------------------
  565. STDMETHODIMP CComp::AddMenuItems( LPDATAOBJECT pdo , LPCONTEXTMENUCALLBACK pcmc , PLONG pl )
  566. {
  567. // CONTEXTMENUITEM cmi;
  568. if( pdo == NULL || pcmc == NULL )
  569. {
  570. return E_UNEXPECTED;
  571. }
  572. // do not allow scope node types
  573. if( m_pCompdata->IsConnectionFolder( pdo ) || m_pCompdata->IsSettingsFolder( pdo ) )
  574. {
  575. return S_FALSE;
  576. }
  577. CBaseNode *pNode = NULL;
  578. pNode = static_cast< CBaseNode * >( pdo );
  579. if( pNode == NULL )
  580. {
  581. return S_FALSE;
  582. }
  583. // hey root node has no menu items to insert.
  584. if( pNode->GetNodeType() == 0 )
  585. {
  586. return S_FALSE;
  587. }
  588. if( pNode->AddMenuItems( pcmc , pl ) )
  589. {
  590. return S_OK;
  591. }
  592. return E_FAIL;
  593. }
  594. //--------------------------------------------------------------------------
  595. // Toggles connection
  596. //--------------------------------------------------------------------------
  597. STDMETHODIMP CComp::Command( LONG lCmd , LPDATAOBJECT pdo )
  598. {
  599. TCHAR buf[ 512 ];
  600. TCHAR tchmsg[ 256 ];
  601. HRESULT hr;
  602. if( pdo == NULL )
  603. {
  604. return E_UNEXPECTED;
  605. }
  606. HWND hMain;
  607. if( FAILED( m_pConsole->GetMainWindow( &hMain ) ) )
  608. {
  609. hMain = NULL;
  610. }
  611. CResultNode *pNode = NULL;
  612. CSettingNode *pSetNode = NULL;
  613. if( pdo == NULL )
  614. {
  615. return S_FALSE;
  616. }
  617. if( ( ( CBaseNode * )pdo )->GetNodeType( ) == RSETTINGS_NODE )
  618. {
  619. pSetNode = ( CSettingNode * )pdo;
  620. BOOL bVal;
  621. DWORD dwStatus = 0;
  622. switch( lCmd )
  623. {
  624. case IDM_SETTINGS_PROPERTIES:
  625. OnDblClk( pdo );
  626. break;
  627. case IDM_SETTINGS_DELTEMPDIRSONEXIT:
  628. case IDM_SETTINGS_USETMPDIR:
  629. case IDM_SETTINGS_ADP:
  630. case IDM_SETTINGS_SS:
  631. {
  632. bVal = ( BOOL )pSetNode->xx_GetValue( );
  633. HCURSOR hCursor = SetCursor( LoadCursor( NULL , MAKEINTRESOURCE( IDC_WAIT ) ) );
  634. hr = pSetNode->SetAttributeValue( !bVal , &dwStatus );
  635. if( FAILED( hr ) )
  636. {
  637. SnodeErrorHandler( hMain , pSetNode->GetObjectId( ) , dwStatus );
  638. }
  639. //
  640. // We might want to move this code into OnRefresh() but for now, this is fix for
  641. // not updating attribute value and don't want to cause other regression
  642. //
  643. HRESULT hr;
  644. HRESULTITEM itemID;
  645. hr = m_pResultData->FindItemByLParam( (LPARAM) pdo, &itemID );
  646. if( SUCCEEDED(hr) )
  647. {
  648. m_pResultData->UpdateItem( itemID );
  649. }
  650. SetCursor( hCursor );
  651. }
  652. break;
  653. default:
  654. if( pSetNode->GetObjectId() >= CUSTOM_EXTENSION )
  655. {
  656. IExtendServerSettings *pEss = reinterpret_cast< IExtendServerSettings * >( pSetNode->GetInterface() );
  657. if( pEss != NULL )
  658. {
  659. pEss->ExecMenuCmd( lCmd , hMain , &dwStatus );
  660. // this forces the ui to be updated.
  661. if( dwStatus == UPDATE_TERMSRV || dwStatus == UPDATE_TERMSRV_SESSDIR )
  662. {
  663. ICfgComp *pCfgcomp = NULL;
  664. m_pCompdata->GetServer( &pCfgcomp );
  665. if( pCfgcomp != NULL )
  666. {
  667. ODS( L"TSCC!ExecMenuCmd forcing termsrv update\n" );
  668. if( dwStatus == UPDATE_TERMSRV_SESSDIR )
  669. {
  670. HCURSOR hCursor = SetCursor( LoadCursor( NULL ,
  671. MAKEINTRESOURCE( IDC_WAIT ) ) );
  672. if( FAILED( pCfgcomp->UpdateSessionDirectory( &dwStatus ) ) )
  673. {
  674. ReportStatusError( hMain , dwStatus );
  675. }
  676. SetCursor(hCursor);
  677. }
  678. else
  679. {
  680. pCfgcomp->ForceUpdate( );
  681. }
  682. pCfgcomp->Release();
  683. }
  684. }
  685. pSetNode->SetAttributeValue( 0 , &dwStatus );
  686. }
  687. }
  688. }
  689. }
  690. else if( ( ( CBaseNode * )pdo )->GetNodeType( ) == RESULT_NODE )
  691. {
  692. pNode = ( CResultNode * )pdo;
  693. if( lCmd == IDM_ENABLE_CONNECTION )
  694. {
  695. if( pNode->m_bEditMode )
  696. {
  697. xxxErrMessage( hMain , IDS_ERR_INEDITMODE , IDS_WARN_TITLE , MB_OK | MB_ICONWARNING );
  698. return S_FALSE;
  699. }
  700. ICfgComp *pCfgcomp;
  701. if( pNode->GetServer( &pCfgcomp ) != 0 )
  702. {
  703. WS *pWs;
  704. LONG lSz;
  705. if( SUCCEEDED( pCfgcomp->GetWSInfo( pNode->GetConName( ) , &lSz , &pWs ) ) )
  706. {
  707. BOOL bProceed = TRUE;
  708. pWs->fEnableWinstation = !pNode->GetConnectionState( );
  709. if( pWs->fEnableWinstation == 0 )
  710. {
  711. LONG lCount;
  712. // check to see if anyone is connected
  713. pCfgcomp->QueryLoggedOnCount( pNode->GetConName( ) , &lCount );
  714. if( lCount > 0 )
  715. {
  716. LoadString( _Module.GetResourceInstance( ) , IDS_DISABLELIVECONNECTION , tchmsg , SIZE_OF_BUFFER( tchmsg ) );
  717. }
  718. else
  719. {
  720. LoadString( _Module.GetResourceInstance( ) , IDS_DISABLECONNECTION , tchmsg , SIZE_OF_BUFFER( tchmsg ) );
  721. }
  722. wsprintf( buf , tchmsg , pNode->GetConName( ) );
  723. LoadString( _Module.GetResourceInstance( ) , IDS_WARN_TITLE , tchmsg , SIZE_OF_BUFFER( tchmsg ) );
  724. if( MessageBox( hMain , buf , tchmsg , MB_ICONWARNING | MB_YESNO ) == IDNO )
  725. {
  726. bProceed = FALSE;
  727. }
  728. }
  729. if( bProceed )
  730. {
  731. /*pNode->EnableConnection( pWs->fEnableWinstation );
  732. pNode->SetImageIdx( ( pWs->fEnableWinstation ? 1 : 2 ) );
  733. pCfgcomp->UpDateWS( pWs , UPDATE_ENABLEWINSTATION );
  734. m_pConsole->UpdateAllViews( ( LPDATAOBJECT )pNode , 0 , 0 );
  735. */
  736. DWORD dwStatus;
  737. if( FAILED( hr = pCfgcomp->UpDateWS( pWs , UPDATE_ENABLEWINSTATION , &dwStatus, TRUE ) ) )
  738. {
  739. if( hr == E_ACCESSDENIED )
  740. {
  741. TscAccessDeniedMsg( hMain );
  742. }
  743. else
  744. {
  745. TscGeneralErrMsg( hMain );
  746. }
  747. }
  748. else
  749. {
  750. pNode->EnableConnection( pWs->fEnableWinstation );
  751. pNode->SetImageIdx( ( pWs->fEnableWinstation ? 1 : 2 ) );
  752. m_pConsole->UpdateAllViews( ( LPDATAOBJECT )pNode , 0 , 0 );
  753. }
  754. }
  755. if(pWs->fEnableWinstation && pWs->PdClass == SdAsync)
  756. {
  757. ASYNCCONFIGW AsyncConfig;
  758. HRESULT hResult = pCfgcomp->GetAsyncConfig( pWs->Name , WsName , &AsyncConfig );
  759. if( SUCCEEDED( hResult ) )
  760. {
  761. if( AsyncConfig.ModemName[0] )
  762. {
  763. LoadString( _Module.GetResourceInstance( ) , IDS_REBOOT_REQD , buf , SIZE_OF_BUFFER( buf ) );
  764. LoadString( _Module.GetResourceInstance( ) , IDS_WARN_TITLE , tchmsg , SIZE_OF_BUFFER( tchmsg ) );
  765. MessageBox( hMain , buf , tchmsg , MB_ICONWARNING | MB_OK );
  766. }
  767. }
  768. }
  769. CoTaskMemFree( pWs );
  770. }
  771. pCfgcomp->Release( );
  772. }
  773. }
  774. else if( lCmd == IDM_RENAME_CONNECTION )
  775. {
  776. if( pNode->m_bEditMode )
  777. {
  778. xxxErrMessage( hMain , IDS_ERR_INEDITMODE , IDS_WARN_TITLE , MB_OK | MB_ICONWARNING );
  779. return S_FALSE;
  780. }
  781. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_RENAME ) , hMain , RenameDlgProc , ( LPARAM )pNode );
  782. }
  783. }
  784. return S_OK;
  785. }
  786. //--------------------------------------------------------------------------
  787. STDMETHODIMP CComp::CreatePropertyPages( LPPROPERTYSHEETCALLBACK psc , LONG_PTR Handle , LPDATAOBJECT pdo )
  788. {
  789. HRESULT hr = E_OUTOFMEMORY;
  790. if( psc == NULL )
  791. {
  792. return E_UNEXPECTED;
  793. }
  794. CPropsheet *pPropsheet = new CPropsheet( );
  795. if( pPropsheet != NULL )
  796. {
  797. HWND hMain;
  798. if( FAILED( m_pConsole->GetMainWindow( &hMain ) ) )
  799. {
  800. hMain = NULL;
  801. }
  802. if( FAILED( ( hr = pPropsheet->InitDialogs( hMain , psc , dynamic_cast< CResultNode *>( pdo ) , Handle ) ) ) )
  803. {
  804. delete pPropsheet;
  805. }
  806. }
  807. return hr;
  808. }
  809. //--------------------------------------------------------------------------
  810. STDMETHODIMP CComp::QueryPagesFor( LPDATAOBJECT pdo )
  811. {
  812. if( dynamic_cast< CResultNode *>( pdo ) == NULL )
  813. {
  814. return E_INVALIDARG;
  815. }
  816. return S_OK;
  817. }
  818. //--------------------------------------------------------------------------
  819. BOOL CComp::OnDelete( LPDATAOBJECT pDo )
  820. {
  821. CResultNode *pNode = dynamic_cast< CResultNode *>( pDo );
  822. if( pNode == NULL )
  823. {
  824. ODS( L"TSCC: OnDelete, node == NULL\n");
  825. return FALSE;
  826. }
  827. if( pNode->m_bEditMode )
  828. {
  829. HWND hMain;
  830. if( FAILED( m_pConsole->GetMainWindow( &hMain ) ) )
  831. {
  832. hMain = NULL;
  833. }
  834. xxxErrMessage( hMain , IDS_ERR_INEDITMODE , IDS_WARN_TITLE , MB_OK | MB_ICONWARNING );
  835. return FALSE;
  836. }
  837. return m_pCompdata->OnDeleteItem( pDo );
  838. }
  839. //--------------------------------------------------------------------------
  840. // CResultNode passed in on init
  841. //--------------------------------------------------------------------------
  842. INT_PTR CALLBACK RenameDlgProc( HWND hDlg , UINT msg , WPARAM wp , LPARAM lp )
  843. {
  844. CResultNode *pNode;
  845. TCHAR tchNewName[ 60 ];
  846. // HWND h;
  847. switch( msg )
  848. {
  849. case WM_INITDIALOG :
  850. pNode = ( CResultNode *)lp;
  851. ASSERT( pNode != NULL );
  852. // ok to store null -- it's initializing DWLP_USER area
  853. SetWindowLongPtr( hDlg , DWLP_USER , ( LONG_PTR )pNode );
  854. // Insert name
  855. ICfgComp *pCfgcomp;
  856. if( pNode == NULL )
  857. {
  858. break;
  859. }
  860. if( pNode->GetServer( &pCfgcomp ) == 0 )
  861. {
  862. ASSERT( 0 );
  863. break;
  864. }
  865. SetWindowText( GetDlgItem( hDlg , IDC_STATIC_CURRENT_NAME ) , pNode->GetConName( ) );
  866. pCfgcomp->Release( );
  867. SetFocus( GetDlgItem( hDlg , IDC_EDIT_NEWNAME ) );
  868. SendMessage( GetDlgItem( hDlg , IDC_EDIT_NEWNAME ) , EM_SETLIMITTEXT , ( WPARAM )( WINSTATIONNAME_LENGTH - WINSTATION_NAME_TRUNCATE_BY ) , 0 );
  869. break;
  870. case WM_COMMAND:
  871. if( LOWORD( wp ) == IDOK )
  872. {
  873. pNode = ( CResultNode *)GetWindowLongPtr( hDlg , DWLP_USER );
  874. if( pNode == NULL )
  875. {
  876. break;
  877. }
  878. DWORD dwErr = 0;
  879. if( GetWindowText( GetDlgItem( hDlg , IDC_EDIT_NEWNAME ) , tchNewName , SIZE_OF_BUFFER( tchNewName ) ) == 0 ||
  880. !IsValidConnectionName( tchNewName , &dwErr ) )
  881. {
  882. if( dwErr == ERROR_INVALID_FIRSTCHARACTER )
  883. {
  884. ErrMessage( hDlg , IDS_ERR_INVALIDFIRSTCHAR );
  885. }
  886. else
  887. {
  888. ErrMessage( hDlg , IDS_ERR_INVALIDCHARS );
  889. }
  890. SetFocus( GetDlgItem( hDlg , IDC_EDIT_NEWNAME ) );
  891. SendMessage( GetDlgItem( hDlg , IDC_EDIT_NEWNAME ) , EM_SETSEL , ( WPARAM )0 , ( LPARAM )-1 );
  892. return 0;
  893. }
  894. // verify the name is unique
  895. ICfgComp *pCfgcomp;
  896. if( pNode->GetServer( &pCfgcomp ) == 0 )
  897. {
  898. ODS( L"GetServer failed in RenameDlgProc\n" );
  899. break;
  900. }
  901. do
  902. {
  903. BOOL bUnique = FALSE;
  904. if( FAILED( pCfgcomp->IsWSNameUnique( ( PWINSTATIONNAMEW )tchNewName , &bUnique ) ) )
  905. {
  906. break;
  907. }
  908. if( !bUnique )
  909. {
  910. ErrMessage( hDlg , IDS_ERR_WINNAME );
  911. pCfgcomp->Release( );
  912. SetFocus( GetDlgItem( hDlg , IDC_EDIT_NEWNAME ) );
  913. SendMessage( GetDlgItem( hDlg , IDC_EDIT_NEWNAME ) , EM_SETSEL , ( WPARAM )0 , ( LPARAM )-1 );
  914. return 0;
  915. }
  916. HRESULT hr;
  917. LONG lCount;
  918. TCHAR tchWrnBuf[ 256 ];
  919. TCHAR tchOutput[ 512 ];
  920. // check to see if anyone is connected
  921. pCfgcomp->QueryLoggedOnCount( pNode->GetConName( ) , &lCount );
  922. if( lCount > 0 )
  923. {
  924. if( lCount == 1 )
  925. {
  926. LoadString( _Module.GetResourceInstance() , IDS_RENAME_WRN_SINGLE , tchWrnBuf , SIZE_OF_BUFFER( tchWrnBuf ) );
  927. }
  928. else
  929. {
  930. LoadString( _Module.GetResourceInstance() , IDS_RENAME_WRN_PL , tchWrnBuf , SIZE_OF_BUFFER( tchWrnBuf ) );
  931. }
  932. wsprintf( tchOutput , tchWrnBuf , pNode->GetConName( ) );
  933. LoadString( _Module.GetResourceInstance( ) , IDS_WARN_TITLE , tchWrnBuf , SIZE_OF_BUFFER( tchWrnBuf ) );
  934. if( MessageBox( hDlg , tchOutput , tchWrnBuf , MB_ICONWARNING | MB_YESNO ) == IDNO )
  935. {
  936. break;
  937. }
  938. }
  939. if( FAILED( hr = pCfgcomp->RenameWinstation( ( PWINSTATIONNAMEW )pNode->GetConName( ) , ( PWINSTATIONNAMEW )tchNewName ) ) )
  940. {
  941. ODS( L"TSCC: RenameWinstation failed\n" );
  942. if( hr == E_ACCESSDENIED )
  943. {
  944. TscAccessDeniedMsg( hDlg );
  945. }
  946. else
  947. {
  948. TscGeneralErrMsg( hDlg );
  949. }
  950. break;
  951. }
  952. /*
  953. LONG lCount;
  954. TCHAR tchWrnBuf[ 256 ];
  955. TCHAR tchOutput[ 512 ];
  956. // check to see if anyone is connected
  957. pCfgcomp->QueryLoggedOnCount( pNode->GetConName( ) , &lCount );
  958. if( lCount > 0 )
  959. {
  960. if( lCount == 1 )
  961. {
  962. LoadString( _Module.GetResourceInstance() , IDS_RENAME_WRN_SINGLE , tchWrnBuf , SIZE_OF_BUFFER( tchWrnBuf ) );
  963. }
  964. else
  965. {
  966. LoadString( _Module.GetResourceInstance() , IDS_RENAME_WRN_PL , tchWrnBuf , SIZE_OF_BUFFER( tchWrnBuf ) );
  967. }
  968. wsprintf( tchOutput , tchWrnBuf , pNode->GetConName( ) );
  969. LoadString( _Module.GetResourceInstance( ) , IDS_WARN_TITLE , tchWrnBuf , SIZE_OF_BUFFER( tchWrnBuf ) );
  970. MessageBox( hDlg , tchOutput , tchWrnBuf , MB_OK | MB_ICONWARNING );
  971. }
  972. */
  973. WS *pWs;
  974. LONG lSz;
  975. if( SUCCEEDED( pCfgcomp->GetWSInfo(tchNewName , &lSz , &pWs ) ) )
  976. {
  977. if(pWs->fEnableWinstation && pWs->PdClass == SdAsync)
  978. {
  979. ASYNCCONFIGW AsyncConfig;
  980. HRESULT hResult = pCfgcomp->GetAsyncConfig( pWs->Name , WsName , &AsyncConfig );
  981. if( SUCCEEDED( hResult ) )
  982. {
  983. if( AsyncConfig.ModemName[0] )
  984. {
  985. LoadString( _Module.GetResourceInstance( ) , IDS_REBOOT_REQD , tchOutput , SIZE_OF_BUFFER( tchOutput ) );
  986. LoadString( _Module.GetResourceInstance( ) , IDS_WARN_TITLE , tchWrnBuf , SIZE_OF_BUFFER( tchWrnBuf ) );
  987. MessageBox( hDlg , tchOutput , tchWrnBuf , MB_ICONWARNING | MB_OK );
  988. }
  989. }
  990. }
  991. CoTaskMemFree( pWs );
  992. }
  993. pNode->SetConName( tchNewName , SIZE_OF_BUFFER( tchNewName ) );
  994. }while( 0 );
  995. pCfgcomp->Release( );
  996. EndDialog( hDlg , 0 );
  997. }
  998. else if( LOWORD( wp ) == IDCANCEL )
  999. {
  1000. EndDialog( hDlg , 0 );
  1001. }
  1002. break;
  1003. }
  1004. return 0;
  1005. }
  1006. //--------------------------------------------------------------------------
  1007. BOOL IsValidConnectionName( LPTSTR szConName , PDWORD pdwErr )
  1008. {
  1009. TCHAR tchInvalidChars[ 80 ];
  1010. tchInvalidChars[0] = 0;
  1011. if( szConName == NULL || pdwErr == NULL )
  1012. {
  1013. return FALSE;
  1014. }
  1015. if( _istdigit( szConName[ 0 ] ) )
  1016. {
  1017. *pdwErr = ERROR_INVALID_FIRSTCHARACTER;
  1018. return FALSE;
  1019. }
  1020. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance() , IDS_INVALID_CHARS , tchInvalidChars , SIZE_OF_BUFFER( tchInvalidChars ) ) );
  1021. int nLen = lstrlen( tchInvalidChars );
  1022. while( *szConName )
  1023. {
  1024. for( int idx = 0 ; idx < nLen ; idx++ )
  1025. {
  1026. if( *szConName == tchInvalidChars[ idx ] )
  1027. {
  1028. *pdwErr = ERROR_ILLEGAL_CHARACTER;
  1029. return FALSE;
  1030. }
  1031. }
  1032. szConName++;
  1033. }
  1034. *pdwErr = ERROR_SUCCESS;
  1035. return TRUE;
  1036. }
  1037. //----------------------------------------------------------------------
  1038. BOOL CComp::OnHelp( LPDATAOBJECT pDo )
  1039. {
  1040. TCHAR tchTopic[ 80 ];
  1041. HRESULT hr = E_FAIL;
  1042. if( pDo == NULL || m_pDisplayHelp == NULL )
  1043. {
  1044. return hr;
  1045. }
  1046. INT_PTR nNodeType = ( ( CBaseNode * )pDo )->GetNodeType();
  1047. if( nNodeType == RESULT_NODE || nNodeType == MAIN_NODE || nNodeType == 0 )
  1048. {
  1049. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance() , IDS_TSCCHELPTOPIC , tchTopic , SIZE_OF_BUFFER( tchTopic ) ) );
  1050. hr = m_pDisplayHelp->ShowTopic( tchTopic );
  1051. }
  1052. else if( nNodeType == SETTINGS_NODE || nNodeType == RSETTINGS_NODE )
  1053. {
  1054. if( nNodeType == SETTINGS_NODE )
  1055. {
  1056. IExtendServerSettings *pEss = NULL;
  1057. INT iRet = -1;
  1058. CSettingNode *pNode = dynamic_cast< CSettingNode *>( pDo );
  1059. if( pNode != NULL )
  1060. {
  1061. if( pNode->GetObjectId( ) >= CUSTOM_EXTENSION )
  1062. {
  1063. pEss = reinterpret_cast< IExtendServerSettings * >( pNode->GetInterface( ) );
  1064. if( pEss != NULL )
  1065. {
  1066. pEss->OnHelp( &iRet );
  1067. if( iRet == 0 )
  1068. {
  1069. return TRUE;
  1070. }
  1071. }
  1072. }
  1073. }
  1074. }
  1075. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance() , IDS_SETTINGSHELP , tchTopic , SIZE_OF_BUFFER( tchTopic ) ) );
  1076. hr = m_pDisplayHelp->ShowTopic( tchTopic );
  1077. }
  1078. return ( SUCCEEDED( hr ) ? TRUE : FALSE );
  1079. }
  1080. //----------------------------------------------------------------------
  1081. BOOL CComp::OnDblClk( LPDATAOBJECT pDo )
  1082. {
  1083. CSettingNode *pNode = dynamic_cast< CSettingNode *>( pDo );
  1084. if( pNode == NULL )
  1085. {
  1086. // we're only concerned about Setting nodes
  1087. return FALSE;
  1088. }
  1089. HWND hMain;
  1090. if( FAILED( m_pConsole->GetMainWindow( &hMain ) ) )
  1091. {
  1092. hMain = NULL;
  1093. }
  1094. INT nObjectId = pNode->GetObjectId( );
  1095. switch( nObjectId )
  1096. {
  1097. /*
  1098. case 0:
  1099. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_CACHED_SESSIONS ) , hMain , CachedSessionsDlgProc , ( LPARAM )pNode );
  1100. break;*/
  1101. case DELETED_DIRS_ONEXIT:
  1102. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_YESNODIALOG ) , hMain , DeleteTempDirsDlgProc , ( LPARAM )pNode );
  1103. break;
  1104. case PERSESSION_TEMPDIR:
  1105. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_DIALOG_PERSESSION ) , hMain , UsePerSessionTempDirsDlgProc , ( LPARAM )pNode );
  1106. break;
  1107. /*
  1108. case DEF_CONSECURITY:
  1109. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_DEFCONSEC ) , hMain , DefConSecurityDlgProc , ( LPARAM )pNode );
  1110. break;
  1111. */
  1112. case LICENSING:
  1113. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_LICENSING ) , hMain , LicensingDlgProc , ( LPARAM )pNode );
  1114. break;
  1115. case ACTIVE_DESK:
  1116. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_ADP_DIALOG ) , hMain , ConfigActiveDesktop , ( LPARAM )pNode );
  1117. break;
  1118. case USERSECURITY:
  1119. // error if we're trying to modify property in remote admin mode
  1120. if( !g_bAppSrvMode )
  1121. {
  1122. xxxErrMessage( hMain , IDS_REMOTEADMIN_ONLY , IDS_WARN_TITLE , MB_OK | MB_ICONINFORMATION );
  1123. break;
  1124. }
  1125. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_PROPPAGE_TERMINAL_SERVER_PERM ) , hMain , UserPermCompat , ( LPARAM )pNode );
  1126. break;
  1127. case SINGLE_SESSION:
  1128. // error if we're trying to modify property in remote admin mode
  1129. if( !g_bAppSrvMode )
  1130. {
  1131. xxxErrMessage( hMain , IDS_REMOTEADMIN_ONLY , IDS_WARN_TITLE , MB_OK | MB_ICONINFORMATION );
  1132. break;
  1133. }
  1134. ::DialogBoxParam( _Module.GetModuleInstance( ) , MAKEINTRESOURCE( IDD_SINGLE_SESSION) , hMain , ConfigSingleSession , ( LPARAM )pNode );
  1135. break;
  1136. default:
  1137. if( nObjectId >= CUSTOM_EXTENSION )
  1138. {
  1139. IExtendServerSettings *pEss = reinterpret_cast< IExtendServerSettings * >( pNode->GetInterface() );
  1140. if( pEss != NULL )
  1141. {
  1142. DWORD dwStatus;
  1143. pEss->InvokeUI( hMain , &dwStatus );
  1144. if( dwStatus == UPDATE_TERMSRV || dwStatus == UPDATE_TERMSRV_SESSDIR )
  1145. {
  1146. ICfgComp *pCfgcomp = NULL;
  1147. m_pCompdata->GetServer( &pCfgcomp );
  1148. if( pCfgcomp != NULL )
  1149. {
  1150. ODS( L"TSCC!Comp OnDblClk forcing termsrv update\n" );
  1151. if( dwStatus == UPDATE_TERMSRV_SESSDIR )
  1152. {
  1153. HCURSOR hCursor = SetCursor( LoadCursor( NULL ,
  1154. MAKEINTRESOURCE( IDC_WAIT ) ) );
  1155. if( FAILED( pCfgcomp->UpdateSessionDirectory( &dwStatus ) ) )
  1156. {
  1157. ReportStatusError( hMain , dwStatus );
  1158. }
  1159. SetCursor(hCursor);
  1160. }
  1161. else
  1162. {
  1163. pCfgcomp->ForceUpdate( );
  1164. }
  1165. pCfgcomp->Release();
  1166. }
  1167. }
  1168. }
  1169. }
  1170. }
  1171. return TRUE;
  1172. }
  1173. /*
  1174. //----------------------------------------------------------------------
  1175. HRESULT CComp::SetColumnWidth( int nCol )
  1176. {
  1177. HWND hMain;
  1178. int nCurColLen;
  1179. CResultNode *pNode;
  1180. do
  1181. {
  1182. if( FAILED( m_pHeaderCtrl->GetColumnWidth( nCol , &nCurColLen ) ) )
  1183. {
  1184. break;
  1185. }
  1186. if( FAILED( m_pConsole->GetMainWindow( &hMain ) ) )
  1187. {
  1188. break;
  1189. }
  1190. HDC hdc = GetDC( hMain );
  1191. SIZE sz;
  1192. int idx = 0;
  1193. TCHAR *psz;
  1194. while( ( pNode = *m_pCompdata->GetResultNode( idx ) ) != NULL )
  1195. {
  1196. switch( nCol )
  1197. {
  1198. case 0:
  1199. psz = pNode->GetConName( );
  1200. break;
  1201. case 1:
  1202. psz = pNode->GetTTName( );
  1203. break;
  1204. case 2:
  1205. psz = pNode->GetTypeName( );
  1206. break;
  1207. // comment is too big allow user to adjust size
  1208. }
  1209. GetTextExtentPoint32( hdc , psz , lstrlen( psz ) , &sz );
  1210. if( sz.cx > nCurColLen )
  1211. {
  1212. nCurColLen = sz.cx;
  1213. }
  1214. idx++;
  1215. }
  1216. m_pHeaderCtrl->SetColumnWidth( nCol , nCurColLen );
  1217. ReleaseDC( hMain , hdc );
  1218. } while( 0 );
  1219. return S_OK;
  1220. }
  1221. */
  1222. //----------------------------------------------------------------------
  1223. HRESULT CComp::SetColumnsForSettingsPane( )
  1224. {
  1225. HWND hParent;
  1226. SIZE sz = { 0 , 0 };
  1227. TCHAR tchBuffer[ 256 ];
  1228. INT nMaxLen;
  1229. if( FAILED( m_pConsole->GetMainWindow( &hParent ) ) )
  1230. {
  1231. hParent = NULL;
  1232. }
  1233. HDC hdc = GetDC( hParent );
  1234. if( hdc != NULL )
  1235. {
  1236. m_pCompdata->GetMaxTextLengthSetting( tchBuffer , &nMaxLen );
  1237. VERIFY_S( TRUE , GetTextExtentPoint32( hdc , tchBuffer , nMaxLen , &sz ) );
  1238. m_nSettingCol = sz.cx - 16 ; // remove icon width from column width
  1239. m_pCompdata->GetMaxTextLengthAttribute( tchBuffer , &nMaxLen );
  1240. VERIFY_S( TRUE , GetTextExtentPoint32( hdc , tchBuffer , nMaxLen , &sz ) );
  1241. m_nAttribCol = sz.cx;
  1242. ReleaseDC( hParent , hdc );
  1243. }
  1244. return S_OK;
  1245. }