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.

353 lines
9.2 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 SLT_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, CID cid,
  71. const NLS_STR & nlsPermName,
  72. BITFIELD & bitsMask ) ;
  73. BITFIELD * QueryBitMask( void )
  74. { return &_bitsMask ; }
  75. } ;
  76. /*************************************************************************
  77. NAME: SPECIAL_DIALOG
  78. SYNOPSIS: This class is the "Special" dialog that the user will use
  79. to check the individual access writes.
  80. INTERFACE:
  81. SetCheckBoxNames
  82. Sets the name of each Checkbox based on the passed MASK_MAP
  83. (looks for each PERMTYPE_SPECIAL item in the MASK_MAP and
  84. consecutively sets the permission name). The name should have
  85. the embedded '&' accelerator.
  86. Resize
  87. Given the current state of the dialog, resizes the checkbox and
  88. repositions the contained controls so it is aesthetically
  89. pleasing.
  90. ApplyPermissionsToCheckBoxes
  91. Checks the appropriate checkboxes based on the passed bitfield
  92. QueryUserSelectedBits
  93. Builds a bitfield from the checkboxes the user selected
  94. QueryCheckBox
  95. Returns a pointer to the checkbox at the passed index (checks
  96. the index).
  97. QueryCount
  98. Returns the number of successfully constructed checkboxes
  99. QueryAccessBits
  100. Returns the Access permission map that this dialog is editting.
  101. PARENT: PERM_BASE_DLG
  102. USES: SLT, MASK_MAP, BITFIELD, ACCESS_PERMISSION, ACCESS_PERM_CHECKBOX
  103. CAVEATS:
  104. NOTES: This first ACCESS_PERM_CHECKBOX's CID in this dialog should start at
  105. CHECK_PERM_1 and be numbered consecutively up to
  106. (CHECK_PERM_1 + COUNT_OF_CHECKBOXES).
  107. HISTORY:
  108. Johnl 29-Aug-1991 Created
  109. **************************************************************************/
  110. class SPECIAL_DIALOG : public PERM_BASE_DLG
  111. {
  112. private:
  113. //
  114. // User/Group name we are editting
  115. //
  116. SLT _sltSubjectName ;
  117. //
  118. // The Bitfield/string pair map we are using.
  119. //
  120. MASK_MAP * _pAccessMaskMap ;
  121. //
  122. // Number of constructed checkboxes
  123. //
  124. UINT _cUsedCheckBoxes ;
  125. //
  126. // Pointer to the permission we are going to edit
  127. //
  128. BITFIELD * _pbitsAccessPerm ;
  129. //
  130. // Array of checkboxes (all checkboxes in this dialog are initially
  131. // hidden and disabled)
  132. //
  133. ACCESS_PERM_CHECKBOX *_pAccessPermCheckBox ;
  134. //
  135. // The frame surrounding the checkboxes (we may need to resize).
  136. //
  137. CONTROL_WINDOW _cwinPermFrame ;
  138. ULONG _ulHelpContext ;
  139. protected:
  140. virtual BOOL OnOK( void ) ;
  141. virtual ULONG QueryHelpContext( void ) ;
  142. APIERR SetCheckBoxNames( MASK_MAP * pAccessMaskMap ) ;
  143. APIERR ApplyPermissionsToCheckBoxes( BITFIELD * bitmask ) ;
  144. void Resize( void ) ;
  145. ULONG QueryHelp( void ) const
  146. { return _ulHelpContext ; }
  147. public:
  148. SPECIAL_DIALOG( const TCHAR * pszDialogName,
  149. HWND hwndParent,
  150. const TCHAR * pszResourceType,
  151. const TCHAR * pszResourceName,
  152. const TCHAR * pszDialogTitle,
  153. BITFIELD * pbitsAccessPerm,
  154. MASK_MAP * pAccessMaskMap,
  155. const TCHAR * pszSubjectTitle,
  156. ULONG ulHelpContext ) ;
  157. virtual ~SPECIAL_DIALOG() ;
  158. void QueryUserSelectedBits( BITFIELD * pbitsUserSelected ) ;
  159. ACCESS_PERM_CHECKBOX * QueryCheckBox( UINT index )
  160. { UIASSERT( index < QueryCount() ) ; return &_pAccessPermCheckBox[index] ; }
  161. /* Returns the number of checkboxes that are in use
  162. */
  163. UINT QueryCount( void )
  164. { return _cUsedCheckBoxes ; }
  165. BITFIELD * QueryAccessBits( void )
  166. { return _pbitsAccessPerm ; }
  167. /* Returns TRUE if a whole column of checkboxes is filled (thus we don't
  168. * need to resize vertically).
  169. */
  170. BOOL IsFilledVertically( void )
  171. { return (QueryCount() >= COUNT_OF_CHECKBOXES / 2 ) ; }
  172. } ;
  173. /*************************************************************************
  174. NAME: NT_SPECIAL_DIALOG
  175. SYNOPSIS: This class includes an "All" radio button choice that
  176. corresponds to Generic All. It is used for all NT objects
  177. except for the "New Item" permissions.
  178. INTERFACE:
  179. PARENT: SPECIAL_DIALOG
  180. CAVEATS:
  181. NOTES:
  182. HISTORY:
  183. Johnl 30-Mar-1992 Created
  184. **************************************************************************/
  185. class NT_SPECIAL_DIALOG : public SPECIAL_DIALOG
  186. {
  187. private:
  188. MAGIC_GROUP _mgrpSelectionOptions ;
  189. protected:
  190. virtual BOOL OnOK( void ) ;
  191. virtual ULONG QueryHelpContext( void ) ;
  192. public:
  193. NT_SPECIAL_DIALOG( const TCHAR * pszDialogName,
  194. HWND hwndParent,
  195. const TCHAR * pszResourceType,
  196. const TCHAR * pszResourceName,
  197. const TCHAR * pszDialogTitle,
  198. BITFIELD * pbitsAccessPerm,
  199. MASK_MAP * pAccessMaskMap,
  200. const TCHAR * pszSubjectTitle,
  201. ULONG ulHelpContext,
  202. INT cMagicGroupButtons = 2,
  203. CID cidDefaultMagicGroupButton = BUTTON_PERMIT) ;
  204. ~NT_SPECIAL_DIALOG() ;
  205. BOOL IsAllSpecified( void )
  206. { return _mgrpSelectionOptions.QuerySelection() == BUTTON_ALL ; }
  207. MAGIC_GROUP * QueryMagicGroup( void ) const
  208. { return &_mgrpSelectionOptions ; }
  209. } ;
  210. /*************************************************************************
  211. NAME: NEW_OBJ_SPECIAL_DIALOG
  212. SYNOPSIS: This dialog is essentially the SPECIAL_DIALOG except a
  213. magic group has been added that allows the user to
  214. specify the special permissions are not specified for
  215. new files
  216. INTERFACE: Same as SPECIAL_DIALOG except:
  217. IsSpecified
  218. Returns TRUE if the user has chosen the "Permit"
  219. radio button, FALSE otherwise.
  220. PARENT: SPECIAL_DIALOG
  221. USES: MAGIC_GROUP
  222. CAVEATS:
  223. NOTES:
  224. HISTORY:
  225. Johnl 18-Nov-1991 Created
  226. **************************************************************************/
  227. class NEW_OBJ_SPECIAL_DIALOG : public NT_SPECIAL_DIALOG
  228. {
  229. protected:
  230. virtual BOOL OnOK( void ) ;
  231. virtual ULONG QueryHelpContext( void ) ;
  232. public:
  233. NEW_OBJ_SPECIAL_DIALOG( const TCHAR * pszDialogName,
  234. HWND hwndParent,
  235. const TCHAR * pszResourceType,
  236. const TCHAR * pszResourceName,
  237. const TCHAR * pszDialogTitle,
  238. BITFIELD * pbitsAccessPerm,
  239. MASK_MAP * pAccessMaskMap,
  240. const TCHAR * pszSubjectTitle,
  241. ULONG ulHelpContext,
  242. BOOL fPermSpecified ) ;
  243. ~NEW_OBJ_SPECIAL_DIALOG() ;
  244. BOOL IsNotSpecified( void )
  245. { return QueryMagicGroup()->QuerySelection() == BUTTON_NOT_SPECIFIED ; }
  246. } ;
  247. #endif // RC_INVOKED
  248. #endif // _SPECDLG_HXX_