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.

425 lines
8.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 1995.
  5. //
  6. // File: shrpage.hxx
  7. //
  8. // Contents: "Sharing" shell property page extension
  9. //
  10. // History: 6-Apr-95 BruceFo Created
  11. // 12-Jul-00 JonN fixed 140878, MSG_MULTIDEL debounce
  12. // 06-Oct-00 jeffreys Split CShareBase out of CSharingPropertyPage
  13. //
  14. //--------------------------------------------------------------------------
  15. #ifndef __SHRPAGE_HXX__
  16. #define __SHRPAGE_HXX__
  17. class CShareInfo;
  18. void _MyShow( HWND hwndParent, INT idControl, BOOL fShow );
  19. class CShareBase : public IOleWindow
  20. {
  21. DECLARE_SIG;
  22. public:
  23. // IUnknown
  24. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  25. STDMETHODIMP_(ULONG) AddRef(void) ;
  26. STDMETHODIMP_(ULONG) Release(void);
  27. // IOleWindow
  28. STDMETHODIMP GetWindow(HWND *phwnd);
  29. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  30. //
  31. // Page callback function for delete
  32. //
  33. static
  34. UINT CALLBACK
  35. PageCallback(
  36. IN HWND hwnd,
  37. IN UINT uMsg,
  38. IN LPPROPSHEETPAGE ppsp
  39. );
  40. //
  41. // Main page dialog procedure: static
  42. //
  43. static
  44. INT_PTR CALLBACK
  45. DlgProcPage(
  46. HWND hWnd,
  47. UINT msg,
  48. WPARAM wParam,
  49. LPARAM lParam
  50. );
  51. //
  52. // constructor, destructor, 2nd phase constructor
  53. //
  54. CShareBase(
  55. IN BOOL bDialog // called as a dialog, not a property page?
  56. );
  57. virtual ~CShareBase();
  58. virtual HRESULT
  59. InitInstance(
  60. IN PCWSTR pszPath
  61. );
  62. protected:
  63. //
  64. // Main page dialog procedure: non-static
  65. //
  66. virtual BOOL
  67. _PageProc(
  68. IN HWND hWnd,
  69. IN UINT msg,
  70. IN WPARAM wParam,
  71. IN LPARAM lParam
  72. );
  73. //
  74. // Window messages and notifications
  75. //
  76. virtual BOOL
  77. _OnInitDialog(
  78. IN HWND /*hwnd*/,
  79. IN HWND /*hwndFocus*/,
  80. IN LPARAM /*lInitParam*/
  81. )
  82. {
  83. return TRUE;
  84. }
  85. virtual BOOL
  86. _OnCommand(
  87. IN HWND hwnd,
  88. IN WORD wNotifyCode,
  89. IN WORD wID,
  90. IN HWND hwndCtl
  91. );
  92. virtual BOOL
  93. _OnNotify(
  94. IN HWND hwnd,
  95. IN int idCtrl,
  96. IN LPNMHDR phdr
  97. );
  98. virtual BOOL
  99. _OnPropertySheetNotify(
  100. IN HWND hwnd,
  101. IN LPNMHDR phdr
  102. );
  103. virtual BOOL
  104. _OnHelp(
  105. IN HWND /*hwnd*/,
  106. IN LPHELPINFO /*lphi*/
  107. )
  108. {
  109. return FALSE;
  110. }
  111. virtual BOOL
  112. _OnContextMenu(
  113. IN HWND /*hwnd*/,
  114. IN HWND /*hwndCtl*/,
  115. IN int /*xPos*/,
  116. IN int /*yPos*/
  117. )
  118. {
  119. return FALSE;
  120. }
  121. //
  122. // Other helper methods
  123. //
  124. virtual BOOL
  125. _ValidatePage(
  126. IN HWND /*hwnd*/
  127. )
  128. {
  129. return TRUE;
  130. }
  131. virtual BOOL
  132. _DoApply(
  133. IN HWND hwnd,
  134. IN BOOL bClose
  135. );
  136. virtual BOOL
  137. _DoCancel(
  138. IN HWND hwnd
  139. );
  140. VOID
  141. _MarkPageDirty(
  142. VOID
  143. );
  144. HRESULT
  145. _ConstructShareList(
  146. VOID
  147. );
  148. HRESULT
  149. _ConstructNewShareInfo(
  150. VOID
  151. );
  152. HWND
  153. _GetFrameWindow(
  154. VOID
  155. )
  156. {
  157. return GetParent(_hwndPage);
  158. }
  159. BOOL
  160. _ValidateNewShareName(
  161. VOID
  162. );
  163. VOID
  164. _CommitShares(
  165. IN BOOL bNotShared
  166. );
  167. //
  168. // Protected class variables
  169. //
  170. LONG _cRef;
  171. PWSTR _pszPath;
  172. HWND _hwndPage; // HWND to the property page
  173. BOOL _bDialog; // called as a dialog, not a property page?
  174. BOOL _bDirty; // Dirty flag: anything changed?
  175. // JonN 7/12/00 140878
  176. // I changed this from BOOL to ULONG, and started accessing it with
  177. // increment/decrement rather than set, to prevent it from being
  178. // cleared prematurely.
  179. ULONG _fInitializingPage; // JonN 7/11/00 140878
  180. BOOL _bNewShare;
  181. CShareInfo* _pInfoList; // doubly-linked circular w/dummy head node
  182. CShareInfo* _pReplaceList; // list of shares to delete: share names replaced with new shares.
  183. CShareInfo* _pCurInfo;
  184. ULONG _cShares; // count of shares, not incl. removed shares
  185. };
  186. class CSharingPropertyPage : public CShareBase
  187. {
  188. DECLARE_SIG;
  189. public:
  190. static
  191. LRESULT CALLBACK
  192. SizeWndProc(
  193. IN HWND hwnd,
  194. IN UINT wMsg,
  195. IN WPARAM wParam,
  196. IN LPARAM lParam
  197. );
  198. //
  199. // constructor, destructor
  200. //
  201. CSharingPropertyPage(
  202. IN BOOL bDialog // called as a dialog, not a property page?
  203. );
  204. ~CSharingPropertyPage();
  205. private:
  206. // Does the operating system support caching on this share?
  207. // This method initializes _bIsCachingSupported, if it is not already true
  208. bool
  209. IsCachingSupported(
  210. VOID
  211. );
  212. //
  213. // Main page dialog procedure: non-static
  214. //
  215. virtual BOOL
  216. _PageProc(
  217. IN HWND hWnd,
  218. IN UINT msg,
  219. IN WPARAM wParam,
  220. IN LPARAM lParam
  221. );
  222. //
  223. // Window messages and notifications
  224. //
  225. virtual BOOL
  226. _OnInitDialog(
  227. IN HWND hwnd,
  228. IN HWND hwndFocus,
  229. IN LPARAM lInitParam
  230. );
  231. virtual BOOL
  232. _OnCommand(
  233. IN HWND hwnd,
  234. IN WORD wNotifyCode,
  235. IN WORD wID,
  236. IN HWND hwndCtl
  237. );
  238. virtual BOOL
  239. _OnHelp(
  240. IN HWND hwnd,
  241. IN LPHELPINFO lphi
  242. );
  243. virtual BOOL
  244. _OnContextMenu(
  245. IN HWND hwnd,
  246. IN HWND hwndCtl,
  247. IN int xPos,
  248. IN int yPos
  249. );
  250. BOOL
  251. _OnPermissions(
  252. IN HWND hwnd
  253. );
  254. BOOL
  255. _OnRemove(
  256. IN HWND hwnd
  257. );
  258. BOOL
  259. _OnNewShare(
  260. IN HWND hwnd
  261. );
  262. BOOL
  263. _OnCaching(
  264. IN HWND hwnd
  265. );
  266. //
  267. // Other helper methods
  268. //
  269. VOID
  270. _InitializeControls(
  271. IN HWND hwnd
  272. );
  273. VOID
  274. _SetControlsToDefaults(
  275. IN HWND hwnd
  276. );
  277. VOID
  278. _SetFieldsFromCurrent(
  279. IN HWND hwnd
  280. );
  281. VOID
  282. _CacheMaxUses(
  283. IN HWND hwnd
  284. );
  285. VOID
  286. _HideControls(
  287. IN HWND hwnd,
  288. IN int cShares
  289. );
  290. VOID
  291. _EnableControls(
  292. IN HWND hwnd,
  293. IN BOOL bEnable
  294. );
  295. BOOL
  296. _ReadControls(
  297. IN HWND hwnd
  298. );
  299. VOID
  300. _SetControlsFromData(
  301. IN HWND hwnd,
  302. IN PWSTR pszPreferredSelection
  303. );
  304. virtual BOOL
  305. _ValidatePage(
  306. IN HWND hwnd
  307. );
  308. virtual BOOL
  309. _DoApply(
  310. IN HWND hwnd,
  311. IN BOOL bClose
  312. );
  313. virtual BOOL
  314. _DoCancel(
  315. IN HWND hwnd
  316. );
  317. VOID
  318. _MarkItemDirty(
  319. VOID
  320. );
  321. #if DBG == 1
  322. VOID
  323. Dump(
  324. IN PWSTR pszCaption
  325. );
  326. #endif // DBG == 1
  327. //
  328. // Private class variables
  329. //
  330. // JonN 7/12/00 140878
  331. // This is the ID of the radio button last selected,
  332. // so that we can "debounce" the MSG_MULTIDEL dialog.
  333. WORD _wIDSelected; // JonN 7/12/00 140878
  334. BOOL _bItemDirty; // Dirty flag: this item changed
  335. BOOL _bShareNameChanged;
  336. BOOL _bCommentChanged;
  337. BOOL _bUserLimitChanged;
  338. WORD _wMaxUsers;
  339. WNDPROC _pfnAllowProc;
  340. bool _bIsCachingSupported; // Does the operating system support caching on this share?
  341. };
  342. #endif // __SHRPAGE_HXX__