1 /*
2  * Shell Menu Site
3  *
4  * Copyright 2014 David Quintana
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 #pragma once
21 
22 interface IAugmentedShellFolder : public IShellFolder
23 {
24     virtual HRESULT STDMETHODCALLTYPE AddNameSpace(LPGUID, IShellFolder *, LPCITEMIDLIST, ULONG) = 0;
25     virtual HRESULT STDMETHODCALLTYPE GetNameSpaceID(LPCITEMIDLIST, LPGUID) = 0;
26     virtual HRESULT STDMETHODCALLTYPE QueryNameSpace(ULONG, LPGUID, IShellFolder **) = 0;
27     virtual HRESULT STDMETHODCALLTYPE EnumNameSpace(ULONG, PULONG) = 0;
28 };
29 
30 interface IAugmentedShellFolder2 : public IAugmentedShellFolder
31 {
32     virtual HRESULT STDMETHODCALLTYPE UnWrapIDList(LPCITEMIDLIST, LONG, IShellFolder **, LPITEMIDLIST *, LPITEMIDLIST *, LONG *) = 0;
33 };
34 
35 /* No idea what QUERYNAMESPACEINFO struct contains, yet */
36 struct QUERYNAMESPACEINFO
37 {
38     BYTE unknown[1];
39 };
40 
41 interface IAugmentedShellFolder3 : public IAugmentedShellFolder2
42 {
43     virtual HRESULT STDMETHODCALLTYPE QueryNameSpace2(ULONG, QUERYNAMESPACEINFO *) = 0;
44 };
45 
46 class CEnumMergedFolder;
47 
48 class CMergedFolder :
49     public CComCoClass<CMergedFolder, &CLSID_MergedFolder>,
50     public CComObjectRootEx<CComMultiThreadModelNoCS>,
51     public IShellFolder2,
52     public IPersistFolder2,
53     public IAugmentedShellFolder3     // -- undocumented
54     //public IShellService,              // DEPRECATED IE4 interface: https://msdn.microsoft.com/en-us/library/windows/desktop/bb774870%28v=vs.85%29.aspx
55     //public ITranslateShellChangeNotify,// -- undocumented
56     //public IStorage,
57     //public IPersistPropertyBag,
58     //public IShellIconOverlay,          // -- undocumented
59     //public ICompositeFolder,           // -- undocumented
60     //public IItemNameLimits,            // https://msdn.microsoft.com/en-us/library/windows/desktop/bb761776%28v=vs.85%29.aspx
61 {
62 private:
63     CComPtr<IShellFolder> m_UserLocal;
64     CComPtr<IShellFolder> m_AllUsers;
65     CComPtr<CEnumMergedFolder> m_EnumSource;
66 
67     LPITEMIDLIST m_UserLocalPidl;
68     LPITEMIDLIST m_AllUsersPidl;
69     LPITEMIDLIST m_shellPidl;
70 
71 public:
72     CMergedFolder();
73     virtual ~CMergedFolder();
74 
75     HRESULT _SetSources(IShellFolder* userLocal, IShellFolder* allUSers);
76 
77     DECLARE_REGISTRY_RESOURCEID(IDR_MERGEDFOLDER)
78     DECLARE_NOT_AGGREGATABLE(CMergedFolder)
79     DECLARE_PROTECT_FINAL_CONSTRUCT()
80 
81     BEGIN_COM_MAP(CMergedFolder)
82         COM_INTERFACE_ENTRY2_IID(IID_IShellFolder, IShellFolder, IShellFolder2)
83         COM_INTERFACE_ENTRY_IID(IID_IShellFolder2,   IShellFolder2)
84         COM_INTERFACE_ENTRY_IID(IID_IPersist,        IPersist)
85         COM_INTERFACE_ENTRY_IID(IID_IPersistFolder,  IPersistFolder)
86         COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2)
87         COM_INTERFACE_ENTRY_IID(IID_IAugmentedShellFolder,  IAugmentedShellFolder)
88         COM_INTERFACE_ENTRY_IID(IID_IAugmentedShellFolder2, IAugmentedShellFolder2)
89         COM_INTERFACE_ENTRY_IID(IID_IAugmentedShellFolder3, IAugmentedShellFolder3)
90         //COM_INTERFACE_ENTRY_IID(IID_IStorage,                   IStorage)
91         //COM_INTERFACE_ENTRY_IID(IID_IShellService,              IShellService)
92         //COM_INTERFACE_ENTRY_IID(IID_ITranslateShellChangeNotify,ITranslateShellChangeNotify)
93         //COM_INTERFACE_ENTRY_IID(IID_IPersistPropertyBag,IPersistPropertyBag)
94         //COM_INTERFACE_ENTRY_IID(IID_IShellIconOverlay,  IShellIconOverlay)
95         //COM_INTERFACE_ENTRY_IID(IID_ICompositeFolder,   ICompositeFolder)
96         //COM_INTERFACE_ENTRY_IID(IID_IItemNameLimits,    IItemNameLimits)
97     END_COM_MAP()
98 
99     // IShellFolder
100     virtual HRESULT STDMETHODCALLTYPE ParseDisplayName(
101         HWND hwndOwner,
102         LPBC pbcReserved,
103         LPOLESTR lpszDisplayName,
104         ULONG *pchEaten,
105         LPITEMIDLIST *ppidl,
106         ULONG *pdwAttributes);
107 
108     virtual HRESULT STDMETHODCALLTYPE EnumObjects(
109         HWND hwndOwner,
110         SHCONTF grfFlags,
111         IEnumIDList **ppenumIDList);
112 
113     virtual HRESULT STDMETHODCALLTYPE BindToObject(
114         LPCITEMIDLIST pidl,
115         LPBC pbcReserved,
116         REFIID riid,
117         void **ppvOut);
118 
119     virtual HRESULT STDMETHODCALLTYPE BindToStorage(
120         LPCITEMIDLIST pidl,
121         LPBC pbcReserved,
122         REFIID riid,
123         void **ppvObj);
124 
125     virtual HRESULT STDMETHODCALLTYPE CompareIDs(
126         LPARAM lParam,
127         LPCITEMIDLIST pidl1,
128         LPCITEMIDLIST pidl2);
129 
130     virtual HRESULT STDMETHODCALLTYPE CreateViewObject(
131         HWND hwndOwner,
132         REFIID riid,
133         void **ppvOut);
134 
135     virtual HRESULT STDMETHODCALLTYPE GetAttributesOf(
136         UINT cidl,
137         PCUITEMID_CHILD_ARRAY apidl,
138         SFGAOF *rgfInOut);
139 
140     virtual HRESULT STDMETHODCALLTYPE GetUIObjectOf(
141         HWND hwndOwner,
142         UINT cidl,
143         PCUITEMID_CHILD_ARRAY apidl,
144         REFIID riid,
145         UINT *prgfInOut,
146         void **ppvOut);
147 
148     virtual HRESULT STDMETHODCALLTYPE GetDisplayNameOf(
149         LPCITEMIDLIST pidl,
150         SHGDNF uFlags,
151         STRRET *lpName);
152 
153     virtual HRESULT STDMETHODCALLTYPE SetNameOf(
154         HWND hwnd,
155         LPCITEMIDLIST pidl,
156         LPCOLESTR lpszName,
157         SHGDNF uFlags,
158         LPITEMIDLIST *ppidlOut);
159 
160     // IShellFolder2
161     virtual HRESULT STDMETHODCALLTYPE GetDefaultSearchGUID(
162         GUID *lpguid);
163 
164     virtual HRESULT STDMETHODCALLTYPE EnumSearches(
165         IEnumExtraSearch **ppenum);
166 
167     virtual HRESULT STDMETHODCALLTYPE GetDefaultColumn(
168         DWORD dwReserved,
169         ULONG *pSort,
170         ULONG *pDisplay);
171 
172     virtual HRESULT STDMETHODCALLTYPE GetDefaultColumnState(
173         UINT iColumn,
174         SHCOLSTATEF *pcsFlags);
175 
176     virtual HRESULT STDMETHODCALLTYPE GetDetailsEx(
177         LPCITEMIDLIST pidl,
178         const SHCOLUMNID *pscid,
179         VARIANT *pv);
180 
181     virtual HRESULT STDMETHODCALLTYPE GetDetailsOf(
182         LPCITEMIDLIST pidl,
183         UINT iColumn,
184         SHELLDETAILS *psd);
185 
186     virtual HRESULT STDMETHODCALLTYPE MapColumnToSCID(
187         UINT iColumn,
188         SHCOLUMNID *pscid);
189 
190     // IPersist
191     virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *lpClassId);
192 
193     // IPersistFolder
194     virtual HRESULT STDMETHODCALLTYPE Initialize(PCIDLIST_ABSOLUTE pidl);
195 
196     // IPersistFolder2
197     virtual HRESULT STDMETHODCALLTYPE GetCurFolder(PIDLIST_ABSOLUTE * pidl);
198 
199     // IAugmentedShellFolder2
200     virtual HRESULT STDMETHODCALLTYPE AddNameSpace(LPGUID lpGuid, IShellFolder * psf, LPCITEMIDLIST pcidl, ULONG dwUnknown);
201     virtual HRESULT STDMETHODCALLTYPE GetNameSpaceID(LPCITEMIDLIST pcidl, LPGUID lpGuid);
202     virtual HRESULT STDMETHODCALLTYPE QueryNameSpace(ULONG dwUnknown, LPGUID lpGuid, IShellFolder ** ppsf);
203     virtual HRESULT STDMETHODCALLTYPE EnumNameSpace(ULONG dwUnknown, PULONG lpUnknown);
204     virtual HRESULT STDMETHODCALLTYPE UnWrapIDList(LPCITEMIDLIST pcidl, LONG lUnknown, IShellFolder ** ppsf, LPITEMIDLIST * ppidl1, LPITEMIDLIST *ppidl2, LONG * lpUnknown);
205 
206     // IAugmentedShellFolder3
207     virtual HRESULT STDMETHODCALLTYPE QueryNameSpace2(ULONG, QUERYNAMESPACEINFO *);
208 };
209