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.

555 lines
14 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: U P N P F O L D . H
  7. //
  8. // Contents: CUPnPDeviceFolder object definition.
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 03 Sep 1999
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _UPNPFOLD_H_
  17. #define _UPNPFOLD_H_
  18. #include <upnpshell.h>
  19. #include <upclsid.h>
  20. #include <shlguid.h>
  21. #include <shlobj.h>
  22. #include <shlobjp.h>
  23. #include "pidlutil.h"
  24. #include "nsbase.h"
  25. #include "upsres.h"
  26. #include "tfind.h"
  27. #include "updpidl.h"
  28. #include "clistndn.h"
  29. //---[ Connection Folder Types ]----------------------------------------------
  30. // The details list view columns. These are used by the view and
  31. // context menus
  32. enum
  33. {
  34. ICOL_NAME = 0,
  35. ICOL_URL, // 1
  36. ICOL_UDN, // 2
  37. ICOL_TYPE, // 3
  38. ICOL_MAX // End of list.
  39. };
  40. // The details list view columns. These are used by the view and
  41. // context menus
  42. typedef struct tagCOLS
  43. {
  44. short int iColumn;
  45. short int iStringRes;
  46. short int iColumnSize;
  47. short int iFormat;
  48. } COLS;
  49. DEFINE_GUID(IID_IExplorerToolbar, 0x8455F0C1L, 0x158F, 0x11D0, 0x89, 0xAE, 0x00, 0xA0, 0xC9, 0x0A, 0x90, 0xAC);
  50. #define SID_SExplorerToolbar IID_IExplorerToolbar
  51. struct __declspec(uuid("ADD8BA80-002B-11D0-8F0F-00C04FD7D062")) IDelegateFolder;
  52. //---[ Connection Folder Classes ]--------------------------------------------
  53. class ATL_NO_VTABLE CUPnPDeviceFolder :
  54. public CComObjectRootEx <CComMultiThreadModel>,
  55. public CComCoClass <CUPnPDeviceFolder, &CLSID_UPnPDeviceFolder>,
  56. public IPersistFolder2,
  57. public IShellExtInit,
  58. public IShellFolder2, // includes IShellFolder
  59. public IDelegateFolder,
  60. public IOleCommandTarget
  61. {
  62. private:
  63. LPITEMIDLIST m_pidlFolderRoot;
  64. IMalloc * m_pMalloc;
  65. IMalloc * m_pDelegateMalloc;
  66. UINT m_cbDelegate; /* Size of delegate header (0 if not delegating) */
  67. HRESULT HrMakeUPnPDevicePidl(IUPnPDevice * pdev,
  68. LPITEMIDLIST * ppidl);
  69. public:
  70. CUPnPDeviceFolder();
  71. ~CUPnPDeviceFolder();
  72. static HRESULT WINAPI UpdateRegistry(BOOL fRegister);
  73. DECLARE_NOT_AGGREGATABLE(CUPnPDeviceFolder)
  74. BEGIN_COM_MAP(CUPnPDeviceFolder)
  75. COM_INTERFACE_ENTRY(IPersist)
  76. COM_INTERFACE_ENTRY(IPersistFolder)
  77. COM_INTERFACE_ENTRY(IPersistFolder2)
  78. COM_INTERFACE_ENTRY(IShellExtInit)
  79. COM_INTERFACE_ENTRY(IShellFolder)
  80. // There's no __declspec(uuid(... entry for IShellFolder2, so we need
  81. // to do this. See: "COM_INTERFACE_ENTRY Macros" in MSDN for more info
  82. COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2)
  83. COM_INTERFACE_ENTRY(IDelegateFolder)
  84. COM_INTERFACE_ENTRY(IOleCommandTarget)
  85. END_COM_MAP()
  86. // *** IPersist methods ***
  87. STDMETHOD(GetClassID) (
  88. LPCLSID lpClassID);
  89. // *** IPersistFolder methods ***
  90. STDMETHOD(Initialize) (
  91. LPCITEMIDLIST pidl);
  92. // *** IPersistFolder2 methods ***
  93. STDMETHOD(GetCurFolder) (
  94. LPITEMIDLIST *ppidl);
  95. // *** IShellFolder methods ***
  96. STDMETHOD(ParseDisplayName) (
  97. HWND hwndOwner,
  98. LPBC pbcReserved,
  99. LPOLESTR lpszDisplayName,
  100. ULONG * pchEaten,
  101. LPITEMIDLIST * ppidl,
  102. ULONG * pdwAttributes);
  103. STDMETHOD(EnumObjects) (
  104. HWND hwndOwner,
  105. DWORD grfFlags,
  106. LPENUMIDLIST * ppenumIDList);
  107. STDMETHOD(BindToObject) (
  108. LPCITEMIDLIST pidl,
  109. LPBC pbcReserved,
  110. REFIID riid,
  111. LPVOID * ppvOut);
  112. STDMETHOD(BindToStorage) (
  113. LPCITEMIDLIST pidl,
  114. LPBC pbcReserved,
  115. REFIID riid,
  116. LPVOID * ppvObj);
  117. STDMETHOD(CompareIDs) (
  118. LPARAM lParam,
  119. LPCITEMIDLIST pidl1,
  120. LPCITEMIDLIST pidl2);
  121. STDMETHOD(CreateViewObject) (
  122. HWND hwndOwner,
  123. REFIID riid,
  124. LPVOID * ppvOut);
  125. STDMETHOD(GetAttributesOf) (
  126. UINT cidl,
  127. LPCITEMIDLIST * apidl,
  128. ULONG * rgfInOut);
  129. STDMETHOD(GetUIObjectOf) (
  130. HWND hwndOwner,
  131. UINT cidl,
  132. LPCITEMIDLIST * apidl,
  133. REFIID riid,
  134. UINT * prgfInOut,
  135. LPVOID * ppvOut);
  136. STDMETHOD(GetDisplayNameOf) (
  137. LPCITEMIDLIST pidl,
  138. DWORD uFlags,
  139. LPSTRRET lpName);
  140. STDMETHOD(SetNameOf) (
  141. HWND hwndOwner,
  142. LPCITEMIDLIST pidl,
  143. LPCOLESTR lpszName,
  144. DWORD uFlags,
  145. LPITEMIDLIST * ppidlOut);
  146. // *** IShellFolder2 methods ***
  147. STDMETHOD(GetDefaultSearchGUID) (
  148. GUID * pguid);
  149. STDMETHOD(EnumSearches) (
  150. IEnumExtraSearch ** ppenum);
  151. STDMETHOD(GetDefaultColumn) (
  152. DWORD dwRes,
  153. ULONG * pSort,
  154. ULONG * pDisplay);
  155. STDMETHOD(GetDefaultColumnState) (
  156. UINT iColumn,
  157. DWORD * pcsFlags);
  158. STDMETHOD(GetDetailsEx) (
  159. LPCITEMIDLIST pidl,
  160. const SHCOLUMNID * pscid,
  161. VARIANT * pv);
  162. STDMETHOD(GetDetailsOf) (
  163. LPCITEMIDLIST pidl,
  164. UINT iColumn,
  165. SHELLDETAILS * psd);
  166. STDMETHOD(MapColumnToSCID) (
  167. UINT iColumn,
  168. SHCOLUMNID * pscid);
  169. // *** IOleWindow methods ***
  170. STDMETHOD(GetWindow) (
  171. HWND * lphwnd);
  172. STDMETHOD(ContextSensitiveHelp) (
  173. BOOL fEnterMode);
  174. // *** IShellExtInit methods ***
  175. STDMETHOD(Initialize) (
  176. LPCITEMIDLIST pidlFolder,
  177. LPDATAOBJECT lpdobj,
  178. HKEY hkeyProgID);
  179. // IOleCommandTarget members
  180. STDMETHODIMP QueryStatus(
  181. const GUID * pguidCmdGroup,
  182. ULONG cCmds,
  183. OLECMD prgCmds[],
  184. OLECMDTEXT * pCmdText);
  185. STDMETHODIMP Exec(
  186. const GUID * pguidCmdGroup,
  187. DWORD nCmdID,
  188. DWORD nCmdexecopt,
  189. VARIANTARG * pvaIn,
  190. VARIANTARG * pvaOut);
  191. // *** IDelegateFolder members ***
  192. STDMETHOD(SetItemAlloc)(
  193. IMalloc *pmalloc);
  194. // Other interfaces
  195. LPITEMIDLIST PidlGetFolderRoot();
  196. HRESULT HrMakeUPnPDevicePidl(FolderDeviceNode * pDeviceNode,
  197. LPITEMIDLIST * ppidl);
  198. };
  199. class ATL_NO_VTABLE CUPnPDeviceFolderEnum :
  200. public CComObjectRootEx <CComMultiThreadModel>,
  201. public CComCoClass <CUPnPDeviceFolderEnum, &CLSID_UPnPDeviceEnum>,
  202. public IEnumIDList
  203. {
  204. private:
  205. LPITEMIDLIST m_pidlFolder;
  206. CListFolderDeviceNode m_CListDevices;
  207. DWORD m_cDevices;
  208. DWORD m_dwFlags;
  209. CUPnPDeviceFolder * m_psf;
  210. BOOL m_fFirstEnumeration;
  211. public:
  212. CUPnPDeviceFolderEnum();
  213. ~CUPnPDeviceFolderEnum();
  214. VOID Initialize(
  215. LPITEMIDLIST pidlFolder,
  216. CUPnPDeviceFolder * psf
  217. );
  218. DECLARE_NOT_AGGREGATABLE(CUPnPDeviceFolderEnum)
  219. BEGIN_COM_MAP(CUPnPDeviceFolderEnum)
  220. COM_INTERFACE_ENTRY(IEnumIDList)
  221. END_COM_MAP()
  222. // *** IEnumIDList methods ***
  223. STDMETHOD(Next) (
  224. ULONG celt,
  225. LPITEMIDLIST * rgelt,
  226. ULONG * pceltFetched);
  227. STDMETHOD(Skip) (
  228. ULONG celt);
  229. STDMETHOD(Reset) ();
  230. STDMETHOD(Clone) (
  231. IEnumIDList ** ppenum);
  232. public:
  233. static HRESULT CreateInstance (
  234. REFIID riid,
  235. void** ppv);
  236. private:
  237. VOID BuildCurrentDeviceList();
  238. };
  239. struct __declspec(uuid("000214ec-0000-0000-c000-000000000046")) IShellDetails;
  240. class ATL_NO_VTABLE CUPnPDeviceFolderDetails :
  241. public CComObjectRootEx <CComMultiThreadModel>,
  242. public CComCoClass <CUPnPDeviceFolderDetails, &CLSID_UPnPDeviceDetails>,
  243. public IShellDetails
  244. {
  245. private:
  246. HWND m_hwndOwner;
  247. public:
  248. CUPnPDeviceFolderDetails();
  249. ~CUPnPDeviceFolderDetails();
  250. DECLARE_NOT_AGGREGATABLE(CUPnPDeviceFolderDetails)
  251. BEGIN_COM_MAP(CUPnPDeviceFolderDetails)
  252. COM_INTERFACE_ENTRY(IShellDetails)
  253. END_COM_MAP()
  254. // *** IShellDetails methods ***
  255. STDMETHOD(GetDetailsOf)(
  256. LPCITEMIDLIST pidl,
  257. UINT iColumn,
  258. LPSHELLDETAILS pDetails);
  259. STDMETHOD(ColumnClick)(
  260. UINT iColumn);
  261. HRESULT HrInitialize(HWND hwndOwner);
  262. public:
  263. static HRESULT CreateInstance (
  264. REFIID riid,
  265. void** ppv);
  266. };
  267. typedef enum CMENU_TYPE
  268. {
  269. CMT_OBJECT = 1,
  270. CMT_BACKGROUND = 2
  271. };
  272. class ATL_NO_VTABLE CUPnPDeviceFolderContextMenu :
  273. public CComObjectRootEx <CComMultiThreadModel>,
  274. public CComCoClass <CUPnPDeviceFolderContextMenu, &CLSID_UPnPDeviceContextMenu>,
  275. public IContextMenu
  276. {
  277. private:
  278. HWND m_hwndOwner;
  279. LPITEMIDLIST * m_apidl;
  280. ULONG m_cidl;
  281. LPSHELLFOLDER m_psf;
  282. CMENU_TYPE m_cmt;
  283. public:
  284. CUPnPDeviceFolderContextMenu();
  285. ~CUPnPDeviceFolderContextMenu();
  286. // DECLARE_REGISTRY_RESOURCEID(IDR_UPNPFOLDCONTEXTMENU)
  287. DECLARE_NOT_AGGREGATABLE(CUPnPDeviceFolderContextMenu)
  288. BEGIN_COM_MAP(CUPnPDeviceFolderContextMenu)
  289. COM_INTERFACE_ENTRY(IContextMenu)
  290. END_COM_MAP()
  291. // *** IContextMenu methods ***
  292. STDMETHOD(QueryContextMenu) (
  293. HMENU hmenu,
  294. UINT indexMenu,
  295. UINT idCmdFirst,
  296. UINT idCmdLast,
  297. UINT uFlags);
  298. STDMETHOD(InvokeCommand) (
  299. LPCMINVOKECOMMANDINFO lpici);
  300. STDMETHOD(GetCommandString) (
  301. UINT_PTR idCmd,
  302. UINT uType,
  303. UINT * pwReserved,
  304. PSTR pszName,
  305. UINT cchMax);
  306. public:
  307. static HRESULT CreateInstance (
  308. REFIID riid,
  309. void** ppv,
  310. CMENU_TYPE cmt,
  311. HWND hwndOwner,
  312. UINT cidl,
  313. LPCITEMIDLIST * apidl,
  314. LPSHELLFOLDER psf);
  315. private:
  316. HRESULT HrInitialize(
  317. CMENU_TYPE cmt,
  318. HWND hwndOwner,
  319. UINT cidl,
  320. LPCITEMIDLIST * apidl,
  321. LPSHELLFOLDER psf);
  322. };
  323. class ATL_NO_VTABLE CUPnPDeviceFolderExtractIcon :
  324. public CComObjectRootEx <CComMultiThreadModel>,
  325. public CComCoClass <CUPnPDeviceFolderExtractIcon, &CLSID_UPnPDeviceExtractIcon>,
  326. public IExtractIconW,
  327. public IExtractIconA
  328. {
  329. private:
  330. BSTR m_DeviceType;
  331. BSTR m_DeviceUDN; // Not used currently. Needed for downloading device specific icon
  332. HRESULT HrLoadIcons(
  333. PCWSTR pszFile,
  334. UINT nIconIndex,
  335. int nSizeLarge,
  336. int nSizeSmall,
  337. HICON * phiconLarge,
  338. HICON * phiconSmall);
  339. public:
  340. CUPnPDeviceFolderExtractIcon();
  341. ~CUPnPDeviceFolderExtractIcon();
  342. DECLARE_NOT_AGGREGATABLE(CUPnPDeviceFolderExtractIcon)
  343. BEGIN_COM_MAP(CUPnPDeviceFolderExtractIcon)
  344. COM_INTERFACE_ENTRY(IExtractIconW)
  345. COM_INTERFACE_ENTRY(IExtractIconA)
  346. END_COM_MAP()
  347. // *** IExtractIconW methods ***
  348. STDMETHOD(GetIconLocation) (
  349. UINT uFlags,
  350. PWSTR szIconFile,
  351. UINT cchMax,
  352. int * piIndex,
  353. UINT * pwFlags);
  354. STDMETHOD(Extract) (
  355. PCWSTR pszFile,
  356. UINT nIconIndex,
  357. HICON * phiconLarge,
  358. HICON * phiconSmall,
  359. UINT nIconSize);
  360. // *** IExtractIcon methods ***
  361. STDMETHOD(GetIconLocation) (
  362. UINT uFlags,
  363. PSTR szIconFile,
  364. UINT cchMax,
  365. int * piIndex,
  366. UINT * pwFlags);
  367. STDMETHOD(Extract) (
  368. PCSTR pszFile,
  369. UINT nIconIndex,
  370. HICON * phiconLarge,
  371. HICON * phiconSmall,
  372. UINT nIconSize);
  373. public:
  374. static HRESULT CreateInstance (
  375. LPCITEMIDLIST apidl,
  376. REFIID riid,
  377. void** ppv);
  378. HRESULT Initialize(
  379. LPCITEMIDLIST apidl);
  380. };
  381. class ATL_NO_VTABLE CUPnPDeviceFolderQueryInfo :
  382. public CComObjectRootEx <CComMultiThreadModel>,
  383. public CComCoClass <CUPnPDeviceFolderQueryInfo, &CLSID_UPnPDeviceQueryInfo>,
  384. public IQueryInfo
  385. {
  386. private:
  387. LPITEMIDLIST m_pidl;
  388. public:
  389. CUPnPDeviceFolderQueryInfo();
  390. ~CUPnPDeviceFolderQueryInfo();
  391. VOID PidlInitialize(LPITEMIDLIST pidl)
  392. {
  393. m_pidl = (pidl) ? CloneIDL (pidl) : NULL;
  394. }
  395. DECLARE_NOT_AGGREGATABLE(CUPnPDeviceFolderQueryInfo)
  396. BEGIN_COM_MAP(CUPnPDeviceFolderQueryInfo)
  397. COM_INTERFACE_ENTRY(IQueryInfo)
  398. END_COM_MAP()
  399. // *** IQueryInfo methods ***
  400. STDMETHOD(GetInfoTip) (
  401. DWORD dwFlags,
  402. WCHAR **ppwszTip);
  403. STDMETHOD(GetInfoFlags) (
  404. DWORD *pdwFlags);
  405. public:
  406. static HRESULT CreateInstance (
  407. REFIID riid,
  408. void** ppv);
  409. };
  410. //---[ Helper Functions ]------------------------------------------------------
  411. HRESULT HrRegisterFolderClass(VOID);
  412. HRESULT HrUnRegisterDelegateFolderKey(VOID);
  413. HRESULT HrUnRegisterUPnPUIKey(VOID);
  414. HRESULT CALLBACK HrShellViewCallback(
  415. IShellView * psvOuter,
  416. IShellFolder * psf,
  417. HWND hwnd,
  418. UINT uMsg,
  419. WPARAM wParam,
  420. LPARAM lParam);
  421. HRESULT CALLBACK HrShellContextMenuCallback(
  422. LPSHELLFOLDER psf,
  423. HWND hwndView,
  424. LPDATAOBJECT pdtobj,
  425. UINT uMsg,
  426. WPARAM wParam,
  427. LPARAM lParam);
  428. HRESULT HrDataObjGetHIDA(
  429. IDataObject * pdtobj,
  430. STGMEDIUM * pmedium,
  431. LPIDA * ppida);
  432. VOID HIDAReleaseStgMedium(
  433. LPIDA pida,
  434. STGMEDIUM * pmedium);
  435. HRESULT HrSHReleaseStgMedium(
  436. LPSTGMEDIUM pmedium);
  437. LPITEMIDLIST ILFromHIDA(
  438. LPIDA pida,
  439. UINT iPidaIndex);
  440. #endif // _UPNPFOLD_H_