[SHELL32] Partially implement CFolderItems. Thanks to Giannis for the advice :)
[reactos.git] / reactos / dll / win32 / shell32 / CFolder.cpp
1 /*
2 * Folder implementation
3 *
4 * Copyright 2015 Mark Jansen
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
21 #include "precomp.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(shell);
24
25
26 CFolder::CFolder()
27 {
28 }
29
30 CFolder::~CFolder()
31 {
32 }
33
34 void CFolder::Init(LPITEMIDLIST idlist)
35 {
36 m_idlist.Attach(idlist);
37 }
38
39 HRESULT CFolder::GetShellFolder(CComPtr<IShellFolder>& psfCurrent)
40 {
41 CComPtr<IShellFolder> psfDesktop;
42
43 HRESULT hr = SHGetDesktopFolder(&psfDesktop);
44 if (FAILED_UNEXPECTEDLY(hr))
45 return hr;
46
47 return psfDesktop->BindToObject(m_idlist, NULL, IID_PPV_ARG(IShellFolder, &psfCurrent));
48 }
49
50 // *** Folder methods ***
51 HRESULT STDMETHODCALLTYPE CFolder::get_Title(BSTR *pbs)
52 {
53 if (!pbs)
54 return E_POINTER;
55
56 WCHAR path[MAX_PATH+2] = {0};
57 HRESULT hr = ILGetDisplayNameExW(NULL, m_idlist, path, ILGDN_INFOLDER);
58 if (FAILED_UNEXPECTEDLY(hr))
59 return hr;
60
61 *pbs = SysAllocString(path);
62 return S_OK;
63 }
64
65 HRESULT STDMETHODCALLTYPE CFolder::get_Application(IDispatch **ppid)
66 {
67 TRACE("(%p, %p)\n", this, ppid);
68 return E_NOTIMPL;
69 }
70
71 HRESULT STDMETHODCALLTYPE CFolder::get_Parent(IDispatch **ppid)
72 {
73 TRACE("(%p %p)\n", this, ppid);
74 return E_NOTIMPL;
75 }
76
77 HRESULT STDMETHODCALLTYPE CFolder::get_ParentFolder(Folder **ppsf)
78 {
79 TRACE("(%p, %p)\n", this);
80 return E_NOTIMPL;
81 }
82
83 HRESULT STDMETHODCALLTYPE CFolder::Items(FolderItems **ppid)
84 {
85 CFolderItems* items = new CComObject<CFolderItems>();
86 items->AddRef();
87
88 HRESULT hr = items->Init(ILClone(m_idlist));
89 if (FAILED_UNEXPECTEDLY(hr))
90 {
91 items->Release();
92 return hr;
93 }
94
95 *ppid = items;
96 return S_OK;
97 }
98
99 HRESULT STDMETHODCALLTYPE CFolder::ParseName(BSTR bName, FolderItem **ppid)
100 {
101 TRACE("(%p, %s, %p)\n", this, wine_dbgstr_w(bName), ppid);
102 if (!ppid)
103 return E_POINTER;
104 *ppid = NULL;
105
106 CComPtr<IShellFolder> psfCurrent;
107 HRESULT hr = GetShellFolder(psfCurrent);
108 if (FAILED_UNEXPECTEDLY(hr))
109 return hr;
110
111 CComHeapPtr<ITEMIDLIST_RELATIVE> relativePidl;
112 hr = psfCurrent->ParseDisplayName(NULL, NULL, bName, NULL, &relativePidl, NULL);
113 if (!SUCCEEDED(hr))
114 return S_FALSE;
115
116 CFolderItem* item = new CComObject<CFolderItem>();
117 item->AddRef();
118 item->Init(ILCombine(m_idlist, relativePidl));
119 *ppid = item;
120 return S_OK;
121 }
122
123 HRESULT STDMETHODCALLTYPE CFolder::NewFolder(BSTR bName, VARIANT vOptions)
124 {
125 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_w(bName), wine_dbgstr_variant(&vOptions));
126 return E_NOTIMPL;
127 }
128
129 HRESULT STDMETHODCALLTYPE CFolder::MoveHere(VARIANT vItem, VARIANT vOptions)
130 {
131 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_variant(&vItem), wine_dbgstr_variant(&vOptions));
132 return E_NOTIMPL;
133 }
134
135 HRESULT STDMETHODCALLTYPE CFolder::CopyHere(VARIANT vItem, VARIANT vOptions)
136 {
137 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_variant(&vItem), wine_dbgstr_variant(&vOptions));
138 return E_NOTIMPL;
139 }
140
141 HRESULT STDMETHODCALLTYPE CFolder::GetDetailsOf(VARIANT vItem, int iColumn, BSTR *pbs)
142 {
143 TRACE("(%p, %s, %i, %p)\n", this, wine_dbgstr_variant(&vItem), iColumn, pbs);
144 return E_NOTIMPL;
145 }
146
147
148 // *** Folder2 methods ***
149 HRESULT STDMETHODCALLTYPE CFolder::get_Self(FolderItem **ppfi)
150 {
151 TRACE("(%p, %p)\n", this, ppfi);
152 if (!ppfi)
153 return E_POINTER;
154 CFolderItem* item = new CComObject<CFolderItem>();
155 item->AddRef();
156 item->Init(ILClone(m_idlist));
157 *ppfi = item;
158 return S_OK;
159 }
160
161 HRESULT STDMETHODCALLTYPE CFolder::get_OfflineStatus(LONG *pul)
162 {
163 TRACE("(%p, %p)\n", this, pul);
164 return E_NOTIMPL;
165 }
166
167 HRESULT STDMETHODCALLTYPE CFolder::Synchronize()
168 {
169 TRACE("(%p)\n", this);
170 return E_NOTIMPL;
171 }
172
173 HRESULT STDMETHODCALLTYPE CFolder::get_HaveToShowWebViewBarricade(VARIANT_BOOL *pbHaveToShowWebViewBarricade)
174 {
175 TRACE("(%p, %p)\n", this, pbHaveToShowWebViewBarricade);
176 return E_NOTIMPL;
177 }
178
179 HRESULT STDMETHODCALLTYPE CFolder::DismissedWebViewBarricade()
180 {
181 TRACE("(%p)\n", this);
182 return E_NOTIMPL;
183 }
184
185