Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2605 lines
77 KiB

  1. //
  2. // tscsetting.cpp
  3. //
  4. // Terminal Services Client settings collection
  5. //
  6. // Copyright(C) Microsoft Corporation 2000
  7. // Author: Nadim Abdo (nadima)
  8. //
  9. #include "stdafx.h"
  10. #define TRC_GROUP TRC_GROUP_UI
  11. #define TRC_FILE "tscsetting.cpp"
  12. #include <atrcapi.h>
  13. #include "tscsetting.h"
  14. #include "autreg.h"
  15. #include "autil.h"
  16. #include "wuiids.h"
  17. #include "sh.h"
  18. #ifdef OS_WINCE
  19. //TEMP HACK for CE
  20. BOOL UTREG_UI_DEDICATED_TERMINAL_DFLT = FALSE;
  21. #endif
  22. LPCTSTR tscScreenResStringTable[UI_NUMBER_DESKTOP_SIZE_IDS] = { _T("640x480"),
  23. _T("800x600"),
  24. _T("1024x768"),
  25. _T("1280x1024"),
  26. _T("1600x1200")
  27. };
  28. UINT tscScreenResTable[UI_NUMBER_DESKTOP_SIZE_IDS][2] = { {640, 480},
  29. {800, 600},
  30. {1024, 768},
  31. {1280, 1024},
  32. {1600, 1200}
  33. };
  34. const unsigned ProportionDefault[TS_BITMAPCACHE_MAX_CELL_CACHES] =
  35. {
  36. UTREG_UH_BM_CACHE1_PROPORTION_DFLT,
  37. UTREG_UH_BM_CACHE2_PROPORTION_DFLT,
  38. UTREG_UH_BM_CACHE3_PROPORTION_DFLT,
  39. UTREG_UH_BM_CACHE4_PROPORTION_DFLT,
  40. UTREG_UH_BM_CACHE5_PROPORTION_DFLT,
  41. };
  42. #if ((!defined(OS_WINCE)) || (defined(ENABLE_BMP_CACHING_FOR_WINCE)))
  43. const unsigned PersistenceDefault[TS_BITMAPCACHE_MAX_CELL_CACHES] =
  44. {
  45. UTREG_UH_BM_CACHE1_PERSISTENCE_DFLT,
  46. UTREG_UH_BM_CACHE2_PERSISTENCE_DFLT,
  47. UTREG_UH_BM_CACHE3_PERSISTENCE_DFLT,
  48. UTREG_UH_BM_CACHE4_PERSISTENCE_DFLT,
  49. UTREG_UH_BM_CACHE5_PERSISTENCE_DFLT,
  50. };
  51. #endif // ((!defined(OS_WINCE)) || (defined(ENABLE_BMP_CACHING_FOR_WINCE)))
  52. const unsigned MaxEntriesDefault[TS_BITMAPCACHE_MAX_CELL_CACHES] =
  53. {
  54. UTREG_UH_BM_CACHE1_MAXENTRIES_DFLT,
  55. UTREG_UH_BM_CACHE2_MAXENTRIES_DFLT,
  56. UTREG_UH_BM_CACHE3_MAXENTRIES_DFLT,
  57. UTREG_UH_BM_CACHE4_MAXENTRIES_DFLT,
  58. UTREG_UH_BM_CACHE5_MAXENTRIES_DFLT,
  59. };
  60. #define NUM_MRU_ENTRIES 10
  61. LPCTSTR mruEntriesNames[NUM_MRU_ENTRIES] = {
  62. UTREG_UI_SERVER_MRU0, UTREG_UI_SERVER_MRU1, UTREG_UI_SERVER_MRU2,
  63. UTREG_UI_SERVER_MRU3, UTREG_UI_SERVER_MRU4, UTREG_UI_SERVER_MRU5,
  64. UTREG_UI_SERVER_MRU6, UTREG_UI_SERVER_MRU7, UTREG_UI_SERVER_MRU8,
  65. UTREG_UI_SERVER_MRU9
  66. };
  67. #define NUM_GLYPH_CACHE_SETTINGS 10
  68. LPCTSTR tscGlyphCacheEntries[NUM_GLYPH_CACHE_SETTINGS] = {
  69. UTREG_UH_GL_CACHE1_CELLSIZE,
  70. UTREG_UH_GL_CACHE2_CELLSIZE,
  71. UTREG_UH_GL_CACHE3_CELLSIZE,
  72. UTREG_UH_GL_CACHE4_CELLSIZE,
  73. UTREG_UH_GL_CACHE5_CELLSIZE,
  74. UTREG_UH_GL_CACHE6_CELLSIZE,
  75. UTREG_UH_GL_CACHE7_CELLSIZE,
  76. UTREG_UH_GL_CACHE8_CELLSIZE,
  77. UTREG_UH_GL_CACHE9_CELLSIZE,
  78. UTREG_UH_GL_CACHE10_CELLSIZE,
  79. };
  80. UINT tscGlyphCacheDefaults[NUM_GLYPH_CACHE_SETTINGS] = {
  81. UTREG_UH_GL_CACHE1_CELLSIZE_DFLT,
  82. UTREG_UH_GL_CACHE2_CELLSIZE_DFLT,
  83. UTREG_UH_GL_CACHE3_CELLSIZE_DFLT,
  84. UTREG_UH_GL_CACHE4_CELLSIZE_DFLT,
  85. UTREG_UH_GL_CACHE5_CELLSIZE_DFLT,
  86. UTREG_UH_GL_CACHE6_CELLSIZE_DFLT,
  87. UTREG_UH_GL_CACHE7_CELLSIZE_DFLT,
  88. UTREG_UH_GL_CACHE8_CELLSIZE_DFLT,
  89. UTREG_UH_GL_CACHE9_CELLSIZE_DFLT,
  90. UTREG_UH_GL_CACHE10_CELLSIZE_DFLT
  91. };
  92. CTscSettings::CTscSettings()
  93. {
  94. memset(this, 0, sizeof(CTscSettings));
  95. }
  96. CTscSettings::~CTscSettings()
  97. {
  98. }
  99. VOID CTscSettings::SetFileName(LPTSTR szFile)
  100. {
  101. _tcsncpy(_szFileName, szFile, SIZECHAR(_szFileName));
  102. }
  103. //
  104. // Load all the settings from the store.
  105. // values not in the store are automatically intialized to their
  106. // defaults by the store object.
  107. //
  108. // parameters:
  109. // pStore - persistant store object
  110. // returns
  111. // hresult code
  112. //
  113. HRESULT CTscSettings::LoadFromStore(ISettingsStore* pStore)
  114. {
  115. UINT i;
  116. CUT ut;
  117. #ifndef OS_WINCE
  118. LONG delta;
  119. #endif
  120. DC_BEGIN_FN("LoadFromStore");
  121. TRC_ASSERT(pStore, (TB,_T("pStore parameter is NULL to LoadFromStore")));
  122. if(!pStore)
  123. {
  124. return E_INVALIDARG;
  125. }
  126. TRC_ASSERT(pStore->IsOpenForRead(), (TB,_T("pStore is not OPEN for read")));
  127. if(!pStore->IsOpenForRead())
  128. {
  129. return E_FAIL;
  130. }
  131. //
  132. // Here we go...read in a gazillion properties
  133. // for some of these properties we do some special processing
  134. // to transmogrify (<-- word copyright adamo 2000) them.
  135. //
  136. ///////////////////////////////////////////////////////////////////
  137. // Fullscren property
  138. //
  139. UINT screenMode;
  140. #define SCREEN_MODE_UNSPECIFIED 0
  141. if(!pStore->ReadInt(UTREG_UI_SCREEN_MODE,
  142. SCREEN_MODE_UNSPECIFIED,
  143. &screenMode))
  144. {
  145. return E_FAIL;
  146. }
  147. if(SCREEN_MODE_UNSPECIFIED == screenMode)
  148. {
  149. //Screen mode was not specified.
  150. //The following logic is used to determine
  151. //if we're going full screen
  152. // 1) If no DesktopSize ID is specified then go fullscreen
  153. UINT val;
  154. #define DUMMY_DEFAULT ((UINT)-1)
  155. if(!pStore->ReadInt(UTREG_UI_DESKTOP_SIZEID,
  156. DUMMY_DEFAULT,
  157. &val))
  158. {
  159. return E_FAIL;
  160. }
  161. if(val == DUMMY_DEFAULT)
  162. {
  163. //DesktopSizeId was NOT specified
  164. //go fullscreen
  165. SetStartFullScreen(TRUE);
  166. }
  167. else
  168. {
  169. SetStartFullScreen(FALSE);
  170. }
  171. }
  172. else
  173. {
  174. //Go fullscreen according to setting
  175. SetStartFullScreen((UI_FULLSCREEN == screenMode));
  176. }
  177. #ifndef OS_WINCE
  178. ///////////////////////////////////////////////////////////////////
  179. // Window position string
  180. //
  181. TCHAR szBuffer[TSC_WINDOW_POSITION_STR_LEN];
  182. if(!pStore->ReadString(UTREG_UI_WIN_POS_STR,
  183. UTREG_UI_WIN_POS_STR_DFLT,
  184. szBuffer,
  185. sizeof(szBuffer)/sizeof(TCHAR)))
  186. {
  187. return E_FAIL;
  188. }
  189. TRC_NRM((TB, _T("Store read - Window Position string = %s"), szBuffer));
  190. // parse the string into ten fields
  191. int nRead = _stscanf(szBuffer, TSC_WINDOW_POSITION_INI_FORMAT,
  192. &_windowPlacement.flags,
  193. &_windowPlacement.showCmd,
  194. &_windowPlacement.rcNormalPosition.left,
  195. &_windowPlacement.rcNormalPosition.top,
  196. &_windowPlacement.rcNormalPosition.right,
  197. &_windowPlacement.rcNormalPosition.bottom);
  198. if (nRead != TSC_NUMBER_FIELDS_TO_READ)
  199. {
  200. TRC_ABORT((TB, _T("Illegal Window Position %s configured"), szBuffer));
  201. TRC_DBG((TB, _T("Parsed %u variables (should be %d) from registry"),
  202. nRead, TSC_NUMBER_FIELDS_TO_READ));
  203. TCHAR szWPosDflt[] = UTREG_UI_WIN_POS_STR_DFLT;
  204. nRead = _stscanf(szWPosDflt,
  205. TSC_WINDOW_POSITION_INI_FORMAT,
  206. &_windowPlacement.flags,
  207. &_windowPlacement.showCmd,
  208. &_windowPlacement.rcNormalPosition.left,
  209. &_windowPlacement.rcNormalPosition.top,
  210. &_windowPlacement.rcNormalPosition.right,
  211. &_windowPlacement.rcNormalPosition.bottom);
  212. if (nRead != TSC_NUMBER_FIELDS_TO_READ)
  213. {
  214. TRC_ABORT((TB,_T("Internal Error: Invalid default Window Position")));
  215. }
  216. }
  217. else
  218. {
  219. TRC_DBG((TB, _T("Parsed string to WINDOWPOSITION")));
  220. }
  221. _windowPlacement.length = sizeof(_windowPlacement);
  222. //
  223. // Validate the windowPlacement struct
  224. // replacing with reasonable defaults if a field is invalid
  225. //
  226. if(_windowPlacement.flags != 0 &&
  227. _windowPlacement.flags != WPF_ASYNCWINDOWPLACEMENT &&
  228. _windowPlacement.flags != WPF_RESTORETOMAXIMIZED &&
  229. _windowPlacement.flags != WPF_SETMINPOSITION)
  230. {
  231. TRC_DBG((TB,_T("Overriding _windowPlacement.flags from %d to 0"),
  232. _windowPlacement.flags));
  233. _windowPlacement.flags = 0;
  234. }
  235. //
  236. // Validate the showCmd and if the windowplacement
  237. // represents a minimized window, restore it
  238. //
  239. if(_windowPlacement.showCmd != SW_MAXIMIZE &&
  240. _windowPlacement.showCmd != SW_RESTORE &&
  241. _windowPlacement.showCmd != SW_SHOW &&
  242. _windowPlacement.showCmd != SW_SHOWMAXIMIZED &&
  243. _windowPlacement.showCmd != SW_SHOWNORMAL)
  244. {
  245. TRC_DBG((TB,_T("Overriding showCmd from %d to %d"),
  246. _windowPlacement.showCmd, SW_RESTORE));
  247. _windowPlacement.showCmd = SW_RESTORE;
  248. }
  249. if(_windowPlacement.rcNormalPosition.top < 0)
  250. {
  251. _windowPlacement.rcNormalPosition.top = 0;
  252. }
  253. //
  254. // Ensure a minimum width and height
  255. //
  256. delta = _windowPlacement.rcNormalPosition.right -
  257. _windowPlacement.rcNormalPosition.left;
  258. if( delta < 50)
  259. {
  260. _windowPlacement.rcNormalPosition.left = 0;
  261. _windowPlacement.rcNormalPosition.right = DEFAULT_DESKTOP_WIDTH;
  262. }
  263. delta = _windowPlacement.rcNormalPosition.bottom -
  264. _windowPlacement.rcNormalPosition.top;
  265. if( delta < 50)
  266. {
  267. _windowPlacement.rcNormalPosition.top = 0;
  268. _windowPlacement.rcNormalPosition.bottom = DEFAULT_DESKTOP_HEIGHT;
  269. }
  270. #endif //OS_WINCE
  271. //
  272. // The windowplacement is further validated on connection to
  273. // ensure the window is actually visible on screen.
  274. //
  275. #if !defined(OS_WINCE) || defined(OS_WINCE_NONFULLSCREEN)
  276. ///////////////////////////////////////////////////////////////////
  277. // Desktop size ID
  278. //
  279. if(!pStore->ReadInt(UTREG_UI_DESKTOP_SIZEID, UTREG_UI_DESKTOP_SIZEID_DFLT,
  280. &_desktopSizeID))
  281. {
  282. return E_FAIL;
  283. }
  284. TRC_NRM((TB, _T("Store read - Desktop Size ID = %u"), _desktopSizeID));
  285. if (_desktopSizeID > (UI_NUMBER_DESKTOP_SIZE_IDS - 1))
  286. {
  287. TRC_ABORT((TB, _T("Illegal desktopSizeID %d configured"),
  288. _desktopSizeID));
  289. _desktopSizeID = (UINT)UTREG_UI_DESKTOP_SIZEID_DFLT;
  290. }
  291. SetDesktopWidth( tscScreenResTable[_desktopSizeID][0]);
  292. SetDesktopHeight( tscScreenResTable[_desktopSizeID][1]);
  293. ///////////////////////////////////////////////////////////////////
  294. // New style desktop width/height
  295. //
  296. UINT deskWidth = DEFAULT_DESKTOP_WIDTH;
  297. UINT deskHeight = DEFAULT_DESKTOP_HEIGHT;
  298. if(!pStore->ReadInt(UTREG_UI_DESKTOP_WIDTH,
  299. UTREG_UI_DESKTOP_WIDTH_DFLT,
  300. &deskWidth))
  301. {
  302. return E_FAIL;
  303. }
  304. if(!pStore->ReadInt(UTREG_UI_DESKTOP_HEIGHT,
  305. UTREG_UI_DESKTOP_HEIGHT_DFLT,
  306. &deskHeight))
  307. {
  308. return E_FAIL;
  309. }
  310. if(deskWidth != UTREG_UI_DESKTOP_WIDTH_DFLT &&
  311. deskHeight != UTREG_UI_DESKTOP_HEIGHT_DFLT)
  312. {
  313. //Override the old sytle desktopsize ID setting
  314. //with the newwer desktopwidth/height
  315. if(deskWidth >= MIN_DESKTOP_WIDTH &&
  316. deskHeight >= MIN_DESKTOP_HEIGHT &&
  317. deskWidth <= MAX_DESKTOP_WIDTH &&
  318. deskHeight <= MAX_DESKTOP_HEIGHT)
  319. {
  320. SetDesktopWidth(deskWidth);
  321. SetDesktopHeight(deskHeight);
  322. }
  323. }
  324. if( GetStartFullScreen() )
  325. {
  326. //
  327. // Full screen overrides all resolution
  328. // settings in the RDP file
  329. //
  330. int xMaxSize = GetSystemMetrics(SM_CXSCREEN);
  331. int yMaxSize = GetSystemMetrics(SM_CYSCREEN);
  332. xMaxSize = xMaxSize > MAX_DESKTOP_WIDTH ? MAX_DESKTOP_WIDTH : xMaxSize;
  333. yMaxSize = yMaxSize > MAX_DESKTOP_HEIGHT?MAX_DESKTOP_HEIGHT : yMaxSize;
  334. SetDesktopWidth( xMaxSize );
  335. SetDesktopHeight( yMaxSize );
  336. }
  337. #else // !defined(OS_WINCE) || defined(OS_WINCE_NONFULLSCREEN)
  338. ///////////////////////////////////////////////////////////////////
  339. // WinCE desktop width/height
  340. //
  341. // WinCE needs to calculate the correct size from the beginning
  342. _desktopSizeID = 0;
  343. int xSize = GetSystemMetrics(SM_CXSCREEN);
  344. int ySize = GetSystemMetrics(SM_CYSCREEN);
  345. SetDesktopWidth(xSize);
  346. SetDesktopHeight(ySize);
  347. #endif // !defined(OS_WINCE) || defined(OS_WINCE_NONFULLSCREEN)
  348. ///////////////////////////////////////////////////////////////////
  349. // Color depth
  350. //
  351. //
  352. // Find the actual display depth
  353. // don't worry about these functions failing - if they do,
  354. // we'll use the store setting
  355. //
  356. HDC hdc = GetDC(NULL);
  357. UINT screenBpp;
  358. TRC_ASSERT((NULL != hdc), (TB,_T("Failed to get DC")));
  359. if(hdc)
  360. {
  361. screenBpp = GetDeviceCaps(hdc, BITSPIXEL);
  362. TRC_NRM((TB, _T("HDC %p has %u bpp"), hdc, screenBpp));
  363. ReleaseDC(NULL, hdc);
  364. }
  365. else
  366. {
  367. screenBpp = TSC_DEFAULT_BPP;
  368. }
  369. UINT clientBpp;
  370. //
  371. // Set the default to any color depth up to 16 bpp and then limit
  372. // it to that depth
  373. //
  374. UINT clampedScreenBpp = screenBpp > 16 ? 16 : screenBpp;
  375. if(!pStore->ReadInt(UTREG_UI_SESSION_BPP, clampedScreenBpp, &clientBpp))
  376. {
  377. return E_FAIL;
  378. }
  379. TRC_NRM((TB, _T("Store read - color depth = %d"), clientBpp));
  380. if(clientBpp == 32)
  381. {
  382. //32 is not supported, it maps directly to 24
  383. clientBpp = 24;
  384. }
  385. if(clientBpp >= screenBpp && screenBpp >= 8)
  386. {
  387. clientBpp = screenBpp;
  388. }
  389. if(clientBpp == 8 ||
  390. clientBpp == 15 ||
  391. clientBpp == 16 ||
  392. clientBpp == 24)
  393. {
  394. SetColorDepth(clientBpp);
  395. }
  396. else
  397. {
  398. //Default for safety
  399. SetColorDepth(8);
  400. }
  401. ///////////////////////////////////////////////////////////////////
  402. // Auto connect flag
  403. //
  404. if(!pStore->ReadBool(UTREG_UI_AUTO_CONNECT, UTREG_UI_AUTO_CONNECT_DFLT,
  405. &_fAutoConnectEnabled))
  406. {
  407. return E_FAIL;
  408. }
  409. ///////////////////////////////////////////////////////////////////
  410. // Server MRU list
  411. //
  412. for(i=0; i<NUM_MRU_ENTRIES; i++)
  413. {
  414. //MRU settings are global so they come from the registry
  415. ut.UT_ReadRegistryString( TSC_DEFAULT_REG_SESSION,
  416. (LPTSTR)mruEntriesNames[i],
  417. UTREG_UI_FULL_ADDRESS_DFLT,
  418. _szMRUServer[i],
  419. SIZECHAR(_szMRUServer[i]));
  420. }
  421. TCHAR szServer[TSC_MAX_ADDRESS_LENGTH];
  422. if(!pStore->ReadString( UTREG_UI_FULL_ADDRESS,
  423. UTREG_UI_FULL_ADDRESS_DFLT,
  424. szServer,
  425. SIZECHAR(szServer)))
  426. {
  427. return E_FAIL;
  428. }
  429. SetConnectString(szServer);
  430. ///////////////////////////////////////////////////////////////////
  431. // Smooth scrolling option
  432. //
  433. if(!pStore->ReadBool(UTREG_UI_SMOOTH_SCROLL, UTREG_UI_SMOOTH_SCROLL_DFLT,
  434. &_smoothScrolling))
  435. {
  436. return E_FAIL;
  437. }
  438. ///////////////////////////////////////////////////////////////////
  439. // Smart sizing option
  440. //
  441. #ifdef SMART_SIZING
  442. if(!pStore->ReadBool(UTREG_UI_SMARTSIZING, UTREG_UI_SMARTSIZING_DFLT,
  443. &_smartSizing))
  444. {
  445. return E_FAIL;
  446. }
  447. #endif // SMART_SIZING
  448. ///////////////////////////////////////////////////////////////////
  449. // Connect to console option
  450. //
  451. if(!pStore->ReadBool(UTREG_UI_CONNECTTOCONSOLE,
  452. UTREG_UI_CONNECTTOCONSOLE_DFLT, &_fConnectToConsole))
  453. {
  454. return E_FAIL;
  455. }
  456. ///////////////////////////////////////////////////////////////////
  457. // Accelerator check state
  458. //
  459. if(!pStore->ReadBool(UTREG_UI_ACCELERATOR_PASSTHROUGH_ENABLED,
  460. UTREG_UI_ACCELERATOR_PASSTHROUGH_ENABLED_DFLT,
  461. &_acceleratorPassthrough))
  462. {
  463. return E_FAIL;
  464. }
  465. ///////////////////////////////////////////////////////////////////
  466. // Shadow bitmap enabled
  467. //
  468. if(!pStore->ReadBool(UTREG_UI_SHADOW_BITMAP,
  469. UTREG_UI_SHADOW_BITMAP_DFLT,
  470. &_shadowBitmapEnabled))
  471. {
  472. return E_FAIL;
  473. }
  474. ///////////////////////////////////////////////////////////////////
  475. // Transport type
  476. // Currently limited to TCP
  477. //
  478. if(!pStore->ReadInt(UTREG_UI_TRANSPORT_TYPE,
  479. TRANSPORT_TCP,
  480. &_transportType))
  481. {
  482. return E_FAIL;
  483. }
  484. TRC_NRM((TB, _T("Store read - Transport type = %d"), _transportType));
  485. if (_transportType != TRANSPORT_TCP)
  486. {
  487. TRC_ABORT((TB, _T("Illegal Tansport Type %d configured"),
  488. _transportType));
  489. _transportType = TRANSPORT_TCP;
  490. }
  491. ///////////////////////////////////////////////////////////////////
  492. // SAS sequence
  493. //
  494. if(!pStore->ReadInt(UTREG_UI_SAS_SEQUENCE,
  495. UTREG_UI_SAS_SEQUENCE_DFLT,
  496. &_sasSequence))
  497. {
  498. return E_FAIL;
  499. }
  500. TRC_NRM((TB, _T("Store read - SAS Sequence = %#x"), _sasSequence));
  501. if ((_sasSequence != RNS_UD_SAS_DEL) &&
  502. (_sasSequence != RNS_UD_SAS_NONE))
  503. {
  504. TRC_ABORT((TB, _T("Illegal SAS Sequence %#x configured"), _sasSequence));
  505. _sasSequence = UTREG_UI_SAS_SEQUENCE_DFLT;
  506. }
  507. ///////////////////////////////////////////////////////////////////
  508. // Encryption enabled
  509. //
  510. if(!pStore->ReadBool(UTREG_UI_ENCRYPTION_ENABLED,
  511. UTREG_UI_ENCRYPTION_ENABLED_DFLT,
  512. &_encryptionEnabled))
  513. {
  514. return E_FAIL;
  515. }
  516. TRC_NRM((TB, _T("Store read - Encryption Enabled = %d"), _encryptionEnabled));
  517. ///////////////////////////////////////////////////////////////////
  518. // Dedicated terminal
  519. //
  520. if(!pStore->ReadBool(UTREG_UI_DEDICATED_TERMINAL,
  521. UTREG_UI_DEDICATED_TERMINAL_DFLT,
  522. &_dedicatedTerminal))
  523. {
  524. return E_FAIL;
  525. }
  526. TRC_NRM((TB, _T("Store read - Dedicated terminal= %d"), _dedicatedTerminal));
  527. ///////////////////////////////////////////////////////////////////
  528. // MCS port
  529. //
  530. if(!pStore->ReadInt(UTREG_UI_MCS_PORT,
  531. UTREG_UI_MCS_PORT_DFLT,
  532. &_MCSPort))
  533. {
  534. return E_FAIL;
  535. }
  536. if (_MCSPort > 65535) {
  537. // At the moment, error message is not granular enough to indicate that
  538. // the port number is bogus. So, just set it to the default if we have
  539. // an out of range number.
  540. TRC_ERR((TB,_T("MCS port is not in valid range - resetting to default.")));
  541. _MCSPort = UTREG_UI_MCS_PORT_DFLT;
  542. }
  543. ///////////////////////////////////////////////////////////////////
  544. // Enable MOUSE
  545. //
  546. if(!pStore->ReadBool(UTREG_UI_ENABLE_MOUSE,
  547. UTREG_UI_ENABLE_MOUSE_DFLT,
  548. &_fEnableMouse))
  549. {
  550. return E_FAIL;
  551. }
  552. ///////////////////////////////////////////////////////////////////
  553. // Disable CTRL-ALT-DEL
  554. //
  555. if(!pStore->ReadBool(UTREG_UI_DISABLE_CTRLALTDEL,
  556. UTREG_UI_DISABLE_CTRLALTDEL_DFLT,
  557. &_fDisableCtrlAltDel))
  558. {
  559. return E_FAIL;
  560. }
  561. ///////////////////////////////////////////////////////////////////
  562. // Enable Windows key
  563. //
  564. if(!pStore->ReadBool(UTREG_UI_ENABLE_WINDOWSKEY,
  565. UTREG_UI_ENABLE_WINDOWSKEY_DFLT,
  566. &_fEnableWindowsKey))
  567. {
  568. return E_FAIL;
  569. }
  570. ///////////////////////////////////////////////////////////////////
  571. // Double click detect
  572. //
  573. if(!pStore->ReadBool(UTREG_UI_DOUBLECLICK_DETECT,
  574. UTREG_UI_DOUBLECLICK_DETECT_DFLT,
  575. &_fDoubleClickDetect))
  576. {
  577. return E_FAIL;
  578. }
  579. ///////////////////////////////////////////////////////////////////
  580. // Keyboard hooking mode
  581. //
  582. UINT keyHookMode;
  583. if(!pStore->ReadInt(UTREG_UI_KEYBOARD_HOOK,
  584. UTREG_UI_KEYBOARD_HOOK_DFLT,
  585. &keyHookMode))
  586. {
  587. return E_FAIL;
  588. }
  589. if (keyHookMode == UTREG_UI_KEYBOARD_HOOK_NEVER ||
  590. keyHookMode == UTREG_UI_KEYBOARD_HOOK_ALWAYS ||
  591. keyHookMode == UTREG_UI_KEYBOARD_HOOK_FULLSCREEN)
  592. {
  593. #ifdef OS_WINCE
  594. if (keyHookMode == UTREG_UI_KEYBOARD_HOOK_FULLSCREEN)
  595. {
  596. keyHookMode = UTREG_UI_KEYBOARD_HOOK_ALWAYS;
  597. }
  598. #endif
  599. SetKeyboardHookMode(keyHookMode);
  600. }
  601. else
  602. {
  603. SetKeyboardHookMode(UTREG_UI_KEYBOARD_HOOK_NEVER);
  604. }
  605. ///////////////////////////////////////////////////////////////////
  606. // Sound redirection mode
  607. //
  608. UINT soundMode;
  609. if(!pStore->ReadInt(UTREG_UI_AUDIO_MODE,
  610. UTREG_UI_AUDIO_MODE_DFLT,
  611. &soundMode))
  612. {
  613. return E_FAIL;
  614. }
  615. if (soundMode == UTREG_UI_AUDIO_MODE_REDIRECT ||
  616. soundMode == UTREG_UI_AUDIO_MODE_PLAY_ON_SERVER ||
  617. soundMode == UTREG_UI_AUDIO_MODE_NONE)
  618. {
  619. SetSoundRedirectionMode(soundMode);
  620. }
  621. else
  622. {
  623. SetSoundRedirectionMode(UTREG_UI_AUDIO_MODE_DFLT);
  624. }
  625. ///////////////////////////////////////////////////////////////////
  626. // AutoLogon settings
  627. // Decide which version to use based on finding (in order)
  628. // AutoLogon50
  629. // AutoLogon
  630. // UserName50
  631. //
  632. //50 autologon
  633. if(!pStore->ReadBool(UTREG_UI_AUTOLOGON50,
  634. UTREG_UI_AUTOLOGON50_DFLT,
  635. &_fAutoLogon))
  636. {
  637. return E_FAIL;
  638. }
  639. memset(_szUserName, 0, sizeof(_szUserName));
  640. memset(_szDomain, 0, sizeof(_szDomain));
  641. memset(_szAlternateShell, 0, sizeof(_szAlternateShell));
  642. memset(_szWorkingDir, 0, sizeof(_szWorkingDir));
  643. ///////////////////////////////////////////////////////////////////
  644. // User name
  645. //
  646. if(!pStore->ReadString(UTREG_UI_USERNAME,
  647. UTREG_UI_USERNAME_DFLT,
  648. _szUserName,
  649. SIZECHAR(_szUserName)))
  650. {
  651. return E_FAIL;
  652. }
  653. //
  654. // Domain
  655. //
  656. if(!pStore->ReadString(UTREG_UI_DOMAIN,
  657. UTREG_UI_DOMAIN_DFLT,
  658. _szDomain,
  659. SIZECHAR(_szDomain)))
  660. {
  661. return E_FAIL;
  662. }
  663. if (!ReadPassword( pStore ))
  664. {
  665. //Not fatal..Allow rest of properties to be read
  666. TRC_ERR((TB,_T("Password read failed")));
  667. }
  668. //
  669. // Alternate shell (i.e StartProgram)
  670. //
  671. if(!pStore->ReadString(UTREG_UI_ALTERNATESHELL,
  672. UTREG_UI_ALTERNATESHELL_DFLT,
  673. _szAlternateShell,
  674. SIZECHAR(_szAlternateShell)))
  675. {
  676. return E_FAIL;
  677. }
  678. //
  679. // WorkDir
  680. //
  681. if(!pStore->ReadString(UTREG_UI_WORKINGDIR,
  682. UTREG_UI_WORKINGDIR_DFLT,
  683. _szWorkingDir,
  684. SIZECHAR(_szWorkingDir)))
  685. {
  686. return E_FAIL;
  687. }
  688. if(_tcscmp(_szAlternateShell,TEXT("")))
  689. {
  690. SetEnableStartProgram(TRUE);
  691. }
  692. else
  693. {
  694. SetEnableStartProgram(FALSE);
  695. }
  696. //
  697. // Maximize shell
  698. //
  699. if(!pStore->ReadBool(UTREG_UI_MAXIMIZESHELL50,
  700. UTREG_UI_MAXIMIZESHELL50_DFLT,
  701. &_fMaximizeShell))
  702. {
  703. return E_FAIL;
  704. }
  705. // ~~~~~~ ~~~~ ~~~~~ ~~~~ ~~~~~ ~~~~ ~~~~ ~~~ ~~~~ ~~~~ ~~~~~ ~~~~
  706. // FIXFIX Read HotKeys
  707. // (hotkeys are in a separate folder in the registry)
  708. // so they break the clean persistent store interface because a new
  709. // set of functions is needed to open a subkey
  710. //
  711. ///////////////////////////////////////////////////////////////////
  712. // Compression
  713. //
  714. if(!pStore->ReadBool(UTREG_UI_COMPRESS,UTREG_UI_COMPRESS_DFLT,
  715. &_fCompress))
  716. {
  717. return E_FAIL;
  718. }
  719. TRC_NRM((TB, _T("Store read - Compression Enabled = %d"), _fCompress));
  720. ///////////////////////////////////////////////////////////////////
  721. // Bitmap memory cache size
  722. //
  723. #ifndef OS_WINCE
  724. if(!pStore->ReadInt(UTREG_UH_TOTAL_BM_CACHE,
  725. UTREG_UH_TOTAL_BM_CACHE_DFLT,
  726. &_RegBitmapCacheSize))
  727. {
  728. return E_FAIL;
  729. }
  730. #else
  731. _RegBitmapCacheSize = ut.UT_ReadRegistryInt(UTREG_SECTION,
  732. UTREG_UH_TOTAL_BM_CACHE,
  733. UTREG_UH_TOTAL_BM_CACHE_DFLT);
  734. #endif
  735. ///////////////////////////////////////////////////////////////////
  736. // Update frequency
  737. //
  738. if(!pStore->ReadInt(UTREG_UH_DRAW_THRESHOLD,
  739. UTREG_UH_DRAW_THRESHOLD_DFLT,
  740. &_drawThreshold))
  741. {
  742. return E_FAIL;
  743. }
  744. ///////////////////////////////////////////////////////////////////
  745. // Disk/mem cache sizes
  746. //
  747. // 8bpp
  748. if(!pStore->ReadInt(TSC_BITMAPCACHE_8BPP_PROPNAME,
  749. TSC_BITMAPCACHEVIRTUALSIZE_8BPP,
  750. &_BitmapVirtualCache8BppSize))
  751. {
  752. return E_FAIL;
  753. }
  754. // 16bpp
  755. if(!pStore->ReadInt(TSC_BITMAPCACHE_16BPP_PROPNAME,
  756. TSC_BITMAPCACHEVIRTUALSIZE_16BPP,
  757. &_BitmapVirtualCache16BppSize))
  758. {
  759. return E_FAIL;
  760. }
  761. // 24bpp
  762. if(!pStore->ReadInt(TSC_BITMAPCACHE_24BPP_PROPNAME,
  763. TSC_BITMAPCACHEVIRTUALSIZE_24BPP,
  764. &_BitmapVirtualCache24BppSize))
  765. {
  766. return E_FAIL;
  767. }
  768. //
  769. // Bitmap disk cache size reg settings are usually
  770. // set in the registry. Override any file specified
  771. // or default values (read above) with reg settings.
  772. // (the previous values are passed in as 'defaults'
  773. // to get the desired overriding.
  774. //
  775. _BitmapVirtualCache8BppSize = (UINT) ut.UT_ReadRegistryInt(UTREG_SECTION,
  776. TSC_BITMAPCACHE_8BPP_PROPNAME,
  777. _BitmapVirtualCache8BppSize);
  778. _BitmapVirtualCache16BppSize = (UINT) ut.UT_ReadRegistryInt(UTREG_SECTION,
  779. TSC_BITMAPCACHE_16BPP_PROPNAME,
  780. _BitmapVirtualCache16BppSize);
  781. _BitmapVirtualCache24BppSize = (UINT) ut.UT_ReadRegistryInt(UTREG_SECTION,
  782. TSC_BITMAPCACHE_24BPP_PROPNAME,
  783. _BitmapVirtualCache24BppSize);
  784. //
  785. // Range validate bitmap cache size settings
  786. //
  787. if (_BitmapVirtualCache8BppSize > TSC_MAX_BITMAPCACHESIZE)
  788. {
  789. _BitmapVirtualCache8BppSize = TSC_MAX_BITMAPCACHESIZE;
  790. }
  791. if (_BitmapVirtualCache16BppSize > TSC_MAX_BITMAPCACHESIZE)
  792. {
  793. _BitmapVirtualCache16BppSize = TSC_MAX_BITMAPCACHESIZE;
  794. }
  795. if (_BitmapVirtualCache24BppSize > TSC_MAX_BITMAPCACHESIZE)
  796. {
  797. _BitmapVirtualCache24BppSize = TSC_MAX_BITMAPCACHESIZE;
  798. }
  799. ///////////////////////////////////////////////////////////////////
  800. // Whether to scale disk and mem bitmap caches by the protocol BPP
  801. //
  802. if(!pStore->ReadInt(UTREG_UH_SCALE_BM_CACHE,
  803. UTREG_UH_SCALE_BM_CACHE_DFLT,
  804. &_RegScaleBitmapCachesByBPP))
  805. {
  806. return E_FAIL;
  807. }
  808. ///////////////////////////////////////////////////////////////////
  809. // Number of bitmap caches
  810. //
  811. if(!pStore->ReadInt(UTREG_UH_BM_NUM_CELL_CACHES,
  812. UTREG_UH_BM_NUM_CELL_CACHES_DFLT,
  813. &_RegNumBitmapCaches))
  814. {
  815. return E_FAIL;
  816. }
  817. //
  818. // Bitmap cache settings galore....
  819. //
  820. //
  821. for (i = 0; i < TS_BITMAPCACHE_MAX_CELL_CACHES; i++)
  822. {
  823. TCHAR QueryStr[32];
  824. _stprintf(QueryStr, UTREG_UH_BM_CACHE_PROPORTION_TEMPLATE,
  825. _T('1') + i);
  826. //
  827. // Bitmap cache proportion
  828. //
  829. if(!pStore->ReadInt(QueryStr,
  830. ProportionDefault[i],
  831. &_RegBCProportion[i]))
  832. {
  833. return E_FAIL;
  834. }
  835. #if ((!defined(OS_WINCE)) || (defined(ENABLE_BMP_CACHING_FOR_WINCE)))
  836. _stprintf(QueryStr, UTREG_UH_BM_CACHE_PERSISTENCE_TEMPLATE,
  837. _T('1') + i);
  838. //
  839. // Bitmap send keys
  840. //
  841. if(!pStore->ReadInt(QueryStr,
  842. PersistenceDefault[i] ? TRUE : FALSE,
  843. &_bSendBitmapKeys[i]))
  844. {
  845. return E_FAIL;
  846. }
  847. #endif // ((!defined(OS_WINCE)) || (defined(ENABLE_BMP_CACHING_FOR_WINCE)))
  848. _stprintf(QueryStr, UTREG_UH_BM_CACHE_MAXENTRIES_TEMPLATE,
  849. _T('1') + i);
  850. //
  851. // Bitmap cache max entries
  852. //
  853. if(!pStore->ReadInt(QueryStr,
  854. MaxEntriesDefault[i],
  855. &_RegBCMaxEntries[i]))
  856. {
  857. return E_FAIL;
  858. }
  859. if (_RegBCMaxEntries[i] < MaxEntriesDefault[i])
  860. {
  861. _RegBCMaxEntries[i] = MaxEntriesDefault[i];
  862. }
  863. }
  864. ///////////////////////////////////////////////////////////////////
  865. // Glyph support level
  866. //
  867. if(!pStore->ReadInt(UTREG_UH_GL_SUPPORT,
  868. UTREG_UH_GL_SUPPORT_DFLT,
  869. &_GlyphSupportLevel))
  870. {
  871. return E_FAIL;
  872. }
  873. ///////////////////////////////////////////////////////////////////
  874. // Glyph cache cell sizes
  875. //
  876. for(i=0; i<NUM_GLYPH_CACHE_SETTINGS; i++)
  877. {
  878. if(!pStore->ReadInt(tscGlyphCacheEntries[i],
  879. tscGlyphCacheDefaults[i],
  880. &_GlyphCacheSize[i]))
  881. {
  882. return E_FAIL;
  883. }
  884. }
  885. ///////////////////////////////////////////////////////////////////
  886. // Frag cell size
  887. //
  888. if(!pStore->ReadInt(UTREG_UH_FG_CELLSIZE,
  889. UTREG_UH_FG_CELLSIZE_DFLT,
  890. &_fragCellSize))
  891. {
  892. return E_FAIL;
  893. }
  894. ///////////////////////////////////////////////////////////////////
  895. // Brush support level
  896. //
  897. if(!pStore->ReadInt(UTREG_UH_FG_CELLSIZE,
  898. UTREG_UH_FG_CELLSIZE_DFLT,
  899. &_brushSupportLevel))
  900. {
  901. return E_FAIL;
  902. }
  903. ///////////////////////////////////////////////////////////////////
  904. // Maximum input event count
  905. //
  906. if(!pStore->ReadInt(UTREG_IH_MAX_EVENT_COUNT,
  907. UTREG_IH_MAX_EVENT_COUNT_DFLT,
  908. &_maxInputEventCount))
  909. {
  910. return E_FAIL;
  911. }
  912. ///////////////////////////////////////////////////////////////////
  913. // Events at once
  914. //
  915. if(!pStore->ReadInt(UTREG_IH_NRM_EVENT_COUNT,
  916. UTREG_IH_NRM_EVENT_COUNT_DFLT,
  917. &_eventsAtOnce))
  918. {
  919. return E_FAIL;
  920. }
  921. ///////////////////////////////////////////////////////////////////
  922. // Minimum send interval
  923. //
  924. if(!pStore->ReadInt(UTREG_IH_MIN_SEND_INTERVAL,
  925. UTREG_IH_MIN_SEND_INTERVAL_DFLT,
  926. &_minSendInterval))
  927. {
  928. return E_FAIL;
  929. }
  930. ///////////////////////////////////////////////////////////////////
  931. // Keepalive interval in milliseconds
  932. //
  933. if(!pStore->ReadInt(UTREG_IH_KEEPALIVE_INTERVAL,
  934. UTREG_IH_KEEPALIVE_INTERVAL_DFLT,
  935. &_keepAliveIntervalMS))
  936. {
  937. return E_FAIL;
  938. }
  939. ///////////////////////////////////////////////////////////////////
  940. // Keybaord layout string
  941. //
  942. memset(_szKeybLayoutStr, 0, sizeof(_szKeybLayoutStr));
  943. #ifndef OS_WINCE
  944. //
  945. // Precedence is (1) Registry (2) RDP file (per connection)
  946. //
  947. ut.UT_ReadRegistryString(UTREG_SECTION,
  948. UTREG_UI_KEYBOARD_LAYOUT,
  949. UTREG_UI_KEYBOARD_LAYOUT_DFLT,
  950. _szKeybLayoutStr,
  951. sizeof(_szKeybLayoutStr));
  952. TCHAR szKeybLayoutDflt[UTREG_UI_KEYBOARD_LAYOUT_LEN];
  953. StringCchCopy(szKeybLayoutDflt,
  954. SIZE_TCHARS(szKeybLayoutDflt),
  955. _szKeybLayoutStr
  956. );
  957. //
  958. // Override with any per-connection settings
  959. //
  960. if(!pStore->ReadString(UTREG_UI_KEYBOARD_LAYOUT,
  961. szKeybLayoutDflt,
  962. _szKeybLayoutStr,
  963. sizeof(_szKeybLayoutStr)/sizeof(TCHAR)))
  964. {
  965. return E_FAIL;
  966. }
  967. #else
  968. ut.UT_ReadRegistryString(UTREG_SECTION,
  969. UTREG_UI_KEYBOARD_LAYOUT,
  970. UTREG_UI_KEYBOARD_LAYOUT_DFLT,
  971. _szKeybLayoutStr,
  972. sizeof(_szKeybLayoutStr));
  973. #endif
  974. ///////////////////////////////////////////////////////////////////
  975. // Shutdown timeout
  976. //
  977. if(!pStore->ReadInt(UTREG_UI_SHUTDOWN_TIMEOUT,
  978. UTREG_UI_SHUTDOWN_TIMEOUT_DFLT,
  979. &_shutdownTimeout))
  980. {
  981. return E_FAIL;
  982. }
  983. ///////////////////////////////////////////////////////////////////
  984. // Connection timeout
  985. //
  986. if(!pStore->ReadInt(UTREG_UI_OVERALL_CONN_TIMEOUT,
  987. UTREG_UI_OVERALL_CONN_TIMEOUT_DFLT,
  988. &_connectionTimeout))
  989. {
  990. return E_FAIL;
  991. }
  992. ///////////////////////////////////////////////////////////////////
  993. // Single connection timeout
  994. //
  995. if(!pStore->ReadInt(UTREG_UI_SINGLE_CONN_TIMEOUT,
  996. UTREG_UI_SINGLE_CONN_TIMEOUT_DFLT,
  997. &_singleConTimeout))
  998. {
  999. return E_FAIL;
  1000. }
  1001. #ifdef OS_WINCE
  1002. ///////////////////////////////////////////////////////////////////
  1003. // Keyboard type
  1004. //
  1005. _keyboardType = ut.UT_ReadRegistryInt(
  1006. UTREG_SECTION,
  1007. UTREG_UI_KEYBOARD_TYPE,
  1008. UTREG_UI_KEYBOARD_TYPE_DFLT);
  1009. ///////////////////////////////////////////////////////////////////
  1010. // Keyboard sub-type
  1011. //
  1012. _keyboardSubType = ut.UT_ReadRegistryInt(
  1013. UTREG_SECTION,
  1014. UTREG_UI_KEYBOARD_SUBTYPE,
  1015. UTREG_UI_KEYBOARD_SUBTYPE_DFLT);
  1016. ///////////////////////////////////////////////////////////////////
  1017. // Keyboard function key
  1018. //
  1019. _keyboardFunctionKey = ut.UT_ReadRegistryInt(
  1020. UTREG_SECTION,
  1021. UTREG_UI_KEYBOARD_FUNCTIONKEY,
  1022. UTREG_UI_KEYBOARD_FUNCTIONKEY_DFLT);
  1023. #endif // OS_WINCE
  1024. //
  1025. // Debug options
  1026. //
  1027. #ifdef DC_DEBUG
  1028. ///////////////////////////////////////////////////////////////////
  1029. // Hatch bitmap PDU
  1030. //
  1031. if(!pStore->ReadBool(UTREG_UI_HATCH_BITMAP_PDU_DATA,
  1032. UTREG_UI_HATCH_BITMAP_PDU_DATA_DFLT,
  1033. &_hatchBitmapPDUData))
  1034. {
  1035. return E_FAIL;
  1036. }
  1037. ///////////////////////////////////////////////////////////////////
  1038. // Hatch SSB order data
  1039. //
  1040. if(!pStore->ReadBool(UTREG_UI_HATCH_SSB_ORDER_DATA,
  1041. UTREG_UI_HATCH_SSB_ORDER_DATA_DFLT,
  1042. &_hatchSSBOrderData))
  1043. {
  1044. return E_FAIL;
  1045. }
  1046. ///////////////////////////////////////////////////////////////////
  1047. // Hatch index PDU data
  1048. //
  1049. if(!pStore->ReadBool(UTREG_UI_HATCH_INDEX_PDU_DATA,
  1050. UTREG_UI_HATCH_INDEX_PDU_DATA_DFLT,
  1051. &_hatchIndexPDUData))
  1052. {
  1053. return E_FAIL;
  1054. }
  1055. ///////////////////////////////////////////////////////////////////
  1056. // Hatch memblt order data
  1057. //
  1058. if(!pStore->ReadBool(UTREG_UI_HATCH_MEMBLT_ORDER_DATA,
  1059. UTREG_UI_HATCH_MEMBLT_ORDER_DATA_DFLT,
  1060. &_hatchMemBltOrderData))
  1061. {
  1062. return E_FAIL;
  1063. }
  1064. ///////////////////////////////////////////////////////////////////
  1065. // Label memblt orders
  1066. //
  1067. if(!pStore->ReadBool(UTREG_UI_LABEL_MEMBLT_ORDERS,
  1068. UTREG_UI_LABEL_MEMBLT_ORDERS_DFLT,
  1069. &_labelMemBltOrders))
  1070. {
  1071. return E_FAIL;
  1072. }
  1073. ///////////////////////////////////////////////////////////////////
  1074. // Bitmap cache monitor
  1075. //
  1076. if(!pStore->ReadBool(UTREG_UI_BITMAP_CACHE_MONITOR,
  1077. UTREG_UI_BITMAP_CACHE_MONITOR_DFLT,
  1078. &_bitmapCacheMonitor))
  1079. {
  1080. return E_FAIL;
  1081. }
  1082. #endif // DC_DEBUG
  1083. ///////////////////////////////////////////////////////////////////
  1084. // DNS browsing domain name
  1085. //
  1086. memset(_browseDNSDomainName,0,sizeof(_browseDNSDomainName));
  1087. if(!pStore->ReadString(UTREG_UI_BROWSE_DOMAIN_NAME,
  1088. UTREG_UI_BROWSE_DOMAIN_NAME_DFLT,
  1089. _browseDNSDomainName,
  1090. sizeof(_browseDNSDomainName)/sizeof(TCHAR)))
  1091. {
  1092. return E_FAIL;
  1093. }
  1094. if(_tcscmp(_browseDNSDomainName,
  1095. UTREG_UI_BROWSE_DOMAIN_NAME_DFLT))
  1096. {
  1097. _fbrowseDNSDomain = TRUE;
  1098. }
  1099. else
  1100. {
  1101. _fbrowseDNSDomain = FALSE;
  1102. }
  1103. //
  1104. // Get the plugin list. For security reasons we only read
  1105. // this from the registry - it would be dangerous to allow an RDP
  1106. // file to specify DLLs that could potentially live off machine
  1107. //
  1108. DC_MEMSET(_szPluginList, 0, sizeof(_szPluginList));
  1109. //
  1110. // Get reg plugin list
  1111. //
  1112. CSH::SH_GetPluginDllList(TSC_DEFAULT_REG_SESSION, _szPluginList,
  1113. SIZECHAR(_szPluginList));
  1114. ///////////////////////////////////////////////////////////////////
  1115. // Icon file
  1116. //
  1117. memset(_szIconFile, 0, sizeof(_szIconFile));
  1118. if(!pStore->ReadString(TSC_ICON_FILE,
  1119. _T(""),
  1120. _szIconFile,
  1121. sizeof(_szIconFile)/sizeof(TCHAR)))
  1122. {
  1123. return E_FAIL;
  1124. }
  1125. ///////////////////////////////////////////////////////////////////
  1126. // Icon index
  1127. //
  1128. if(!pStore->ReadInt(TSC_ICON_INDEX,
  1129. TSC_ICON_INDEX_DEFAULT,
  1130. &_iconIndex))
  1131. {
  1132. return E_FAIL;
  1133. }
  1134. if(!pStore->ReadBool(TSCSETTING_REDIRECTDRIVES,
  1135. TSCSETTING_REDIRECTDRIVES_DFLT,
  1136. &_fDriveRedirectionEnabled))
  1137. {
  1138. return E_FAIL;
  1139. }
  1140. if(!pStore->ReadBool(TSCSETTING_REDIRECTPRINTERS,
  1141. TSCSETTING_REDIRECTPRINTERS_DFLT,
  1142. &_fPrinterRedirectionEnabled))
  1143. {
  1144. return E_FAIL;
  1145. }
  1146. if(!pStore->ReadBool(TSCSETTING_REDIRECTCOMPORTS,
  1147. TSCSETTING_REDIRECTCOMPORTS_DFLT,
  1148. &_fPortRedirectionEnabled))
  1149. {
  1150. return E_FAIL;
  1151. }
  1152. if(!pStore->ReadBool(TSCSETTING_REDIRECTSCARDS,
  1153. TSCSETTING_REDIRECTSCARDS_DFLT,
  1154. &_fSCardRedirectionEnabled))
  1155. {
  1156. return E_FAIL;
  1157. }
  1158. if(!pStore->ReadBool(TSCSETTING_DISPLAYCONNECTIONBAR,
  1159. TSCSETTING_DISPLAYCONNECTIONBAR_DFLT,
  1160. &_fDisplayBBar))
  1161. {
  1162. return E_FAIL;
  1163. }
  1164. //
  1165. // AutoReconnection
  1166. //
  1167. if (!pStore->ReadBool(TSCSETTING_ENABLEAUTORECONNECT,
  1168. TSCSETTING_ENABLEAUTORECONNECT_DFLT,
  1169. &_fEnableAutoReconnect))
  1170. {
  1171. return E_FAIL;
  1172. }
  1173. //
  1174. // Autoreconnect max retries
  1175. //
  1176. if (!pStore->ReadInt(TSCSETTING_ARC_RETRIES,
  1177. TSCSETTING_ARC_RETRIES_DFLT,
  1178. &_nArcMaxRetries))
  1179. {
  1180. return E_FAIL;
  1181. }
  1182. //
  1183. // Pin bbar is global
  1184. //
  1185. _fPinBBar = (BOOL) ut.UT_ReadRegistryInt(UTREG_SECTION,
  1186. TSCSETTING_PINCONNECTIONBAR,
  1187. TSCSETTING_PINCONNECTIONBAR_DFLT);
  1188. if (!ReadPerfOptions(pStore))
  1189. {
  1190. TRC_ERR((TB,_T("ReadPerfOptions failed")));
  1191. return E_FAIL;
  1192. }
  1193. //
  1194. // FIXFIX..Missing props:
  1195. // Wince: iRegistryPaletteIsFixed/put_WinceFixedPalette
  1196. // HOTKEYS
  1197. // plugindlls
  1198. //
  1199. DC_END_FN();
  1200. return S_OK;
  1201. }
  1202. //
  1203. // Write back settings to the store,
  1204. // Only do this for settings that could have been modified
  1205. // (by the UI/control).
  1206. // any other settings are transparently rewritten out by the
  1207. // the store.
  1208. //
  1209. HRESULT CTscSettings::SaveToStore(ISettingsStore* pStore)
  1210. {
  1211. CUT ut;
  1212. DC_BEGIN_FN("SaveToStore");
  1213. TRC_ASSERT(pStore,(TB,_T("pStore is null")));
  1214. if(!pStore)
  1215. {
  1216. return E_INVALIDARG;
  1217. }
  1218. TRC_ASSERT(pStore->IsOpenForWrite(),
  1219. (TB,_T("pStore is not open for write")));
  1220. if(!pStore->IsOpenForWrite())
  1221. {
  1222. return E_FAIL;
  1223. }
  1224. //
  1225. // Note all UI contrallable settings are _always_
  1226. // written out to the RDP file
  1227. //
  1228. ///////////////////////////////////////////////////////////////////
  1229. // FullScreen
  1230. //
  1231. UINT screenMode = GetStartFullScreen() ? UI_FULLSCREEN : UI_WINDOWED;
  1232. if(!pStore->WriteInt(UTREG_UI_SCREEN_MODE,
  1233. UTREG_UI_SCREEN_MODE_DFLT,
  1234. screenMode,
  1235. TRUE))
  1236. {
  1237. return E_FAIL;
  1238. }
  1239. ///////////////////////////////////////////////////////////////////
  1240. // Desktop width/height
  1241. //
  1242. UINT deskWidth = GetDesktopWidth();
  1243. if(!pStore->WriteInt(UTREG_UI_DESKTOP_WIDTH,
  1244. UTREG_UI_DESKTOP_WIDTH_DFLT,
  1245. deskWidth,
  1246. TRUE))
  1247. {
  1248. return E_FAIL;
  1249. }
  1250. UINT deskHeight = GetDesktopHeight();
  1251. if(!pStore->WriteInt(UTREG_UI_DESKTOP_HEIGHT,
  1252. UTREG_UI_DESKTOP_HEIGHT_DFLT,
  1253. deskHeight,
  1254. TRUE))
  1255. {
  1256. return E_FAIL;
  1257. }
  1258. ///////////////////////////////////////////////////////////////////
  1259. // Color depth
  1260. //
  1261. UINT colorDepth = GetColorDepth();
  1262. if(!pStore->WriteInt(UTREG_UI_SESSION_BPP,
  1263. -1, //invalid default to force always write
  1264. colorDepth,
  1265. TRUE))
  1266. {
  1267. return E_FAIL;
  1268. }
  1269. ///////////////////////////////////////////////////////////////////
  1270. // Window placement string
  1271. //
  1272. TCHAR szBuffer[TSC_WINDOW_POSITION_STR_LEN];
  1273. DC_TSPRINTF(szBuffer,
  1274. TSC_WINDOW_POSITION_INI_FORMAT,
  1275. _windowPlacement.flags,
  1276. _windowPlacement.showCmd,
  1277. _windowPlacement.rcNormalPosition.left,
  1278. _windowPlacement.rcNormalPosition.top,
  1279. _windowPlacement.rcNormalPosition.right,
  1280. _windowPlacement.rcNormalPosition.bottom);
  1281. TRC_DBG((TB, _T("Top = %d"), _windowPlacement.rcNormalPosition.top));
  1282. if(!pStore->WriteString(UTREG_UI_WIN_POS_STR,
  1283. UTREG_UI_WIN_POS_STR_DFLT,
  1284. szBuffer,
  1285. TRUE))
  1286. {
  1287. return E_FAIL;
  1288. }
  1289. if(!pStore->WriteString(UTREG_UI_FULL_ADDRESS,
  1290. UTREG_UI_FULL_ADDRESS_DFLT,
  1291. GetFlatConnectString(),
  1292. TRUE))
  1293. {
  1294. return E_FAIL;
  1295. }
  1296. ///////////////////////////////////////////////////////////////////
  1297. // Compression
  1298. //
  1299. if(!pStore->WriteBool(UTREG_UI_COMPRESS,
  1300. UTREG_UI_COMPRESS_DFLT,
  1301. _fCompress,
  1302. TRUE))
  1303. {
  1304. return E_FAIL;
  1305. }
  1306. ///////////////////////////////////////////////////////////////////
  1307. // SmartSizing
  1308. //
  1309. #ifdef SMART_SIZING
  1310. if(!pStore->WriteBool(UTREG_UI_SMARTSIZING,
  1311. UTREG_UI_SMARTSIZING_DFLT,
  1312. _smartSizing,
  1313. FALSE))
  1314. {
  1315. return E_FAIL;
  1316. }
  1317. #endif // SMART_SIZING
  1318. ///////////////////////////////////////////////////////////////////
  1319. // Connect to console option
  1320. //
  1321. // Don't save it. Only way it can get set right now is from the
  1322. // command line, and we wouldn't want that to screw with somebody's
  1323. // .rdp file.
  1324. //
  1325. ///////////////////////////////////////////////////////////////////
  1326. // Keyb Hook mode
  1327. //
  1328. if(!pStore->WriteInt(UTREG_UI_KEYBOARD_HOOK,
  1329. UTREG_UI_KEYBOARD_HOOK_DFLT,
  1330. GetKeyboardHookMode(),
  1331. TRUE))
  1332. {
  1333. return E_FAIL;
  1334. }
  1335. ///////////////////////////////////////////////////////////////////
  1336. // Sound redir mode
  1337. //
  1338. if(!pStore->WriteInt(UTREG_UI_AUDIO_MODE,
  1339. UTREG_UI_AUDIO_MODE_DFLT,
  1340. GetSoundRedirectionMode(),
  1341. TRUE))
  1342. {
  1343. return E_FAIL;
  1344. }
  1345. ///////////////////////////////////////////////////////////////////
  1346. // Drives and printers
  1347. //
  1348. if(!pStore->WriteBool(TSCSETTING_REDIRECTDRIVES,
  1349. TSCSETTING_REDIRECTDRIVES_DFLT,
  1350. _fDriveRedirectionEnabled,
  1351. TRUE))
  1352. {
  1353. return E_FAIL;
  1354. }
  1355. if(!pStore->WriteBool(TSCSETTING_REDIRECTPRINTERS,
  1356. TSCSETTING_REDIRECTPRINTERS_DFLT,
  1357. _fPrinterRedirectionEnabled,
  1358. TRUE))
  1359. {
  1360. return E_FAIL;
  1361. }
  1362. if(!pStore->WriteBool(TSCSETTING_REDIRECTCOMPORTS,
  1363. TSCSETTING_REDIRECTCOMPORTS_DFLT,
  1364. _fPortRedirectionEnabled,
  1365. TRUE))
  1366. {
  1367. return E_FAIL;
  1368. }
  1369. if(!pStore->WriteBool(TSCSETTING_REDIRECTSCARDS,
  1370. TSCSETTING_REDIRECTSCARDS_DFLT,
  1371. _fSCardRedirectionEnabled,
  1372. TRUE))
  1373. {
  1374. return E_FAIL;
  1375. }
  1376. if(!pStore->WriteBool(TSCSETTING_DISPLAYCONNECTIONBAR,
  1377. TSCSETTING_DISPLAYCONNECTIONBAR_DFLT,
  1378. _fDisplayBBar,
  1379. TRUE))
  1380. {
  1381. return E_FAIL;
  1382. }
  1383. ut.UT_WriteRegistryInt(UTREG_SECTION,
  1384. TSCSETTING_PINCONNECTIONBAR,
  1385. TSCSETTING_PINCONNECTIONBAR_DFLT,
  1386. _fPinBBar);
  1387. //
  1388. // AutoReconnection
  1389. //
  1390. if (!pStore->WriteBool(TSCSETTING_ENABLEAUTORECONNECT,
  1391. TSCSETTING_ENABLEAUTORECONNECT_DFLT,
  1392. _fEnableAutoReconnect,
  1393. TRUE))
  1394. {
  1395. return E_FAIL;
  1396. }
  1397. ///////////////////////////////////////////////////////////////////
  1398. // User name
  1399. //
  1400. if(!pStore->WriteString(UTREG_UI_USERNAME,
  1401. UTREG_UI_USERNAME_DFLT,
  1402. _szUserName,
  1403. TRUE))
  1404. {
  1405. return E_FAIL;
  1406. }
  1407. //
  1408. // Domain
  1409. //
  1410. if(!pStore->WriteString(UTREG_UI_DOMAIN,
  1411. UTREG_UI_DOMAIN_DFLT,
  1412. _szDomain,
  1413. TRUE))
  1414. {
  1415. return E_FAIL;
  1416. }
  1417. if(GetEnableStartProgram())
  1418. {
  1419. //
  1420. // Alternate shell (i.e StartProgram)
  1421. //
  1422. if(!pStore->WriteString(UTREG_UI_ALTERNATESHELL,
  1423. UTREG_UI_ALTERNATESHELL_DFLT,
  1424. _szAlternateShell,
  1425. TRUE))
  1426. {
  1427. return E_FAIL;
  1428. }
  1429. //
  1430. // WorkDir
  1431. //
  1432. if(!pStore->WriteString(UTREG_UI_WORKINGDIR,
  1433. UTREG_UI_WORKINGDIR_DFLT,
  1434. _szWorkingDir,
  1435. TRUE))
  1436. {
  1437. return E_FAIL;
  1438. }
  1439. }
  1440. else
  1441. {
  1442. //The setting is disabled so write out the default
  1443. //values which will delete any existing settings
  1444. //in the file.
  1445. if(!pStore->WriteString(UTREG_UI_ALTERNATESHELL,
  1446. UTREG_UI_ALTERNATESHELL_DFLT,
  1447. UTREG_UI_ALTERNATESHELL_DFLT,
  1448. TRUE))
  1449. {
  1450. return E_FAIL;
  1451. }
  1452. //
  1453. // WorkDir
  1454. //
  1455. if(!pStore->WriteString(UTREG_UI_WORKINGDIR,
  1456. UTREG_UI_WORKINGDIR_DFLT,
  1457. UTREG_UI_WORKINGDIR_DFLT,
  1458. TRUE))
  1459. {
  1460. return E_FAIL;
  1461. }
  1462. }
  1463. //
  1464. // Delete old format on save
  1465. //
  1466. pStore->DeleteValueIfPresent(UTREG_UI_PASSWORD50);
  1467. pStore->DeleteValueIfPresent(UTREG_UI_SALT50);
  1468. if (GetPasswordProvided() && CSH::IsCryptoAPIPresent() &&
  1469. GetSavePassword())
  1470. {
  1471. HRESULT hr;
  1472. TCHAR szClearPass[TSC_MAX_PASSLENGTH_TCHARS];
  1473. memset(szClearPass, 0, sizeof(szClearPass));
  1474. hr = GetClearTextPass(szClearPass, sizeof(szClearPass));
  1475. if (SUCCEEDED(hr))
  1476. {
  1477. DATA_BLOB din;
  1478. DATA_BLOB dout;
  1479. din.cbData = sizeof(szClearPass);
  1480. din.pbData = (PBYTE)&szClearPass;
  1481. dout.pbData = NULL;
  1482. if (CSH::DataProtect( &din, &dout))
  1483. {
  1484. BOOL bRet =
  1485. pStore->WriteBinary(UI_SETTING_PASSWORD51,
  1486. dout.pbData,
  1487. dout.cbData);
  1488. LocalFree( dout.pbData );
  1489. //
  1490. // Wipe stack copy
  1491. //
  1492. SecureZeroMemory(szClearPass, sizeof(szClearPass));
  1493. if(!bRet)
  1494. {
  1495. return E_FAIL;
  1496. }
  1497. }
  1498. else
  1499. {
  1500. return E_FAIL;
  1501. }
  1502. }
  1503. }
  1504. else
  1505. {
  1506. pStore->DeleteValueIfPresent(UI_SETTING_PASSWORD51);
  1507. }
  1508. if (!WritePerfOptions( pStore ))
  1509. {
  1510. TRC_ERR((TB,_T("WritePerfOptions failed")));
  1511. return FALSE;
  1512. }
  1513. if(SaveRegSettings())
  1514. {
  1515. return S_OK;
  1516. }
  1517. else
  1518. {
  1519. TRC_ERR((TB,_T("SaveRegSettings failed")));
  1520. return E_FAIL;
  1521. }
  1522. DC_END_FN();
  1523. return S_OK;
  1524. }
  1525. int CTscSettings::GetSoundRedirectionMode()
  1526. {
  1527. return _soundRedirectionMode;
  1528. }
  1529. void CTscSettings::SetSoundRedirectionMode(int soundMode)
  1530. {
  1531. DC_BEGIN_FN("SetSoundRedirectionMode");
  1532. TRC_ASSERT(soundMode == UTREG_UI_AUDIO_MODE_REDIRECT ||
  1533. soundMode == UTREG_UI_AUDIO_MODE_PLAY_ON_SERVER ||
  1534. soundMode == UTREG_UI_AUDIO_MODE_NONE,
  1535. (TB,_T("Invalid soundMode")));
  1536. _soundRedirectionMode = soundMode;
  1537. DC_END_FN();
  1538. }
  1539. int CTscSettings::GetKeyboardHookMode()
  1540. {
  1541. return _keyboardHookMode;
  1542. }
  1543. void CTscSettings::SetKeyboardHookMode(int hookmode)
  1544. {
  1545. DC_BEGIN_FN("SetKeyboardHookMode");
  1546. TRC_ASSERT(hookmode == UTREG_UI_KEYBOARD_HOOK_NEVER ||
  1547. hookmode == UTREG_UI_KEYBOARD_HOOK_ALWAYS ||
  1548. hookmode == UTREG_UI_KEYBOARD_HOOK_FULLSCREEN,
  1549. (TB,_T("Invalid hookmode")));
  1550. _keyboardHookMode = hookmode;
  1551. DC_END_FN();
  1552. }
  1553. VOID CTscSettings::SetLogonUserName(LPCTSTR szUserName)
  1554. {
  1555. _tcsncpy(_szUserName, szUserName, SIZECHAR(_szUserName));
  1556. }
  1557. VOID CTscSettings::SetDomain(LPCTSTR szDomain)
  1558. {
  1559. _tcsncpy(_szDomain, szDomain, SIZECHAR(_szDomain));
  1560. }
  1561. VOID CTscSettings::SetStartProgram(LPCTSTR szStartProg)
  1562. {
  1563. _tcsncpy(_szAlternateShell, szStartProg, SIZECHAR(_szAlternateShell));
  1564. }
  1565. VOID CTscSettings::SetWorkDir(LPCTSTR szWorkDir)
  1566. {
  1567. _tcsncpy(_szWorkingDir, szWorkDir, SIZECHAR(_szWorkingDir));
  1568. }
  1569. //
  1570. // Apply settings to the control
  1571. //
  1572. HRESULT CTscSettings::ApplyToControl(IMsRdpClient* pTsc)
  1573. {
  1574. HRESULT hr = E_FAIL;
  1575. INT portNumber = -1;
  1576. TCHAR szCanonicalServerName[TSC_MAX_ADDRESS_LENGTH];
  1577. TCHAR szConnectArgs[TSC_MAX_ADDRESS_LENGTH];
  1578. IMsTscNonScriptable* pTscNonScript = NULL;
  1579. IMsRdpClientSecuredSettings* pSecuredSet = NULL;
  1580. IMsRdpClientAdvancedSettings2* pAdvSettings = NULL;
  1581. IMsRdpClient2* pTsc2 = NULL;
  1582. USES_CONVERSION;
  1583. DC_BEGIN_FN("ApplyToControl");
  1584. TRC_ASSERT(pTsc,(TB,_T("pTsc is NULL")));
  1585. if(pTsc)
  1586. {
  1587. TRC_ASSERT(GetDesktopHeight() &&
  1588. GetDesktopWidth(),
  1589. (TB, _T("Invalid desktop width/height\n")));
  1590. if (!GetDesktopHeight() ||
  1591. !GetDesktopWidth())
  1592. {
  1593. hr = E_FAIL;
  1594. DC_QUIT;
  1595. }
  1596. CHECK_DCQUIT_HR(pTsc->get_SecuredSettings2(&pSecuredSet));
  1597. CHECK_DCQUIT_HR(pTsc->put_UserName( T2OLE( (LPTSTR)GetLogonUserName())));
  1598. CHECK_DCQUIT_HR(pTsc->put_Domain( T2OLE( (LPTSTR)GetDomain())));
  1599. CHECK_DCQUIT_HR(pTsc->put_DesktopWidth(GetDesktopWidth()));
  1600. CHECK_DCQUIT_HR(pTsc->put_DesktopHeight(GetDesktopHeight()));
  1601. int colorDepth = GetColorDepth();
  1602. if(colorDepth)
  1603. {
  1604. CHECK_DCQUIT_HR(pTsc->put_ColorDepth(colorDepth));
  1605. }
  1606. CHECK_DCQUIT_HR(pTsc->put_FullScreen( BOOL_TO_VB(GetStartFullScreen())) );
  1607. if(GetEnableStartProgram())
  1608. {
  1609. CHECK_DCQUIT_HR( pSecuredSet->put_StartProgram(
  1610. T2OLE( (LPTSTR)GetStartProgram())));
  1611. CHECK_DCQUIT_HR( pSecuredSet->put_WorkDir(
  1612. T2OLE( (LPTSTR)GetWorkDir())) );
  1613. }
  1614. else
  1615. {
  1616. OLECHAR nullChar = 0;
  1617. CHECK_DCQUIT_HR( pSecuredSet->put_StartProgram( &nullChar ));
  1618. CHECK_DCQUIT_HR( pSecuredSet->put_WorkDir( &nullChar ));
  1619. }
  1620. CHECK_DCQUIT_HR(pTsc->QueryInterface(IID_IMsRdpClient2, (VOID**)&pTsc2));
  1621. CHECK_DCQUIT_HR(pTsc2->get_AdvancedSettings3( &pAdvSettings));
  1622. if (!pAdvSettings)
  1623. {
  1624. hr = E_FAIL;
  1625. DC_QUIT;
  1626. }
  1627. CHECK_DCQUIT_HR(pAdvSettings->put_RedirectDrives(
  1628. (VARIANT_BOOL)_fDriveRedirectionEnabled));
  1629. CHECK_DCQUIT_HR(pAdvSettings->put_RedirectPrinters(
  1630. (VARIANT_BOOL)_fPrinterRedirectionEnabled))
  1631. CHECK_DCQUIT_HR(pAdvSettings->put_RedirectPorts(
  1632. (VARIANT_BOOL)_fPortRedirectionEnabled));
  1633. CHECK_DCQUIT_HR(pAdvSettings->put_RedirectSmartCards(
  1634. (VARIANT_BOOL)_fSCardRedirectionEnabled));
  1635. //
  1636. // Enable mouse support
  1637. //
  1638. CHECK_DCQUIT_HR(pAdvSettings->put_EnableMouse(
  1639. BOOL_TO_VB(_fEnableMouse)));
  1640. // Bitmap disk cache sizes (per color depth)
  1641. // 8bpp / TSAC legacy size
  1642. //
  1643. CHECK_DCQUIT_HR(pAdvSettings->put_BitmapVirtualCacheSize(
  1644. _BitmapVirtualCache8BppSize));
  1645. // 16 and 24 bpp sizes
  1646. CHECK_DCQUIT_HR(pAdvSettings->put_BitmapVirtualCache16BppSize(
  1647. _BitmapVirtualCache16BppSize));
  1648. CHECK_DCQUIT_HR(pAdvSettings->put_BitmapVirtualCache24BppSize(
  1649. _BitmapVirtualCache24BppSize));
  1650. CHECK_DCQUIT_HR(pSecuredSet->put_KeyboardHookMode(
  1651. GetKeyboardHookMode() ));
  1652. CHECK_DCQUIT_HR(pSecuredSet->put_AudioRedirectionMode(
  1653. GetSoundRedirectionMode()));
  1654. hr = pTsc->QueryInterface(IID_IMsTscNonScriptable,
  1655. (void**)&pTscNonScript);
  1656. if(FAILED(hr) || !pTscNonScript)
  1657. {
  1658. CHECK_DCQUIT_HR(hr);
  1659. }
  1660. if(GetPasswordProvided())
  1661. {
  1662. TCHAR szClearPass[TSC_MAX_PASSLENGTH_TCHARS];
  1663. memset(szClearPass, 0, sizeof(szClearPass));
  1664. hr = GetClearTextPass(szClearPass, sizeof(szClearPass));
  1665. if (SUCCEEDED(hr))
  1666. {
  1667. hr = pTscNonScript->put_ClearTextPassword(szClearPass);
  1668. }
  1669. else
  1670. {
  1671. hr = pTscNonScript->ResetPassword();
  1672. }
  1673. //
  1674. // Wipe stack copy
  1675. //
  1676. SecureZeroMemory(szClearPass, sizeof(szClearPass));
  1677. CHECK_DCQUIT_HR(hr);
  1678. }
  1679. else
  1680. {
  1681. CHECK_DCQUIT_HR(pTscNonScript->ResetPassword());
  1682. }
  1683. hr = _ConnectString.GetServerPortion(
  1684. szCanonicalServerName,
  1685. SIZE_TCHARS(szCanonicalServerName)
  1686. );
  1687. CHECK_DCQUIT_HR(hr);
  1688. //
  1689. // Figure out if a port was specified as part of the
  1690. // server name and if so strip it off the end and set
  1691. // the port property
  1692. //
  1693. portNumber = CUT::GetPortNumberFromServerName(
  1694. szCanonicalServerName
  1695. );
  1696. if(-1 != portNumber)
  1697. {
  1698. TRC_NRM((TB,_T("Port specified as part of srv name: %d"),
  1699. portNumber));
  1700. //Strip out the port number portion
  1701. //from the server.
  1702. TCHAR szServer[TSC_MAX_ADDRESS_LENGTH];
  1703. CUT::GetServerNameFromFullAddress(
  1704. szCanonicalServerName,
  1705. szServer,
  1706. TSC_MAX_ADDRESS_LENGTH
  1707. );
  1708. CHECK_DCQUIT_HR( pAdvSettings->put_RDPPort( portNumber ) );
  1709. CHECK_DCQUIT_HR( pTsc->put_Server(T2OLE( (LPTSTR)szServer )) );
  1710. }
  1711. else
  1712. {
  1713. //No server[:port] specified just set the port
  1714. //from prop from the settings
  1715. CHECK_DCQUIT_HR( pAdvSettings->put_RDPPort( GetMCSPort() ) );
  1716. CHECK_DCQUIT_HR( pTsc->put_Server( T2OLE(szCanonicalServerName)) );
  1717. }
  1718. CHECK_DCQUIT_HR( pAdvSettings->put_Compress( GetCompress()) );
  1719. #ifdef SMART_SIZING
  1720. CHECK_DCQUIT_HR( pAdvSettings->put_SmartSizing(
  1721. BOOL_TO_VB(GetSmartSizing())));
  1722. #endif // SMART_SIZING
  1723. CHECK_DCQUIT_HR( pAdvSettings->put_DisableCtrlAltDel(
  1724. GetDisableCtrlAltDel()) );
  1725. CHECK_DCQUIT_HR( pAdvSettings->put_BitmapPersistence(
  1726. GetBitmapPersitenceFromPerfFlags() ));
  1727. CHECK_DCQUIT_HR( pAdvSettings->put_PluginDlls(T2OLE(_szPluginList)) );
  1728. CHECK_DCQUIT_HR( pAdvSettings->put_ConnectToServerConsole(
  1729. BOOL_TO_VB(_fConnectToConsole)));
  1730. CHECK_DCQUIT_HR( pAdvSettings->put_DisplayConnectionBar(
  1731. BOOL_TO_VB(_fDisplayBBar)));
  1732. CHECK_DCQUIT_HR( pAdvSettings->put_PinConnectionBar(
  1733. BOOL_TO_VB(_fPinBBar)));
  1734. CHECK_DCQUIT_HR( pAdvSettings->put_EnableAutoReconnect(
  1735. BOOL_TO_VB(_fEnableAutoReconnect)));
  1736. CHECK_DCQUIT_HR( pAdvSettings->put_MaxReconnectAttempts(
  1737. _nArcMaxRetries));
  1738. CHECK_DCQUIT_HR( pAdvSettings->put_KeyBoardLayoutStr(
  1739. T2OLE(_szKeybLayoutStr)));
  1740. #ifdef OS_WINCE
  1741. CHECK_DCQUIT_HR( pAdvSettings->put_KeyboardType(_keyboardType));
  1742. CHECK_DCQUIT_HR( pAdvSettings->put_KeyboardSubType(_keyboardSubType));
  1743. CHECK_DCQUIT_HR( pAdvSettings->put_KeyboardFunctionKey(_keyboardFunctionKey));
  1744. CHECK_DCQUIT_HR( pAdvSettings->put_BitmapCacheSize(_RegBitmapCacheSize));
  1745. #endif
  1746. //
  1747. // Do some tweaking on the disabled feature list that we pass
  1748. // to the control - remove the bitmap caching bit as that is a
  1749. // separate property
  1750. //
  1751. LONG perfFlags =
  1752. (LONG)(_dwPerfFlags & ~TS_PERF_DISABLE_BITMAPCACHING);
  1753. CHECK_DCQUIT_HR( pAdvSettings->put_PerformanceFlags(perfFlags));
  1754. //
  1755. // Connection arguments come last (they override)
  1756. // Parse and apply settings from any connect args
  1757. //
  1758. memset(szConnectArgs, 0 , sizeof(szConnectArgs));
  1759. hr = _ConnectString.GetArgumentsPortion(
  1760. szConnectArgs,
  1761. SIZE_TCHARS(szConnectArgs)
  1762. );
  1763. CHECK_DCQUIT_HR(hr);
  1764. hr = ApplyConnectionArgumentSettings(
  1765. szConnectArgs,
  1766. pAdvSettings
  1767. );
  1768. if (FAILED(hr)) {
  1769. TRC_ERR((TB,
  1770. _T("ApplyConnectionArgumentSettings failed: 0x%x"),hr));
  1771. }
  1772. }
  1773. else
  1774. {
  1775. hr = E_INVALIDARG;
  1776. DC_QUIT;
  1777. }
  1778. DC_EXIT_POINT:
  1779. if (pTscNonScript) {
  1780. pTscNonScript->Release();
  1781. pTscNonScript = NULL;
  1782. }
  1783. if (pAdvSettings) {
  1784. pAdvSettings->Release();
  1785. pAdvSettings = NULL;
  1786. }
  1787. if (pSecuredSet) {
  1788. pSecuredSet->Release();
  1789. pSecuredSet = NULL;
  1790. }
  1791. if (pTsc2) {
  1792. pTsc2->Release();
  1793. pTsc2 = NULL;
  1794. }
  1795. DC_END_FN();
  1796. return hr;
  1797. }
  1798. #define CONARG_CONSOLE _T("/CONSOLE")
  1799. HRESULT
  1800. CTscSettings::ApplyConnectionArgumentSettings(
  1801. LPCTSTR szConArg,
  1802. IMsRdpClientAdvancedSettings2* pAdvSettings
  1803. )
  1804. {
  1805. HRESULT hr = S_OK;
  1806. BOOL fConnectToConsole = FALSE;
  1807. DC_BEGIN_FN("ApplyConnectionArgumentSettings");
  1808. TCHAR szUpperArg[TSC_MAX_ADDRESS_LENGTH];
  1809. if (szConArg[0] != 0) {
  1810. TRC_NRM((TB,_T("Connect string Connection args - %s"), szConArg));
  1811. hr = StringCchCopy(
  1812. szUpperArg,
  1813. SIZE_TCHARS(szUpperArg),
  1814. szConArg
  1815. );
  1816. if (FAILED(hr)) {
  1817. DC_QUIT;
  1818. }
  1819. //
  1820. // U-case for the string find
  1821. //
  1822. LPTSTR sz = szUpperArg;
  1823. while (*sz) {
  1824. *sz = towupper(*sz);
  1825. sz++;
  1826. }
  1827. //
  1828. // Only one we care about now is "/console"
  1829. //
  1830. if (_tcsstr(szUpperArg, CONARG_CONSOLE)) {
  1831. fConnectToConsole = TRUE;
  1832. }
  1833. }
  1834. else {
  1835. TRC_NRM((TB,_T("No Connection args")));
  1836. }
  1837. if (fConnectToConsole) {
  1838. TRC_NRM((TB,_T("Connect args enabled connect to console")));
  1839. hr = pAdvSettings->put_ConnectToServerConsole(VARIANT_TRUE);
  1840. }
  1841. DC_END_FN();
  1842. DC_EXIT_POINT:
  1843. return hr;
  1844. }
  1845. //
  1846. // Pickup settings the control may have updated
  1847. //
  1848. HRESULT CTscSettings::GetUpdatesFromControl(IMsRdpClient* pTsc)
  1849. {
  1850. DC_BEGIN_FN("GetUpdatesFromControl");
  1851. USES_CONVERSION;
  1852. HRESULT hr = E_FAIL;
  1853. TRC_ASSERT(pTsc,(TB,_T("pTsc is null")));
  1854. if(pTsc)
  1855. {
  1856. BSTR Domain;
  1857. TRACE_HR(pTsc->get_Domain(&Domain));
  1858. if(SUCCEEDED(hr))
  1859. {
  1860. LPTSTR szDomain = OLE2T(Domain);
  1861. if(szDomain)
  1862. {
  1863. SetDomain(szDomain);
  1864. }
  1865. else
  1866. {
  1867. return E_FAIL;
  1868. }
  1869. SysFreeString(Domain);
  1870. }
  1871. else
  1872. {
  1873. return hr;
  1874. }
  1875. BSTR UserName;
  1876. TRACE_HR(pTsc->get_UserName(&UserName));
  1877. if(SUCCEEDED(hr))
  1878. {
  1879. LPTSTR szUserName = OLE2T(UserName);
  1880. if(UserName)
  1881. {
  1882. SetLogonUserName(szUserName);
  1883. }
  1884. else
  1885. {
  1886. return E_FAIL;
  1887. }
  1888. SysFreeString(UserName);
  1889. }
  1890. else
  1891. {
  1892. return hr;
  1893. }
  1894. VARIANT_BOOL vb;
  1895. IMsRdpClientAdvancedSettings* pAdv = NULL;
  1896. TRACE_HR(pTsc->get_AdvancedSettings2(&pAdv));
  1897. if (SUCCEEDED(hr))
  1898. {
  1899. TRACE_HR(pAdv->get_PinConnectionBar(&vb));
  1900. if (SUCCEEDED(hr) && vb == VARIANT_TRUE)
  1901. {
  1902. _fPinBBar = TRUE;
  1903. }
  1904. else
  1905. {
  1906. _fPinBBar = FALSE;
  1907. }
  1908. pAdv->Release();
  1909. pAdv = NULL;
  1910. }
  1911. }
  1912. DC_END_FN();
  1913. return S_OK;
  1914. }
  1915. BOOL CTscSettings::UpdateRegMRU(LPTSTR szNewServer)
  1916. {
  1917. DCINT i, j;
  1918. DCBOOL bServerPresent=FALSE;
  1919. CUT ut;
  1920. DC_BEGIN_FN("UpdateRegMRU");
  1921. for (i=0; i<10;++i)
  1922. {
  1923. if (!_tcsnicmp(_szMRUServer[i],szNewServer,
  1924. SIZECHAR(_szMRUServer[i])))
  1925. {
  1926. bServerPresent = TRUE;
  1927. for (j=i; j>0; --j)
  1928. {
  1929. _tcsncpy(_szMRUServer[j],_szMRUServer[j-1],
  1930. SIZECHAR(_szMRUServer[i]));
  1931. }
  1932. _tcsncpy(_szMRUServer[0], szNewServer,
  1933. SIZECHAR(_szMRUServer[i]));
  1934. }
  1935. }
  1936. if (!bServerPresent)
  1937. {
  1938. for (i=9; i>0; --i)
  1939. {
  1940. _tcsncpy(_szMRUServer[i],_szMRUServer[i-1],
  1941. SIZECHAR(_szMRUServer[0]));
  1942. }
  1943. _tcsncpy(_szMRUServer[0], szNewServer,
  1944. SIZECHAR(_szMRUServer[0]));
  1945. }
  1946. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1947. UTREG_UI_SERVER_MRU0,
  1948. UTREG_UI_SERVER_MRU_DFLT,
  1949. _szMRUServer[0]);
  1950. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1951. UTREG_UI_SERVER_MRU1,
  1952. UTREG_UI_SERVER_MRU_DFLT,
  1953. _szMRUServer[1]);
  1954. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1955. UTREG_UI_SERVER_MRU2,
  1956. UTREG_UI_SERVER_MRU_DFLT,
  1957. _szMRUServer[2]);
  1958. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1959. UTREG_UI_SERVER_MRU3,
  1960. UTREG_UI_SERVER_MRU_DFLT,
  1961. _szMRUServer[3]);
  1962. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1963. UTREG_UI_SERVER_MRU4,
  1964. UTREG_UI_SERVER_MRU_DFLT,
  1965. _szMRUServer[4]);
  1966. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1967. UTREG_UI_SERVER_MRU5,
  1968. UTREG_UI_SERVER_MRU_DFLT,
  1969. _szMRUServer[5]);
  1970. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1971. UTREG_UI_SERVER_MRU6,
  1972. UTREG_UI_SERVER_MRU_DFLT,
  1973. _szMRUServer[6]);
  1974. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1975. UTREG_UI_SERVER_MRU7,
  1976. UTREG_UI_SERVER_MRU_DFLT,
  1977. _szMRUServer[7]);
  1978. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1979. UTREG_UI_SERVER_MRU8,
  1980. UTREG_UI_SERVER_MRU_DFLT,
  1981. _szMRUServer[8]);
  1982. ut.UT_WriteRegistryString(TSC_DEFAULT_REG_SESSION,
  1983. UTREG_UI_SERVER_MRU9,
  1984. UTREG_UI_SERVER_MRU_DFLT,
  1985. _szMRUServer[9]);
  1986. TRC_NRM((TB, _T("Write to registry - Address = %s"), szNewServer));
  1987. DC_END_FN();
  1988. return TRUE;
  1989. }
  1990. //
  1991. // Save those settings that go in the registry
  1992. //
  1993. BOOL CTscSettings::SaveRegSettings()
  1994. {
  1995. DC_BEGIN_FN("SaveRegSettings");
  1996. //
  1997. // Update the MRU list in the registry
  1998. //
  1999. UpdateRegMRU(GetFlatConnectString());
  2000. DC_END_FN();
  2001. return TRUE;
  2002. }
  2003. BOOL CTscSettings::ReadPassword(ISettingsStore* pSto)
  2004. {
  2005. DC_BEGIN_FN("ReadPassword");
  2006. PBYTE pbPass = NULL;
  2007. BOOL bRet = TRUE;
  2008. SetClearTextPass(_T(""));
  2009. SetUIPasswordEdited(FALSE);
  2010. SetSavePassword(FALSE);
  2011. TCHAR szClearPass[TSC_MAX_PASSLENGTH_TCHARS];
  2012. memset(szClearPass, 0, sizeof(szClearPass));
  2013. if (CSH::IsCryptoAPIPresent() &&
  2014. pSto->IsValuePresent(UI_SETTING_PASSWORD51))
  2015. {
  2016. DWORD dwEncPassLen = pSto->GetDataLength(UI_SETTING_PASSWORD51);
  2017. if(dwEncPassLen && dwEncPassLen < 4096)
  2018. {
  2019. pbPass = (PBYTE)LocalAlloc( LPTR, dwEncPassLen);
  2020. if (pbPass && pSto->ReadBinary( UI_SETTING_PASSWORD51,
  2021. pbPass,
  2022. dwEncPassLen ))
  2023. {
  2024. DATA_BLOB din, dout;
  2025. din.cbData = dwEncPassLen;
  2026. din.pbData = pbPass;
  2027. dout.pbData = NULL;
  2028. if (CSH::DataUnprotect(&din, &dout))
  2029. {
  2030. memcpy(szClearPass, dout.pbData,
  2031. min( dout.cbData, sizeof(szClearPass)));
  2032. //
  2033. // Store the password securely
  2034. //
  2035. SetClearTextPass(szClearPass);
  2036. //
  2037. // Wipe stack copy
  2038. //
  2039. SecureZeroMemory(szClearPass, sizeof(szClearPass));
  2040. LocalFree( dout.pbData );
  2041. //
  2042. // If a password was provided default to save
  2043. // it
  2044. //
  2045. if (GetPasswordProvided())
  2046. {
  2047. SetSavePassword( TRUE );
  2048. }
  2049. }
  2050. else
  2051. {
  2052. bRet = FALSE;
  2053. }
  2054. }
  2055. }
  2056. else
  2057. {
  2058. TRC_ERR((TB,_T("Invalid pass length")));
  2059. bRet = FALSE;
  2060. }
  2061. }
  2062. if(pbPass)
  2063. {
  2064. LocalFree(pbPass);
  2065. }
  2066. DC_END_FN();
  2067. return bRet;
  2068. }
  2069. //
  2070. // Store a clear text password. On platforms that support
  2071. // it internally encrypt the password.
  2072. //
  2073. HRESULT CTscSettings::SetClearTextPass(LPCTSTR szClearPass)
  2074. {
  2075. HRESULT hr = E_FAIL;
  2076. DC_BEGIN_FN("SetClearTextPass");
  2077. if (CSH::IsCryptoAPIPresent())
  2078. {
  2079. DATA_BLOB din;
  2080. din.cbData = _tcslen(szClearPass) * sizeof(TCHAR);
  2081. din.pbData = (PBYTE)szClearPass;
  2082. if (_blobEncryptedPassword.pbData)
  2083. {
  2084. LocalFree(_blobEncryptedPassword.pbData);
  2085. _blobEncryptedPassword.pbData = NULL;
  2086. _blobEncryptedPassword.cbData = 0;
  2087. }
  2088. if (din.cbData)
  2089. {
  2090. if (CSH::DataProtect( &din, &_blobEncryptedPassword))
  2091. {
  2092. hr = S_OK;
  2093. }
  2094. else
  2095. {
  2096. TRC_ERR((TB,_T("DataProtect failed")));
  2097. hr = E_FAIL;
  2098. }
  2099. }
  2100. else
  2101. {
  2102. TRC_NRM((TB,_T("0 length password, not encrypting")));
  2103. hr = S_OK;
  2104. }
  2105. }
  2106. else
  2107. {
  2108. hr = StringCchCopy(_szClearPass, SIZECHAR(_szClearPass), szClearPass);
  2109. if (FAILED(hr)) {
  2110. TRC_ERR((TB, _T("String copy failed: hr = 0x%x"), hr));
  2111. }
  2112. }
  2113. DC_END_FN();
  2114. return hr;
  2115. }
  2116. //
  2117. // Retrieve a clear text password
  2118. //
  2119. // On platforms that support it the password is internally encrypted
  2120. //
  2121. // Params
  2122. // [out] szBuffer - receives decrypted password
  2123. // [int] cbLen - length of szBuffer
  2124. //
  2125. HRESULT CTscSettings::GetClearTextPass(LPTSTR szBuffer, INT cbLen)
  2126. {
  2127. HRESULT hr = E_FAIL;
  2128. DC_BEGIN_FN("GetClearTextPass");
  2129. if (CSH::IsCryptoAPIPresent())
  2130. {
  2131. DATA_BLOB dout;
  2132. #ifdef OS_WINCE
  2133. dout.cbData = 0;
  2134. dout.pbData = NULL;
  2135. #endif
  2136. if (_blobEncryptedPassword.cbData)
  2137. {
  2138. if (CSH::DataUnprotect(&_blobEncryptedPassword, &dout))
  2139. {
  2140. memcpy(szBuffer, dout.pbData, min( dout.cbData, (UINT)cbLen));
  2141. //
  2142. // Nuke the original copy
  2143. //
  2144. SecureZeroMemory(dout.pbData, dout.cbData);
  2145. LocalFree( dout.pbData );
  2146. hr = S_OK;
  2147. }
  2148. else
  2149. {
  2150. TRC_ERR((TB,_T("DataUnprotect failed")));
  2151. hr = E_FAIL;
  2152. }
  2153. }
  2154. else
  2155. {
  2156. TRC_NRM((TB,_T("0 length encrypted pass, not decrypting")));
  2157. //
  2158. // Just reset the output buffer
  2159. //
  2160. memset(szBuffer, 0, cbLen);
  2161. hr = S_OK;
  2162. }
  2163. }
  2164. else
  2165. {
  2166. memcpy(szBuffer, _szClearPass, cbLen);
  2167. hr = S_OK;
  2168. }
  2169. DC_END_FN();
  2170. return hr;
  2171. }
  2172. //
  2173. // Returns true if a password was provided
  2174. //
  2175. BOOL CTscSettings::GetPasswordProvided()
  2176. {
  2177. HRESULT hr;
  2178. BOOL fPassProvided = FALSE;
  2179. TCHAR szClearPass[TSC_MAX_PASSWORD_LENGTH_BYTES / sizeof(TCHAR)];
  2180. DC_BEGIN_FN("GetPasswordProvided");
  2181. hr = GetClearTextPass(szClearPass, sizeof(szClearPass));
  2182. if (SUCCEEDED(hr))
  2183. {
  2184. //
  2185. // Blank password means no password
  2186. //
  2187. if (_tcscmp(szClearPass, _T("")))
  2188. {
  2189. fPassProvided = TRUE;
  2190. }
  2191. }
  2192. else
  2193. {
  2194. TRC_ERR((TB,_T("GetClearTextPass failed")));
  2195. }
  2196. SecureZeroMemory(szClearPass, sizeof(szClearPass));
  2197. DC_END_FN();
  2198. return fPassProvided;
  2199. }
  2200. const PERFOPTIONS_PERSISTINFO g_perfOptLut[] = {
  2201. {PO_DISABLE_WALLPAPER, PO_DISABLE_WALLPAPER_DFLT,
  2202. TS_PERF_DISABLE_WALLPAPER, TRUE},
  2203. {PO_DISABLE_FULLWINDOWDRAG, PO_DISABLE_FULLWINDOWDRAG_DFLT,
  2204. TS_PERF_DISABLE_FULLWINDOWDRAG, TRUE},
  2205. {PO_DISABLE_MENU_WINDOW_ANIMS, PO_DISABLE_MENU_WINDOW_ANIMS_DFLT,
  2206. TS_PERF_DISABLE_MENUANIMATIONS, TRUE},
  2207. {PO_DISABLE_THEMES, PO_DISABLE_THEMES_DFLT,
  2208. TS_PERF_DISABLE_THEMING, TRUE},
  2209. {PO_ENABLE_ENHANCED_GRAPHICS, PO_ENABLE_ENHANCED_GRAPHICS_DFLT,
  2210. TS_PERF_ENABLE_ENHANCED_GRAPHICS, FALSE},
  2211. {PO_DISABLE_CURSOR_SETTINGS, PO_DISABLE_CURSOR_SETTINGS_DFLT,
  2212. TS_PERF_DISABLE_CURSORSETTINGS, TRUE}
  2213. };
  2214. #define NUM_PERFLUT_ITEMS sizeof(g_perfOptLut)/sizeof(PERFOPTIONS_PERSISTINFO)
  2215. BOOL CTscSettings::ReadPerfOptions(ISettingsStore* pStore)
  2216. {
  2217. BOOL fBitmapPersistence = FALSE;
  2218. BOOL fSetting;
  2219. INT i;
  2220. DC_BEGIN_FN("ReadPerfOptions");
  2221. _dwPerfFlags = 0;
  2222. //
  2223. // Read in the perf settings and insert into the perf flags
  2224. //
  2225. for (i=0; i<NUM_PERFLUT_ITEMS; i++)
  2226. {
  2227. if (pStore->ReadBool( g_perfOptLut[i].szValName,
  2228. g_perfOptLut[i].fDefaultVal,
  2229. &fSetting ))
  2230. {
  2231. if (fSetting)
  2232. {
  2233. _dwPerfFlags |= g_perfOptLut[i].fFlagVal;
  2234. }
  2235. }
  2236. else
  2237. {
  2238. TRC_ERR((TB,_T("ReadBool failed on %s"),
  2239. g_perfOptLut[i].szValName));
  2240. return FALSE;
  2241. }
  2242. }
  2243. #if ((!defined(OS_WINCE)) || (defined(ENABLE_BMP_CACHING_FOR_WINCE)))
  2244. //
  2245. //
  2246. // Bitmap caching
  2247. //
  2248. if(!pStore->ReadBool(UTREG_UI_BITMAP_PERSISTENCE,
  2249. UTREG_UI_BITMAP_PERSISTENCE_DFLT,
  2250. &fBitmapPersistence))
  2251. {
  2252. return E_FAIL;
  2253. }
  2254. #else
  2255. fBitmapPersistence = UTREG_UI_BITMAP_PERSISTENCE_DFLT;
  2256. #endif
  2257. //
  2258. // Internally bitmap persistence (bitmap caching)
  2259. // is passed around as part of the disabled feature list
  2260. // so add it in
  2261. //
  2262. _dwPerfFlags |= (fBitmapPersistence ? 0 :
  2263. TS_PERF_DISABLE_BITMAPCACHING);
  2264. //
  2265. // Enable cursor setting if it was disabled previously.
  2266. //
  2267. _dwPerfFlags &= ~TS_PERF_DISABLE_CURSORSETTINGS;
  2268. DC_END_FN();
  2269. return TRUE;
  2270. }
  2271. BOOL CTscSettings::WritePerfOptions(ISettingsStore* pStore)
  2272. {
  2273. BOOL fSetting;
  2274. INT i;
  2275. DC_BEGIN_FN("WritePerfOptions");
  2276. //
  2277. // Write out the individual perf settings
  2278. //
  2279. for (i=0; i<NUM_PERFLUT_ITEMS; i++)
  2280. {
  2281. fSetting = _dwPerfFlags & g_perfOptLut[i].fFlagVal ? TRUE : FALSE;
  2282. if (!pStore->WriteBool( g_perfOptLut[i].szValName,
  2283. 0, //ignored default
  2284. fSetting,
  2285. g_perfOptLut[i].fForceSave ))
  2286. {
  2287. TRC_ERR((TB,_T("WriteBool failed on %s"),
  2288. g_perfOptLut[i].szValName));
  2289. return FALSE;
  2290. }
  2291. }
  2292. //
  2293. // Fetch and write out the setting for bitmap caching
  2294. //
  2295. BOOL fBitmapPersistence = GetBitmapPersitenceFromPerfFlags();
  2296. if(!pStore->WriteBool(UTREG_UI_BITMAP_PERSISTENCE,
  2297. UTREG_UI_BITMAP_PERSISTENCE_DFLT,
  2298. fBitmapPersistence,
  2299. TRUE))
  2300. {
  2301. return FALSE;
  2302. }
  2303. DC_END_FN();
  2304. return TRUE;
  2305. }