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.

514 lines
14 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: C O N F O L D . H
  7. //
  8. // Contents: CConnectionFolder object definition.
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 30 Sep 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _CONFOLD_H_
  17. #define _CONFOLD_H_
  18. #include <netshell.h>
  19. #include "nsbase.h"
  20. #include "nsres.h"
  21. #include "cfpidl.h"
  22. #include "pidlutil.h"
  23. #include "contray.h"
  24. #include "connlist.h"
  25. #include <lmcons.h> // For UNLEN definition
  26. //---[ Connection Folder Types ]----------------------------------------------
  27. // The details list view columns. These are used by the view and
  28. // context menus
  29. enum
  30. {
  31. ICOL_NAME = 0,
  32. ICOL_TYPE, // 1
  33. ICOL_STATUS, // 2
  34. ICOL_DEVICE_NAME, // 3
  35. ICOL_PHONEORHOSTADDRESS, // 4
  36. ICOL_OWNER, // 5
  37. ICOL_ADDRESS, // 6
  38. ICOL_PHONENUMBER, // 7
  39. ICOL_HOSTADDRESS, // 8
  40. ICOL_WIRELESS_MODE, // 9
  41. ICOL_MAX, // 10 - End of list.
  42. ICOL_NETCONMEDIATYPE = 0x101, // - not enumerated, just accessed through GetDetailsEx (keep this value in sync with shell)
  43. ICOL_NETCONSUBMEDIATYPE = 0x102, // - not enumerated, just accessed through GetDetailsEx (keep this value in sync with shell)
  44. ICOL_NETCONSTATUS = 0x103, // - not enumerated, just accessed through GetDetailsEx (keep this value in sync with shell)
  45. ICOL_NETCONCHARACTERISTICS= 0x104 // - not enumerated, just accessed through GetDetailsEx (keep this value in sync with shell)
  46. };
  47. // The details list view columns. These are used by the view and
  48. // context menus
  49. typedef struct tagCOLS
  50. {
  51. short int iColumn;
  52. short int iStringRes;
  53. short int iColumnSize;
  54. short int iFormat;
  55. DWORD csFlags; // SHCOLSTATE flags
  56. } COLS;
  57. DEFINE_GUID(IID_IExplorerToolbar, 0x8455F0C1L, 0x158F, 0x11D0, 0x89, 0xAE, 0x00, 0xA0, 0xC9, 0x0A, 0x90, 0xAC);
  58. #define SID_SExplorerToolbar IID_IExplorerToolbar
  59. class CNCWebView;
  60. //---[ Connection Folder Classes ]--------------------------------------------
  61. class ATL_NO_VTABLE CConnectionFolder :
  62. public CComObjectRootEx <CComObjectThreadModel>,
  63. public CComCoClass <CConnectionFolder, &CLSID_ConnectionFolder>,
  64. public IPersistFolder2,
  65. public IShellExtInit,
  66. public IShellFolder2,
  67. public IOleCommandTarget,
  68. public IShellFolderViewCB
  69. {
  70. private:
  71. CPConFoldPidl<ConFoldPidlFolder> m_pidlFolderRoot;
  72. DWORD m_dwEnumerationType;
  73. WCHAR m_szUserName[UNLEN+1];
  74. HWND m_hwndMain;
  75. CNCWebView* m_pWebView;
  76. public:
  77. CConnectionFolder() throw();
  78. ~CConnectionFolder() throw();
  79. static HRESULT WINAPI UpdateRegistry(IN BOOL fRegister);
  80. BEGIN_COM_MAP(CConnectionFolder)
  81. COM_INTERFACE_ENTRY(IPersist)
  82. COM_INTERFACE_ENTRY(IPersistFolder)
  83. COM_INTERFACE_ENTRY(IPersistFolder2)
  84. COM_INTERFACE_ENTRY(IShellExtInit)
  85. COM_INTERFACE_ENTRY(IShellFolder)
  86. COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2)
  87. COM_INTERFACE_ENTRY(IOleCommandTarget)
  88. COM_INTERFACE_ENTRY(IShellFolderViewCB)
  89. END_COM_MAP()
  90. // *** IPersist methods ***
  91. STDMETHOD(GetClassID) (
  92. OUT LPCLSID lpClassID);
  93. // *** IPersistFolder methods ***
  94. STDMETHOD(Initialize) (
  95. IN LPCITEMIDLIST pidl);
  96. // *** IPersistFolder2 methods ***
  97. STDMETHOD(GetCurFolder) (
  98. OUT LPITEMIDLIST *ppidl);
  99. // *** IShellFolder2 methods from IShellFolder ***
  100. STDMETHOD(ParseDisplayName) (
  101. HWND hwndOwner,
  102. LPBC pbcReserved,
  103. LPOLESTR lpszDisplayName,
  104. ULONG * pchEaten,
  105. LPITEMIDLIST * ppidl,
  106. ULONG * pdwAttributes);
  107. STDMETHOD(EnumObjects) (
  108. HWND hwndOwner,
  109. DWORD grfFlags,
  110. LPENUMIDLIST * ppenumIDList);
  111. STDMETHOD(BindToObject) (
  112. LPCITEMIDLIST pidl,
  113. LPBC pbcReserved,
  114. REFIID riid,
  115. LPVOID * ppvOut);
  116. STDMETHOD(BindToStorage) (
  117. LPCITEMIDLIST pidl,
  118. LPBC pbcReserved,
  119. REFIID riid,
  120. LPVOID * ppvObj);
  121. STDMETHOD(CompareIDs) (
  122. LPARAM lParam,
  123. LPCITEMIDLIST pidl1,
  124. LPCITEMIDLIST pidl2);
  125. STDMETHOD(CreateViewObject) (
  126. HWND hwndOwner,
  127. REFIID riid,
  128. LPVOID * ppvOut);
  129. STDMETHOD(GetAttributesOf) (
  130. UINT cidl,
  131. LPCITEMIDLIST * apidl,
  132. ULONG * rgfInOut);
  133. STDMETHOD(GetUIObjectOf) (
  134. HWND hwndOwner,
  135. UINT cidl,
  136. LPCITEMIDLIST * apidl,
  137. REFIID riid,
  138. UINT * prgfInOut,
  139. LPVOID * ppvOut);
  140. STDMETHOD(GetDisplayNameOf) (
  141. LPCITEMIDLIST pidl,
  142. DWORD uFlags,
  143. LPSTRRET lpName);
  144. STDMETHOD(SetNameOf) (
  145. HWND hwndOwner,
  146. LPCITEMIDLIST pidl,
  147. LPCOLESTR lpszName,
  148. DWORD uFlags,
  149. LPITEMIDLIST * ppidlOut);
  150. // *** IShellFolder2 specific methods ***
  151. STDMETHOD(EnumSearches) (
  152. IEnumExtraSearch **ppEnum);
  153. STDMETHOD(GetDefaultColumn) (
  154. DWORD dwReserved,
  155. ULONG *pSort,
  156. ULONG *pDisplay );
  157. STDMETHOD(GetDefaultColumnState) (
  158. UINT iColumn,
  159. DWORD *pcsFlags );
  160. STDMETHOD(GetDefaultSearchGUID) (
  161. LPGUID lpGUID );
  162. STDMETHOD(GetDetailsEx) (
  163. LPCITEMIDLIST pidl,
  164. const SHCOLUMNID *pscid,
  165. VARIANT *pv );
  166. STDMETHOD(GetDetailsOf) (
  167. LPCITEMIDLIST pidl,
  168. UINT iColumn,
  169. LPSHELLDETAILS pDetails );
  170. STDMETHOD(MapColumnToSCID) (
  171. UINT iColumn,
  172. SHCOLUMNID *pscid );
  173. // *** IOleWindow methods ***
  174. STDMETHOD(GetWindow) (
  175. OUT HWND * lphwnd);
  176. STDMETHOD(ContextSensitiveHelp) (
  177. IN BOOL fEnterMode);
  178. // *** IShellExtInit methods ***
  179. STDMETHOD(Initialize) (
  180. IN LPCITEMIDLIST pidlFolder,
  181. OUT LPDATAOBJECT lpdobj,
  182. IN HKEY hkeyProgID);
  183. // IOleCommandTarget members
  184. STDMETHODIMP QueryStatus(
  185. IN const GUID * pguidCmdGroup,
  186. IN ULONG cCmds,
  187. IN OUT OLECMD prgCmds[],
  188. IN OUT OLECMDTEXT * pCmdText);
  189. STDMETHODIMP Exec(
  190. IN const GUID * pguidCmdGroup,
  191. IN DWORD nCmdID,
  192. IN DWORD nCmdexecopt,
  193. IN VARIANTARG * pvaIn,
  194. IN OUT VARIANTARG * pvaOut);
  195. // IShellFolderViewCB methods
  196. STDMETHOD(MessageSFVCB)
  197. (UINT uMsg,
  198. WPARAM wParam,
  199. LPARAM lParam);
  200. // Other interfaces
  201. STDMETHOD(RealMessage)( // This is kind'a a odd name, but used by the shell's MessageSFVCB
  202. UINT uMsg, // implementation, so I'm keeping this consistent for purposes
  203. WPARAM wParam, // of search
  204. LPARAM lParam);
  205. PCONFOLDPIDLFOLDER& PidlGetFolderRoot() throw();
  206. PCWSTR pszGetUserName() throw();
  207. IShellView *m_pShellView;
  208. };
  209. class ATL_NO_VTABLE CConnectionFolderEnum :
  210. public CComObjectRootEx <CComObjectThreadModel>,
  211. public CComCoClass <CConnectionFolderEnum, &CLSID_ConnectionFolderEnum>,
  212. public IEnumIDList
  213. {
  214. private:
  215. PCONFOLDPIDLFOLDER m_pidlFolder;
  216. PCONFOLDPIDLVEC m_apidl;
  217. PCONFOLDPIDLVEC::iterator m_iterPidlCurrent;
  218. DWORD m_dwFlags;
  219. BOOL m_fTray; // Tray owns us.
  220. DWORD m_dwEnumerationType; // inbound/outbound/all
  221. public:
  222. CConnectionFolderEnum() throw();
  223. ~CConnectionFolderEnum() throw();
  224. VOID PidlInitialize(
  225. IN BOOL fTray,
  226. IN const PCONFOLDPIDLFOLDER& pidlFolder,
  227. IN DWORD dwEnumerationType);
  228. DECLARE_REGISTRY_RESOURCEID(IDR_CONFOLDENUM)
  229. BEGIN_COM_MAP(CConnectionFolderEnum)
  230. COM_INTERFACE_ENTRY(IEnumIDList)
  231. END_COM_MAP()
  232. // *** IEnumIDList methods ***
  233. STDMETHOD(Next) (
  234. IN ULONG celt,
  235. OUT LPITEMIDLIST * rgelt,
  236. OUT ULONG * pceltFetched);
  237. STDMETHOD(Skip) (
  238. IN ULONG celt);
  239. STDMETHOD(Reset) ();
  240. STDMETHOD(Clone) (
  241. OUT IEnumIDList ** ppenum);
  242. public:
  243. static HRESULT CreateInstance (
  244. IN REFIID riid,
  245. OUT void** ppv);
  246. public:
  247. HRESULT HrRetrieveConManEntries();
  248. };
  249. typedef enum CMENU_TYPE
  250. {
  251. CMT_OBJECT = 1,
  252. CMT_BACKGROUND = 2
  253. };
  254. class ATL_NO_VTABLE CConnectionFolderContextMenu :
  255. public CComObjectRootEx <CComObjectThreadModel>,
  256. public CComCoClass <CConnectionFolderContextMenu, &CLSID_ConnectionFolderContextMenu>,
  257. public IContextMenu
  258. {
  259. private:
  260. HWND m_hwndOwner;
  261. PCONFOLDPIDLVEC m_apidl;
  262. ULONG m_cidl;
  263. LPSHELLFOLDER m_psf;
  264. CMENU_TYPE m_cmt;
  265. public:
  266. CConnectionFolderContextMenu() throw();
  267. ~CConnectionFolderContextMenu() throw();
  268. DECLARE_REGISTRY_RESOURCEID(IDR_CONFOLDCONTEXTMENU)
  269. BEGIN_COM_MAP(CConnectionFolderContextMenu)
  270. COM_INTERFACE_ENTRY(IContextMenu)
  271. END_COM_MAP()
  272. // *** IContextMenu methods ***
  273. STDMETHOD(QueryContextMenu) (
  274. IN OUT HMENU hmenu,
  275. IN UINT indexMenu,
  276. IN UINT idCmdFirst,
  277. IN UINT idCmdLast,
  278. IN UINT uFlags);
  279. STDMETHOD(InvokeCommand) (
  280. IN LPCMINVOKECOMMANDINFO lpici);
  281. STDMETHOD(GetCommandString) (
  282. IN UINT_PTR idCmd,
  283. IN UINT uType,
  284. OUT UINT * pwReserved,
  285. OUT PSTR pszName,
  286. IN UINT cchMax);
  287. public:
  288. static HRESULT CreateInstance (
  289. IN REFIID riid,
  290. OUT void** ppv,
  291. IN CMENU_TYPE cmt,
  292. IN HWND hwndOwner,
  293. IN const PCONFOLDPIDLVEC& apidl,
  294. IN LPSHELLFOLDER psf);
  295. private:
  296. HRESULT HrInitialize(
  297. IN CMENU_TYPE cmt,
  298. IN HWND hwndOwner,
  299. IN const PCONFOLDPIDLVEC& apidl,
  300. IN LPSHELLFOLDER psf);
  301. };
  302. class ATL_NO_VTABLE CConnectionFolderExtractIcon :
  303. public CComObjectRootEx <CComObjectThreadModel>,
  304. public CComCoClass <CConnectionFolderExtractIcon, &CLSID_ConnectionFolderExtractIcon>,
  305. public IExtractIconW,
  306. public IExtractIconA
  307. {
  308. private:
  309. PCONFOLDPIDL m_pidl;
  310. public:
  311. CConnectionFolderExtractIcon() throw();
  312. ~CConnectionFolderExtractIcon() throw();
  313. HRESULT HrInitialize(IN const PCONFOLDPIDL& pidl);
  314. DECLARE_REGISTRY_RESOURCEID(IDR_CONFOLDEXTRACTICON)
  315. BEGIN_COM_MAP(CConnectionFolderExtractIcon)
  316. COM_INTERFACE_ENTRY(IExtractIconW)
  317. COM_INTERFACE_ENTRY(IExtractIconA)
  318. END_COM_MAP()
  319. // *** IExtractIconW methods ***
  320. STDMETHOD(GetIconLocation) (
  321. IN UINT uFlags,
  322. OUT PWSTR szIconFile,
  323. IN UINT cchMax,
  324. OUT int * piIndex,
  325. OUT UINT * pwFlags);
  326. STDMETHOD(Extract) (
  327. IN PCWSTR pszFile,
  328. IN UINT nIconIndex,
  329. OUT HICON * phiconLarge,
  330. OUT HICON * phiconSmall,
  331. IN UINT nIconSize);
  332. // *** IExtractIcon methods ***
  333. STDMETHOD(GetIconLocation) (
  334. IN UINT uFlags,
  335. OUT PSTR szIconFile,
  336. IN UINT cchMax,
  337. OUT int * piIndex,
  338. OUT UINT * pwFlags);
  339. STDMETHOD(Extract) (
  340. IN PCSTR pszFile,
  341. IN UINT nIconIndex,
  342. OUT HICON * phiconLarge,
  343. OUT HICON * phiconSmall,
  344. IN UINT nIconSize);
  345. public:
  346. static HRESULT CreateInstance (
  347. IN LPCITEMIDLIST apidl,
  348. IN REFIID riid,
  349. OUT void** ppv);
  350. };
  351. // Util function for the IExtract code (also used elsewhere)
  352. //
  353. class ATL_NO_VTABLE CConnectionFolderQueryInfo :
  354. public CComObjectRootEx <CComObjectThreadModel>,
  355. public CComCoClass <CConnectionFolderQueryInfo, &CLSID_ConnectionFolderQueryInfo>,
  356. public IQueryInfo
  357. {
  358. private:
  359. PCONFOLDPIDL m_pidl;
  360. public:
  361. CConnectionFolderQueryInfo() throw();
  362. ~CConnectionFolderQueryInfo() throw();
  363. VOID PidlInitialize(const PCONFOLDPIDL& pidl)
  364. {
  365. m_pidl = pidl;
  366. }
  367. DECLARE_REGISTRY_RESOURCEID(IDR_CONFOLDQUERYINFO)
  368. BEGIN_COM_MAP(CConnectionFolderQueryInfo)
  369. COM_INTERFACE_ENTRY(IQueryInfo)
  370. END_COM_MAP()
  371. // *** IQueryInfo methods ***
  372. STDMETHOD(GetInfoTip) (
  373. IN DWORD dwFlags,
  374. OUT WCHAR **ppwszTip);
  375. STDMETHOD(GetInfoFlags) (
  376. OUT DWORD *pdwFlags);
  377. public:
  378. static HRESULT CreateInstance (
  379. IN REFIID riid,
  380. OUT void** ppv);
  381. };
  382. //---[ Helper Functions ]------------------------------------------------------
  383. HRESULT HrRegisterFolderClass(VOID);
  384. HRESULT HrRegisterDUNFileAssociation();
  385. HRESULT CALLBACK HrShellViewCallback(
  386. IShellView * psvOuter,
  387. IShellFolder * psf,
  388. HWND hwnd,
  389. UINT uMsg,
  390. WPARAM wParam,
  391. LPARAM lParam);
  392. HRESULT CALLBACK HrShellContextMenuCallback(
  393. LPSHELLFOLDER psf,
  394. HWND hwndView,
  395. LPDATAOBJECT pdtobj,
  396. UINT uMsg,
  397. WPARAM wParam,
  398. LPARAM lParam);
  399. HRESULT HrDataObjGetHIDA(
  400. IDataObject * pdtobj,
  401. STGMEDIUM * pmedium,
  402. LPIDA * ppida);
  403. VOID HIDAReleaseStgMedium(
  404. LPIDA pida,
  405. STGMEDIUM * pmedium);
  406. HRESULT HrSHReleaseStgMedium(
  407. LPSTGMEDIUM pmedium);
  408. LPITEMIDLIST ILFromHIDA(
  409. LPIDA pida,
  410. UINT iPidaIndex);
  411. EXTERN_C
  412. HRESULT APIENTRY HrLaunchNetworkOptionalComponents(VOID);
  413. #endif // _CONFOLD_H_