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.

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();
  78. ~CConnectionFolder();
  79. static HRESULT WINAPI UpdateRegistry(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. LPCLSID lpClassID);
  93. // *** IPersistFolder methods ***
  94. STDMETHOD(Initialize) (
  95. LPCITEMIDLIST pidl);
  96. // *** IPersistFolder2 methods ***
  97. STDMETHOD(GetCurFolder) (
  98. 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. HWND * lphwnd);
  176. STDMETHOD(ContextSensitiveHelp) (
  177. BOOL fEnterMode);
  178. // *** IShellExtInit methods ***
  179. STDMETHOD(Initialize) (
  180. LPCITEMIDLIST pidlFolder,
  181. LPDATAOBJECT lpdobj,
  182. HKEY hkeyProgID);
  183. // IOleCommandTarget members
  184. STDMETHODIMP QueryStatus(
  185. const GUID * pguidCmdGroup,
  186. ULONG cCmds,
  187. OLECMD prgCmds[],
  188. OLECMDTEXT * pCmdText);
  189. STDMETHODIMP Exec(
  190. const GUID * pguidCmdGroup,
  191. DWORD nCmdID,
  192. DWORD nCmdexecopt,
  193. VARIANTARG * pvaIn,
  194. 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();
  206. PCWSTR pszGetUserName();
  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();
  223. ~CConnectionFolderEnum();
  224. VOID PidlInitialize(
  225. BOOL fTray,
  226. const PCONFOLDPIDLFOLDER& pidlFolder,
  227. 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. ULONG celt,
  235. LPITEMIDLIST * rgelt,
  236. ULONG * pceltFetched);
  237. STDMETHOD(Skip) (
  238. ULONG celt);
  239. STDMETHOD(Reset) ();
  240. STDMETHOD(Clone) (
  241. IEnumIDList ** ppenum);
  242. public:
  243. static HRESULT CreateInstance (
  244. REFIID riid,
  245. 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();
  267. ~CConnectionFolderContextMenu();
  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. HMENU hmenu,
  275. UINT indexMenu,
  276. UINT idCmdFirst,
  277. UINT idCmdLast,
  278. UINT uFlags);
  279. STDMETHOD(InvokeCommand) (
  280. LPCMINVOKECOMMANDINFO lpici);
  281. STDMETHOD(GetCommandString) (
  282. UINT_PTR idCmd,
  283. UINT uType,
  284. UINT * pwReserved,
  285. PSTR pszName,
  286. UINT cchMax);
  287. public:
  288. static HRESULT CreateInstance (
  289. REFIID riid,
  290. void** ppv,
  291. CMENU_TYPE cmt,
  292. HWND hwndOwner,
  293. const PCONFOLDPIDLVEC& apidl,
  294. LPSHELLFOLDER psf);
  295. private:
  296. HRESULT HrInitialize(
  297. CMENU_TYPE cmt,
  298. HWND hwndOwner,
  299. const PCONFOLDPIDLVEC& apidl,
  300. 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();
  312. ~CConnectionFolderExtractIcon();
  313. HRESULT HrInitialize(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. UINT uFlags,
  322. PWSTR szIconFile,
  323. UINT cchMax,
  324. int * piIndex,
  325. UINT * pwFlags);
  326. STDMETHOD(Extract) (
  327. PCWSTR pszFile,
  328. UINT nIconIndex,
  329. HICON * phiconLarge,
  330. HICON * phiconSmall,
  331. UINT nIconSize);
  332. // *** IExtractIcon methods ***
  333. STDMETHOD(GetIconLocation) (
  334. UINT uFlags,
  335. PSTR szIconFile,
  336. UINT cchMax,
  337. int * piIndex,
  338. UINT * pwFlags);
  339. STDMETHOD(Extract) (
  340. PCSTR pszFile,
  341. UINT nIconIndex,
  342. HICON * phiconLarge,
  343. HICON * phiconSmall,
  344. UINT nIconSize);
  345. public:
  346. static HRESULT CreateInstance (
  347. LPCITEMIDLIST apidl,
  348. REFIID riid,
  349. 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();
  362. ~CConnectionFolderQueryInfo();
  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. DWORD dwFlags,
  374. WCHAR **ppwszTip);
  375. STDMETHOD(GetInfoFlags) (
  376. DWORD *pdwFlags);
  377. public:
  378. static HRESULT CreateInstance (
  379. REFIID riid,
  380. 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_