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.

492 lines
16 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. * sharebas.hxx
  7. * This file contains the Base Classes of the Share Dialogs in
  8. * File Manager Extensions.
  9. *
  10. * The hierarchy of Share Dialogs is as follows:
  11. *
  12. * SHARE_DIALOG_BASE // in this file
  13. * ADD_SHARE_DIALOG_BASE // in sharecrt.hxx
  14. * FILEMGR_NEW_SHARE_DIALOG // in sharecrt.hxx
  15. * SVRMGR_NEW_SHARE_DIALOG // in sharecrt.hxx
  16. * SVRMGR_SHARE_PROP_DIALOG // in sharecrt.hxx
  17. * FILEMGR_SHARE_PROP_DIALOG // in sharecrt.hxx
  18. *
  19. * VIEW_SHARE_DIALOG_BASE // in sharestp.hxx
  20. * STOP_SHARING_DIALOG // in sharestp.hxx
  21. * SHARE_MANAGEMENT_DIALOG // in sharemgt.hxx
  22. *
  23. * SHARE_LEVEL_PERMISSIONS_DIALOG // in this file
  24. * CURRENT_USERS_WARNING_DIALOG // in sharestp.hxx
  25. *
  26. * PERMISSION_GROUP // in this file
  27. *
  28. * The following are some miscellaneous classes used.
  29. * SHARE_NAME_WITH_PATH_ENUM_ITER // in this file
  30. *
  31. * The following class are used to manipulate path names.
  32. * SHARE_NET_NAME // in this file
  33. *
  34. * FILE HISTORY:
  35. * Yi-HsinS 8/15/91 Created
  36. * Yi-HsinS 11/15/91 Changed all USHORT to UINT
  37. * Yi-HsinS 12/5/91 Separated FULL_SHARE_NAME, UNC_NAME,
  38. * RELATIVE_PATH_NAME into netname.hxx
  39. * and combine them into NET_NAME
  40. * Yi-HsinS 12/15/91 Added SHARE_NET_NAME
  41. * Yi-HsinS 12/18/91 Make destructor of SHARE_PROPERTIES_BASE
  42. * virtual
  43. * Yi-HsinS 12/31/91 Unicode work - move ADMIN_SHARE to
  44. * strchlit.hxx
  45. * Yi-HsinS 1/8/92 Moved SHARE_PROPERTIES_BASE to
  46. * sharewnp.hxx
  47. * Terryk 4/17/92 Changed User limit from long to ulong
  48. * Yi-HsinS 8/3/92 Rearrange the hierarchy again to match
  49. * Winball dialogs
  50. * Yi-HsinS 10/9/92 Add ulHelpContextBase to
  51. * SHARE_DIALOG_BASE
  52. * Yi-HsinS 11/20/92 Remove _sltAdminInfo
  53. * ChuckC 31/1/93 Moved SERVER_WITH_PASSWORD_PROMPT to
  54. * aprompt.hxx
  55. */
  56. #ifndef _SHAREBAS_HXX_
  57. #define _SHAREBAS_HXX_
  58. #include <lmoesh.hxx> // for SHARE2_ENUM_ITER
  59. #include <lmosrv.hxx> // for SERVER_2
  60. #include <netname.hxx> // for NET_NAME
  61. #include <security.hxx> // for OS_SECURITY_DESCRIPTOR
  62. #include <slestrip.hxx> // for SLE_STRIP
  63. #include <aprompt.hxx> // SERVER_WITH_PASSWORD_PROMPT
  64. #define SHARE_NAME_LENGTH LM20_NNLEN // vs. NNLEN
  65. #define SHARE_COMMENT_LENGTH LM20_MAXCOMMENTSZ // vs. MAXCOMMENTSZ
  66. #define LANMAN_USERS_MAX 0xFFFE // Down-level Servers
  67. // NOTE : There are some problems on what structure to send from
  68. // WIN16 to NT servers or OS2 servers. For now, just assume that the
  69. // maximum user limit that can be set on WIN16 to NT servers
  70. // are the same as to OS2 servers.
  71. #ifndef WIN32
  72. #define NT_USERS_MAX LANMAN_USERS_MAX
  73. #else
  74. #define NT_USERS_MAX 0xFFFFFFFE // NT Servers
  75. #endif
  76. /*************************************************************************
  77. NAME: SHARE_DIALOG_BASE
  78. SYNOPSIS: The base class for new share dialogs and share
  79. properties dialog contained in the file manager or
  80. server manager. It contains the magic group
  81. for User Limit, SLE for Comment field, SLE for the path,
  82. the OK, Cancel, Permissions button and an SLT for showing
  83. admin information.
  84. INTERFACE: SHARE_DIALOG_BASE() - Constructor
  85. ~SHARE_DIALOG_BASE() - Destructor
  86. QueryPBOK() - Return a pointer to the OK button
  87. QueryPBCancel() - Return a pointer to the Cancel button
  88. QueryPBPermissions() - Return a pointer to the Permission button
  89. QueryServer2() - Return the SERVER_WITH_PASSWORD_PROMPT
  90. object. Pure virtual method to be defined
  91. in the derived classes.
  92. QueryShare() - Query the name of the share in the dialog
  93. This is a pure virtual method to be
  94. defined in the derived classes.
  95. PARENT: DIALOG_WINDOW
  96. USES: SLE, SLT, MAGIC_GROUP, SPIN_SLE_NUM, SPIN_GROUP, PUSH_BUTTON
  97. CAVEATS:
  98. NOTES:
  99. HISTORY:
  100. Yi-HsinS 8/25/91 Created
  101. Yi-HsinS 4/20/92 Got rid of uiSpecialUserLimit
  102. **************************************************************************/
  103. class SHARE_DIALOG_BASE : public DIALOG_WINDOW
  104. {
  105. private:
  106. SLE _slePath;
  107. SLE _sleComment;
  108. MAGIC_GROUP _mgrpUserLimit;
  109. SPIN_SLE_NUM _spsleUsers;
  110. SPIN_GROUP _spgrpUsers;
  111. PUSH_BUTTON _buttonOK;
  112. PUSH_BUTTON _buttonCancel;
  113. PUSH_BUTTON _buttonPermissions;
  114. // Below are stored information for share permissions on NT
  115. OS_SECURITY_DESCRIPTOR *_pStoredSecDesc;
  116. BOOL _fSecDescModified;
  117. // Below are stored information for share permissions on
  118. // LM share-level server
  119. NLS_STR _nlsStoredPassword;
  120. UINT _uiStoredPermissions;
  121. // Below are stored information about whether the share is admin only or not
  122. BOOL _fStoredAdminOnly;
  123. //
  124. // Place to store the help context base
  125. //
  126. ULONG _ulHelpContextBase;
  127. protected:
  128. virtual BOOL OnCommand( const CONTROL_EVENT & event );
  129. //
  130. // Helper method called when the permissions button is pressed
  131. //
  132. VOID OnPermissions( VOID );
  133. //
  134. // Helper method for changing share properties of a share
  135. //
  136. APIERR OnChangeShareProperty( SERVER_WITH_PASSWORD_PROMPT *psvr,
  137. const TCHAR *pszShare );
  138. //
  139. // Display the properties of the share on the server in the dialog
  140. //
  141. APIERR UpdateInfo( SERVER_WITH_PASSWORD_PROMPT *psvr,
  142. const TCHAR *pszShare );
  143. //
  144. // Update the permissions information which will be displayed if
  145. // the user hits the permissions button. Also called when a share
  146. // will be "renamed" i.e. deleted and recreated.
  147. //
  148. APIERR UpdatePermissionsInfo( SERVER_WITH_PASSWORD_PROMPT *psvr,
  149. SHARE_2 * psh2,
  150. const TCHAR *pszShare );
  151. //
  152. // Used when the share is on NT servers - Write the share permissions out
  153. //
  154. APIERR ApplySharePermissions( const TCHAR *pszServer,
  155. const TCHAR *pszShare,
  156. const OS_SECURITY_DESCRIPTOR * posSecDesc) ;
  157. //
  158. // Used when the share is on NT servers - Query the permissions of the
  159. // share.
  160. //
  161. APIERR QuerySharePermissions( const TCHAR *pszServer,
  162. const TCHAR *pszShare,
  163. OS_SECURITY_DESCRIPTOR ** pposSecDesc) ;
  164. //
  165. // Used by subclasses which want to force permissions to be written,
  166. // in particular, by SVRMGR_SHARE_PROP_DIALOG when the user changes
  167. // the path to a share.
  168. //
  169. VOID SetSecDescModified()
  170. { _fSecDescModified = TRUE; }
  171. //
  172. // Used only when the share is on LM 2.x share-level servers - query
  173. // the permissions of the share
  174. //
  175. UINT QueryStoredPermissions( VOID ) const
  176. { return _uiStoredPermissions; }
  177. //
  178. // Used only when the share is on LM 2.x share-level servers - query
  179. // the password of the share
  180. //
  181. const TCHAR *QueryStoredPassword( VOID ) const
  182. { return _nlsStoredPassword.QueryPch(); }
  183. //
  184. // Used only when the share is on NT servers - query the
  185. // the security descriptor of the share
  186. //
  187. OS_SECURITY_DESCRIPTOR *QueryStoredSecDesc( VOID ) const
  188. { return _pStoredSecDesc; }
  189. //
  190. // Reset all the stored information - permission, password,
  191. // security descriptors
  192. //
  193. APIERR ClearStoredInfo( VOID );
  194. //
  195. // Set the maximum number that will appear on the spin button
  196. //
  197. APIERR SetMaxUserLimit( ULONG ulMaxUserLimit );
  198. //
  199. // Query or set the contents of Path
  200. //
  201. APIERR QueryPath( NLS_STR *pnlsPath ) const
  202. { return _slePath.QueryText( pnlsPath ); }
  203. VOID SetPath( const TCHAR *pszPath )
  204. { _slePath.SetText( pszPath ); }
  205. //
  206. // Query or set the contents of the SLE comment
  207. //
  208. APIERR QueryComment( NLS_STR *pnlsComment ) const
  209. { return _sleComment.QueryText( pnlsComment ); }
  210. VOID SetComment( const TCHAR *pszComment )
  211. { _sleComment.SetText( pszComment ); }
  212. //
  213. // Query or set the contents of User Limit
  214. //
  215. ULONG QueryUserLimit( VOID ) const;
  216. APIERR SetUserLimit( ULONG ulUserLimit );
  217. //
  218. // Set Focus on the controls - SLE comment or User Limit magic group
  219. // This will be used by derived classes when error occurs.
  220. //
  221. VOID SetFocusOnPath( VOID )
  222. { _slePath.ClaimFocus(); _slePath.SelectString(); }
  223. VOID SetFocusOnComment( VOID )
  224. { _sleComment.ClaimFocus(); _sleComment.SelectString(); }
  225. VOID SetFocusOnUserLimit( VOID )
  226. { _mgrpUserLimit.SetControlValueFocus(); }
  227. //
  228. // Query pointers to the controls
  229. //
  230. SLE *QuerySLEPath( VOID )
  231. { return &_slePath; }
  232. SLE *QuerySLEComment( VOID )
  233. { return &_sleComment; }
  234. SPIN_SLE_NUM *QuerySpinSLEUsers( VOID )
  235. { return &_spsleUsers; }
  236. public:
  237. SHARE_DIALOG_BASE( const TCHAR *pszDlgResource,
  238. HWND hwndParent,
  239. ULONG ulHelpContextBase,
  240. ULONG ulMaxUserLimit = NT_USERS_MAX );
  241. virtual ~SHARE_DIALOG_BASE();
  242. PUSH_BUTTON *QueryPBOK( VOID )
  243. { return &_buttonOK; }
  244. PUSH_BUTTON *QueryPBCancel( VOID )
  245. { return &_buttonCancel; }
  246. PUSH_BUTTON *QueryPBPermissions( VOID )
  247. { return &_buttonPermissions; }
  248. virtual APIERR QueryServer2( SERVER_WITH_PASSWORD_PROMPT **ppsvr ) = 0;
  249. virtual APIERR QueryShare( NLS_STR *pnlsShare ) const = 0;
  250. ULONG QueryHelpContextBase( VOID ) const
  251. { return _ulHelpContextBase; }
  252. };
  253. /*************************************************************************
  254. NAME: PERMISSION_GROUP
  255. SYNOPSIS: The class contains a group to access permissions
  256. on a LM 2.1 share level server. This class is used in
  257. SHARE_LEVEL_PERMISSIONS_DIALOG.
  258. INTERFACE: PERMISSION_GROUP()- Constructor
  259. QueryPermission() - Query the permission in a bitmask
  260. SetPermission() - Set the permission given a bitmask
  261. ClaimFocus() - Set the focus to this group
  262. SetFocusOnOther() - Set focus on Other Edit Field of the
  263. magic group
  264. PARENT: BASE
  265. USES: SLE_STRIP, MAGIC_GROUP
  266. CAVEATS:
  267. NOTES:
  268. HISTORY:
  269. Yi-HsinS 8/25/91 Created
  270. **************************************************************************/
  271. class PERMISSION_GROUP: public BASE
  272. {
  273. private:
  274. MAGIC_GROUP _mgrpPermission;
  275. SLE_STRIP _sleOther;
  276. //
  277. // Check if the permission entered into the Other edit field is valid
  278. // If valid, stored it in *pusPermission. Otherwise, return an error.
  279. //
  280. APIERR GetAndCheckOtherField( UINT *pusPermission ) const;
  281. public:
  282. PERMISSION_GROUP( OWNER_WINDOW *powin,
  283. CID cidBase,
  284. CID cidOtherEditField,
  285. CID cidInitialSelection = RG_NO_SEL,
  286. CONTROL_GROUP *pgroupOwner = NULL );
  287. APIERR QueryPermission( UINT *pusPermission ) const;
  288. APIERR SetPermission( UINT usPermission );
  289. VOID ClaimFocus( VOID )
  290. { _mgrpPermission.SetControlValueFocus(); }
  291. VOID SetFocusOnOther( VOID )
  292. { _sleOther.SelectString(); _sleOther.ClaimFocus(); }
  293. };
  294. /*************************************************************************
  295. NAME: SHARE_LEVEL_PERMISSIONS_DIALOG
  296. SYNOPSIS: This is the dialog for displaying the password and
  297. permissions of the share if it's on a LM 2.x share-level server
  298. INTERFACE: SHARE_LEVEL_PERMISSIONS_DIALOG() - Constructor
  299. PARENT: DIALOG_WINDOW
  300. USES: NLS_STR, SLE, PERMISSION_GROUP
  301. CAVEATS:
  302. NOTES: OnCancel is not redefined here. The default in the
  303. DIALOG_WINDOW class serves the purpose - Dismiss( FALSE )
  304. HISTORY:
  305. Yi-HsinS 8/25/91 Created
  306. **************************************************************************/
  307. class SHARE_LEVEL_PERMISSIONS_DIALOG : public DIALOG_WINDOW
  308. {
  309. private:
  310. //
  311. // Place to store the password typed by the user
  312. //
  313. NLS_STR *_pnlsPassword;
  314. //
  315. // Place to store the permissions entered by the user
  316. //
  317. UINT *_puiPermissions;
  318. PERMISSION_GROUP _permgrp;
  319. SLE _slePassword;
  320. //
  321. // Place to store the help context base
  322. //
  323. ULONG _ulHelpContextBase;
  324. protected:
  325. virtual BOOL OnOK( VOID );
  326. virtual ULONG QueryHelpContext( VOID );
  327. public:
  328. SHARE_LEVEL_PERMISSIONS_DIALOG( HWND hwndParent,
  329. NLS_STR *pnlsPassword,
  330. UINT *puiPermissions,
  331. ULONG ulHelpContextBase );
  332. };
  333. /*************************************************************************
  334. NAME: SHARE_NAME_WITH_PATH_ENUM_ITER
  335. SYNOPSIS: The class for iterating the share names on the server with
  336. the selected path. It is similar to SHARE2_ENUM_ITER
  337. except that a pointer to share name is returned instead
  338. of the whole share_info_2 and only the share names with
  339. the same path as the selected path is returned.
  340. INTERFACE: SHARE_NAME_WITH_PATH_ENUM_ITER() - Constructor
  341. operator()() - Iterator
  342. PARENT: BASE
  343. USES: SHARE2_ENUM_ITER, NLS_STR
  344. CAVEATS:
  345. NOTES:
  346. HISTORY:
  347. Yi-HsinS 8/25/91 Created
  348. **************************************************************************/
  349. class SHARE_NAME_WITH_PATH_ENUM_ITER : public BASE
  350. {
  351. private:
  352. SHARE2_ENUM_ITER _sh2EnumIter;
  353. //
  354. // The path that we want to match with the path of the shares returned.
  355. //
  356. NLS_STR _nlsActPath;
  357. public:
  358. SHARE_NAME_WITH_PATH_ENUM_ITER( SHARE2_ENUM &shPathEnum,
  359. const NLS_STR &nlsActPath );
  360. const TCHAR *operator()( VOID );
  361. };
  362. /*************************************************************************
  363. NAME: SHARE_NET_NAME
  364. SYNOPSIS: This class is actually the same as the NET_NAME class
  365. except that its constructor checks for the errors of local
  366. computer. If it's not sharable, find out whether the
  367. local machine is not an NT machine or the Server service
  368. on NT has not been started.
  369. INTERFACE: SHARE_NET_NAME() - Constructor
  370. PARENT: NET_NAME
  371. USES:
  372. CAVEATS:
  373. NOTES:
  374. HISTORY:
  375. Yi-HsinS 12/15/91 Created
  376. **************************************************************************/
  377. class SHARE_NET_NAME : public NET_NAME
  378. {
  379. public:
  380. SHARE_NET_NAME( const TCHAR *pszSharePath,
  381. NETNAME_TYPE netNameType = TYPE_UNKNOWN );
  382. };
  383. #endif