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.

331 lines
7.5 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. BOOL m_bDC; // domain controller
  35. BOOL m_bIsConfigLoaded;
  36. BOOL GetUserConfig( PDWORD );
  37. TCHAR m_szRemoteServerName[ MAX_PATH ];
  38. BOOL m_bDSAType;
  39. PSID m_pUserSid;
  40. public:
  41. CTSUserSheet();
  42. ~CTSUserSheet();
  43. BOOL SetServerAndUser( LPWSTR , LPWSTR );
  44. BOOL GetServer(PWSTR *);
  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. //
  55. // public data
  56. //
  57. USERCONFIG m_userconfig;
  58. UINT m_cref;
  59. };
  60. //---------------------------------------------------------------------
  61. // CDialogBase - as the name implies base class for all the dialogs
  62. //---------------------------------------------------------------------
  63. class CDialogBase
  64. {
  65. protected:
  66. BOOL m_bPersisted;
  67. HWND m_hWnd;
  68. CTSUserSheet *m_pUSht;
  69. static UINT CALLBACK PageCallback(HWND hDlg, UINT uMsg, LPPROPSHEETPAGE ppsp);
  70. public:
  71. virtual BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  72. virtual BOOL OnDestroy( ){ return TRUE; }
  73. virtual BOOL GetPropertySheetPage( PROPSHEETPAGE& ){ return FALSE;}
  74. virtual BOOL PersistSettings( HWND ){ return FALSE;}
  75. virtual BOOL IsValidSettings( HWND ){ return TRUE;}
  76. virtual BOOL OnNotify( int , LPNMHDR , HWND );
  77. virtual BOOL OnContextMenu( HWND , POINT& );
  78. virtual BOOL OnHelp( HWND , LPHELPINFO );
  79. CDialogBase( );
  80. //virtual ~CDialogBase( );
  81. };
  82. //---------------------------------------------------------------------
  83. // Dialog for profile page
  84. //---------------------------------------------------------------------
  85. class CEnviroDlg : public CDialogBase
  86. {
  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. static WNDPROC m_pfWndproc;
  119. CBXSTATE m_cbxst[ 3 ];
  120. WORD m_wAction;
  121. WORD m_wCon;
  122. TOKTABLE m_tokday[ 4 ];
  123. TOKTABLE m_tokhour[ 6 ];
  124. TOKTABLE m_tokmin[ 5 ];
  125. public:
  126. CTimeOutDlg( CTSUserSheet * );
  127. BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  128. BOOL GetPropertySheetPage( PROPSHEETPAGE& );
  129. BOOL OnDestroy( );
  130. BOOL PersistSettings( HWND );
  131. BOOL IsValidSettings( HWND );
  132. void OnCommand( WORD , WORD , HWND );
  133. static INT_PTR CALLBACK DlgProc( HWND , UINT , WPARAM , LPARAM );
  134. BOOL ConvertToMinutes( HWND , PULONG );
  135. BOOL InsertSortedAndSetCurSel( HWND , DWORD );
  136. BOOL RestorePreviousValue( HWND );
  137. BOOL SaveChangedSelection( HWND );
  138. void OnCBNSELCHANGE( HWND );
  139. BOOL ConvertToDuration ( ULONG , LPTSTR );
  140. LRESULT ParseDurationEntry( LPTSTR , PULONG );
  141. int GetCBXSTATEindex( HWND );
  142. void OnCBEditChange( HWND );
  143. BOOL DoesContainDigits( LPTSTR );
  144. BOOL OnCBDropDown( HWND );
  145. BOOL IsToken( LPTSTR , TOKEN );
  146. BOOL LoadAbbreviates( );
  147. BOOL xxxLoadAbbreviate( PTOKTABLE );
  148. BOOL xxxUnLoadAbbreviate( PTOKTABLE );
  149. void InitTokTables( );
  150. };
  151. //---------------------------------------------------------------------
  152. // Dialog for Shadowing settings page
  153. //---------------------------------------------------------------------
  154. class CShadowDlg : public CDialogBase
  155. {
  156. WORD m_wOldRad;
  157. public:
  158. CShadowDlg( CTSUserSheet * );
  159. BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  160. BOOL GetPropertySheetPage( PROPSHEETPAGE& );
  161. BOOL OnDestroy( );
  162. void OnCommand( WORD , WORD , HWND );
  163. // BOOL OnNotify( int , LPNMHDR , HWND );
  164. BOOL PersistSettings( HWND );
  165. static INT_PTR CALLBACK DlgProc( HWND , UINT , WPARAM , LPARAM );
  166. };
  167. //---------------------------------------------------------------------
  168. // Dialog for profile page
  169. //---------------------------------------------------------------------
  170. class CProfileDlg : public CDialogBase
  171. {
  172. int m_ncbxOld;
  173. WORD m_wOldRadio;
  174. BOOL m_bTSHomeFolderChanged;
  175. public:
  176. CProfileDlg( CTSUserSheet * );
  177. BOOL OnInitDialog( HWND , WPARAM , LPARAM );
  178. BOOL GetPropertySheetPage( PROPSHEETPAGE& );
  179. BOOL OnDestroy( );
  180. void OnCommand( WORD , WORD , HWND );
  181. BOOL EnableRemoteHomeDirectory( HWND , BOOL );
  182. BOOL SetWTSProfilePath( HWND , USERCONFIG& );
  183. BOOL SetWTSLocalPath( HWND , USERCONFIG& );
  184. BOOL SetWTSRemotePath( HWND , USERCONFIG& );
  185. BOOL IsPathValid( LPTSTR , BOOL );
  186. BOOL PersistSettings( HWND );
  187. BOOL IsValidSettings( HWND );
  188. BOOL IsLocalPathValid( HWND );
  189. BOOL IsRemotePathValid( HWND hDlg );
  190. void ExpandUserName( LPTSTR );
  191. BOOL createdir( LPTSTR , BOOL , PDWORD );
  192. BOOL CreateSecureDir(LPTSTR szPath , PDWORD pdwErr);
  193. BOOL IsLocalComputer(WCHAR*);
  194. static INT_PTR CALLBACK DlgProc( HWND , UINT , WPARAM , LPARAM );
  195. HRESULT CreateRemoteFolder(LPCTSTR path);
  196. BOOL CreateSystemPath(TCHAR* tchPath);
  197. };
  198. #endif //_TSUSERSHEET_H