1 /*
2 * PROJECT: shell32
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Folder implementation
5 * COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8 #include "precomp.h"
9
10 WINE_DEFAULT_DEBUG_CHANNEL(shell);
11
12
CFolder()13 CFolder::CFolder()
14 {
15 }
16
~CFolder()17 CFolder::~CFolder()
18 {
19 }
20
Initialize(LPITEMIDLIST idlist)21 HRESULT CFolder::Initialize(LPITEMIDLIST idlist)
22 {
23 m_idlist.Attach(ILClone(idlist));
24 return CShellDispatch_Constructor(IID_PPV_ARG(IShellDispatch, &m_Application));
25 }
26
GetShellFolder(CComPtr<IShellFolder> & psfCurrent)27 HRESULT CFolder::GetShellFolder(CComPtr<IShellFolder>& psfCurrent)
28 {
29 CComPtr<IShellFolder> psfDesktop;
30
31 HRESULT hr = SHGetDesktopFolder(&psfDesktop);
32 if (FAILED_UNEXPECTEDLY(hr))
33 return hr;
34
35 return psfDesktop->BindToObject(m_idlist, NULL, IID_PPV_ARG(IShellFolder, &psfCurrent));
36 }
37
38 // *** Folder methods ***
get_Title(BSTR * pbs)39 HRESULT STDMETHODCALLTYPE CFolder::get_Title(BSTR *pbs)
40 {
41 if (!pbs)
42 return E_POINTER;
43
44 WCHAR path[MAX_PATH+2] = {0};
45 HRESULT hr = ILGetDisplayNameExW(NULL, m_idlist, path, ILGDN_INFOLDER) ? S_OK : E_FAIL;
46 if (FAILED_UNEXPECTEDLY(hr))
47 return hr;
48
49 *pbs = SysAllocString(path);
50 return S_OK;
51 }
52
get_Application(IDispatch ** ppid)53 HRESULT STDMETHODCALLTYPE CFolder::get_Application(IDispatch **ppid)
54 {
55 TRACE("(%p, %p)\n", this, ppid);
56
57 if (!ppid)
58 return E_INVALIDARG;
59
60 *ppid = m_Application;
61 (*ppid)->AddRef();
62
63 return S_OK;
64 }
65
get_Parent(IDispatch ** ppid)66 HRESULT STDMETHODCALLTYPE CFolder::get_Parent(IDispatch **ppid)
67 {
68 TRACE("(%p %p)\n", this, ppid);
69
70 if (ppid)
71 *ppid = NULL;
72
73 return E_NOTIMPL;
74 }
75
get_ParentFolder(Folder ** ppsf)76 HRESULT STDMETHODCALLTYPE CFolder::get_ParentFolder(Folder **ppsf)
77 {
78 TRACE("(%p, %p)\n", this);
79
80 *ppsf = NULL;
81
82 return E_NOTIMPL;
83 }
84
Items(FolderItems ** ppid)85 HRESULT STDMETHODCALLTYPE CFolder::Items(FolderItems **ppid)
86 {
87 /* FolderItems_Constructor */
88 return ShellObjectCreatorInit<CFolderItems>(static_cast<LPITEMIDLIST>(m_idlist), this, IID_PPV_ARG(FolderItems, ppid));
89 }
90
ParseName(BSTR bName,FolderItem ** ppid)91 HRESULT STDMETHODCALLTYPE CFolder::ParseName(BSTR bName, FolderItem **ppid)
92 {
93 TRACE("(%p, %s, %p)\n", this, wine_dbgstr_w(bName), ppid);
94 if (!ppid)
95 return E_POINTER;
96 *ppid = NULL;
97
98 CComPtr<IShellFolder> psfCurrent;
99 HRESULT hr = GetShellFolder(psfCurrent);
100 if (FAILED_UNEXPECTEDLY(hr))
101 return hr;
102
103 CComHeapPtr<ITEMIDLIST_RELATIVE> relativePidl;
104 hr = psfCurrent->ParseDisplayName(NULL, NULL, bName, NULL, &relativePidl, NULL);
105 if (!SUCCEEDED(hr))
106 return S_FALSE;
107
108 CComHeapPtr<ITEMIDLIST> combined;
109 combined.Attach(ILCombine(m_idlist, relativePidl));
110
111 return ShellObjectCreatorInit<CFolderItem>(this, static_cast<LPITEMIDLIST>(combined), IID_PPV_ARG(FolderItem, ppid));
112 }
113
NewFolder(BSTR bName,VARIANT vOptions)114 HRESULT STDMETHODCALLTYPE CFolder::NewFolder(BSTR bName, VARIANT vOptions)
115 {
116 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_w(bName), wine_dbgstr_variant(&vOptions));
117 return E_NOTIMPL;
118 }
119
MoveHere(VARIANT vItem,VARIANT vOptions)120 HRESULT STDMETHODCALLTYPE CFolder::MoveHere(VARIANT vItem, VARIANT vOptions)
121 {
122 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_variant(&vItem), wine_dbgstr_variant(&vOptions));
123 return E_NOTIMPL;
124 }
125
CopyHere(VARIANT vItem,VARIANT vOptions)126 HRESULT STDMETHODCALLTYPE CFolder::CopyHere(VARIANT vItem, VARIANT vOptions)
127 {
128 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_variant(&vItem), wine_dbgstr_variant(&vOptions));
129 return E_NOTIMPL;
130 }
131
GetDetailsOf(VARIANT vItem,int iColumn,BSTR * pbs)132 HRESULT STDMETHODCALLTYPE CFolder::GetDetailsOf(VARIANT vItem, int iColumn, BSTR *pbs)
133 {
134 TRACE("(%p, %s, %i, %p)\n", this, wine_dbgstr_variant(&vItem), iColumn, pbs);
135 return E_NOTIMPL;
136 }
137
138
139 // *** Folder2 methods ***
get_Self(FolderItem ** ppfi)140 HRESULT STDMETHODCALLTYPE CFolder::get_Self(FolderItem **ppfi)
141 {
142 TRACE("(%p, %p)\n", this, ppfi);
143 if (!ppfi)
144 return E_POINTER;
145
146 return ShellObjectCreatorInit<CFolderItem>(this, static_cast<LPITEMIDLIST>(m_idlist), IID_PPV_ARG(FolderItem, ppfi));
147 }
148
get_OfflineStatus(LONG * pul)149 HRESULT STDMETHODCALLTYPE CFolder::get_OfflineStatus(LONG *pul)
150 {
151 TRACE("(%p, %p)\n", this, pul);
152 return E_NOTIMPL;
153 }
154
Synchronize()155 HRESULT STDMETHODCALLTYPE CFolder::Synchronize()
156 {
157 TRACE("(%p)\n", this);
158 return E_NOTIMPL;
159 }
160
get_HaveToShowWebViewBarricade(VARIANT_BOOL * pbHaveToShowWebViewBarricade)161 HRESULT STDMETHODCALLTYPE CFolder::get_HaveToShowWebViewBarricade(VARIANT_BOOL *pbHaveToShowWebViewBarricade)
162 {
163 TRACE("(%p, %p)\n", this, pbHaveToShowWebViewBarricade);
164 return E_NOTIMPL;
165 }
166
DismissedWebViewBarricade()167 HRESULT STDMETHODCALLTYPE CFolder::DismissedWebViewBarricade()
168 {
169 TRACE("(%p)\n", this);
170 return E_NOTIMPL;
171 }
172
173
174