c7e8c2ddb184ea1c71021617fe9c8e68e6527d1b
[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* item = new CComObject<CFolderItems>();
86 item->AddRef();
87 *ppid = item;
88 return S_OK;
89 }
90
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 CFolderItem* item = new CComObject<CFolderItem>();
109 item->AddRef();
110 item->Init(ILCombine(m_idlist, relativePidl));
111 *ppid = item;
112 return S_OK;
113 }
114
115 HRESULT STDMETHODCALLTYPE CFolder::NewFolder(BSTR bName, VARIANT vOptions)
116 {
117 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_w(bName), wine_dbgstr_variant(&vOptions));
118 return E_NOTIMPL;
119 }
120
121 HRESULT STDMETHODCALLTYPE CFolder::MoveHere(VARIANT vItem, VARIANT vOptions)
122 {
123 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_variant(&vItem), wine_dbgstr_variant(&vOptions));
124 return E_NOTIMPL;
125 }
126
127 HRESULT STDMETHODCALLTYPE CFolder::CopyHere(VARIANT vItem, VARIANT vOptions)
128 {
129 TRACE("(%p, %s, %s)\n", this, wine_dbgstr_variant(&vItem), wine_dbgstr_variant(&vOptions));
130 return E_NOTIMPL;
131 }
132
133 HRESULT STDMETHODCALLTYPE CFolder::GetDetailsOf(VARIANT vItem, int iColumn, BSTR *pbs)
134 {
135 TRACE("(%p, %s, %i, %p)\n", this, wine_dbgstr_variant(&vItem), iColumn, pbs);
136 return E_NOTIMPL;
137 }
138
139
140 // *** Folder2 methods ***
141 HRESULT STDMETHODCALLTYPE CFolder::get_Self(FolderItem **ppfi)
142 {
143 TRACE("(%p, %p)\n", this, ppfi);
144 if (!ppfi)
145 return E_POINTER;
146 CFolderItem* item = new CComObject<CFolderItem>();
147 item->AddRef();
148 item->Init(ILClone(m_idlist));
149 *ppfi = item;
150 return S_OK;
151 }
152
153 HRESULT STDMETHODCALLTYPE CFolder::get_OfflineStatus(LONG *pul)
154 {
155 TRACE("(%p, %p)\n", this, pul);
156 return E_NOTIMPL;
157 }
158
159 HRESULT STDMETHODCALLTYPE CFolder::Synchronize()
160 {
161 TRACE("(%p)\n", this);
162 return E_NOTIMPL;
163 }
164
165 HRESULT STDMETHODCALLTYPE CFolder::get_HaveToShowWebViewBarricade(VARIANT_BOOL *pbHaveToShowWebViewBarricade)
166 {
167 TRACE("(%p, %p)\n", this, pbHaveToShowWebViewBarricade);
168 return E_NOTIMPL;
169 }
170
171 HRESULT STDMETHODCALLTYPE CFolder::DismissedWebViewBarricade()
172 {
173 TRACE("(%p)\n", this);
174 return E_NOTIMPL;
175 }
176
177