Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

337 lines
7.0 KiB

  1. #ifndef _TSUSERSHEET_H
  2. #define _TSUSERSHEET_H
  3. #include <winsta.h>
  4. #define NUM_OF_PAGES 4
  5. class CDialogBase;
  6. #ifdef UNICODE
  7. #define COPYWCHAR2TCHAR( SRC , DEST ) \
  8. wcscpy( SRC , DEST );
  9. #else
  10. #define COPYWCHAR2TCHAR( SRC , DEST ) \
  11. { \
  12. DWORD dwLen; \
  13. dwLen = wcslen( DEST ); \
  14. WideCharToMultiByte( CP_ACP , 0 , DEST , dwLen , SRC , dwLen / sizeof( WCHAR ) , 0 , 0 ); \
  15. }
  16. #endif
  17. #define ALN_APPLY ( WM_USER + 900 )
  18. const ULONG kMilliMinute = 60000;
  19. const ULONG kMaxTimeoutMinute = 71580;
  20. #define E_PARSE_VALUEOVERFLOW 0x80000000
  21. #define E_PARSE_INVALID 0xffffffff
  22. #define E_SUCCESS 0
  23. #define E_PARSE_MISSING_DIGITS 0X7fffffff
  24. enum TOKEN { TOKEN_DAY , TOKEN_HOUR , TOKEN_MINUTE };
  25. //---------------------------------------------------------------------
  26. // Class for managing user manager for Terminal server extensions
  27. //---------------------------------------------------------------------
  28. class CTSUserSheet
  29. {
  30. private:
  31. LPTSTR m_pstrMachinename;
  32. LPTSTR m_pstrUsername;
  33. CDialogBase *m_pDlg[ NUM_OF_PAGES ];
  34. UINT m_cref;
  35. BOOL m_bDC; // domain controller
  36. BOOL m_bIsConfigLoaded;
  37. BOOL GetUserConfig( PDWORD );
  38. TCHAR m_szRemoteServerName[ MAX_PATH ];
  39. BOOL m_bDSAType;
  40. PSID m_pUserSid;
  41. public:
  42. CTSUserSheet();
  43. ~CTSUserSheet();
  44. BOOL SetServerAndUser( LPWSTR , LPWSTR );
  45. HRESULT AddPagesToPropSheet( LPPROPERTYSHEETCALLBACK pProvider );
  46. HRESULT AddPagesToDSAPropSheet( LPFNADDPROPSHEETPAGE , LPARAM );
  47. BOOL SetUserConfig( USERCONFIG& , PDWORD );
  48. USERCONFIG& GetCurrentUserConfig( PDWORD );
  49. LPTSTR GetUserName( ) { return m_pstrUsername; }
  50. void SetDSAType( BOOL bT ) { m_bDSAType = bT; }
  51. BOOL GetDSAType( void ) { return m_bDSAType; }
  52. void CopyUserSid( PSID );
  53. PSID GetUserSid( ) { return m_pUserSid; }
  54. UINT AddRef( );
  55. UINT Release( );
  56. //
  57. // public data
  58. //
  59. USERCONFIG m_userconfig;
  60. };
  61. //---------------------------------------------------------------------
  62. // CDialogBase - as the name implies base class for all the dialogs
  63. //---------------------------------------------------------------------
  64. class CDialogBase
  65. {
  66. protected:
  67. BOOL m_bPersisted;
  68. HWND m_hWnd;
  69. public:
  70. virtual BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  71. virtual BOOL OnDestroy( ){ return TRUE; }
  72. virtual BOOL GetPropertySheetPage( PROPSHEETPAGE& ){ return FALSE;}
  73. virtual BOOL PersistSettings( HWND ){ return FALSE;}
  74. virtual BOOL IsValidSettings( HWND ){ return TRUE;}
  75. virtual BOOL OnNotify( int , LPNMHDR , HWND );
  76. virtual BOOL OnContextMenu( HWND , POINT& );
  77. virtual BOOL OnHelp( HWND , LPHELPINFO );
  78. CDialogBase( );
  79. //virtual ~CDialogBase( );
  80. };
  81. //---------------------------------------------------------------------
  82. // Dialog for profile page
  83. //---------------------------------------------------------------------
  84. class CEnviroDlg : public CDialogBase
  85. {
  86. CTSUserSheet *m_pUSht;
  87. public:
  88. CEnviroDlg( CTSUserSheet *);
  89. BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  90. BOOL GetPropertySheetPage( PROPSHEETPAGE& );
  91. BOOL OnDestroy( );
  92. BOOL PersistSettings( HWND );
  93. void OnCommand( WORD , WORD , HWND );
  94. static INT_PTR CALLBACK DlgProc( HWND , UINT , WPARAM , LPARAM );
  95. };
  96. //---------------------------------------------------------------------
  97. // retains object state for the timeout dlg combx
  98. //---------------------------------------------------------------------
  99. typedef struct _cbxstate
  100. {
  101. int icbxSel;
  102. BOOL bEdit;
  103. } CBXSTATE;
  104. //---------------------------------------------------------------------
  105. // keeps a list of the time unit abbreviations and full names
  106. // ie: h hr hrs hour hours
  107. //---------------------------------------------------------------------
  108. typedef struct _toktable
  109. {
  110. LPTSTR pszAbbrv;
  111. DWORD dwresourceid;
  112. } TOKTABLE, *PTOKTABLE;
  113. //---------------------------------------------------------------------
  114. // Dialog for Timeout settings page
  115. //---------------------------------------------------------------------
  116. class CTimeOutDlg : public CDialogBase
  117. {
  118. CTSUserSheet *m_pUSht;
  119. static WNDPROC m_pfWndproc;
  120. CBXSTATE m_cbxst[ 3 ];
  121. WORD m_wAction;
  122. WORD m_wCon;
  123. TOKTABLE m_tokday[ 4 ];
  124. TOKTABLE m_tokhour[ 6 ];
  125. TOKTABLE m_tokmin[ 5 ];
  126. public:
  127. CTimeOutDlg( CTSUserSheet * );
  128. BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  129. BOOL GetPropertySheetPage( PROPSHEETPAGE& );
  130. BOOL OnDestroy( );
  131. BOOL PersistSettings( HWND );
  132. BOOL IsValidSettings( HWND );
  133. void OnCommand( WORD , WORD , HWND );
  134. static INT_PTR CALLBACK DlgProc( HWND , UINT , WPARAM , LPARAM );
  135. BOOL ConvertToMinutes( HWND , PULONG );
  136. BOOL InsertSortedAndSetCurSel( HWND , DWORD );
  137. BOOL RestorePreviousValue( HWND );
  138. BOOL SaveChangedSelection( HWND );
  139. void OnCBNSELCHANGE( HWND );
  140. BOOL ConvertToDuration ( ULONG , LPTSTR );
  141. LRESULT ParseDurationEntry( LPTSTR , PULONG );
  142. int GetCBXSTATEindex( HWND );
  143. void OnCBEditChange( HWND );
  144. BOOL DoesContainDigits( LPTSTR );
  145. BOOL OnCBDropDown( HWND );
  146. BOOL IsToken( LPTSTR , TOKEN );
  147. BOOL LoadAbbreviates( );
  148. BOOL xxxLoadAbbreviate( PTOKTABLE );
  149. BOOL xxxUnLoadAbbreviate( PTOKTABLE );
  150. void InitTokTables( );
  151. };
  152. //---------------------------------------------------------------------
  153. // Dialog for Shadowing settings page
  154. //---------------------------------------------------------------------
  155. class CShadowDlg : public CDialogBase
  156. {
  157. CTSUserSheet *m_pUSht;
  158. WORD m_wOldRad;
  159. public:
  160. CShadowDlg( CTSUserSheet * );
  161. BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  162. BOOL GetPropertySheetPage( PROPSHEETPAGE& );
  163. BOOL OnDestroy( );
  164. void OnCommand( WORD , WORD , HWND );
  165. // BOOL OnNotify( int , LPNMHDR , HWND );
  166. BOOL PersistSettings( HWND );
  167. static INT_PTR CALLBACK DlgProc( HWND , UINT , WPARAM , LPARAM );
  168. };
  169. //---------------------------------------------------------------------
  170. // Dialog for profile page
  171. //---------------------------------------------------------------------
  172. class CProfileDlg : public CDialogBase
  173. {
  174. CTSUserSheet *m_pUSht;
  175. int m_ncbxOld;
  176. WORD m_wOldRadio;
  177. BOOL m_bTSHomeFolderChanged;
  178. public:
  179. CProfileDlg( CTSUserSheet * );
  180. BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  181. BOOL GetPropertySheetPage( PROPSHEETPAGE& );
  182. BOOL OnDestroy( );
  183. void OnCommand( WORD , WORD , HWND );
  184. BOOL EnableRemoteHomeDirectory( HWND , BOOL );
  185. BOOL SetWTSProfilePath( HWND , USERCONFIG& );
  186. BOOL SetWTSLocalPath( HWND , USERCONFIG& );
  187. BOOL SetWTSRemotePath( HWND , USERCONFIG& );
  188. BOOL IsPathValid( LPTSTR , BOOL );
  189. BOOL PersistSettings( HWND );
  190. BOOL IsValidSettings( HWND );
  191. BOOL IsLocalPathValid( HWND );
  192. BOOL IsRemotePathValid( HWND hDlg );
  193. void ExpandUserName( LPTSTR );
  194. BOOL createdir( LPTSTR , BOOL , PDWORD );
  195. static INT_PTR CALLBACK DlgProc( HWND , UINT , WPARAM , LPARAM );
  196. };
  197. #endif //_TSUSERSHEET_H