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.

929 lines
25 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include"stdafx.h"
  3. #include"snodes.h"
  4. #include"resource.h"
  5. #define ERROR_USERDEFINED_LICENSE_VIOLATION ( ( DWORD )0xC000026AL )
  6. extern void xxxErrMessage( HWND hwnd , INT_PTR nResMessageId , INT_PTR nResTitleId , UINT nFlags );
  7. extern void TscAccessDeniedMsg( HWND hwnd );
  8. extern void TscGeneralErrMsg( HWND hwnd );
  9. extern void ReportStatusError( HWND hwnd , DWORD dwStatus );
  10. void SnodeErrorHandler( HWND hParent , INT nObjectId , DWORD dwStatus );
  11. //----------------------------------------------------------
  12. CSettingNode::CSettingNode( )
  13. {
  14. m_szAttributeName = NULL;
  15. m_szAttributeValue = NULL;
  16. SetNodeType( RSETTINGS_NODE );
  17. m_objectid = -1;
  18. m_pSettings = NULL;
  19. m_hrStatus = S_OK;
  20. }
  21. //----------------------------------------------------------
  22. void CSettingNode::SetObjectId( INT id )
  23. {
  24. m_objectid = id;
  25. }
  26. //----------------------------------------------------------
  27. HRESULT CSettingNode::SetAttributeValue( DWORD nVal , PDWORD pdwStatus )
  28. {
  29. HRESULT hr = S_OK;
  30. ISettingsComp *pSettings = NULL;
  31. INT nObjectId = GetObjectId( );
  32. if( nObjectId < CUSTOM_EXTENSION )
  33. {
  34. pSettings = reinterpret_cast< ISettingsComp *>( m_pSettings );
  35. if( pSettings == NULL )
  36. {
  37. ODS( L"CSettingNode::SetAttributeValue downcasting failure\n" );
  38. return E_FAIL;
  39. }
  40. }
  41. if( nObjectId == LICENSING )
  42. {
  43. DWORD dwNewStatus;
  44. hr = pSettings->SetLicensingMode( nVal , pdwStatus, &dwNewStatus );
  45. if( SUCCEEDED( hr ) )
  46. {
  47. xx_SetValue( nVal );
  48. }
  49. else
  50. {
  51. if ((NULL != pdwStatus) && (ERROR_SUCCESS == *pdwStatus))
  52. {
  53. // make sure any failure gets returned to caller
  54. *pdwStatus = dwNewStatus;
  55. }
  56. }
  57. }
  58. else
  59. {
  60. if( nObjectId == DELETED_DIRS_ONEXIT ) // Delete temp dirs on exit
  61. {
  62. hr = pSettings->SetDelDirsOnExit( ( BOOL )nVal );
  63. }
  64. else if( nObjectId == PERSESSION_TEMPDIR )// User temp dirs per session
  65. {
  66. hr = pSettings->SetUseTempDirPerSession( ( BOOL )nVal );
  67. }
  68. /* else if( nObjectId == DEF_CONSECURITY ) // default security descriptor
  69. {
  70. hr = m_pSettings->SetDefaultSecurity( nVal );
  71. }*/
  72. else if( nObjectId == ACTIVE_DESK )
  73. {
  74. hr = pSettings->SetActiveDesktopState( nVal , pdwStatus );
  75. }
  76. else if( nObjectId == USERSECURITY )
  77. {
  78. hr = pSettings->SetUserPerm( nVal , pdwStatus );
  79. if( FAILED( hr ) )
  80. {
  81. return hr;
  82. }
  83. }
  84. else if( nObjectId == SINGLE_SESSION )
  85. {
  86. hr = pSettings->SetSingleSessionState( nVal , pdwStatus );
  87. }
  88. if( FAILED( hr ) )
  89. {
  90. if( hr == E_ACCESSDENIED )
  91. {
  92. *pdwStatus = ERROR_ACCESS_DENIED;
  93. }
  94. else
  95. {
  96. *pdwStatus = ( DWORD )hr; // general failure
  97. }
  98. }
  99. else
  100. {
  101. xx_SetValue( nVal );
  102. }
  103. }
  104. return hr;
  105. }
  106. //----------------------------------------------------------
  107. BOOL CSettingNode::SetAttributeName( LPTSTR psz )
  108. {
  109. if( psz != NULL )
  110. {
  111. int cchText = lstrlen( psz ) + 1;
  112. if( m_szAttributeName != NULL )
  113. {
  114. delete[] m_szAttributeName;
  115. }
  116. m_szAttributeName = ( LPTSTR )new TCHAR[ cchText ];
  117. if( m_szAttributeName != NULL )
  118. {
  119. lstrcpy( m_szAttributeName , psz );
  120. }
  121. return TRUE;
  122. }
  123. return FALSE;
  124. }
  125. //----------------------------------------------------------
  126. LPTSTR CSettingNode::GetAttributeValue( )
  127. {
  128. DWORD nVal = 0;
  129. DWORD dwStatus;
  130. ISettingsComp *pSettings = NULL;
  131. HRESULT hr = S_OK;
  132. INT nObjectId = GetObjectId( );
  133. if( nObjectId < CUSTOM_EXTENSION )
  134. {
  135. pSettings = reinterpret_cast< ISettingsComp *>( m_pSettings );
  136. if( pSettings == NULL )
  137. {
  138. hr = E_FAIL;
  139. }
  140. ODS( L"Getting attribute value\n" );
  141. }
  142. if( SUCCEEDED( hr ) )
  143. {
  144. POLICY_TS_MACHINE p;
  145. RegGetMachinePolicy(&p);
  146. switch( nObjectId )
  147. {
  148. case DELETED_DIRS_ONEXIT: // Delete temp dirs on exit
  149. hr = pSettings->GetDelDirsOnExit( ( PBOOL )&nVal );
  150. if (p.fPolicyDeleteTempFoldersOnExit)
  151. nVal = p.fDeleteTempFoldersOnExit;
  152. break;
  153. case PERSESSION_TEMPDIR:// User temp dirs per session
  154. hr = pSettings->GetUseTempDirPerSession( ( PBOOL )&nVal );
  155. if (p.fPolicyTempFoldersPerSession)
  156. nVal = p.fTempFoldersPerSession;
  157. break;
  158. /* case DEF_CONSECURITY: // default security descriptor
  159. hr = m_pSettings->GetDefaultSecurity( &nVal );
  160. break;
  161. */
  162. case LICENSING: // licensing mode
  163. hr = pSettings->GetLicensingMode( &nVal , &dwStatus );
  164. break;
  165. case ACTIVE_DESK:
  166. hr = pSettings->GetActiveDesktopState( ( PBOOL )&nVal , &dwStatus );
  167. break;
  168. case USERSECURITY:
  169. hr = pSettings->GetUserPerm( ( PBOOL )&nVal , &dwStatus );
  170. break;
  171. case SINGLE_SESSION:
  172. hr = pSettings->GetSingleSessionState( ( PBOOL )&nVal , &dwStatus );
  173. if (p.fPolicySingleSessionPerUser)
  174. nVal = p.fSingleSessionPerUser;
  175. break;
  176. default:
  177. if( nObjectId >= CUSTOM_EXTENSION )
  178. {
  179. ODS( L"Getting attribute value\n" );
  180. nVal = 0; // we don't care we leave it up to the provider
  181. hr = S_OK;
  182. }
  183. }
  184. }
  185. if( FAILED( hr ) )
  186. {
  187. TCHAR szBuffer[ 80 ];
  188. szBuffer[0] = 0;
  189. if( m_szAttributeValue != NULL )
  190. {
  191. delete[] m_szAttributeValue;
  192. }
  193. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_SSERROR , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  194. m_szAttributeValue = ( LPTSTR )new TCHAR[ lstrlen( szBuffer ) + 1 ];
  195. if( m_szAttributeValue != NULL )
  196. {
  197. lstrcpy( m_szAttributeValue , szBuffer );
  198. }
  199. if( nObjectId != LICENSING )
  200. {
  201. xx_SetValue( 0 );
  202. }
  203. }
  204. else
  205. {
  206. xx_SetValue( nVal );
  207. }
  208. m_hrStatus = hr;
  209. return m_szAttributeValue;
  210. }
  211. //----------------------------------------------------------
  212. DWORD CSettingNode::GetImageIdx( )
  213. {
  214. return ( DWORD )3;
  215. }
  216. //----------------------------------------------------------
  217. BOOL CSettingNode::AddMenuItems( LPCONTEXTMENUCALLBACK pcmc , PLONG pl )
  218. {
  219. HRESULT hr = E_FAIL;
  220. TCHAR tchName[ 80 ];
  221. TCHAR tchStatus[ 256 ];
  222. CONTEXTMENUITEM cmi;
  223. BOOL bVal = FALSE;
  224. INT nObjectId = GetObjectId( );
  225. POLICY_TS_MACHINE p;
  226. RegGetMachinePolicy(&p);
  227. switch( nObjectId )
  228. {
  229. case DELETED_DIRS_ONEXIT:
  230. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  231. cmi.strName = tchName;
  232. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  233. cmi.strStatusBarText = tchStatus;
  234. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  235. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  236. cmi.fFlags = cmi.fSpecialFlags = 0;
  237. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  238. hr = pcmc->AddItem( &cmi );
  239. if( SUCCEEDED( hr ) )
  240. {
  241. bVal = ( BOOL )xx_GetValue( );
  242. if( bVal )
  243. {
  244. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  245. cmi.strName = tchName;
  246. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOTDELTEMP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  247. cmi.strStatusBarText = tchStatus;
  248. }
  249. else
  250. {
  251. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YESMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  252. cmi.strName = tchName;
  253. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DELTEMP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  254. cmi.strStatusBarText = tchStatus;
  255. }
  256. if (p.fPolicyDeleteTempFoldersOnExit)
  257. {
  258. //Clear the last 2 bits since MF_GRAYED is
  259. //incompatible with MF_DISABLED
  260. cmi.fFlags &= 0xFFFFFFFCL;
  261. cmi.fFlags |= MF_GRAYED;
  262. }
  263. cmi.lCommandID = IDM_SETTINGS_DELTEMPDIRSONEXIT;
  264. hr = pcmc->AddItem( &cmi );
  265. }
  266. break;
  267. case PERSESSION_TEMPDIR:
  268. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  269. cmi.strName = tchName;
  270. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  271. cmi.strStatusBarText = tchStatus;
  272. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  273. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  274. cmi.fFlags = cmi.fSpecialFlags = 0;
  275. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  276. hr = pcmc->AddItem( &cmi );
  277. if( SUCCEEDED( hr ) )
  278. {
  279. bVal = ( BOOL )xx_GetValue( );
  280. if( bVal )
  281. {
  282. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  283. cmi.strName = tchName;
  284. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOTUSEPERSESSION_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  285. cmi.strStatusBarText = tchStatus;
  286. }
  287. else
  288. {
  289. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YESMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  290. cmi.strName = tchName;
  291. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_USEPERSESSION_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  292. cmi.strStatusBarText = tchStatus;
  293. }
  294. if (p.fPolicyTempFoldersPerSession)
  295. {
  296. //Clear the last 2 bits since MF_GRAYED is
  297. //incompatible with MF_DISABLED
  298. cmi.fFlags &= 0xFFFFFFFCL;
  299. cmi.fFlags |= MF_GRAYED;
  300. }
  301. cmi.lCommandID = IDM_SETTINGS_USETMPDIR;
  302. hr = pcmc->AddItem( &cmi );
  303. }
  304. break;
  305. /* case DEF_CONSECURITY:
  306. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  307. cmi.strName = tchName;
  308. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  309. cmi.strStatusBarText = tchStatus;
  310. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  311. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  312. cmi.fFlags = cmi.fSpecialFlags = 0;
  313. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  314. hr = pcmc->AddItem( &cmi );
  315. break;
  316. */
  317. case LICENSING:
  318. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  319. cmi.strName = tchName;
  320. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  321. cmi.strStatusBarText = tchStatus;
  322. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  323. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  324. cmi.fFlags = cmi.fSpecialFlags = 0;
  325. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  326. hr = pcmc->AddItem( &cmi );
  327. break;
  328. case ACTIVE_DESK:
  329. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  330. cmi.strName = tchName;
  331. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ACTIVEDESK_PROP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  332. cmi.strStatusBarText = tchStatus;
  333. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  334. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  335. cmi.fFlags = cmi.fSpecialFlags = 0;
  336. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  337. hr = pcmc->AddItem( &cmi );
  338. if( SUCCEEDED( hr ) )
  339. {
  340. bVal = ( BOOL )xx_GetValue( );
  341. if( bVal )
  342. {
  343. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLEMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  344. cmi.strName = tchName;
  345. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLE_ADP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  346. cmi.strStatusBarText = tchStatus;
  347. }
  348. else
  349. {
  350. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLEMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  351. cmi.strName = tchName;
  352. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLE_ADP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  353. cmi.strStatusBarText = tchStatus;
  354. }
  355. cmi.lCommandID = IDM_SETTINGS_ADP;
  356. hr = pcmc->AddItem( &cmi );
  357. }
  358. break;
  359. case SINGLE_SESSION:
  360. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  361. cmi.strName = tchName;
  362. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  363. cmi.strStatusBarText = tchStatus;
  364. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  365. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  366. cmi.fFlags = cmi.fSpecialFlags = 0;
  367. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  368. hr = pcmc->AddItem( &cmi );
  369. if( SUCCEEDED( hr ) )
  370. {
  371. bVal = ( BOOL )xx_GetValue( );
  372. if( bVal )
  373. {
  374. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  375. cmi.strName = tchName;
  376. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLE_SINGLESESSION_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  377. cmi.strStatusBarText = tchStatus;
  378. }
  379. else
  380. {
  381. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YESMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  382. cmi.strName = tchName;
  383. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLE_SINGLESESSION_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  384. cmi.strStatusBarText = tchStatus;
  385. }
  386. if (p.fPolicySingleSessionPerUser)
  387. {
  388. //Clear the last 2 bits since MF_GRAYED is
  389. //incompatible with MF_DISABLED
  390. cmi.fFlags &= 0xFFFFFFFCL;
  391. cmi.fFlags |= MF_GRAYED;
  392. }
  393. cmi.lCommandID = IDM_SETTINGS_SS;
  394. hr = pcmc->AddItem( &cmi );
  395. }
  396. break;
  397. case USERSECURITY:
  398. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  399. cmi.strName = tchName;
  400. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  401. cmi.strStatusBarText = tchStatus;
  402. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  403. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  404. cmi.fFlags = cmi.fSpecialFlags = 0;
  405. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  406. hr = pcmc->AddItem( &cmi );
  407. break;
  408. default:
  409. if( nObjectId >= CUSTOM_EXTENSION )
  410. {
  411. IExtendServerSettings *pSetting = reinterpret_cast< IExtendServerSettings * >( m_pSettings );
  412. if( pSetting != NULL )
  413. {
  414. PMENUEXTENSION pMex = NULL;
  415. INT cbItems = 0;
  416. if( SUCCEEDED( pSetting->GetMenuItems( &cbItems , &pMex ) ) )
  417. {
  418. for( INT i = 0 ; i < cbItems; i++ )
  419. {
  420. cmi.strName = pMex[ i ].MenuItemName;
  421. cmi.strStatusBarText = pMex[ i ].StatusBarText;
  422. cmi.lCommandID = pMex[ i ].cmd;
  423. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  424. cmi.fFlags = cmi.fSpecialFlags = 0;
  425. *pl |= CCM_INSERTIONALLOWED_TOP;
  426. if (p.fPolicySessionDirectoryActive)
  427. {
  428. //Gray out everything but properties
  429. if (cmi.lCommandID != IDM_MENU_PROPS)
  430. {
  431. //Clear the last 2 bits since MF_GRAYED is
  432. //incompatible with MF_DISABLED
  433. cmi.fFlags &= 0xFFFFFFFCL;
  434. cmi.fFlags |= MF_GRAYED;
  435. }
  436. }
  437. pcmc->AddItem( &cmi );
  438. }
  439. hr = S_OK;
  440. LocalFree( pMex );
  441. }
  442. }
  443. }
  444. }
  445. return ( SUCCEEDED( hr ) ? TRUE : FALSE );
  446. }
  447. //----------------------------------------------------------
  448. BOOL CSettingNode::SetInterface( LPUNKNOWN pInf )
  449. {
  450. pInf->AddRef( );
  451. m_pSettings = pInf;
  452. return TRUE;
  453. }
  454. //----------------------------------------------------------
  455. CSettingNode::~CSettingNode( )
  456. {
  457. DBGMSG( L"CSettingNode dtor called for objectid %d\n" , m_objectid );
  458. if( m_szAttributeName != NULL )
  459. {
  460. delete[] m_szAttributeName;
  461. }
  462. if( m_szAttributeValue != NULL )
  463. {
  464. delete[] m_szAttributeValue;
  465. }
  466. if( m_pSettings != NULL )
  467. {
  468. m_pSettings->Release( );
  469. }
  470. }
  471. //---------------------------------------------------------
  472. // Helper functions
  473. //---------------------------------------------------------
  474. BOOL CSettingNode::xx_SetValue( INT nVal )
  475. {
  476. TCHAR szBuffer[ 1024 ];
  477. szBuffer[0] = 0;
  478. INT nObjectId = GetObjectId( );
  479. if( m_szAttributeValue != NULL )
  480. {
  481. delete[] m_szAttributeValue;
  482. }
  483. switch( nObjectId )
  484. {
  485. case SINGLE_SESSION:
  486. if( ( BOOL )nVal )
  487. {
  488. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YES , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  489. }
  490. else
  491. {
  492. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NO , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  493. }
  494. break;
  495. case DELETED_DIRS_ONEXIT: // Delete temp dirs on exit
  496. if( ( BOOL )nVal )
  497. {
  498. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YES , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  499. }
  500. else
  501. {
  502. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NO , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  503. }
  504. break;
  505. case PERSESSION_TEMPDIR:// User temp dirs per session
  506. if( ( BOOL )nVal )
  507. {
  508. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YES , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  509. }
  510. else
  511. {
  512. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NO , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  513. }
  514. break;
  515. /*
  516. case DEF_CONSECURITY: // default security descriptor
  517. switch( nVal )
  518. {
  519. case 0: // this shoudl never happen
  520. case 1:
  521. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_RAA , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  522. break;
  523. case 2:
  524. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_AS , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  525. break;
  526. case 3:
  527. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_AA , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  528. break;
  529. }
  530. break;
  531. */
  532. case LICENSING: // licensing mode
  533. {
  534. ISettingsComp *pSettings = reinterpret_cast< ISettingsComp * > (m_pSettings);
  535. if (NULL != pSettings)
  536. {
  537. WCHAR *wszName, *wszDescription;
  538. DWORD dwStatus;
  539. HRESULT hr;
  540. hr = pSettings->GetLicensingModeInfo(
  541. nVal,
  542. &wszName,
  543. &wszDescription,
  544. &dwStatus);
  545. if (SUCCEEDED(hr))
  546. {
  547. _ASSERTE( ERROR_SUCCESS == dwStatus );
  548. lstrcpyn(szBuffer,wszName,sizeof(szBuffer)/sizeof(TCHAR));
  549. CoTaskMemFree(wszName);
  550. CoTaskMemFree(wszDescription);
  551. }
  552. }
  553. }
  554. break;
  555. case ACTIVE_DESK:
  556. if( ( BOOL )nVal )
  557. {
  558. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLED , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  559. }
  560. else
  561. {
  562. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLED , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  563. }
  564. break;
  565. case USERSECURITY:
  566. if( ( BOOL )nVal )
  567. {
  568. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_USERPERM_NT4 , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  569. }
  570. else
  571. {
  572. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_USERPERM_W2K , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  573. }
  574. break;
  575. default:
  576. if( nObjectId >= CUSTOM_EXTENSION )
  577. {
  578. IExtendServerSettings *pSettings = reinterpret_cast< IExtendServerSettings *>( m_pSettings );
  579. if( pSettings != NULL )
  580. {
  581. pSettings->GetDisplayableValueName( szBuffer );
  582. DBGMSG( L"xx_SetValue for Extension returned %s\n" , szBuffer );
  583. }
  584. }
  585. } // switch
  586. m_szAttributeValue = ( LPTSTR )new TCHAR[ lstrlen( szBuffer ) + 1 ];
  587. if( m_szAttributeValue != NULL )
  588. {
  589. lstrcpy( m_szAttributeValue , szBuffer );
  590. }
  591. m_nGenericValue = nVal;
  592. return TRUE;
  593. }
  594. //----------------------------------------------------------------------
  595. // And all out central server setting error handler
  596. // this is setup in this manner to allow MMC to own the Msgbx as well
  597. // as the custom dialog pages
  598. //
  599. void SnodeErrorHandler( HWND hParent , INT nObjectId , DWORD dwStatus )
  600. {
  601. switch( nObjectId )
  602. {
  603. case DELETED_DIRS_ONEXIT: // Delete temp dirs on exit
  604. case PERSESSION_TEMPDIR:// User temp dirs per session
  605. case SINGLE_SESSION: // Restrict to single session per user
  606. // case DEF_CONSECURITY: // default security descriptor
  607. case LICENSING: // licensing mode
  608. case ACTIVE_DESK:
  609. if( dwStatus == ERROR_ACCESS_DENIED )
  610. {
  611. TscAccessDeniedMsg( hParent );
  612. }
  613. else
  614. {
  615. TscGeneralErrMsg( hParent );
  616. }
  617. break;
  618. case USERSECURITY:
  619. if( dwStatus != 0 )
  620. {
  621. ReportStatusError( hParent , dwStatus );
  622. }
  623. } // switch
  624. }