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.

367 lines
9.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. SpecDlg.hxx
  7. This dialog contains the definition for the Permissions Special
  8. dialog
  9. FILE HISTORY:
  10. Johnl 29-Aug-1991 Created
  11. */
  12. #ifndef _SPECDLG_HXX_
  13. #define _SPECDLG_HXX_
  14. #include "permdlg.hxx"
  15. #define CID_SPECIAL_BASE (CID_PERM_LAST)
  16. /* The checkbox control IDs must be in consecutive order.
  17. */
  18. #define COUNT_OF_CHECKBOXES 18
  19. #define CHECK_PERM_1 (CID_SPECIAL_BASE+1)
  20. #define CHECK_PERM_2 (CID_SPECIAL_BASE+2)
  21. #define CHECK_PERM_3 (CID_SPECIAL_BASE+3)
  22. #define CHECK_PERM_4 (CID_SPECIAL_BASE+4)
  23. #define CHECK_PERM_5 (CID_SPECIAL_BASE+5)
  24. #define CHECK_PERM_6 (CID_SPECIAL_BASE+6)
  25. #define CHECK_PERM_7 (CID_SPECIAL_BASE+7)
  26. #define CHECK_PERM_8 (CID_SPECIAL_BASE+8)
  27. #define CHECK_PERM_9 (CID_SPECIAL_BASE+9)
  28. #define CHECK_PERM_10 (CID_SPECIAL_BASE+10)
  29. #define CHECK_PERM_11 (CID_SPECIAL_BASE+11)
  30. #define CHECK_PERM_12 (CID_SPECIAL_BASE+12)
  31. #define CHECK_PERM_13 (CID_SPECIAL_BASE+13)
  32. #define CHECK_PERM_14 (CID_SPECIAL_BASE+14)
  33. #define CHECK_PERM_15 (CID_SPECIAL_BASE+15)
  34. #define CHECK_PERM_16 (CID_SPECIAL_BASE+16)
  35. #define CHECK_PERM_17 (CID_SPECIAL_BASE+17)
  36. #define CHECK_PERM_18 (CID_SPECIAL_BASE+18)
  37. #define SLE_SUBJECT_NAME (CID_SPECIAL_BASE+20)
  38. #define FRAME_PERMISSION_BOX (CID_SPECIAL_BASE+21)
  39. /* BUTTON_PERMIT (aka "Other") and BUTTON_ALL (generic all) are in all
  40. * of the NT special permission dialogs. The BUTTON_NOT_SPECIFIED button
  41. * is only in the "New Item" special dialog.
  42. */
  43. #define BUTTON_PERMIT (CID_SPECIAL_BASE+25)
  44. #define BUTTON_ALL (CID_SPECIAL_BASE+26)
  45. #define BUTTON_NOT_SPECIFIED (CID_SPECIAL_BASE+27)
  46. #ifndef RC_INVOKED
  47. /*************************************************************************
  48. NAME: ACCESS_PERM_CHECKBOX
  49. SYNOPSIS: This class is a checkbox that has a bitfield associated
  50. with it.
  51. INTERFACE:
  52. ACCESS_PERM_CHECKBOX
  53. Takes normal parameters plus the name of this checkbox and
  54. the bitfield to associate this checkbox with.
  55. QueryBitMask
  56. Returns the bitmask this CHECKBOX is associated with.
  57. See CHECKBOX for all other methods.
  58. PARENT: CHECKBOX
  59. USES: BITFIELD
  60. CAVEATS:
  61. NOTES:
  62. HISTORY:
  63. Johnl 30-Aug-1991 Created
  64. **************************************************************************/
  65. class ACCESS_PERM_CHECKBOX : public CHECKBOX
  66. {
  67. private:
  68. BITFIELD _bitsMask ;
  69. public:
  70. ACCESS_PERM_CHECKBOX( OWNER_WINDOW * powin,
  71. CID cid,
  72. const NLS_STR & nlsPermName,
  73. BITFIELD & bitsMask ) ;
  74. BITFIELD * QueryBitMask( void )
  75. { return &_bitsMask ; }
  76. } ;
  77. /*************************************************************************
  78. NAME: SPECIAL_DIALOG
  79. SYNOPSIS: This class is the "Special" dialog that the user will use
  80. to check the individual access writes.
  81. INTERFACE:
  82. SetCheckBoxNames
  83. Sets the name of each Checkbox based on the passed MASK_MAP
  84. (looks for each PERMTYPE_SPECIAL item in the MASK_MAP and
  85. consecutively sets the permission name). The name should have
  86. the embedded '&' accelerator.
  87. Resize
  88. Given the current state of the dialog, resizes the checkbox and
  89. repositions the contained controls so it is aesthetically
  90. pleasing.
  91. ApplyPermissionsToCheckBoxes
  92. Checks the appropriate checkboxes based on the passed bitfield
  93. QueryUserSelectedBits
  94. Builds a bitfield from the checkboxes the user selected
  95. QueryCheckBox
  96. Returns a pointer to the checkbox at the passed index (checks
  97. the index).
  98. QueryCount
  99. Returns the number of successfully constructed checkboxes
  100. QueryAccessBits
  101. Returns the Access permission map that this dialog is editting.
  102. PARENT: PERM_BASE_DLG
  103. USES: SLT, MASK_MAP, BITFIELD, ACCESS_PERMISSION, ACCESS_PERM_CHECKBOX
  104. CAVEATS:
  105. NOTES: This first ACCESS_PERM_CHECKBOX's CID in this dialog should start at
  106. CHECK_PERM_1 and be numbered consecutively up to
  107. (CHECK_PERM_1 + COUNT_OF_CHECKBOXES).
  108. HISTORY:
  109. Johnl 29-Aug-1991 Created
  110. **************************************************************************/
  111. class SPECIAL_DIALOG : public PERM_BASE_DLG
  112. {
  113. private:
  114. //
  115. // User/Group name we are editting
  116. //
  117. SLE _sleSubjectName ;
  118. //
  119. // The Bitfield/string pair map we are using.
  120. //
  121. MASK_MAP * _pAccessMaskMap ;
  122. //
  123. // Number of constructed checkboxes
  124. //
  125. UINT _cUsedCheckBoxes ;
  126. //
  127. // Pointer to the permission we are going to edit
  128. //
  129. BITFIELD * _pbitsAccessPerm ;
  130. //
  131. // Array of checkboxes (all checkboxes in this dialog are initially
  132. // hidden and disabled)
  133. //
  134. ACCESS_PERM_CHECKBOX *_pAccessPermCheckBox ;
  135. //
  136. // The frame surrounding the checkboxes (we may need to resize).
  137. //
  138. CONTROL_WINDOW _cwinPermFrame ;
  139. //
  140. // This flag is TRUE if we are a special group that cannot be
  141. // denied all (such as LM groups).
  142. //
  143. BOOL _fCannotDenyAll ;
  144. //
  145. // This flag is TRUE if this dialog is read only, FALSE otherwise.
  146. //
  147. BOOL _fIsReadOnly ;
  148. protected:
  149. virtual BOOL OnOK( void ) ;
  150. virtual ULONG QueryHelpContext( void ) ;
  151. APIERR SetCheckBoxNames( MASK_MAP * pAccessMaskMap, BOOL fReadOnly ) ;
  152. APIERR ApplyPermissionsToCheckBoxes( BITFIELD * bitmask ) ;
  153. void Resize( void ) ;
  154. BOOL IsReadOnly( void ) const
  155. { return _fIsReadOnly ; }
  156. public:
  157. SPECIAL_DIALOG( const TCHAR * pszDialogName,
  158. HWND hwndParent,
  159. const TCHAR * pszResourceType,
  160. const TCHAR * pszResourceName,
  161. const TCHAR * pszHelpFileName,
  162. const TCHAR * pszDialogTitle,
  163. BITFIELD * pbitsAccessPerm,
  164. MASK_MAP * pAccessMaskMap,
  165. const TCHAR * pszSubjectTitle,
  166. ULONG * ahcHelp,
  167. BOOL fIsReadOnly ) ;
  168. virtual ~SPECIAL_DIALOG() ;
  169. void QueryUserSelectedBits( BITFIELD * pbitsUserSelected ) ;
  170. ACCESS_PERM_CHECKBOX * QueryCheckBox( UINT index )
  171. { UIASSERT( index < QueryCount() ) ; return &_pAccessPermCheckBox[index] ; }
  172. /* Returns the number of checkboxes that are in use
  173. */
  174. UINT QueryCount( void )
  175. { return _cUsedCheckBoxes ; }
  176. BITFIELD * QueryAccessBits( void )
  177. { return _pbitsAccessPerm ; }
  178. /* Returns TRUE if a whole column of checkboxes is filled (thus we don't
  179. * need to resize vertically).
  180. */
  181. BOOL IsFilledVertically( void )
  182. { return (QueryCount() >= COUNT_OF_CHECKBOXES / 2 ) ; }
  183. } ;
  184. /*************************************************************************
  185. NAME: NT_SPECIAL_DIALOG
  186. SYNOPSIS: This class includes an "All" radio button choice that
  187. corresponds to Generic All. It is used for all NT objects
  188. except for the "New Item" permissions.
  189. INTERFACE:
  190. PARENT: SPECIAL_DIALOG
  191. CAVEATS:
  192. NOTES:
  193. HISTORY:
  194. Johnl 30-Mar-1992 Created
  195. **************************************************************************/
  196. class NT_SPECIAL_DIALOG : public SPECIAL_DIALOG
  197. {
  198. private:
  199. MAGIC_GROUP _mgrpSelectionOptions ;
  200. protected:
  201. virtual BOOL OnOK( void ) ;
  202. public:
  203. NT_SPECIAL_DIALOG( const TCHAR * pszDialogName,
  204. HWND hwndParent,
  205. const TCHAR * pszResourceType,
  206. const TCHAR * pszResourceName,
  207. const TCHAR * pszHelpFileName,
  208. const TCHAR * pszDialogTitle,
  209. BITFIELD * pbitsAccessPerm,
  210. MASK_MAP * pAccessMaskMap,
  211. const TCHAR * pszSubjectTitle,
  212. ULONG * ahcHelp,
  213. BOOL fIsReadOnly,
  214. INT cMagicGroupButtons = 2,
  215. CID cidDefaultMagicGroupButton = BUTTON_PERMIT) ;
  216. ~NT_SPECIAL_DIALOG() ;
  217. BOOL IsAllSpecified( void )
  218. { return _mgrpSelectionOptions.QuerySelection() == BUTTON_ALL ; }
  219. const MAGIC_GROUP * QueryMagicGroup( void ) const
  220. { return &_mgrpSelectionOptions ; }
  221. } ;
  222. /*************************************************************************
  223. NAME: NEW_OBJ_SPECIAL_DIALOG
  224. SYNOPSIS: This dialog is essentially the SPECIAL_DIALOG except a
  225. magic group has been added that allows the user to
  226. specify the special permissions are not specified for
  227. new files
  228. INTERFACE: Same as SPECIAL_DIALOG except:
  229. IsSpecified
  230. Returns TRUE if the user has chosen the "Permit"
  231. radio button, FALSE otherwise.
  232. PARENT: SPECIAL_DIALOG
  233. USES: MAGIC_GROUP
  234. CAVEATS:
  235. NOTES:
  236. HISTORY:
  237. Johnl 18-Nov-1991 Created
  238. **************************************************************************/
  239. class NEW_OBJ_SPECIAL_DIALOG : public NT_SPECIAL_DIALOG
  240. {
  241. protected:
  242. virtual BOOL OnOK( void ) ;
  243. virtual ULONG QueryHelpContext( void ) ;
  244. public:
  245. NEW_OBJ_SPECIAL_DIALOG( const TCHAR * pszDialogName,
  246. HWND hwndParent,
  247. const TCHAR * pszResourceType,
  248. const TCHAR * pszResourceName,
  249. const TCHAR * pszHelpFileName,
  250. const TCHAR * pszDialogTitle,
  251. BITFIELD * pbitsAccessPerm,
  252. MASK_MAP * pAccessMaskMap,
  253. const TCHAR * pszSubjectTitle,
  254. ULONG * ahcHelp,
  255. BOOL fIsReadOnly,
  256. BOOL fPermSpecified ) ;
  257. ~NEW_OBJ_SPECIAL_DIALOG() ;
  258. BOOL IsNotSpecified( void )
  259. { return QueryMagicGroup()->QuerySelection() == BUTTON_NOT_SPECIFIED ; }
  260. } ;
  261. #endif // RC_INVOKED
  262. #endif // _SPECDLG_HXX_