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.

2723 lines
61 KiB

  1. /**MOD+**********************************************************************/
  2. /* Module: advset.cpp */
  3. /* */
  4. /* Class : CMstscAdvSettings */
  5. /* */
  6. /* Purpose: Implements advanced settings for RDP ActiveX control */
  7. /* */
  8. /* Copyright(C) Microsoft Corporation 1999-2000 */
  9. /* */
  10. /* Author : Nadim Abdo (nadima) */
  11. /****************************************************************************/
  12. #include "stdafx.h"
  13. #include "advset.h"
  14. #include "atlwarn.h"
  15. #include "securedset.h"
  16. BEGIN_EXTERN_C
  17. #define TRC_GROUP TRC_GROUP_UI
  18. #define TRC_FILE "advset"
  19. #include <atrcapi.h>
  20. END_EXTERN_C
  21. CMstscAdvSettings::CMstscAdvSettings()
  22. {
  23. m_pUI=NULL;
  24. m_bLockedForWrite=FALSE;
  25. _pAxControl = NULL;
  26. //
  27. // Default is to make self safe for scripting
  28. //
  29. m_bMakeSafeForScripting = TRUE;
  30. }
  31. CMstscAdvSettings::~CMstscAdvSettings()
  32. {
  33. }
  34. BOOL CMstscAdvSettings::SetUI(CUI* pUI)
  35. {
  36. ATLASSERT(pUI);
  37. if(!pUI)
  38. {
  39. return FALSE;
  40. }
  41. m_pUI = pUI;
  42. return TRUE;
  43. }
  44. //
  45. // SmoothScroll property
  46. //
  47. STDMETHODIMP CMstscAdvSettings::put_SmoothScroll(LONG smoothScroll)
  48. {
  49. if(GetLockedForWrite())
  50. {
  51. return E_FAIL;
  52. }
  53. m_pUI->_UI.smoothScrolling = smoothScroll != 0;
  54. return S_OK;
  55. }
  56. STDMETHODIMP CMstscAdvSettings::get_SmoothScroll(LONG* psmoothScroll)
  57. {
  58. ATLASSERT(m_pUI);
  59. if(!psmoothScroll)
  60. {
  61. return E_POINTER;
  62. }
  63. *psmoothScroll = m_pUI->_UI.smoothScrolling;
  64. return S_OK;
  65. }
  66. //
  67. // AcceleratorPassthrough property
  68. //
  69. STDMETHODIMP CMstscAdvSettings::put_AcceleratorPassthrough(LONG acceleratorPassthrough)
  70. {
  71. if(GetLockedForWrite())
  72. {
  73. return E_FAIL;
  74. }
  75. m_pUI->_UI.acceleratorCheckState = acceleratorPassthrough != 0;
  76. return S_OK;
  77. }
  78. STDMETHODIMP CMstscAdvSettings::get_AcceleratorPassthrough(LONG* pacceleratorPassthrough)
  79. {
  80. ATLASSERT(m_pUI);
  81. if(!pacceleratorPassthrough)
  82. {
  83. return E_POINTER;
  84. }
  85. *pacceleratorPassthrough = m_pUI->_UI.acceleratorCheckState;
  86. return S_OK;
  87. }
  88. //
  89. // ShadowBitmap property
  90. //
  91. STDMETHODIMP CMstscAdvSettings::put_ShadowBitmap(LONG shadowBitmap)
  92. {
  93. if(GetLockedForWrite())
  94. {
  95. return E_FAIL;
  96. }
  97. m_pUI->_UI.shadowBitmapEnabled = shadowBitmap != 0;
  98. return S_OK;
  99. }
  100. STDMETHODIMP CMstscAdvSettings::get_ShadowBitmap(LONG* pshadowBitmap)
  101. {
  102. ATLASSERT(m_pUI);
  103. if(!pshadowBitmap)
  104. {
  105. return E_POINTER;
  106. }
  107. *pshadowBitmap = m_pUI->_UI.shadowBitmapEnabled;
  108. return S_OK;
  109. }
  110. //
  111. // TransportType property
  112. //
  113. STDMETHODIMP CMstscAdvSettings::put_TransportType(LONG transportType)
  114. {
  115. HRESULT hr = E_FAIL;
  116. if(GetLockedForWrite())
  117. {
  118. return E_FAIL;
  119. }
  120. //
  121. // Validate - property is redundant today because we only have
  122. // one allowed transport but we keep it for future extensibility
  123. //
  124. if (transportType == UI_TRANSPORT_TYPE_TCP) {
  125. m_pUI->_UI.transportType = (DCUINT16)transportType;
  126. hr = S_OK;
  127. }
  128. else {
  129. hr = E_INVALIDARG;
  130. }
  131. return hr;
  132. }
  133. STDMETHODIMP CMstscAdvSettings::get_TransportType(LONG* ptransportType)
  134. {
  135. ATLASSERT(m_pUI);
  136. if(!ptransportType)
  137. {
  138. return E_POINTER;
  139. }
  140. *ptransportType = m_pUI->_UI.transportType;
  141. return S_OK;
  142. }
  143. //
  144. // SasSequence property
  145. //
  146. STDMETHODIMP CMstscAdvSettings::put_SasSequence(LONG sasSequence)
  147. {
  148. if(GetLockedForWrite())
  149. {
  150. return E_FAIL;
  151. }
  152. m_pUI->_UI.sasSequence = (DCUINT16)sasSequence;
  153. return S_OK;
  154. }
  155. STDMETHODIMP CMstscAdvSettings::get_SasSequence(LONG* psasSequence)
  156. {
  157. ATLASSERT(m_pUI);
  158. if(!psasSequence)
  159. {
  160. return E_POINTER;
  161. }
  162. *psasSequence = m_pUI->_UI.sasSequence;
  163. return S_OK;
  164. }
  165. //
  166. // EncryptionEnabled property
  167. //
  168. STDMETHODIMP CMstscAdvSettings::put_EncryptionEnabled(LONG encryptionEnabled)
  169. {
  170. if(GetLockedForWrite())
  171. {
  172. return E_FAIL;
  173. }
  174. m_pUI->_UI.encryptionEnabled = encryptionEnabled != 0;
  175. return S_OK;
  176. }
  177. STDMETHODIMP CMstscAdvSettings::get_EncryptionEnabled(LONG* pencryptionEnabled)
  178. {
  179. ATLASSERT(m_pUI);
  180. if(!pencryptionEnabled)
  181. {
  182. return E_POINTER;
  183. }
  184. *pencryptionEnabled = m_pUI->_UI.encryptionEnabled;
  185. return S_OK;
  186. }
  187. //
  188. // DedicatedTerminal property
  189. //
  190. STDMETHODIMP CMstscAdvSettings::put_DedicatedTerminal(LONG dedicatedTerminal)
  191. {
  192. if(GetLockedForWrite())
  193. {
  194. return E_FAIL;
  195. }
  196. m_pUI->_UI.dedicatedTerminal = dedicatedTerminal != 0;
  197. return S_OK;
  198. }
  199. STDMETHODIMP CMstscAdvSettings::get_DedicatedTerminal(LONG* pdedicatedTerminal)
  200. {
  201. ATLASSERT(m_pUI);
  202. if(!pdedicatedTerminal)
  203. {
  204. return E_POINTER;
  205. }
  206. *pdedicatedTerminal = m_pUI->_UI.dedicatedTerminal;
  207. return S_OK;
  208. }
  209. //
  210. // MCSPort property
  211. //
  212. STDMETHODIMP CMstscAdvSettings::put_RDPPort(LONG RDPPort)
  213. {
  214. if(GetLockedForWrite())
  215. {
  216. return E_FAIL;
  217. }
  218. if(RDPPort < 0 || RDPPort > 65535)
  219. {
  220. return E_INVALIDARG;
  221. }
  222. m_pUI->_UI.MCSPort = (DCUINT16)RDPPort;
  223. return S_OK;
  224. }
  225. STDMETHODIMP CMstscAdvSettings::get_RDPPort(LONG* pRDPPort)
  226. {
  227. if(!pRDPPort)
  228. {
  229. return E_POINTER;
  230. }
  231. *pRDPPort = m_pUI->_UI.MCSPort;
  232. return S_OK;
  233. }
  234. //
  235. // EnableMouse property
  236. //
  237. STDMETHODIMP CMstscAdvSettings::put_EnableMouse(LONG enableMouse)
  238. {
  239. //
  240. // Deprecated
  241. //
  242. return S_FALSE;
  243. }
  244. STDMETHODIMP CMstscAdvSettings::get_EnableMouse(LONG* penableMouse)
  245. {
  246. //
  247. // Deprecated
  248. //
  249. return S_FALSE;
  250. }
  251. //
  252. // DisableCtrlAltDel property
  253. //
  254. STDMETHODIMP CMstscAdvSettings::put_DisableCtrlAltDel(LONG disableCtrlAltDel)
  255. {
  256. if(GetLockedForWrite())
  257. {
  258. return E_FAIL;
  259. }
  260. m_pUI->_UI.fDisableCtrlAltDel = disableCtrlAltDel != 0;
  261. return S_OK;
  262. }
  263. STDMETHODIMP CMstscAdvSettings::get_DisableCtrlAltDel(LONG* pdisableCtrlAltDel)
  264. {
  265. ATLASSERT(m_pUI);
  266. if(!pdisableCtrlAltDel)
  267. {
  268. return E_POINTER;
  269. }
  270. *pdisableCtrlAltDel = m_pUI->_UI.fDisableCtrlAltDel;
  271. return S_OK;
  272. }
  273. //
  274. // EnableWindowsKey property
  275. //
  276. STDMETHODIMP CMstscAdvSettings::put_EnableWindowsKey(LONG enableWindowsKey)
  277. {
  278. if(GetLockedForWrite())
  279. {
  280. return E_FAIL;
  281. }
  282. m_pUI->_UI.fEnableWindowsKey = enableWindowsKey != 0;
  283. return S_OK;
  284. }
  285. STDMETHODIMP CMstscAdvSettings::get_EnableWindowsKey(LONG* penableWindowsKey)
  286. {
  287. ATLASSERT(m_pUI);
  288. if(!penableWindowsKey)
  289. {
  290. return E_POINTER;
  291. }
  292. *penableWindowsKey = m_pUI->_UI.fEnableWindowsKey;
  293. return S_OK;
  294. }
  295. //
  296. // DoubleClickDetect property
  297. //
  298. STDMETHODIMP CMstscAdvSettings::put_DoubleClickDetect(LONG doubleClickDetect)
  299. {
  300. if(GetLockedForWrite())
  301. {
  302. return E_FAIL;
  303. }
  304. m_pUI->_UI.fDoubleClickDetect = doubleClickDetect != 0;
  305. return S_OK;
  306. }
  307. STDMETHODIMP CMstscAdvSettings::get_DoubleClickDetect(LONG* pdoubleClickDetect)
  308. {
  309. ATLASSERT(m_pUI);
  310. if(!pdoubleClickDetect)
  311. {
  312. return E_POINTER;
  313. }
  314. *pdoubleClickDetect = m_pUI->_UI.fDoubleClickDetect;
  315. return S_OK;
  316. }
  317. //
  318. // MaximizeShell property
  319. //
  320. STDMETHODIMP CMstscAdvSettings::put_MaximizeShell(LONG maximizeShell)
  321. {
  322. if(GetLockedForWrite())
  323. {
  324. return E_FAIL;
  325. }
  326. m_pUI->_UI.fMaximizeShell = maximizeShell != 0;
  327. return S_OK;
  328. }
  329. STDMETHODIMP CMstscAdvSettings::get_MaximizeShell(LONG* pmaximizeShell)
  330. {
  331. ATLASSERT(m_pUI);
  332. if(!pmaximizeShell)
  333. {
  334. return E_POINTER;
  335. }
  336. *pmaximizeShell = m_pUI->_UI.fMaximizeShell;
  337. return S_OK;
  338. }
  339. //
  340. // HotKeyFullScreen property
  341. //
  342. STDMETHODIMP CMstscAdvSettings::put_HotKeyFullScreen(LONG hotKeyFullScreen)
  343. {
  344. if(GetLockedForWrite())
  345. {
  346. return E_FAIL;
  347. }
  348. m_pUI->_UI.hotKey.fullScreen = hotKeyFullScreen;
  349. return S_OK;
  350. }
  351. STDMETHODIMP CMstscAdvSettings::get_HotKeyFullScreen(LONG* photKeyFullScreen)
  352. {
  353. ATLASSERT(m_pUI);
  354. if(!photKeyFullScreen)
  355. {
  356. return E_POINTER;
  357. }
  358. *photKeyFullScreen = m_pUI->_UI.hotKey.fullScreen;
  359. return S_OK;
  360. }
  361. //
  362. // HotKeyCtrlEsc property
  363. //
  364. STDMETHODIMP CMstscAdvSettings::put_HotKeyCtrlEsc(LONG hotKeyCtrlEsc)
  365. {
  366. if(GetLockedForWrite())
  367. {
  368. return E_FAIL;
  369. }
  370. m_pUI->_UI.hotKey.ctrlEsc = hotKeyCtrlEsc;
  371. return S_OK;
  372. }
  373. STDMETHODIMP CMstscAdvSettings::get_HotKeyCtrlEsc(LONG* photKeyCtrlEsc)
  374. {
  375. ATLASSERT(m_pUI);
  376. if(!photKeyCtrlEsc)
  377. {
  378. return E_POINTER;
  379. }
  380. *photKeyCtrlEsc = m_pUI->_UI.hotKey.ctrlEsc;
  381. return S_OK;
  382. }
  383. //
  384. // HotKeyAltEsc property
  385. //
  386. STDMETHODIMP CMstscAdvSettings::put_HotKeyAltEsc(LONG hotKeyAltEsc)
  387. {
  388. if(GetLockedForWrite())
  389. {
  390. return E_FAIL;
  391. }
  392. m_pUI->_UI.hotKey.altEsc = hotKeyAltEsc;
  393. return S_OK;
  394. }
  395. STDMETHODIMP CMstscAdvSettings::get_HotKeyAltEsc(LONG* photKeyAltEsc)
  396. {
  397. ATLASSERT(m_pUI);
  398. if(!photKeyAltEsc)
  399. {
  400. return E_POINTER;
  401. }
  402. *photKeyAltEsc = m_pUI->_UI.hotKey.altEsc;
  403. return S_OK;
  404. }
  405. //
  406. // HotKeyAltTab property
  407. //
  408. STDMETHODIMP CMstscAdvSettings::put_HotKeyAltTab(LONG hotKeyAltTab)
  409. {
  410. if(GetLockedForWrite())
  411. {
  412. return E_FAIL;
  413. }
  414. m_pUI->_UI.hotKey.altTab = hotKeyAltTab;
  415. return S_OK;
  416. }
  417. STDMETHODIMP CMstscAdvSettings::get_HotKeyAltTab(LONG* photKeyAltTab)
  418. {
  419. ATLASSERT(m_pUI);
  420. if(!photKeyAltTab)
  421. {
  422. return E_POINTER;
  423. }
  424. *photKeyAltTab = m_pUI->_UI.hotKey.altTab;
  425. return S_OK;
  426. }
  427. //
  428. // HotKeyAltShiftTab property
  429. //
  430. STDMETHODIMP CMstscAdvSettings::put_HotKeyAltShiftTab(LONG hotKeyAltShiftTab)
  431. {
  432. if(GetLockedForWrite())
  433. {
  434. return E_FAIL;
  435. }
  436. m_pUI->_UI.hotKey.altShifttab = hotKeyAltShiftTab;
  437. return S_OK;
  438. }
  439. STDMETHODIMP CMstscAdvSettings::get_HotKeyAltShiftTab(LONG* photKeyAltShiftTab)
  440. {
  441. ATLASSERT(m_pUI);
  442. if(!photKeyAltShiftTab)
  443. {
  444. return E_POINTER;
  445. }
  446. *photKeyAltShiftTab = m_pUI->_UI.hotKey.altShifttab;
  447. return S_OK;
  448. }
  449. //
  450. // HotKeyAltSpace property
  451. //
  452. STDMETHODIMP CMstscAdvSettings::put_HotKeyAltSpace(LONG hotKeyAltSpace)
  453. {
  454. if(GetLockedForWrite())
  455. {
  456. return E_FAIL;
  457. }
  458. m_pUI->_UI.hotKey.altSpace = hotKeyAltSpace;
  459. return S_OK;
  460. }
  461. STDMETHODIMP CMstscAdvSettings::get_HotKeyAltSpace(LONG* photKeyAltSpace)
  462. {
  463. ATLASSERT(m_pUI);
  464. if(!photKeyAltSpace)
  465. {
  466. return E_POINTER;
  467. }
  468. *photKeyAltSpace = m_pUI->_UI.hotKey.altSpace;
  469. return S_OK;
  470. }
  471. //
  472. // HotKeyCtrlAltDel property
  473. //
  474. STDMETHODIMP CMstscAdvSettings::put_HotKeyCtrlAltDel(LONG hotKeyCtrlAltDel)
  475. {
  476. if(GetLockedForWrite())
  477. {
  478. return E_FAIL;
  479. }
  480. m_pUI->_UI.hotKey.ctlrAltdel = hotKeyCtrlAltDel;
  481. return S_OK;
  482. }
  483. STDMETHODIMP CMstscAdvSettings::get_HotKeyCtrlAltDel(LONG* photKeyCtrlAltDel)
  484. {
  485. ATLASSERT(m_pUI);
  486. if(!photKeyCtrlAltDel)
  487. {
  488. return E_POINTER;
  489. }
  490. *photKeyCtrlAltDel = m_pUI->_UI.hotKey.ctlrAltdel;
  491. return S_OK;
  492. }
  493. //
  494. // Compress property
  495. //
  496. STDMETHODIMP CMstscAdvSettings::put_Compress(LONG compress)
  497. {
  498. if(GetLockedForWrite())
  499. {
  500. return E_FAIL;
  501. }
  502. m_pUI->UI_SetCompress(compress != 0);
  503. return S_OK;
  504. }
  505. STDMETHODIMP CMstscAdvSettings::get_Compress(LONG* pcompress)
  506. {
  507. ATLASSERT(m_pUI);
  508. if(!pcompress)
  509. {
  510. return E_POINTER;
  511. }
  512. *pcompress = m_pUI->UI_GetCompress();
  513. return S_OK;
  514. }
  515. //
  516. // BitmapPeristence property
  517. //
  518. STDMETHODIMP CMstscAdvSettings::put_BitmapPeristence(LONG bitmapPeristence)
  519. {
  520. if(GetLockedForWrite())
  521. {
  522. return E_FAIL;
  523. }
  524. m_pUI->_UI.fBitmapPersistence = (bitmapPeristence != 0);
  525. return S_OK;
  526. }
  527. STDMETHODIMP CMstscAdvSettings::get_BitmapPeristence(LONG* pbitmapPeristence)
  528. {
  529. ATLASSERT(m_pUI);
  530. if(!pbitmapPeristence)
  531. {
  532. return E_POINTER;
  533. }
  534. *pbitmapPeristence = m_pUI->_UI.fBitmapPersistence;
  535. return S_OK;
  536. }
  537. //
  538. // BitmapPersistence property
  539. //
  540. STDMETHODIMP CMstscAdvSettings::put_BitmapPersistence(LONG bitmapPersistence)
  541. {
  542. //Call on older incorrectly spelled property
  543. return put_BitmapPeristence(bitmapPersistence);
  544. }
  545. STDMETHODIMP CMstscAdvSettings::get_BitmapPersistence(LONG* pbitmapPersistence)
  546. {
  547. //Call on older incorrectly spelled property
  548. return get_BitmapPeristence(pbitmapPersistence);
  549. }
  550. //
  551. ////////////////////////////////////////////////////////////////////////////////////
  552. //
  553. // orderDrawThreshold property
  554. //
  555. STDMETHODIMP CMstscAdvSettings::put_orderDrawThreshold(LONG orderDrawThreshold)
  556. {
  557. //
  558. // Deprecated
  559. //
  560. return S_FALSE;
  561. }
  562. STDMETHODIMP CMstscAdvSettings::get_orderDrawThreshold(LONG* porderDrawThreshold)
  563. {
  564. //
  565. // Deprecated
  566. //
  567. return S_FALSE;
  568. }
  569. //
  570. // BitmapCacheSize property
  571. //
  572. STDMETHODIMP CMstscAdvSettings::put_BitmapCacheSize(LONG bitmapCacheSize)
  573. {
  574. if(GetLockedForWrite())
  575. {
  576. return E_FAIL;
  577. }
  578. #ifndef OS_WINCE
  579. if (bitmapCacheSize > 0 && bitmapCacheSize <= TSC_MAX_BITMAPCACHESIZE)
  580. #else //bitmap cache size is measured in KB and TSC_MAX_BITMAPCACHESIZE is in MB
  581. if (bitmapCacheSize > 0 && bitmapCacheSize <= TSC_MAX_BITMAPCACHESIZE*1024)
  582. #endif
  583. {
  584. m_pUI->_UI.RegBitmapCacheSize = bitmapCacheSize;
  585. return S_OK;
  586. }
  587. else
  588. {
  589. return E_INVALIDARG;
  590. }
  591. }
  592. STDMETHODIMP CMstscAdvSettings::get_BitmapCacheSize(LONG* pbitmapCacheSize)
  593. {
  594. ATLASSERT(m_pUI);
  595. if(!pbitmapCacheSize)
  596. {
  597. return E_POINTER;
  598. }
  599. *pbitmapCacheSize = m_pUI->_UI.RegBitmapCacheSize;
  600. return S_OK;
  601. }
  602. //
  603. // BitmapVirtualCacheSize property
  604. //
  605. // TSAC's v1.0 only property for cache file size.
  606. // In whistler applies to 8bpp cache file
  607. // See BitmapVirtualCache16BppSize/24BppSize methods
  608. //
  609. STDMETHODIMP CMstscAdvSettings::put_BitmapVirtualCacheSize(
  610. LONG bitmapVirtualCacheSize)
  611. {
  612. if(GetLockedForWrite())
  613. {
  614. return E_FAIL;
  615. }
  616. if (bitmapVirtualCacheSize > 0 &&
  617. bitmapVirtualCacheSize <= TSC_MAX_BITMAPCACHESIZE)
  618. {
  619. m_pUI->_UI.RegBitmapVirtualCache8BppSize = bitmapVirtualCacheSize;
  620. }
  621. else
  622. {
  623. return E_INVALIDARG;
  624. }
  625. return S_OK;
  626. }
  627. STDMETHODIMP CMstscAdvSettings::get_BitmapVirtualCacheSize(
  628. LONG* pbitmapVirtualCacheSize)
  629. {
  630. if(!pbitmapVirtualCacheSize)
  631. {
  632. return E_POINTER;
  633. }
  634. *pbitmapVirtualCacheSize = m_pUI->_UI.RegBitmapVirtualCache8BppSize;
  635. return S_OK;
  636. }
  637. //
  638. // ScaleBitmapCachesByBPP property
  639. //
  640. STDMETHODIMP CMstscAdvSettings::put_ScaleBitmapCachesByBPP(LONG bScale)
  641. {
  642. //
  643. // Deprecated
  644. //
  645. return S_FALSE;
  646. }
  647. STDMETHODIMP CMstscAdvSettings::get_ScaleBitmapCachesByBPP(LONG *pbScale)
  648. {
  649. //
  650. // Deprecated
  651. //
  652. return S_FALSE;
  653. }
  654. //
  655. // NumBitmapCaches property
  656. //
  657. STDMETHODIMP CMstscAdvSettings::put_NumBitmapCaches(LONG numBitmapCaches)
  658. {
  659. //
  660. // Deprecated
  661. //
  662. return S_FALSE;
  663. }
  664. STDMETHODIMP CMstscAdvSettings::get_NumBitmapCaches(LONG* pnumBitmapCaches)
  665. {
  666. //
  667. // Deprecated
  668. //
  669. return S_FALSE;
  670. }
  671. //
  672. // CachePersistenceActive property
  673. //
  674. STDMETHODIMP CMstscAdvSettings::put_CachePersistenceActive(LONG cachePersistenceActive)
  675. {
  676. if(GetLockedForWrite())
  677. {
  678. return E_FAIL;
  679. }
  680. m_pUI->_UI.RegPersistenceActive = cachePersistenceActive != 0;
  681. return S_OK;
  682. }
  683. STDMETHODIMP CMstscAdvSettings::get_CachePersistenceActive(LONG* pcachePersistenceActive)
  684. {
  685. ATLASSERT(m_pUI);
  686. if(!pcachePersistenceActive)
  687. {
  688. return E_POINTER;
  689. }
  690. *pcachePersistenceActive = m_pUI->_UI.RegPersistenceActive;
  691. return S_OK;
  692. }
  693. //
  694. // brushSupportLevel property
  695. //
  696. STDMETHODIMP CMstscAdvSettings::put_brushSupportLevel(LONG brushSupportLevel)
  697. {
  698. //
  699. // Deprecated
  700. //
  701. return S_FALSE;
  702. }
  703. STDMETHODIMP CMstscAdvSettings::get_brushSupportLevel(LONG* pbrushSupportLevel)
  704. {
  705. //
  706. // Deprecated
  707. //
  708. return S_FALSE;
  709. }
  710. //
  711. // put_PersistCacheDirectory property (Set only)
  712. //
  713. STDMETHODIMP CMstscAdvSettings::put_PersistCacheDirectory(BSTR PersistCacheDirectory)
  714. {
  715. //
  716. // Deprecated
  717. //
  718. return S_FALSE;
  719. }
  720. //
  721. // minInputSendInterval property
  722. //
  723. STDMETHODIMP CMstscAdvSettings::put_minInputSendInterval(LONG minInputSendInterval)
  724. {
  725. //
  726. // Deprecated
  727. //
  728. return S_FALSE;
  729. }
  730. STDMETHODIMP CMstscAdvSettings::get_minInputSendInterval(LONG* pminInputSendInterval)
  731. {
  732. //
  733. // Deprecated
  734. //
  735. return S_FALSE;
  736. }
  737. //
  738. // InputEventsAtOnce property
  739. //
  740. STDMETHODIMP CMstscAdvSettings::put_InputEventsAtOnce(LONG inputEventsAtOnce)
  741. {
  742. //
  743. // Deprecated
  744. //
  745. return S_FALSE;
  746. }
  747. STDMETHODIMP CMstscAdvSettings::get_InputEventsAtOnce(LONG* pinputEventsAtOnce)
  748. {
  749. //
  750. // Deprecated
  751. //
  752. return S_FALSE;
  753. }
  754. //
  755. // maxEventCount property
  756. //
  757. STDMETHODIMP CMstscAdvSettings::put_maxEventCount(LONG maxEventCount)
  758. {
  759. //
  760. // Deprecated
  761. //
  762. return S_FALSE;
  763. }
  764. STDMETHODIMP CMstscAdvSettings::get_maxEventCount(LONG* pmaxEventCount)
  765. {
  766. //
  767. // Deprecated
  768. //
  769. return S_FALSE;
  770. }
  771. //
  772. // keepAliveInterval property
  773. //
  774. STDMETHODIMP CMstscAdvSettings::put_keepAliveInterval(LONG keepAliveInterval)
  775. {
  776. HRESULT hr;
  777. if(GetLockedForWrite()) {
  778. return E_FAIL;
  779. }
  780. if (keepAliveInterval >= MIN_KEEP_ALIVE_INTERVAL ||
  781. KEEP_ALIVE_INTERVAL_OFF == keepAliveInterval) {
  782. m_pUI->_UI.keepAliveInterval = keepAliveInterval;
  783. hr = S_OK;
  784. }
  785. else {
  786. hr = E_INVALIDARG;
  787. }
  788. return hr;
  789. }
  790. STDMETHODIMP CMstscAdvSettings::get_keepAliveInterval(LONG* pkeepAliveInterval)
  791. {
  792. ATLASSERT(m_pUI);
  793. if(!pkeepAliveInterval)
  794. {
  795. return E_POINTER;
  796. }
  797. *pkeepAliveInterval = m_pUI->_UI.keepAliveInterval;
  798. return S_OK;
  799. }
  800. //
  801. // allowBackgroundInput property
  802. //
  803. STDMETHODIMP CMstscAdvSettings::put_allowBackgroundInput(LONG allowBackgroundInput)
  804. {
  805. if (!m_bMakeSafeForScripting) {
  806. if(GetLockedForWrite()) {
  807. return E_FAIL;
  808. }
  809. m_pUI->_UI.allowBackgroundInput = allowBackgroundInput != 0;
  810. return S_OK;
  811. }
  812. else {
  813. //
  814. // Deprecated when SFS
  815. //
  816. return S_FALSE;
  817. }
  818. }
  819. STDMETHODIMP CMstscAdvSettings::get_allowBackgroundInput(LONG* pallowBackgroundInput)
  820. {
  821. if (!m_bMakeSafeForScripting) {
  822. if(!pallowBackgroundInput) {
  823. return E_POINTER;
  824. }
  825. *pallowBackgroundInput = m_pUI->_UI.allowBackgroundInput;
  826. return S_OK;
  827. }
  828. else {
  829. //
  830. // Deprecated when SFS
  831. //
  832. return S_FALSE;
  833. }
  834. }
  835. //
  836. // KeyBoardLayoutStr property (put only)
  837. //
  838. STDMETHODIMP CMstscAdvSettings::put_KeyBoardLayoutStr(BSTR KeyBoardLayoutStr)
  839. {
  840. HRESULT hr = E_FAIL;
  841. if(GetLockedForWrite())
  842. {
  843. return E_FAIL;
  844. }
  845. if (KeyBoardLayoutStr) {
  846. hr = CUT::StringPropPut(m_pUI->_UI.szKeyBoardLayoutStr,
  847. SIZE_TCHARS(m_pUI->_UI.szKeyBoardLayoutStr),
  848. KeyBoardLayoutStr);
  849. }
  850. else {
  851. m_pUI->_UI.szKeyBoardLayoutStr[0] = NULL;
  852. hr = S_OK;
  853. }
  854. return hr;
  855. }
  856. //
  857. // shutdownTimeout property
  858. //
  859. STDMETHODIMP CMstscAdvSettings::put_shutdownTimeout(LONG shutdownTimeout)
  860. {
  861. HRESULT hr;
  862. if(GetLockedForWrite()) {
  863. return E_FAIL;
  864. }
  865. if (shutdownTimeout < MAX_TIMEOUT_SECONDS) {
  866. m_pUI->_UI.shutdownTimeout = shutdownTimeout;
  867. hr = S_OK;
  868. }
  869. else {
  870. hr = E_INVALIDARG;
  871. }
  872. return hr;
  873. }
  874. STDMETHODIMP CMstscAdvSettings::get_shutdownTimeout(LONG* pshutdownTimeout)
  875. {
  876. ATLASSERT(m_pUI);
  877. if(!pshutdownTimeout)
  878. {
  879. return E_POINTER;
  880. }
  881. *pshutdownTimeout = m_pUI->_UI.shutdownTimeout;
  882. return S_OK;
  883. }
  884. //
  885. // overallConnectionTimeout property
  886. //
  887. STDMETHODIMP CMstscAdvSettings::put_overallConnectionTimeout(LONG overallConnectionTimeout)
  888. {
  889. HRESULT hr;
  890. if(GetLockedForWrite()) {
  891. return E_FAIL;
  892. }
  893. if (overallConnectionTimeout < MAX_TIMEOUT_SECONDS) {
  894. m_pUI->_UI.connectionTimeOut = overallConnectionTimeout;
  895. hr = S_OK;
  896. }
  897. else {
  898. hr = E_INVALIDARG;
  899. }
  900. return hr;
  901. }
  902. STDMETHODIMP CMstscAdvSettings::get_overallConnectionTimeout(LONG* poverallConnectionTimeout)
  903. {
  904. ATLASSERT(m_pUI);
  905. if(!poverallConnectionTimeout)
  906. {
  907. return E_POINTER;
  908. }
  909. *poverallConnectionTimeout = m_pUI->_UI.connectionTimeOut;
  910. return S_OK;
  911. }
  912. //
  913. // singleConnectionTimeout property
  914. //
  915. STDMETHODIMP CMstscAdvSettings::put_singleConnectionTimeout(LONG singleConnectionTimeout)
  916. {
  917. HRESULT hr;
  918. if(GetLockedForWrite()) {
  919. return E_FAIL;
  920. }
  921. if (singleConnectionTimeout < MAX_TIMEOUT_SECONDS) {
  922. m_pUI->_UI.singleTimeout = singleConnectionTimeout;
  923. hr = S_OK;
  924. }
  925. else {
  926. hr = E_INVALIDARG;
  927. }
  928. return hr;
  929. }
  930. STDMETHODIMP CMstscAdvSettings::get_singleConnectionTimeout(LONG* psingleConnectionTimeout)
  931. {
  932. ATLASSERT(m_pUI);
  933. if(!psingleConnectionTimeout)
  934. {
  935. return E_POINTER;
  936. }
  937. *psingleConnectionTimeout = m_pUI->_UI.singleTimeout;
  938. return S_OK;
  939. }
  940. //
  941. // KeyboardType property
  942. //
  943. STDMETHODIMP CMstscAdvSettings::put_KeyboardType(LONG keyboardType)
  944. {
  945. #ifndef OS_WINCE
  946. UNREFERENCED_PARAMETER(keyboardType);
  947. return E_NOTIMPL;
  948. #else
  949. if(GetLockedForWrite())
  950. {
  951. return E_FAIL;
  952. }
  953. m_pUI->_UI.winceKeyboardType = keyboardType;
  954. return S_OK;
  955. #endif
  956. }
  957. STDMETHODIMP CMstscAdvSettings::get_KeyboardType(LONG* pkeyboardType)
  958. {
  959. #ifndef OS_WINCE
  960. UNREFERENCED_PARAMETER(pkeyboardType);
  961. return E_NOTIMPL;
  962. #else
  963. if(!pkeyboardType)
  964. {
  965. return E_POINTER;
  966. }
  967. *pkeyboardType = m_pUI->_UI.winceKeyboardType;
  968. return S_OK;
  969. #endif
  970. }
  971. //
  972. // KeyboardSubType property
  973. //
  974. STDMETHODIMP CMstscAdvSettings::put_KeyboardSubType(LONG keyboardSubType)
  975. {
  976. #ifndef OS_WINCE
  977. UNREFERENCED_PARAMETER(keyboardSubType);
  978. return E_NOTIMPL;
  979. #else
  980. if(GetLockedForWrite())
  981. {
  982. return E_FAIL;
  983. }
  984. m_pUI->_UI.winceKeyboardSubType = keyboardSubType;
  985. return S_OK;
  986. #endif
  987. }
  988. STDMETHODIMP CMstscAdvSettings::get_KeyboardSubType(LONG* pkeyboardSubType)
  989. {
  990. #ifndef OS_WINCE
  991. UNREFERENCED_PARAMETER(pkeyboardSubType);
  992. return E_NOTIMPL;
  993. #else
  994. if(!pkeyboardSubType)
  995. {
  996. return E_POINTER;
  997. }
  998. *pkeyboardSubType = m_pUI->_UI.winceKeyboardSubType;
  999. return S_OK;
  1000. #endif
  1001. }
  1002. //
  1003. // KeyboardFunctionKey property
  1004. //
  1005. STDMETHODIMP CMstscAdvSettings::put_KeyboardFunctionKey(LONG keyboardFunctionKey)
  1006. {
  1007. #ifndef OS_WINCE
  1008. UNREFERENCED_PARAMETER(keyboardFunctionKey);
  1009. return E_NOTIMPL;
  1010. #else
  1011. if(GetLockedForWrite())
  1012. {
  1013. return E_FAIL;
  1014. }
  1015. m_pUI->_UI.winceKeyboardFunctionKey = keyboardFunctionKey;
  1016. return S_OK;
  1017. #endif
  1018. }
  1019. STDMETHODIMP CMstscAdvSettings::get_KeyboardFunctionKey(LONG* pkeyboardFunctionKey)
  1020. {
  1021. #ifndef OS_WINCE
  1022. UNREFERENCED_PARAMETER(pkeyboardFunctionKey);
  1023. return E_NOTIMPL;
  1024. #else
  1025. if(!pkeyboardFunctionKey)
  1026. {
  1027. return E_POINTER;
  1028. }
  1029. *pkeyboardFunctionKey = m_pUI->_UI.winceKeyboardFunctionKey;
  1030. return S_OK;
  1031. #endif
  1032. }
  1033. //
  1034. // WinceFixedPalette property
  1035. //
  1036. STDMETHODIMP CMstscAdvSettings::put_WinceFixedPalette(LONG WinceFixedPalette)
  1037. {
  1038. #ifndef OS_WINCE
  1039. UNREFERENCED_PARAMETER(WinceFixedPalette);
  1040. return E_NOTIMPL;
  1041. #else
  1042. //
  1043. // Fix for WINCE
  1044. //
  1045. return E_NOTIMPL;
  1046. #endif
  1047. }
  1048. STDMETHODIMP CMstscAdvSettings::get_WinceFixedPalette(LONG* pWinceFixedPalette)
  1049. {
  1050. #ifndef OS_WINCE
  1051. UNREFERENCED_PARAMETER(pWinceFixedPalette);
  1052. return E_NOTIMPL;
  1053. #else
  1054. //
  1055. // Fix for WINCE
  1056. //
  1057. return E_NOTIMPL;
  1058. #endif
  1059. }
  1060. //
  1061. // PluginDlls
  1062. //
  1063. STDMETHODIMP CMstscAdvSettings::put_PluginDlls(BSTR PluginDlls)
  1064. {
  1065. DC_BEGIN_FN("put_PluginDlls");
  1066. if(GetLockedForWrite())
  1067. {
  1068. return E_FAIL;
  1069. }
  1070. if (PluginDlls)
  1071. {
  1072. LPTSTR szPlugins = (LPTSTR)(PluginDlls);
  1073. //
  1074. //SECURITY!!!
  1075. //If we are safe for scripting, the plugin list
  1076. //must be verified to ensure it contains just dll names (no paths)
  1077. //Then a system defined base path is prepended to each dll name
  1078. //
  1079. if(m_bMakeSafeForScripting)
  1080. {
  1081. BOOL bIsSecureDllList = IsSecureDllList(szPlugins);
  1082. if(bIsSecureDllList)
  1083. {
  1084. LPTSTR szExplicitPathDllList =
  1085. CreateExplicitPathList(szPlugins);
  1086. if(szExplicitPathDllList)
  1087. {
  1088. m_pUI->UI_SetVChanAddinList(szExplicitPathDllList);
  1089. LocalFree(szExplicitPathDllList);
  1090. }
  1091. else
  1092. {
  1093. //
  1094. // Unable to create an explicit path list
  1095. //
  1096. TRC_ERR((TB,_T("CreateExplicitPathList failed for %s"),
  1097. szPlugins));
  1098. return E_FAIL;
  1099. }
  1100. }
  1101. else
  1102. {
  1103. TRC_ERR((TB,_T("IsSecureDllList failed for %s"), szPlugins));
  1104. return E_FAIL;
  1105. }
  1106. }
  1107. else
  1108. {
  1109. //
  1110. // Don't need to be safe for an untrusted caller
  1111. // just pass in the vcahn plugin list directly to the core
  1112. //
  1113. m_pUI->UI_SetVChanAddinList( szPlugins);
  1114. }
  1115. }
  1116. else
  1117. {
  1118. m_pUI->UI_SetVChanAddinList(NULL);
  1119. }
  1120. DC_END_FN();
  1121. return S_OK;
  1122. }
  1123. //
  1124. // IsSecureDllList
  1125. // determines if the CSV list of dlls in szDllList is secure
  1126. // the criteria we use are
  1127. // only dll names can be specified. NO PATHS, NO NETWORK SHARES.
  1128. //
  1129. BOOL CMstscAdvSettings::IsSecureDllList(LPCTSTR szDllList)
  1130. {
  1131. ATLASSERT(szDllList);
  1132. if(szDllList)
  1133. {
  1134. //
  1135. // The only allowed values are alphanumeric characters
  1136. // '.' and ','.
  1137. //
  1138. LPCTSTR psz = szDllList;
  1139. while (*psz) {
  1140. if (!(iswalnum(*psz) || *psz == _T(',') || *psz == _T('.'))) {
  1141. return FALSE;
  1142. }
  1143. psz++;
  1144. }
  1145. //
  1146. // Check for evil characters '/\%'
  1147. //
  1148. if(_tcspbrk( szDllList, TEXT("/\\%")))
  1149. {
  1150. return FALSE;
  1151. }
  1152. //
  1153. // Now check for '..'
  1154. //
  1155. if(_tcsstr( szDllList, TEXT("..")))
  1156. {
  1157. return FALSE;
  1158. }
  1159. return TRUE;
  1160. }
  1161. else
  1162. {
  1163. return FALSE;
  1164. }
  1165. }
  1166. #define TS_VDLLPATH_KEYNAME TEXT("SOFTWARE\\Microsoft\\Terminal Server Client")
  1167. #define TS_VDLLPATH TEXT("vdllpath")
  1168. //
  1169. // CreateExplicitPathList
  1170. // params:
  1171. // szDllList - CSV list of dll names
  1172. // returns:
  1173. // CSV list of Dlls with explicit paths. Or NULL on error.
  1174. // ******CALLER MUST FREE RETURN STRING****
  1175. //
  1176. // Path prefix is taken from registry, or default value of system32
  1177. // if no registry setting is specified
  1178. //
  1179. //
  1180. LPTSTR CMstscAdvSettings::CreateExplicitPathList(LPCTSTR szDllList)
  1181. {
  1182. HKEY hKey;
  1183. LONG retVal;
  1184. BOOL bGotPathPrefix = FALSE;
  1185. int i;
  1186. LPTSTR szExplicitPathList = NULL;
  1187. LPTSTR szDllListTmp = NULL;
  1188. HRESULT hr;
  1189. TCHAR szPathPrefix[MAX_PATH];
  1190. if(!szDllList || !*szDllList)
  1191. {
  1192. return NULL;
  1193. }
  1194. //
  1195. // Try to get a path prefix from the registry
  1196. //
  1197. retVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  1198. TS_VDLLPATH_KEYNAME,
  1199. 0,
  1200. KEY_READ,
  1201. &hKey);
  1202. if(ERROR_SUCCESS == retVal)
  1203. {
  1204. DWORD cbData = sizeof(szPathPrefix);
  1205. DWORD dwType;
  1206. retVal = RegQueryValueEx(hKey, TS_VDLLPATH, NULL, &dwType,
  1207. (PBYTE)&szPathPrefix,
  1208. &cbData);
  1209. if(ERROR_SUCCESS == retVal && REG_SZ == dwType)
  1210. {
  1211. //
  1212. // validate that the vdllpath does not contain any '\\'
  1213. // we don't just check the first char because someone
  1214. // could just pad with whitespace.
  1215. // This is done because network shares are not allowed
  1216. // for the dll path prefix
  1217. //
  1218. if((cbData >= 2 * sizeof(TCHAR)) &&
  1219. (_tcsstr( szPathPrefix, TEXT("\\\\"))))
  1220. {
  1221. //security violation, return failure
  1222. return NULL;
  1223. }
  1224. else
  1225. {
  1226. bGotPathPrefix = TRUE;
  1227. }
  1228. }
  1229. RegCloseKey(hKey);
  1230. }
  1231. if(!bGotPathPrefix)
  1232. {
  1233. #ifndef OS_WINCE
  1234. //Use default value of the system32 directory
  1235. if(!GetSystemDirectory( szPathPrefix, sizeof(szPathPrefix)/sizeof(TCHAR)))
  1236. {
  1237. return NULL;
  1238. }
  1239. else
  1240. {
  1241. bGotPathPrefix = TRUE;
  1242. }
  1243. #else
  1244. //CE doesn't have a GetSystemDirectory directory
  1245. return NULL;
  1246. #endif
  1247. }
  1248. int cbDllListLen = _tcslen(szDllList) * sizeof(TCHAR) + sizeof(TCHAR);
  1249. szDllListTmp = (LPTSTR) LocalAlloc(LPTR, cbDllListLen);
  1250. if(NULL == szDllListTmp)
  1251. {
  1252. return NULL;
  1253. }
  1254. //
  1255. // szDllListTmp is allocated large enough to hold
  1256. // the szDllList so no need to length validate the copy
  1257. //
  1258. hr = StringCbCopy(szDllListTmp, cbDllListLen, szDllList);
  1259. if (FAILED(hr)) {
  1260. LocalFree(szDllListTmp);
  1261. return NULL;
  1262. }
  1263. int countDlls = 0;
  1264. LPTSTR DllNames[CHANNEL_MAX_COUNT];
  1265. for(i=0; i<CHANNEL_MAX_COUNT; i++)
  1266. {
  1267. DllNames[i] = NULL;
  1268. }
  1269. //
  1270. // Create an array of dllnames
  1271. // pointers in DllNames point inplace to substrings in szDllListTmp
  1272. //
  1273. BOOL bCurCharIsStart = FALSE;
  1274. DllNames[0] = szDllListTmp;
  1275. countDlls = 1;
  1276. LPTSTR sz = szDllListTmp;
  1277. while(*sz)
  1278. {
  1279. if(bCurCharIsStart)
  1280. {
  1281. DllNames[countDlls++] = sz;
  1282. if(countDlls > CHANNEL_MAX_COUNT)
  1283. {
  1284. //ABORT
  1285. LocalFree(szDllListTmp);
  1286. return NULL;
  1287. }
  1288. //Reset
  1289. bCurCharIsStart = FALSE;
  1290. }
  1291. if(TCHAR(',') == *sz)
  1292. {
  1293. *sz = NULL;
  1294. bCurCharIsStart = TRUE;
  1295. }
  1296. sz++;
  1297. }
  1298. //
  1299. // bytes needed for the explicit path version
  1300. // is at most MAX_PATH * number of dlls (20 is added to give us extra space)
  1301. //
  1302. int cbExplicitPath = countDlls * (MAX_PATH + 20) * sizeof(TCHAR);
  1303. szExplicitPathList = (LPTSTR) LocalAlloc(LPTR,
  1304. cbExplicitPath);
  1305. if(NULL == szExplicitPathList)
  1306. {
  1307. LocalFree(szDllListTmp);
  1308. return NULL;
  1309. }
  1310. memset(szExplicitPathList, 0 , cbExplicitPath);
  1311. //
  1312. // Construct the explicit path list
  1313. // by splatting in the prefix followed by '\' followed by the dll name
  1314. // ensure that none of the dll paths exceed MAX_PATH..If any do, return FAILURE
  1315. //
  1316. int lenPrefix = _tcslen(szPathPrefix);
  1317. for(i=0; i<countDlls;i++)
  1318. {
  1319. int lenPath = lenPrefix;
  1320. lenPath += _tcslen(DllNames[i]);
  1321. lenPath += 1; // for '\'
  1322. if(lenPath >= MAX_PATH - 1)
  1323. {
  1324. LocalFree(szExplicitPathList);
  1325. LocalFree(szDllListTmp);
  1326. return NULL;
  1327. }
  1328. hr = StringCbCat(szExplicitPathList,
  1329. cbExplicitPath,
  1330. szPathPrefix);
  1331. if (SUCCEEDED(hr)) {
  1332. hr = StringCbCat(szExplicitPathList,
  1333. cbExplicitPath,
  1334. _T("\\"));
  1335. if (SUCCEEDED(hr)) {
  1336. hr = StringCbCat(szExplicitPathList,
  1337. cbExplicitPath,
  1338. DllNames[i]);
  1339. if (SUCCEEDED(hr)) {
  1340. if (i != (countDlls -1)) {
  1341. //Last DLL, no trailing ","
  1342. hr = StringCbCat(szExplicitPathList,
  1343. cbExplicitPath,
  1344. _T(","));
  1345. }
  1346. }
  1347. }
  1348. }
  1349. if (FAILED(hr)) {
  1350. LocalFree(szExplicitPathList);
  1351. LocalFree(szDllListTmp);
  1352. return NULL;
  1353. }
  1354. }
  1355. LocalFree(szDllListTmp);
  1356. //caller must free
  1357. return szExplicitPathList;
  1358. }
  1359. //
  1360. // IconFile
  1361. //
  1362. STDMETHODIMP CMstscAdvSettings::put_IconFile(BSTR IconFile)
  1363. {
  1364. HRESULT hr = E_FAIL;
  1365. //
  1366. // Don't allow this property to be set in the web control case
  1367. // for attack surface reduction as we don't want to allow a script
  1368. // caller access to the local file system.
  1369. //
  1370. #if (defined(OS_WINCE) || defined(REDIST_CONTROL))
  1371. return S_FALSE;
  1372. #else
  1373. if(GetLockedForWrite())
  1374. {
  1375. return E_FAIL;
  1376. }
  1377. if (IconFile) {
  1378. hr = CUT::StringPropPut(m_pUI->_UI.szIconFile,
  1379. SIZE_TCHARS(m_pUI->_UI.szIconFile),
  1380. (LPTSTR)IconFile);
  1381. }
  1382. else {
  1383. m_pUI->_UI.szIconFile[0] = NULL;
  1384. hr = S_OK;
  1385. }
  1386. return hr;
  1387. #endif
  1388. }
  1389. //
  1390. // Icon Index
  1391. //
  1392. STDMETHODIMP CMstscAdvSettings::put_IconIndex(LONG IconIndex)
  1393. {
  1394. //
  1395. // Don't allow this property to be set in the web control case
  1396. // for attack surface reduction as we don't want to allow a script
  1397. // caller access to the local file system.
  1398. //
  1399. #if (defined(OS_WINCE) || defined(REDIST_CONTROL))
  1400. return S_FALSE;
  1401. #else
  1402. if(GetLockedForWrite())
  1403. {
  1404. return E_FAIL;
  1405. }
  1406. m_pUI->_UI.iconIndex = IconIndex;
  1407. return S_OK;
  1408. #endif
  1409. }
  1410. //
  1411. // Container handled full screen mode
  1412. //
  1413. STDMETHODIMP CMstscAdvSettings::put_ContainerHandledFullScreen(BOOL ContainerHandledFullScreen)
  1414. {
  1415. HRESULT hr = E_FAIL;
  1416. DC_BEGIN_FN("put_ContainerHandledFullScreen");
  1417. if(GetLockedForWrite()) {
  1418. return E_FAIL;
  1419. }
  1420. if (!m_bMakeSafeForScripting) {
  1421. m_pUI->_UI.fContainerHandlesFullScreenToggle =
  1422. (ContainerHandledFullScreen != 0);
  1423. hr = S_OK;
  1424. }
  1425. else {
  1426. hr = S_FALSE;
  1427. }
  1428. DC_END_FN();
  1429. return hr;
  1430. }
  1431. STDMETHODIMP CMstscAdvSettings::get_ContainerHandledFullScreen(BOOL* pContainerHandledFullScreen)
  1432. {
  1433. HRESULT hr = E_FAIL;
  1434. DC_BEGIN_FN("get_ContainerHandledFullScreen");
  1435. if(!pContainerHandledFullScreen) {
  1436. return E_INVALIDARG;
  1437. }
  1438. if (!m_bMakeSafeForScripting) {
  1439. *pContainerHandledFullScreen = m_pUI->_UI.fContainerHandlesFullScreenToggle ?
  1440. VB_TRUE : VB_FALSE;
  1441. hr = S_OK;
  1442. }
  1443. else {
  1444. hr = S_FALSE;
  1445. }
  1446. DC_END_FN();
  1447. return hr;
  1448. }
  1449. //
  1450. // Disable loading RDPDR on first initialization
  1451. //
  1452. STDMETHODIMP CMstscAdvSettings::put_DisableRdpdr(BOOL DisableRdpdr)
  1453. {
  1454. if(!GetLockedForWrite())
  1455. {
  1456. if(!m_pUI->UI_IsCoreInitialized())
  1457. {
  1458. m_pUI->_UI.fDisableInternalRdpDr = (DisableRdpdr != 0);
  1459. return S_OK;
  1460. }
  1461. else
  1462. {
  1463. return E_FAIL;
  1464. }
  1465. }
  1466. else
  1467. {
  1468. return E_FAIL;
  1469. }
  1470. }
  1471. STDMETHODIMP CMstscAdvSettings::get_DisableRdpdr(BOOL* pDisableRdpdr)
  1472. {
  1473. if( pDisableRdpdr )
  1474. {
  1475. *pDisableRdpdr = m_pUI->_UI.fDisableInternalRdpDr ? VB_TRUE : VB_FALSE;
  1476. return S_OK;
  1477. }
  1478. else
  1479. {
  1480. return E_FAIL;
  1481. }
  1482. }
  1483. STDMETHODIMP CMstscAdvSettings::put_ConnectToServerConsole(VARIANT_BOOL connectToConsole)
  1484. {
  1485. if(!GetLockedForWrite())
  1486. {
  1487. m_pUI->UI_SetConnectToServerConsole(connectToConsole != 0);
  1488. return S_OK;
  1489. }
  1490. else
  1491. {
  1492. return E_FAIL;
  1493. }
  1494. }
  1495. STDMETHODIMP CMstscAdvSettings::get_ConnectToServerConsole(VARIANT_BOOL* pConnectToConsole)
  1496. {
  1497. if(pConnectToConsole)
  1498. {
  1499. *pConnectToConsole = (m_pUI->UI_GetConnectToServerConsole() ? VB_TRUE : VB_FALSE);
  1500. return S_OK;
  1501. }
  1502. else
  1503. {
  1504. return E_INVALIDARG;
  1505. }
  1506. }
  1507. STDMETHODIMP CMstscAdvSettings::put_MinutesToIdleTimeout(
  1508. LONG minutesToIdleTimeout)
  1509. {
  1510. DC_BEGIN_FN("put_MinutesToIdleTimeout");
  1511. if(!GetLockedForWrite())
  1512. {
  1513. if(minutesToIdleTimeout > MAX_MINS_TOIDLETIMEOUT)
  1514. {
  1515. TRC_ERR((TB,_T("idle timeout out of range: %d"),
  1516. minutesToIdleTimeout));
  1517. return E_INVALIDARG;
  1518. }
  1519. if(m_pUI->UI_SetMinsToIdleTimeout( minutesToIdleTimeout ))
  1520. {
  1521. return S_OK;
  1522. }
  1523. else
  1524. {
  1525. return E_FAIL;
  1526. }
  1527. }
  1528. else
  1529. {
  1530. return E_FAIL;
  1531. }
  1532. DC_END_FN();
  1533. }
  1534. STDMETHODIMP CMstscAdvSettings::get_MinutesToIdleTimeout(
  1535. LONG* pminutesToIdleTimeout)
  1536. {
  1537. DC_BEGIN_FN("get_MinutesToIdleTimeout");
  1538. if(pminutesToIdleTimeout)
  1539. {
  1540. *pminutesToIdleTimeout = m_pUI->UI_GetMinsToIdleTimeout();
  1541. return S_OK;
  1542. }
  1543. else
  1544. {
  1545. return E_INVALIDARG;
  1546. }
  1547. DC_END_FN();
  1548. }
  1549. #ifdef SMART_SIZING
  1550. /**PROC+*********************************************************************/
  1551. /* Name: get_SmartSize
  1552. /*
  1553. /* Purpose: get smart sizing property
  1554. /*
  1555. /**PROC-*********************************************************************/
  1556. STDMETHODIMP CMstscAdvSettings::get_SmartSizing(VARIANT_BOOL* pfSmartSize)
  1557. {
  1558. ATLASSERT(m_pUI);
  1559. if(!pfSmartSize)
  1560. {
  1561. return E_INVALIDARG;
  1562. }
  1563. *pfSmartSize = m_pUI->UI_GetSmartSizing() ? VB_TRUE : VB_FALSE;
  1564. return S_OK;
  1565. }
  1566. /**PROC+*********************************************************************/
  1567. /* Name: put_SmartSize
  1568. /*
  1569. /* Purpose: put smart sizing property
  1570. /*
  1571. /**PROC-*********************************************************************/
  1572. STDMETHODIMP CMstscAdvSettings::put_SmartSizing(VARIANT_BOOL fSmartSize)
  1573. {
  1574. OSVERSIONINFOA OsVer;
  1575. memset(&OsVer, 0x0, sizeof(OSVERSIONINFOA));
  1576. OsVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
  1577. GetVersionExA(&OsVer);
  1578. HRESULT hr = S_OK;
  1579. if ((VER_PLATFORM_WIN32_NT != OsVer.dwPlatformId) && fSmartSize) {
  1580. //
  1581. // Win9x doesn't support halftoning, so no smart sizing for them!
  1582. //
  1583. return E_NOTIMPL;
  1584. }
  1585. //no, these lines of code are not as bad as they look
  1586. //vb's true is 0xFFFFFFF so don't just blindy assign
  1587. hr = m_pUI->UI_SetSmartSizing( fSmartSize != 0);
  1588. return hr;
  1589. }
  1590. #endif // SMART_SIZING
  1591. //
  1592. // Pass in the local printing doc name string to RDPDR
  1593. // this method's main purpose is so we don't need to add
  1594. // a localizable string to the control. There is a default
  1595. // english string built into the control, a container can
  1596. // pass in any replacement (i.e localized) string it pleases
  1597. //
  1598. STDMETHODIMP CMstscAdvSettings::put_RdpdrLocalPrintingDocName(
  1599. BSTR RdpdrLocalPrintingDocName)
  1600. {
  1601. DC_BEGIN_FN("put_RdpdrLocalPrintingDocName");
  1602. DC_END_FN();
  1603. return S_FALSE; //deprecated
  1604. }
  1605. //
  1606. // Return the currently selected string
  1607. // for the local printing doc name. This is just a string
  1608. // RDPDR uses but we want to avoid localizing the control
  1609. // so the string is passed in from the container.
  1610. //
  1611. STDMETHODIMP CMstscAdvSettings::get_RdpdrLocalPrintingDocName(
  1612. BSTR *pRdpdrLocalPrintingDocName)
  1613. {
  1614. DC_BEGIN_FN("get_RdpdrLocalPrintingDocName");
  1615. DC_END_FN();
  1616. return S_FALSE; //deprecated
  1617. }
  1618. STDMETHODIMP CMstscAdvSettings::put_RdpdrClipCleanTempDirString(
  1619. BSTR RdpdrClipCleanTempDirString)
  1620. {
  1621. DC_BEGIN_FN("put_RdpdrClipCleanTempDirString");
  1622. DC_END_FN();
  1623. return S_FALSE; //deprecated
  1624. }
  1625. STDMETHODIMP CMstscAdvSettings::get_RdpdrClipCleanTempDirString(
  1626. BSTR *pRdpdrClipCleanTempDirString)
  1627. {
  1628. DC_BEGIN_FN("get_RdpdrClipCleanTempDirString");
  1629. DC_END_FN();
  1630. return S_FALSE; //deprecated
  1631. }
  1632. STDMETHODIMP CMstscAdvSettings::put_RdpdrClipPasteInfoString(
  1633. BSTR RdpdrClipPasteInfoString)
  1634. {
  1635. DC_BEGIN_FN("put_RdpdrClipPasteInfoString");
  1636. DC_END_FN();
  1637. return S_FALSE; //deprecated
  1638. }
  1639. STDMETHODIMP CMstscAdvSettings::get_RdpdrClipPasteInfoString(
  1640. BSTR *pRdpdrClipPasteInfoString)
  1641. {
  1642. DC_BEGIN_FN("get_RdpdrClipPasteInfoString");
  1643. DC_END_FN();
  1644. return S_FALSE; //deprecated
  1645. }
  1646. //
  1647. // New Whistler scriptable access to password API
  1648. // this just delegates to the non-scriptable API from TSAC
  1649. //
  1650. STDMETHODIMP CMstscAdvSettings::put_ClearTextPassword(BSTR clearTextPassword)
  1651. {
  1652. DC_BEGIN_FN("put_ClearTextPassword");
  1653. TRC_ASSERT(_pAxControl,
  1654. (TB,_T("_pAxControl is NULL")));
  1655. if(!GetLockedForWrite() && _pAxControl)
  1656. {
  1657. if(clearTextPassword)
  1658. {
  1659. return _pAxControl->put_ClearTextPassword( clearTextPassword );
  1660. }
  1661. else
  1662. {
  1663. return E_INVALIDARG;
  1664. }
  1665. }
  1666. else
  1667. {
  1668. return E_FAIL;
  1669. }
  1670. DC_END_FN();
  1671. }
  1672. /**PROC+*********************************************************************/
  1673. /* Name: put_DisplayConnectionBar
  1674. /*
  1675. /* Purpose: Set display connection bar prop
  1676. /* cannot be set in web control (it is always true there)
  1677. /*
  1678. /**PROC-*********************************************************************/
  1679. STDMETHODIMP CMstscAdvSettings::put_DisplayConnectionBar(
  1680. VARIANT_BOOL fDisplayConnectionBar)
  1681. {
  1682. ATLASSERT(m_pUI);
  1683. #if (!defined (OS_WINCE)) || (!defined (WINCE_SDKBUILD))
  1684. if(!m_bMakeSafeForScripting && !GetLockedForWrite())
  1685. {
  1686. m_pUI->UI_SetEnableBBar( fDisplayConnectionBar != 0);
  1687. }
  1688. else
  1689. {
  1690. //
  1691. // Not allowed to toggle this
  1692. // if need to be safe for scripting as the bbar
  1693. // prevents spoofing attacks because people
  1694. // can always realize this is a TS session.
  1695. //
  1696. return E_FAIL;
  1697. }
  1698. return S_OK;
  1699. #else
  1700. return E_NOTIMPL;
  1701. #endif
  1702. }
  1703. /**PROC+*********************************************************************/
  1704. /* Name: get_DisplayConnectionBar
  1705. /*
  1706. /* Purpose: put start connected property
  1707. /*
  1708. /**PROC-*********************************************************************/
  1709. STDMETHODIMP CMstscAdvSettings::get_DisplayConnectionBar(
  1710. VARIANT_BOOL* pfDisplayConnectionBar)
  1711. {
  1712. #if (!defined (OS_WINCE)) || (!defined (WINCE_SDKBUILD))
  1713. if(pfDisplayConnectionBar)
  1714. {
  1715. *pfDisplayConnectionBar =
  1716. m_pUI->UI_GetEnableBBar() ? VB_TRUE : VB_FALSE;
  1717. return S_OK;
  1718. }
  1719. else
  1720. {
  1721. return E_INVALIDARG;
  1722. }
  1723. #else
  1724. return E_NOTIMPL;
  1725. #endif
  1726. }
  1727. /**PROC+*********************************************************************/
  1728. /* Name: put_PinConnectionBar
  1729. /*
  1730. /* Purpose: Set Pin connection bar prop
  1731. /* cannot be set in web control (it is always true there)
  1732. /*
  1733. /**PROC-*********************************************************************/
  1734. STDMETHODIMP CMstscAdvSettings::put_PinConnectionBar(
  1735. VARIANT_BOOL fPinConnectionBar)
  1736. {
  1737. #if (!defined (OS_WINCE)) || (!defined (WINCE_SDKBUILD))
  1738. if (!m_bMakeSafeForScripting) {
  1739. if (!GetLockedForWrite())
  1740. {
  1741. m_pUI->UI_SetBBarPinned( fPinConnectionBar != 0);
  1742. }
  1743. else
  1744. {
  1745. //
  1746. // Not allowed to toggle this
  1747. // if need to be safe for scripting as the bbar
  1748. // prevents spoofing attacks because people
  1749. // can always realize this is a TS session.
  1750. //
  1751. return E_FAIL;
  1752. }
  1753. return S_OK;
  1754. }
  1755. else {
  1756. return E_NOTIMPL;
  1757. }
  1758. #else
  1759. return E_NOTIMPL;
  1760. #endif
  1761. }
  1762. /**PROC+*********************************************************************/
  1763. /* Name: get_PinConnectionBar
  1764. /*
  1765. /* Purpose: put start connected property
  1766. /*
  1767. /**PROC-*********************************************************************/
  1768. STDMETHODIMP CMstscAdvSettings::get_PinConnectionBar(
  1769. VARIANT_BOOL* pfPinConnectionBar)
  1770. {
  1771. #if (!defined (OS_WINCE)) || (!defined (WINCE_SDKBUILD))
  1772. if (!m_bMakeSafeForScripting) {
  1773. if(pfPinConnectionBar)
  1774. {
  1775. *pfPinConnectionBar =
  1776. m_pUI->UI_GetBBarPinned() ? VB_TRUE : VB_FALSE;
  1777. return S_OK;
  1778. }
  1779. else
  1780. {
  1781. return E_INVALIDARG;
  1782. }
  1783. }
  1784. else {
  1785. return E_NOTIMPL;
  1786. }
  1787. #else
  1788. return E_NOTIMPL;
  1789. #endif
  1790. }
  1791. //
  1792. // GrabFocusOnConnect (defaults to true)
  1793. // can turn this off to allow containers to control
  1794. // when the client gets the focus (e.g the MMC snapin)
  1795. // needs to manage this for multiple instances
  1796. //
  1797. STDMETHODIMP CMstscAdvSettings::put_GrabFocusOnConnect(
  1798. VARIANT_BOOL fGrabFocusOnConnect)
  1799. {
  1800. DC_BEGIN_FN("put_GrabFocusOnConnect");
  1801. ATLASSERT(m_pUI);
  1802. if(!GetLockedForWrite())
  1803. {
  1804. m_pUI->UI_SetGrabFocusOnConnect( fGrabFocusOnConnect != 0);
  1805. return S_OK;
  1806. }
  1807. else
  1808. {
  1809. return E_FAIL;
  1810. }
  1811. DC_END_FN();
  1812. }
  1813. STDMETHODIMP CMstscAdvSettings::get_GrabFocusOnConnect(
  1814. VARIANT_BOOL* pfGrabFocusOnConnect)
  1815. {
  1816. DC_BEGIN_FN("get_GrabFocusOnConnect");
  1817. if(pfGrabFocusOnConnect)
  1818. {
  1819. *pfGrabFocusOnConnect =
  1820. m_pUI->UI_GetGrabFocusOnConnect() ? VB_TRUE : VB_FALSE;
  1821. return S_OK;
  1822. }
  1823. else
  1824. {
  1825. return E_INVALIDARG;
  1826. }
  1827. DC_END_FN();
  1828. }
  1829. //
  1830. // Name: put_LoadBalanceInfo
  1831. //
  1832. // Purpose: LoadBalance info property input function.
  1833. //
  1834. #define LBINFO_MAX_LENGTH 256
  1835. STDMETHODIMP CMstscAdvSettings::put_LoadBalanceInfo(BSTR newLBInfo)
  1836. {
  1837. DC_BEGIN_FN("put_LoadBalanceInfo");
  1838. if(!GetLockedForWrite())
  1839. {
  1840. if (newLBInfo)
  1841. {
  1842. if (SysStringByteLen(newLBInfo) <= LBINFO_MAX_LENGTH)
  1843. m_pUI->UI_SetLBInfo((PBYTE)newLBInfo, SysStringByteLen(newLBInfo));
  1844. else
  1845. return E_INVALIDARG;
  1846. }
  1847. else
  1848. {
  1849. m_pUI->UI_SetLBInfo(NULL, 0);
  1850. }
  1851. }
  1852. else {
  1853. return E_FAIL;
  1854. }
  1855. DC_END_FN();
  1856. return S_OK;
  1857. }
  1858. //
  1859. // Name: get_LoadBalanceInfo
  1860. //
  1861. // Purpose: LoadBalance info property get function.
  1862. //
  1863. STDMETHODIMP CMstscAdvSettings::get_LoadBalanceInfo(BSTR* pLBInfo)
  1864. {
  1865. DC_BEGIN_FN("get_LoadBalanceInfo");
  1866. if(!pLBInfo)
  1867. {
  1868. return E_INVALIDARG;
  1869. }
  1870. *pLBInfo = SysAllocStringByteLen((LPCSTR)(m_pUI->_UI.bstrScriptedLBInfo),
  1871. SysStringByteLen(m_pUI->_UI.bstrScriptedLBInfo));
  1872. if(!*pLBInfo)
  1873. {
  1874. return E_OUTOFMEMORY;
  1875. }
  1876. return S_OK;
  1877. }
  1878. STDMETHODIMP CMstscAdvSettings::put_RedirectDrives(VARIANT_BOOL redirectDrives)
  1879. {
  1880. DC_BEGIN_FN("put_RedirectDrives");
  1881. if(!GetLockedForWrite())
  1882. {
  1883. if (CMsTscSecuredSettings::IsDriveRedirGloballyDisabled())
  1884. {
  1885. m_pUI->UI_SetDriveRedirectionEnabled(FALSE);
  1886. return S_FALSE;
  1887. }
  1888. else
  1889. {
  1890. m_pUI->UI_SetDriveRedirectionEnabled( (redirectDrives != 0));
  1891. return S_OK;
  1892. }
  1893. }
  1894. else
  1895. {
  1896. return E_FAIL;
  1897. }
  1898. DC_END_FN();
  1899. }
  1900. STDMETHODIMP CMstscAdvSettings::get_RedirectDrives(VARIANT_BOOL *pRedirectDrives)
  1901. {
  1902. if(pRedirectDrives)
  1903. {
  1904. *pRedirectDrives = m_pUI->UI_GetDriveRedirectionEnabled() ?
  1905. VB_TRUE : VB_FALSE;
  1906. return S_OK;
  1907. }
  1908. else
  1909. {
  1910. return E_INVALIDARG;
  1911. }
  1912. }
  1913. STDMETHODIMP CMstscAdvSettings::put_RedirectPrinters(VARIANT_BOOL redirectPrinters)
  1914. {
  1915. if(!GetLockedForWrite())
  1916. {
  1917. m_pUI->UI_SetPrinterRedirectionEnabled( (redirectPrinters != 0));
  1918. return S_OK;
  1919. }
  1920. else
  1921. {
  1922. return E_FAIL;
  1923. }
  1924. }
  1925. STDMETHODIMP CMstscAdvSettings::get_RedirectPrinters(VARIANT_BOOL *pRedirectPrinters)
  1926. {
  1927. if(pRedirectPrinters)
  1928. {
  1929. *pRedirectPrinters = m_pUI->UI_GetPrinterRedirectionEnabled() ?
  1930. VB_TRUE : VB_FALSE;
  1931. return S_OK;
  1932. }
  1933. else
  1934. {
  1935. return E_INVALIDARG;
  1936. }
  1937. }
  1938. STDMETHODIMP CMstscAdvSettings::put_RedirectPorts(VARIANT_BOOL redirectPorts)
  1939. {
  1940. if(!GetLockedForWrite())
  1941. {
  1942. m_pUI->UI_SetPortRedirectionEnabled( (redirectPorts != 0));
  1943. return S_OK;
  1944. }
  1945. else
  1946. {
  1947. return E_FAIL;
  1948. }
  1949. }
  1950. STDMETHODIMP CMstscAdvSettings::get_RedirectPorts(VARIANT_BOOL *pRedirectPorts)
  1951. {
  1952. if(pRedirectPorts)
  1953. {
  1954. *pRedirectPorts = m_pUI->UI_GetPortRedirectionEnabled() ?
  1955. VB_TRUE : VB_FALSE;
  1956. return S_OK;
  1957. }
  1958. else
  1959. {
  1960. return E_INVALIDARG;
  1961. }
  1962. }
  1963. STDMETHODIMP CMstscAdvSettings::put_RedirectSmartCards(VARIANT_BOOL redirectScard)
  1964. {
  1965. if(!GetLockedForWrite())
  1966. {
  1967. m_pUI->UI_SetSCardRedirectionEnabled(redirectScard != 0);
  1968. return S_OK;
  1969. }
  1970. else
  1971. {
  1972. return E_FAIL;
  1973. }
  1974. }
  1975. STDMETHODIMP CMstscAdvSettings::get_RedirectSmartCards(VARIANT_BOOL *pRedirectScard)
  1976. {
  1977. if(pRedirectScard)
  1978. {
  1979. *pRedirectScard = m_pUI->UI_GetSCardRedirectionEnabled() ?
  1980. VB_TRUE : VB_FALSE;
  1981. return S_OK;
  1982. }
  1983. else
  1984. {
  1985. return E_INVALIDARG;
  1986. }
  1987. }
  1988. //
  1989. // BitmapVirtualCache16BppSize property
  1990. //
  1991. // Applies to 15/16Bpp cache file size
  1992. //
  1993. STDMETHODIMP CMstscAdvSettings::put_BitmapVirtualCache16BppSize(
  1994. LONG bitmapVirtualCache16BppSize)
  1995. {
  1996. if(GetLockedForWrite())
  1997. {
  1998. return E_FAIL;
  1999. }
  2000. if (bitmapVirtualCache16BppSize > 0 &&
  2001. bitmapVirtualCache16BppSize <= TSC_MAX_BITMAPCACHESIZE)
  2002. {
  2003. m_pUI->_UI.RegBitmapVirtualCache16BppSize =
  2004. bitmapVirtualCache16BppSize;
  2005. }
  2006. else
  2007. {
  2008. return E_INVALIDARG;
  2009. }
  2010. return S_OK;
  2011. }
  2012. STDMETHODIMP CMstscAdvSettings::get_BitmapVirtualCache16BppSize(
  2013. LONG* pbitmapVirtualCache16BppSize)
  2014. {
  2015. if(!pbitmapVirtualCache16BppSize)
  2016. {
  2017. return E_POINTER;
  2018. }
  2019. *pbitmapVirtualCache16BppSize =
  2020. m_pUI->_UI.RegBitmapVirtualCache16BppSize;
  2021. return S_OK;
  2022. }
  2023. //
  2024. // BitmapVirtualCache24BppSize property
  2025. //
  2026. // Applies to 24Bpp cache file size
  2027. //
  2028. STDMETHODIMP CMstscAdvSettings::put_BitmapVirtualCache24BppSize(
  2029. LONG bitmapVirtualCache24BppSize)
  2030. {
  2031. if(GetLockedForWrite())
  2032. {
  2033. return E_FAIL;
  2034. }
  2035. if (bitmapVirtualCache24BppSize > 0 &&
  2036. bitmapVirtualCache24BppSize <= TSC_MAX_BITMAPCACHESIZE)
  2037. {
  2038. m_pUI->_UI.RegBitmapVirtualCache24BppSize =
  2039. bitmapVirtualCache24BppSize;
  2040. }
  2041. else
  2042. {
  2043. return E_INVALIDARG;
  2044. }
  2045. return S_OK;
  2046. }
  2047. STDMETHODIMP CMstscAdvSettings::get_BitmapVirtualCache24BppSize(
  2048. LONG* pbitmapVirtualCache24BppSize)
  2049. {
  2050. if(!pbitmapVirtualCache24BppSize)
  2051. {
  2052. return E_POINTER;
  2053. }
  2054. *pbitmapVirtualCache24BppSize =
  2055. m_pUI->_UI.RegBitmapVirtualCache24BppSize;
  2056. return S_OK;
  2057. }
  2058. //
  2059. // Sets the disabled feature list (for perf reasons can disable
  2060. // certain features at the server e.g wallpaper)
  2061. //
  2062. STDMETHODIMP CMstscAdvSettings::put_PerformanceFlags(
  2063. LONG DisableFeatList)
  2064. {
  2065. DC_BEGIN_FN("put_PerformanceFlags");
  2066. if(GetLockedForWrite())
  2067. {
  2068. return E_FAIL;
  2069. }
  2070. m_pUI->UI_SetPerformanceFlags((DWORD)DisableFeatList);
  2071. DC_END_FN();
  2072. return S_OK;
  2073. }
  2074. STDMETHODIMP CMstscAdvSettings::get_PerformanceFlags(
  2075. LONG* pDisableFeatList)
  2076. {
  2077. DC_BEGIN_FN("get_PerformanceFlags");
  2078. if(!pDisableFeatList)
  2079. {
  2080. return E_POINTER;
  2081. }
  2082. *pDisableFeatList = (LONG)
  2083. m_pUI->UI_GetPerformanceFlags();
  2084. DC_END_FN();
  2085. return S_OK;
  2086. }
  2087. /*****************************************************************************/
  2088. /* Purpose : This is Remote Assistance specific call to support reverse */
  2089. /* connection pcHealth must have invoke necessary routine in Salem *
  2090. /* to connection with TermSrv and then instruct Salem to pass this */
  2091. /* connection to ActiveX control to begin login sequence */
  2092. /* */
  2093. /* Param : IN pConnectionEndPoint - Connected socket */
  2094. /*****************************************************************************/
  2095. STDMETHODIMP
  2096. CMstscAdvSettings::put_ConnectWithEndpoint(
  2097. VARIANT* pConnectionEndpoint
  2098. )
  2099. {
  2100. #if REDIST_CONTROL
  2101. return E_NOTIMPL;
  2102. #else
  2103. HRESULT hr = S_OK;
  2104. DC_BEGIN_FN( "ConnectionEndpoint" );
  2105. if( pConnectionEndpoint->vt != VT_BYREF )
  2106. {
  2107. hr = E_HANDLE;
  2108. }
  2109. else
  2110. {
  2111. hr = _pAxControl->SetConnectWithEndpoint(
  2112. (SOCKET)pConnectionEndpoint->byref );
  2113. }
  2114. DC_END_FN();
  2115. return hr;
  2116. #endif
  2117. }
  2118. /*****************************************************************************/
  2119. /* Purpose : This is Remote Assistance specific call to notify TS public */
  2120. /* key uses in generate session encryption key. */
  2121. /* */
  2122. /* Param : IN fNotify - TRUE to notify public key, FALSE otherwise */
  2123. /*****************************************************************************/
  2124. STDMETHODIMP
  2125. CMstscAdvSettings::put_NotifyTSPublicKey(
  2126. VARIANT_BOOL fNotify
  2127. )
  2128. {
  2129. #if REDIST_CONTROL
  2130. return E_NOTIMPL;
  2131. #else
  2132. #ifndef OS_WINCE
  2133. HRESULT hr;
  2134. #endif
  2135. if(GetLockedForWrite())
  2136. {
  2137. return E_FAIL;
  2138. }
  2139. m_pUI->UI_SetNotifyTSPublicKey( fNotify );
  2140. return S_OK;
  2141. #endif
  2142. }
  2143. /*****************************************************************************/
  2144. /* Purpose : Get current setting on whether ActiveX control will notify */
  2145. /* container when it received TS public key */
  2146. /* */
  2147. /* Returns : TRUE to notify public key, FALSE otherwise */
  2148. /*****************************************************************************/
  2149. STDMETHODIMP
  2150. CMstscAdvSettings::get_NotifyTSPublicKey(
  2151. VARIANT_BOOL* pfNotifyTSPublicKey
  2152. )
  2153. {
  2154. #if REDIST_CONTROL
  2155. return E_NOTIMPL;
  2156. #else
  2157. BOOL fNotify;
  2158. if(!pfNotifyTSPublicKey)
  2159. {
  2160. return E_POINTER;
  2161. }
  2162. fNotify = m_pUI->UI_GetNotifyTSPublicKey();
  2163. return S_OK;
  2164. #endif
  2165. }
  2166. //
  2167. // Retrieves VARIANT_TRUE if we can autoreconnect
  2168. // i.e. the core has received an autoreconnect cookie
  2169. // from the server from a previous connection and the
  2170. // server has not been changed
  2171. //
  2172. STDMETHODIMP
  2173. CMstscAdvSettings::get_CanAutoReconnect(
  2174. VARIANT_BOOL* pfCanAutoReconnect
  2175. )
  2176. {
  2177. HRESULT hr;
  2178. DC_BEGIN_FN("get_CanAutoReconnect");
  2179. if (pfCanAutoReconnect)
  2180. {
  2181. *pfCanAutoReconnect =
  2182. m_pUI->UI_CanAutoReconnect() ? VB_TRUE : VB_FALSE;
  2183. hr = S_OK;
  2184. }
  2185. else
  2186. {
  2187. hr = E_INVALIDARG;
  2188. }
  2189. DC_END_FN();
  2190. return hr;
  2191. }
  2192. //
  2193. // Sets w/not any autoreconnection information
  2194. // will be used for the next connection. Also specifies
  2195. // if we should store any autoreconnection information
  2196. // the server sends down.
  2197. //
  2198. STDMETHODIMP
  2199. CMstscAdvSettings::put_EnableAutoReconnect(
  2200. VARIANT_BOOL fEnableAutoReconnect
  2201. )
  2202. {
  2203. HRESULT hr;
  2204. DC_BEGIN_FN("put_EnableAutoReconnect");
  2205. if (!GetLockedForWrite() && m_pUI)
  2206. {
  2207. m_pUI->UI_SetEnableAutoReconnect(fEnableAutoReconnect != 0);
  2208. hr = S_OK;
  2209. }
  2210. else
  2211. {
  2212. hr = E_FAIL;
  2213. }
  2214. DC_END_FN();
  2215. return hr;
  2216. }
  2217. //
  2218. // Retrieves state of w/not we should use autoreconnection
  2219. //
  2220. //
  2221. STDMETHODIMP
  2222. CMstscAdvSettings::get_EnableAutoReconnect(
  2223. VARIANT_BOOL* pfEnableAutoReconnect
  2224. )
  2225. {
  2226. HRESULT hr;
  2227. DC_BEGIN_FN("get_EnableAutoReconnect");
  2228. if (pfEnableAutoReconnect)
  2229. {
  2230. *pfEnableAutoReconnect =
  2231. m_pUI->UI_GetEnableAutoReconnect() ? VB_TRUE : VB_FALSE;
  2232. hr = S_OK;
  2233. }
  2234. else
  2235. {
  2236. hr = E_INVALIDARG;
  2237. }
  2238. DC_END_FN();
  2239. return hr;
  2240. }
  2241. //
  2242. // Specify the max number of ARC retries
  2243. //
  2244. STDMETHODIMP
  2245. CMstscAdvSettings::put_MaxReconnectAttempts(
  2246. LONG MaxReconnectAttempts
  2247. )
  2248. {
  2249. HRESULT hr;
  2250. DC_BEGIN_FN("put_MaxReconnectAttempts");
  2251. if (!GetLockedForWrite() && m_pUI)
  2252. {
  2253. if (MaxReconnectAttempts > 200) {
  2254. MaxReconnectAttempts = 200;
  2255. }
  2256. else if (MaxReconnectAttempts < 0) {
  2257. MaxReconnectAttempts = 0;
  2258. }
  2259. m_pUI->UI_SetMaxArcAttempts(MaxReconnectAttempts);
  2260. hr = S_OK;
  2261. }
  2262. else
  2263. {
  2264. hr = E_FAIL;
  2265. }
  2266. DC_END_FN();
  2267. return hr;
  2268. }
  2269. //
  2270. // Retrieves state of w/not we should use autoreconnection
  2271. //
  2272. //
  2273. STDMETHODIMP
  2274. CMstscAdvSettings::get_MaxReconnectAttempts(
  2275. LONG* pMaxReconnectAttempts
  2276. )
  2277. {
  2278. HRESULT hr;
  2279. DC_BEGIN_FN("get_MaxReconnectAttempts");
  2280. if (pMaxReconnectAttempts)
  2281. {
  2282. *pMaxReconnectAttempts =
  2283. m_pUI->UI_GetMaxArcAttempts();
  2284. hr = S_OK;
  2285. }
  2286. else
  2287. {
  2288. hr = E_INVALIDARG;
  2289. }
  2290. DC_END_FN();
  2291. return hr;
  2292. }
  2293. //
  2294. // Display BBar minimize button
  2295. //
  2296. STDMETHODIMP
  2297. CMstscAdvSettings::put_ConnectionBarShowMinimizeButton(
  2298. VARIANT_BOOL fShowMinimizeButton
  2299. )
  2300. {
  2301. HRESULT hr;
  2302. DC_BEGIN_FN("put_EnableAutoReconnect");
  2303. if (!GetLockedForWrite() && m_pUI)
  2304. {
  2305. m_pUI->UI_SetBBarShowMinimize(fShowMinimizeButton != 0);
  2306. hr = S_OK;
  2307. }
  2308. else
  2309. {
  2310. hr = E_FAIL;
  2311. }
  2312. DC_END_FN();
  2313. return hr;
  2314. }
  2315. //
  2316. // get display bbar minimize button
  2317. //
  2318. STDMETHODIMP
  2319. CMstscAdvSettings::get_ConnectionBarShowMinimizeButton(
  2320. VARIANT_BOOL* pfShowMinimizeButton
  2321. )
  2322. {
  2323. HRESULT hr;
  2324. DC_BEGIN_FN("get_ConnectionBarShowMinimizeButton");
  2325. if (pfShowMinimizeButton)
  2326. {
  2327. *pfShowMinimizeButton =
  2328. m_pUI->UI_GetBBarShowMinimize() ? VB_TRUE : VB_FALSE;
  2329. hr = S_OK;
  2330. }
  2331. else
  2332. {
  2333. hr = E_INVALIDARG;
  2334. }
  2335. DC_END_FN();
  2336. return hr;
  2337. }
  2338. //
  2339. // set bbar restore button
  2340. //
  2341. STDMETHODIMP
  2342. CMstscAdvSettings::put_ConnectionBarShowRestoreButton(
  2343. VARIANT_BOOL fShowRestoreButton
  2344. )
  2345. {
  2346. HRESULT hr;
  2347. DC_BEGIN_FN("put_EnableAutoReconnect");
  2348. if (!GetLockedForWrite() && m_pUI)
  2349. {
  2350. m_pUI->UI_SetBBarShowRestore(fShowRestoreButton != 0);
  2351. hr = S_OK;
  2352. }
  2353. else
  2354. {
  2355. hr = E_FAIL;
  2356. }
  2357. DC_END_FN();
  2358. return hr;
  2359. }
  2360. //
  2361. // get bbar restore button
  2362. //
  2363. STDMETHODIMP
  2364. CMstscAdvSettings::get_ConnectionBarShowRestoreButton(
  2365. VARIANT_BOOL* pfShowRestoreButton
  2366. )
  2367. {
  2368. HRESULT hr;
  2369. DC_BEGIN_FN("get_ConnectionBarShowRestoreButton");
  2370. if (pfShowRestoreButton)
  2371. {
  2372. *pfShowRestoreButton =
  2373. m_pUI->UI_GetBBarShowRestore() ? VB_TRUE : VB_FALSE;
  2374. hr = S_OK;
  2375. }
  2376. else
  2377. {
  2378. hr = E_INVALIDARG;
  2379. }
  2380. DC_END_FN();
  2381. return hr;
  2382. }