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.

622 lines
16 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. SubjLB.hxx
  7. This file contains the definition for the subject listbox and
  8. ancillary classes
  9. FILE HISTORY:
  10. Johnl 19-Aug-1991 Created
  11. */
  12. #ifndef _SUBJLB_HXX_
  13. #define _SUBJLB_HXX_
  14. #include <bltgroup.hxx>
  15. #include <slist.hxx>
  16. #include <bmpblock.hxx> // SUBJECT_BITMAP_BLOCK
  17. //
  18. // Special characters for building mnemonics with
  19. //
  20. #define MNEMONIC_START_CHAR TCH('(')
  21. #define MNEMONIC_END_CHAR TCH(')')
  22. #define MNEMONIC_SEARCH_CHAR MNEMONIC_START_CHAR
  23. #define MNEMONIC_NOT_INHERITTED_MARKER TCH('*')
  24. class SUBJ_LBI ; // Forward Declarations
  25. class SUBJ_PERM_LBI ;
  26. class NT_CONT_SUBJ_PERM_LBI ;
  27. class MULTI_SUBJ_ACCESS_PERM_BASE_DLG ;
  28. class NT_CONT_ACCESS_PERM_DLG ;
  29. class NT_CONT_SUBJECT_PERM_LISTBOX ;
  30. DECLARE_SLIST_OF( SUBJECT )
  31. /*************************************************************************
  32. NAME: SUBJECT_LISTBOX
  33. SYNOPSIS: This listbox lists a set of Subjects (i.e., groups or users)
  34. It is the main listbox in the Add User dialog.
  35. INTERFACE:
  36. QueryNextUnusedColumn()
  37. Returns the next column that derived children may use for there
  38. own purposes (used when filling in the display table).
  39. AddSubject()
  40. Adds a SUBJECT object to the listbox, pass TRUE for the
  41. delete contents on destruction flag if you want the subject
  42. to be deleted when the LBIs are destroyed
  43. QueryDisplayMap()
  44. Returns the display map associated with the passed SUBJECT
  45. QueryColumnWidths()
  46. Returns the widths of the columns suitable for passing to
  47. the DISPLAY_TABLE constructor
  48. Fill()
  49. Fill the listbox with all of the users and groups in the
  50. user's logged on domain.
  51. PARENT:
  52. USES:
  53. CAVEATS: The client is responsible for deleting anything contained
  54. in the listbox's LBIs that the client passes in.
  55. NOTES:
  56. HISTORY:
  57. Johnl 20-Aug-1991 Created
  58. beng 08-Nov-1991 Unsigned widths
  59. Johnl 13-Mar-1992 Revised to fully support flex admin model
  60. JonN 14-Oct-1994 Draws bitmaps from SUBJECT_BITMAP_BLOCK
  61. **************************************************************************/
  62. class SUBJECT_LISTBOX : public BLT_LISTBOX
  63. {
  64. private:
  65. SUBJECT_BITMAP_BLOCK _bmpblock;
  66. protected:
  67. /* Display table for the Subject listbox
  68. */
  69. UINT _anColWidth[5] ;
  70. public:
  71. SUBJECT_LISTBOX( OWNER_WINDOW * pownerwin, CID cid ) ;
  72. ~SUBJECT_LISTBOX() ;
  73. DISPLAY_MAP * QueryDisplayMap( SUBJECT * psubj ) ;
  74. DECLARE_LB_QUERY_ITEM( SUBJ_LBI ) ;
  75. /* Fill the listbox with all of the users/groups in the UAS pointed
  76. * at by location.
  77. */
  78. APIERR Fill( LOCATION & location ) ;
  79. /* Add all of the extra subjects that don't get added from the fill
  80. * method (this is meant to be used for special subjects).
  81. */
  82. //virtual APIERR AddNonStandardSubjects( void ) ;
  83. APIERR AddSubject( SUBJECT * psubj, BOOL fDeleteContentsOnDestruction ) ;
  84. /* Removes the given list of subjects from the listbox
  85. */
  86. APIERR Remove( SLIST_OF( SUBJECT ) * pslSubjects ) ;
  87. INT QueryNextUnusedColumn( void ) const
  88. { return 2 ; }
  89. const UINT * QueryColumnWidths( void ) const
  90. { return _anColWidth ; }
  91. } ;
  92. /*************************************************************************
  93. NAME: SUBJECT_PERM_LISTBOX
  94. SYNOPSIS: This listbox lists the users/groups and the associated
  95. permissions in the main permission dialog.
  96. INTERFACE:
  97. PARENT:
  98. USES:
  99. CAVEATS:
  100. NOTES:
  101. HISTORY:
  102. Johnl 20-Aug-1991 Created
  103. **************************************************************************/
  104. class SUBJECT_PERM_LISTBOX : public SUBJECT_LISTBOX
  105. {
  106. private:
  107. ACCPERM * _paccperm ;
  108. /* Contains the string that identifies "Special" for this object permissions.
  109. */
  110. RESOURCE_STR _nlsSpecialPermName ;
  111. ALIAS_STR _nlsSpecialAccessName ;
  112. public:
  113. SUBJECT_PERM_LISTBOX( OWNER_WINDOW * pownerwin,
  114. CID cid,
  115. ACCPERM * paccperm,
  116. const TCHAR * pszSpecialAccessName ) ;
  117. ~SUBJECT_PERM_LISTBOX() ;
  118. virtual APIERR Fill( void ) ;
  119. APIERR SetCurrentPermission( const NLS_STR & nlsPermName ) ;
  120. APIERR QueryCurrentPermName( NLS_STR * pnlsPermName) const ;
  121. void DeleteCurrentItem( void ) ;
  122. const NLS_STR & QuerySpecialPermName( void ) const
  123. { return _nlsSpecialPermName ; }
  124. const NLS_STR & QuerySpecialAccessName( void ) const
  125. { return _nlsSpecialAccessName ; }
  126. ACCPERM * QueryAccperm( void ) const
  127. { return _paccperm ; }
  128. BOOL IsMnemonicsDisplayed( void )
  129. { return QueryAccperm()->QueryAclConverter()->IsMnemonicsDisplayed() ; }
  130. DECLARE_LB_QUERY_ITEM( SUBJ_PERM_LBI ) ;
  131. } ;
  132. /*************************************************************************
  133. NAME: NT_CONT_SUBJECT_PERM_LISTBOX
  134. SYNOPSIS: This listbox lists the users/groups and the associated
  135. permissions in the main permission dialog. It is used
  136. for NT Access permissions that *also* have New Object
  137. permissions.
  138. INTERFACE: Same as parent
  139. PARENT: SUBJECT_PERM_LISTBOX
  140. USES:
  141. CAVEATS:
  142. NOTES:
  143. HISTORY:
  144. Johnl 26-Sep-1991 Created
  145. **************************************************************************/
  146. class NT_CONT_SUBJECT_PERM_LISTBOX : public SUBJECT_PERM_LISTBOX
  147. {
  148. private:
  149. ALIAS_STR _nlsSpecialNewObjectAccessName ;
  150. public:
  151. NT_CONT_SUBJECT_PERM_LISTBOX( OWNER_WINDOW * pownerwin,
  152. CID cid,
  153. ACCPERM * paccperm,
  154. const TCHAR * pszSpecialAccessName,
  155. const TCHAR * pszSpecialNewObjectAccessName ) ;
  156. ~NT_CONT_SUBJECT_PERM_LISTBOX() ;
  157. virtual APIERR Fill( void ) ;
  158. const NLS_STR & QuerySpecialNewObjectAccessName( void ) const
  159. { return _nlsSpecialNewObjectAccessName ; }
  160. DECLARE_LB_QUERY_ITEM( NT_CONT_SUBJ_PERM_LBI ) ;
  161. } ;
  162. /*************************************************************************
  163. NAME: SUBJ_LB_GROUP
  164. SYNOPSIS: This class cooridinates actions between the Subject listbox
  165. and the permission name combo.
  166. INTERFACE:
  167. PARENT: CONTROL_GROUP
  168. USES:
  169. CAVEATS:
  170. NOTES:
  171. HISTORY:
  172. Johnl 20-Aug-1991 Created
  173. beng 08-Oct-1991 Win32 conversion
  174. **************************************************************************/
  175. class SUBJ_LB_GROUP : public CONTROL_GROUP
  176. {
  177. private:
  178. //
  179. // TRUE if this group is currently enabled, FALSE otherwise. The group
  180. // becomes disabled when the listbox is emptied
  181. //
  182. BOOL _fEnabled ;
  183. //
  184. // TRUE if the drop down combo is currently dropped down. We ignore any
  185. // selection change methods if the combo is dropped down. We update things
  186. // when it is dropped up.
  187. //
  188. BOOL _fIsDropped ;
  189. //
  190. // When the user presses the enter key on one of the "Special..."
  191. // in the combo, OnEnter handles bringing up the special access dialog.
  192. // However when we get the CBN_CLOSEUP message, we try and bring up the
  193. // special access dialog again. This flag indicates we don't need to
  194. // worry about the second notification.
  195. //
  196. BOOL _fOnSpecialHandled ;
  197. SUBJECT_PERM_LISTBOX * _plbSubj ;
  198. COMBOBOX * _pcbPermName ;
  199. SLT * _psltCBTitle ;
  200. PUSH_BUTTON * _pbuttonRemove ;
  201. MULTI_SUBJ_ACCESS_PERM_BASE_DLG * _pOwnerDlg ;
  202. /* Contains the last permission name we set in the combo-box, only used
  203. * when the dialog is read only
  204. */
  205. NLS_STR _nlsLastROSelection ;
  206. protected:
  207. virtual APIERR OnUserAction( CONTROL_WINDOW *, const CONTROL_EVENT & );
  208. const NLS_STR * QueryLastROSelection( void ) const
  209. { return &_nlsLastROSelection ; }
  210. APIERR SetLastROSelection( const TCHAR * pszNewROSel )
  211. { return _nlsLastROSelection.CopyFrom( pszNewROSel ) ; }
  212. public:
  213. SUBJ_LB_GROUP( MULTI_SUBJ_ACCESS_PERM_BASE_DLG * pOwnerDlg,
  214. SUBJECT_PERM_LISTBOX * plbSubj,
  215. COMBOBOX * pcbPermName,
  216. PUSH_BUTTON * pbuttonRemove,
  217. SLT * psltCBTitle ) ;
  218. virtual APIERR UpdatePermNameCombo( const NLS_STR & nlsNewPermName ) ;
  219. APIERR UpdateSubjectListbox( void ) ;
  220. /* Tells the group the user hit enter and unless we want to do something,
  221. * we are about to dismiss the dialog. If conditions warrant (i.e., the
  222. * current selection is a "Special * ..." selection), then we will
  223. * bring up the appropriate dialog (and set *pfDismissDialog to FALSE),
  224. * otherwise we will just grab the current permission
  225. * and boogie (and set *pfDismissDialog to TRUE).
  226. */
  227. virtual APIERR OnEnter( BOOL * pfDismissDialog ) ;
  228. void SetDropDownFlag( BOOL fIsDropped )
  229. { _fIsDropped = fIsDropped ; }
  230. BOOL IsDroppedDown( void ) const
  231. { return _fIsDropped ; }
  232. SUBJECT_PERM_LISTBOX * QuerySubjLB( void )
  233. { return _plbSubj ; }
  234. COMBOBOX * QueryPermNameCombo( void )
  235. { return _pcbPermName ; }
  236. SLT * QueryPermNameLabel( void )
  237. { return _psltCBTitle ; }
  238. PUSH_BUTTON * QueryRemoveButton( void )
  239. { return _pbuttonRemove ; }
  240. MULTI_SUBJ_ACCESS_PERM_BASE_DLG * QueryOwnerDlg( void )
  241. { return _pOwnerDlg ; }
  242. void Enable( BOOL fEnable ) ;
  243. BOOL IsEnabled( void ) const
  244. { return _fEnabled ; }
  245. BOOL IsReadOnly( void ) const ;
  246. void SetOnSpecialHandled( BOOL fOnSpecialHandled )
  247. { _fOnSpecialHandled = fOnSpecialHandled ; }
  248. BOOL IsOnSpecialHandled( void ) const
  249. { return _fOnSpecialHandled ; }
  250. } ;
  251. /*************************************************************************
  252. NAME: NT_CONT_SUBJ_LB_GROUP
  253. SYNOPSIS: Is a simple derivation of the parent class. We add a
  254. check to see if the new object special dialog needs
  255. to be brought up and bring it up if necessary.
  256. INTERFACE:
  257. PARENT: SUBJ_LB_GROUP
  258. USES:
  259. CAVEATS:
  260. NOTES:
  261. HISTORY:
  262. Johnl 20-Aug-1991 Created
  263. **************************************************************************/
  264. class NT_CONT_SUBJ_LB_GROUP : public SUBJ_LB_GROUP
  265. {
  266. public:
  267. NT_CONT_SUBJ_LB_GROUP( NT_CONT_ACCESS_PERM_DLG * pOwnerDlg,
  268. NT_CONT_SUBJECT_PERM_LISTBOX * plbNTContSubj,
  269. COMBOBOX * pcbPermName,
  270. PUSH_BUTTON * pbuttonRemove,
  271. SLT * psltCBTitle )
  272. : SUBJ_LB_GROUP( (MULTI_SUBJ_ACCESS_PERM_BASE_DLG *) pOwnerDlg,
  273. plbNTContSubj, pcbPermName, pbuttonRemove, psltCBTitle )
  274. { /* Nothing to do */ }
  275. virtual APIERR UpdatePermNameCombo( const NLS_STR & nlsNewPermName ) ;
  276. virtual APIERR OnEnter( BOOL * pfDismissDialog ) ;
  277. NT_CONT_SUBJECT_PERM_LISTBOX * QueryNTContSubjLB( void )
  278. { return (NT_CONT_SUBJECT_PERM_LISTBOX *) QuerySubjLB() ; }
  279. } ;
  280. /*************************************************************************
  281. NAME: SUBJ_LBI
  282. SYNOPSIS: SUBJECT_LISTBOX items definition
  283. INTERFACE:
  284. PARENT:
  285. USES:
  286. CAVEATS:
  287. NOTES:
  288. HISTORY:
  289. Johnl 20-Aug-1991 Created
  290. beng 08-Oct-1991 Win32 conversion
  291. **************************************************************************/
  292. class SUBJ_LBI : public LBI
  293. {
  294. private:
  295. SUBJECT * _psubj ;
  296. /* Set to TRUE if we need to delete the subjects we created
  297. * (we don't delete them when the user passes the SUBJECT objects
  298. * to us).
  299. */
  300. BOOL _fDeleteContentsOnDest ;
  301. public:
  302. SUBJ_LBI( SUBJECT * psubj, BOOL fDeleteContentsOnDestruction = FALSE ) ;
  303. ~SUBJ_LBI() ;
  304. virtual int Compare( const LBI * plbi ) const ;
  305. virtual WCHAR QueryLeadingChar( void ) const ;
  306. virtual void Paint( LISTBOX * plb, HDC hdc, const RECT * prect, GUILTT_INFO * pguiltt ) const ;
  307. SUBJECT * QuerySubject( void ) const
  308. { return _psubj ; }
  309. void SetSubject( SUBJECT * pSubj )
  310. { _psubj = pSubj ; }
  311. } ;
  312. /*************************************************************************
  313. NAME: SUBJ_PERM_LBI_BASE
  314. SYNOPSIS: This class is the base class that the subject permission
  315. listbox LBIs will use as a starting point.
  316. The SUBJ_PERM_LBI_BASE and children are primarily responsible
  317. for determing the appropriate permission name (i.e.,
  318. interpretting the current bit patterns and find the correct
  319. name in the mask map(s)).
  320. INTERFACE:
  321. PARENT: SUBJ_LBI
  322. USES: MASK_MAP, NLS_STR
  323. CAVEATS:
  324. NOTES:
  325. HISTORY:
  326. Johnl 20-Aug-1991 Created
  327. beng 08-Oct-1991 Win32 conversion
  328. **************************************************************************/
  329. class SUBJ_PERM_LBI_BASE : public SUBJ_LBI
  330. {
  331. private:
  332. MASK_MAP * _pMaskMap ;
  333. protected:
  334. NLS_STR _nlsPermName ;
  335. public:
  336. SUBJ_PERM_LBI_BASE( SUBJECT * pSubj, MASK_MAP * pmaskmap ) ;
  337. ~SUBJ_PERM_LBI_BASE() ;
  338. virtual void Paint( LISTBOX * plb, HDC hdc, const RECT * prect, GUILTT_INFO * pguiltt ) const ;
  339. /* Updates the permission string after a change to the bitmask.
  340. */
  341. virtual APIERR RefreshPermName( void ) ;
  342. virtual ACCESS_PERMISSION * QueryAccessPerm( void ) const ;
  343. /* Sets the permission bits to the bits that correspond to the
  344. * passed string (must match up with the permission's MASK_MAP
  345. */
  346. virtual APIERR SetPermission( const NLS_STR & nlsPermName ) ;
  347. APIERR BuildPermMnemonic( ACCESS_PERMISSION * pAccessPerm,
  348. MASK_MAP * pmaskmapPerms,
  349. NLS_STR * pnlsMnemonics,
  350. BOOL fIsNewPerm = FALSE ) const ;
  351. MASK_MAP * QueryMaskMap( void ) const
  352. { return _pMaskMap ; }
  353. /* This method returns NULL by default!!
  354. */
  355. virtual MASK_MAP * QueryNewObjectMaskMap( void ) const ;
  356. const TCHAR * QueryPermName( void ) const
  357. { return _nlsPermName.QueryPch() ; }
  358. APIERR SetPermName( const TCHAR * pszPermName )
  359. { _nlsPermName = pszPermName ; return _nlsPermName.QueryError() ; }
  360. } ;
  361. /*************************************************************************
  362. NAME: SUBJ_PERM_LBI
  363. SYNOPSIS: This class is the base class that will be displayed in
  364. the SUBJECT_PERM_LISTBOX class.
  365. INTERFACE:
  366. PARENT: SUBJ_LBI
  367. USES: MASK_MAP, NLS_STR
  368. CAVEATS:
  369. NOTES:
  370. HISTORY:
  371. Johnl 27-Sep-1991 Broke out to support new object permissions
  372. **************************************************************************/
  373. class SUBJ_PERM_LBI : public SUBJ_PERM_LBI_BASE
  374. {
  375. private:
  376. ACCESS_PERMISSION * _pAccessPerm ;
  377. public:
  378. SUBJ_PERM_LBI( ACCESS_PERMISSION * pAccessPerm, MASK_MAP * pmaskmap ) ;
  379. ~SUBJ_PERM_LBI() ;
  380. virtual ACCESS_PERMISSION * QueryAccessPerm( void ) const ;
  381. } ;
  382. /*************************************************************************
  383. NAME: NT_CONT_SUBJ_PERM_LBI
  384. SYNOPSIS: This class contains the logic to support the new object
  385. permissions concept (essentially uses everything from
  386. the parent, but just adds the new object).
  387. INTERFACE:
  388. PARENT: SUBJ_LBI
  389. USES: MASK_MAP, NLS_STR
  390. CAVEATS:
  391. NOTES:
  392. HISTORY:
  393. Johnl 27-Sep-1991 Broke out to support new object permissions
  394. **************************************************************************/
  395. class NT_CONT_SUBJ_PERM_LBI : public SUBJ_PERM_LBI_BASE
  396. {
  397. private:
  398. MASK_MAP * _pNewObjectMaskMap ;
  399. NT_CONT_ACCESS_PERMISSION * _pNTContAccessPerm ;
  400. public:
  401. NT_CONT_SUBJ_PERM_LBI( NT_CONT_ACCESS_PERMISSION * pNTContAccessPerm,
  402. MASK_MAP * pmaskmap,
  403. MASK_MAP * pNewObjectMaskMap ) ;
  404. ~NT_CONT_SUBJ_PERM_LBI() ;
  405. /* Updates the permission string after a change to the bitmask.
  406. */
  407. virtual APIERR RefreshPermName( void ) ;
  408. virtual ACCESS_PERMISSION * QueryAccessPerm( void ) const ;
  409. virtual MASK_MAP * QueryNewObjectMaskMap( void ) const ;
  410. } ;
  411. #endif // _SUBJLB_HXX_