Source code of Windows XP (NT5)
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.

518 lines
14 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /*****************************************************************/
  5. /*
  6. * sharestp.hxx
  7. * Contains the following classes used by the stop sharing dialog
  8. * and the share management dialog.
  9. *
  10. * SHARE_LISTBOX
  11. * SHARE_LBI
  12. *
  13. * CURRENT_USERS_WARNING_DIALOG
  14. * USERS_LISTBOX
  15. * USERS_LBI
  16. *
  17. * VIEW_SHARE_DIALOG_BASE
  18. *
  19. * STOP_SHARING_DIALOG
  20. * STOP_SHARING_GROUP
  21. *
  22. * History:
  23. * Yi-HsinS 1/6/92 Separated from sharefmx.cxx
  24. * Yi-HsinS 3/12/92 Added STOP_SHARING_GROUP
  25. * Yi-HsinS 4/2/92 Added MayRun
  26. * Yi-HsinS 8/2/92 Reorganize the hier. to match winball
  27. * Yi-HsinS 11/20/92 Added support for sticky shares
  28. *
  29. */
  30. #ifndef _SHARESTP_HXX_
  31. #define _SHARESTP_HXX_
  32. #include "sharebas.hxx"
  33. // Bitmask of type of shares to be displayed in the dialogs
  34. #define STYPE_DISK_SHARE 0x00000001
  35. #define STYPE_PRINT_SHARE 0x00000002
  36. #define STYPE_IPC_SHARE 0x00000004
  37. #define STYPE_ALL_SHARE (STYPE_DISK_SHARE | STYPE_PRINT_SHARE | STYPE_IPC_SHARE)
  38. // Types of bitmaps to display in the SHARE_LISTBOX
  39. #define DISKSHARE_TYPE 0 // normal disk share
  40. #define STICKYSHARE_TYPE 1 // sticky disk share
  41. #define IPCSHARE_TYPE 2 // IPC$ share
  42. /*************************************************************************
  43. NAME: SHARE_LBI
  44. SYNOPSIS: Items in the SHARE_LISTBOX in VIEW_SHARE_DIALOG_BASE
  45. to display the share name and path of the share
  46. on the selected computer.
  47. INTERFACE: SHARE_LBI() - Constructor
  48. ~SHARE_LBI() - Destructor
  49. QueryShareName() - Query the share name contained in the LBI
  50. QuerySharePath() - Query the share path contained in the LBI
  51. IsSticky() - TRUE if the share is sticky, FALSE otherwise
  52. PARENT: LBI
  53. USES: NLS_STR
  54. CAVEATS:
  55. NOTES:
  56. HISTORY:
  57. Yi-HsinS 1/6/92 Created
  58. beng 22-Apr-1992 Change to LBI::Paint
  59. **************************************************************************/
  60. class SHARE_LBI: public LBI
  61. {
  62. // Name of the share
  63. NLS_STR _nlsShareName;
  64. // Path that the share represents
  65. NLS_STR _nlsSharePath;
  66. // TRUE if the share is sticky, FALSE otherwise
  67. UINT _nType;
  68. protected:
  69. virtual VOID Paint( LISTBOX *plb, HDC hdc, const RECT *prect,
  70. GUILTT_INFO *pGUILTT ) const;
  71. virtual INT Compare( const LBI *plbi ) const;
  72. public:
  73. SHARE_LBI( const SHARE2_ENUM_OBJ &s2, UINT nType = DISKSHARE_TYPE );
  74. virtual ~SHARE_LBI();
  75. virtual WCHAR QueryLeadingChar( VOID ) const;
  76. NLS_STR *QueryShareName( VOID )
  77. { return &_nlsShareName; }
  78. NLS_STR *QuerySharePath( VOID )
  79. { return &_nlsSharePath; }
  80. BOOL IsSticky( VOID ) const
  81. { return _nType == STICKYSHARE_TYPE; }
  82. };
  83. /*************************************************************************
  84. NAME: SHARE_LISTBOX
  85. SYNOPSIS: Listbox used in VIEW_SHARE_DIALOG_BASE to display the
  86. share name and the path of the share on the
  87. selected computer.
  88. INTERFACE: SHARE_LISTBOX() - Constructor
  89. ~SHARE_LISTBOX() - Destructor
  90. QueryItem() - Query the SHARE_LBI
  91. QueryColumnWidths()- Query the array of column widths
  92. QueryShareBitmap() - Query the share bitmap
  93. QueryStickyShareBitmap() - Query the sticky share bitmap
  94. Update() - Refresh the listbox
  95. PARENT: BLT_LISTBOX
  96. USES: DMID_DTE
  97. CAVEATS:
  98. NOTES:
  99. HISTORY:
  100. Yi-HsinS 1/20/92 Created
  101. **************************************************************************/
  102. class SHARE_LISTBOX: public BLT_LISTBOX
  103. {
  104. private:
  105. //
  106. // Array storing the calculated column widths
  107. //
  108. UINT _adx[3];
  109. //
  110. // Pointer to the bitmap
  111. //
  112. DMID_DTE *_pdmdte;
  113. DMID_DTE *_pdmdteSticky;
  114. DMID_DTE *_pdmdteIPC;
  115. //
  116. // Indicating the type of shares to display in the listbox
  117. //
  118. UINT _nShareType;
  119. public:
  120. SHARE_LISTBOX( OWNER_WINDOW *powin, CID cid, UINT nShareType );
  121. ~SHARE_LISTBOX();
  122. DECLARE_LB_QUERY_ITEM( SHARE_LBI );
  123. const UINT *QueryColumnWidths( VOID ) const
  124. { return _adx; }
  125. DMID_DTE *QueryShareBitmap( VOID )
  126. { return _pdmdte; }
  127. DMID_DTE *QueryStickyShareBitmap( VOID )
  128. { return _pdmdteSticky; }
  129. DMID_DTE *QueryIPCShareBitmap( VOID )
  130. { return _pdmdteIPC; }
  131. APIERR Update( SERVER_WITH_PASSWORD_PROMPT *psvr );
  132. };
  133. /*************************************************************************
  134. NAME: USERS_LBI
  135. SYNOPSIS: Listbox items in the USERS_LISTBOX in
  136. CURRENT_USERS_WARNING_DIALOG
  137. INTERFACE: USERS_LBI() - Constructor
  138. ~USERS_LBI() - Destructor
  139. PARENT: LBI
  140. USES: NLS_STR
  141. CAVEATS:
  142. NOTES:
  143. HISTORY:
  144. Yi-HsinS 8/25/91 Created
  145. beng 4/22/92 Change to LBI::Paint
  146. **************************************************************************/
  147. class USERS_LBI: public LBI
  148. {
  149. // Name of the user
  150. NLS_STR _nlsUserName;
  151. // Number of open files the user has
  152. UINT _usNumOpens;
  153. // Elapsed time since the user connect to the share
  154. ULONG _ulTime;
  155. protected:
  156. virtual VOID Paint( LISTBOX *plb, HDC hdc, const RECT *prect,
  157. GUILTT_INFO *pGUILTT ) const;
  158. virtual INT Compare( const LBI *plbi ) const;
  159. //
  160. // Convert the time in seconds to the output string
  161. //
  162. APIERR ConvertTime( ULONG ulTime, NLS_STR *pnlsTime ) const;
  163. public:
  164. USERS_LBI( const CONN1_ENUM_OBJ &c1 );
  165. virtual ~USERS_LBI();
  166. };
  167. /*************************************************************************
  168. NAME: USERS_LISTBOX
  169. SYNOPSIS: The listbox that displays the user/file opens/elapsed of
  170. the users that have connection to the share to be deleted.
  171. Used by the CURRENT_USERS_WARNING_DIALOG
  172. INTERFACE: USERS_LISTBOX() - Constructor
  173. QueryItem() - Query the USERS_LBI
  174. QueryColumnWidths() - Return the array of column widths
  175. PARENT: BLT_LISTBOX
  176. USES:
  177. CAVEATS:
  178. NOTES:
  179. HISTORY:
  180. Yi-HsinS 1/21/92 Created
  181. **************************************************************************/
  182. class USERS_LISTBOX: public BLT_LISTBOX
  183. {
  184. private:
  185. // Array of column widths
  186. UINT _adx[3];
  187. public:
  188. USERS_LISTBOX( OWNER_WINDOW *powin, CID cid );
  189. DECLARE_LB_QUERY_ITEM( USERS_LBI );
  190. const UINT *QueryColumnWidths( VOID )
  191. { return _adx; }
  192. };
  193. /*************************************************************************
  194. NAME: CURRENT_USERS_WARNING_DIALOG
  195. SYNOPSIS: This dialog pops up if there are users using the share
  196. that is to be deleted. The listbox have three columns,
  197. listing the usernmame, the number of file opens, and the
  198. elapsed time since connection.
  199. INTERFACE: CURRENT_USERS_WARNING_DIALOG() - Constructor
  200. PARENT: DIALOG_WINDOW
  201. USES: USERS_LISTBOX, SLT
  202. CAVEATS:
  203. NOTES: OnOK and OnCancel is not redefined here. The default in the
  204. DIALOG_WINDOW class serves the purpose - Dismiss( FALSE )
  205. OnCancel and Dismiss(TRUE) OnOK.
  206. The list box in this dialog is a read-only listbox.
  207. HISTORY:
  208. Yi-HsinS 8/25/91 Created
  209. **************************************************************************/
  210. class CURRENT_USERS_WARNING_DIALOG: public DIALOG_WINDOW
  211. {
  212. private:
  213. // Display the share name to be deleted
  214. SLT _sltShareText;
  215. // Listbox for displaying the users connected to the share
  216. USERS_LISTBOX _lbUsers;
  217. // Store the help context base
  218. ULONG _ulHelpContextBase;
  219. protected:
  220. virtual ULONG QueryHelpContext( VOID );
  221. public:
  222. CURRENT_USERS_WARNING_DIALOG( HWND hwndParent,
  223. const TCHAR *pszServer,
  224. const TCHAR *pszShare,
  225. ULONG ulHelpContextBase );
  226. };
  227. /*************************************************************************
  228. NAME: VIEW_SHARE_DIALOG_BASE
  229. SYNOPSIS: This is the base dialog for STOP_SHARING_DIALOG in the
  230. file manager and SHARE_MANAGEMENT_DIALOG in the
  231. server manager.
  232. INTERFACE:
  233. PARENT: DIALOG_WINDOW
  234. USES: SLT, SHARE_LISTBOX, SERVER_WITH_PASSWORD_PROMPT
  235. CAVEATS:
  236. NOTES: This class contains all common routines called used
  237. by the share management dialog and stop share dialog.
  238. HISTORY:
  239. Yi-HsinS 8/25/91 Created
  240. **************************************************************************/
  241. class VIEW_SHARE_DIALOG_BASE : public DIALOG_WINDOW
  242. {
  243. private:
  244. // The title of the share listbox
  245. SLT _sltShareTitle;
  246. // Listbox for displaying the shares on the selected computer
  247. SHARE_LISTBOX _lbShare;
  248. SERVER_WITH_PASSWORD_PROMPT *_psvr;
  249. // the help context base
  250. ULONG _ulHelpContextBase;
  251. protected:
  252. VIEW_SHARE_DIALOG_BASE( const TCHAR *pszDlgResource,
  253. HWND hwndParent,
  254. ULONG ulHelpContextBase,
  255. UINT nShareType = STYPE_ALL_SHARE );
  256. ~VIEW_SHARE_DIALOG_BASE();
  257. virtual BOOL OnCommand( const CONTROL_EVENT & event );
  258. //
  259. // Virtual methods that are called when the user double clicks
  260. // on a share in the listbox
  261. //
  262. virtual BOOL OnShareLbDblClk( VOID ) = 0;
  263. //
  264. // Initialize the SERVER_WITH_PASSWORD_PROMPT object and will prompt
  265. // password if needed when focused on a LM share-level server
  266. //
  267. APIERR InitComputer( const TCHAR *pszComputer );
  268. //
  269. // Refresh the listbox
  270. //
  271. APIERR Refresh( VOID );
  272. //
  273. // Stop sharing the share - If there are users connected to the
  274. // share, a warning dialog will popup.
  275. //
  276. APIERR StopShare( const TCHAR *pszShare, BOOL *pfCancel );
  277. //
  278. // Return a pointer to the listbox
  279. //
  280. SHARE_LISTBOX *QueryLBShare( VOID )
  281. { return &_lbShare; }
  282. //
  283. // Query the computer name
  284. //
  285. const TCHAR *QueryComputerName( VOID ) const
  286. { UIASSERT( _psvr != NULL); return _psvr->QueryName(); }
  287. //
  288. // Return the SERVER_WITH_PASSWORD_PROMPT object
  289. //
  290. SERVER_WITH_PASSWORD_PROMPT *QueryServer2( VOID ) const
  291. { UIASSERT( _psvr != NULL); return _psvr; }
  292. //
  293. // Return the help context base
  294. //
  295. ULONG QueryHelpContextBase( VOID ) const
  296. { return _ulHelpContextBase; }
  297. };
  298. /*************************************************************************
  299. NAME: STOP_SHARING_GROUP
  300. SYNOPSIS: This group contains pointers to the share name listbox,
  301. the OK push button and the CANCEL push button.
  302. INTERFACE: STOP_SHARING_GROUP() - Constructor
  303. ~STOP_SHARING_GROUP() - Destructor
  304. PARENT: CONTROL_GROUP
  305. USES: SHARE_LISTBOX, PUSH_BUTTON
  306. CAVEATS:
  307. NOTES: If the number of selected items in the listbox is greater
  308. than 0, we will make OK the default button. Else we will
  309. make CANCEL the default button.
  310. HISTORY:
  311. Yi-HsinS 3/12/92 Created
  312. **************************************************************************/
  313. class STOP_SHARING_GROUP: public CONTROL_GROUP
  314. {
  315. private:
  316. // Pointer to the share listbox
  317. SHARE_LISTBOX *_plbShare;
  318. // Pointer to the OK button
  319. PUSH_BUTTON *_pbuttonOK;
  320. // Pointer to the Cancel button
  321. PUSH_BUTTON *_pbuttonCancel;
  322. SHARE_LISTBOX *QueryLBShare( VOID )
  323. { return _plbShare; }
  324. protected:
  325. virtual APIERR OnUserAction( CONTROL_WINDOW *pcw, const CONTROL_EVENT &e );
  326. public:
  327. STOP_SHARING_GROUP( SHARE_LISTBOX *plbShareName,
  328. PUSH_BUTTON *pbuttonOK,
  329. PUSH_BUTTON *pbuttonCancel );
  330. ~STOP_SHARING_GROUP();
  331. };
  332. /*************************************************************************
  333. NAME: STOP_SHARING_DIALOG
  334. SYNOPSIS: This is the dialog for deleting shares via file manager
  335. INTERFACE: STOP_SHARING_DIALOG() - Constructor
  336. PARENT: VIEW_SHARE_DIALOG_BASE
  337. USES: PUSH_BUTTON, STOP_SHARING_GROUP
  338. CAVEATS:
  339. NOTES:
  340. OnCancel is not redefined here. The default in the
  341. DIALOG_WINDOW class serves the purpose - Dismiss( FALSE ).
  342. HISTORY:
  343. Yi-HsinS 8/25/91 Created
  344. **************************************************************************/
  345. class STOP_SHARING_DIALOG : public VIEW_SHARE_DIALOG_BASE
  346. {
  347. private:
  348. PUSH_BUTTON _buttonOK;
  349. PUSH_BUTTON _buttonCancel;
  350. STOP_SHARING_GROUP _stpShareGrp;
  351. //
  352. // Find out the computer that the user is focusing and
  353. // initialize all information shown in the dialog.
  354. //
  355. APIERR Init( const TCHAR *pszSelectedDir );
  356. protected:
  357. virtual BOOL OnOK( VOID );
  358. virtual ULONG QueryHelpContext( VOID );
  359. //
  360. // Virtual methods that are called when the user double clicks
  361. // on a share in the listbox
  362. //
  363. virtual BOOL OnShareLbDblClk( VOID );
  364. public:
  365. STOP_SHARING_DIALOG( HWND hwndParent,
  366. const TCHAR *pszSelectedDir,
  367. ULONG ulHelpContextBase );
  368. };
  369. #endif