Skip to content

Commit e8dcbcc

Browse files
committed
[SHELL32] Sync CShellDispatch and family with wine.
Incorporates work from Ivan Rodionov. CORE-12955
1 parent fd87f0a commit e8dcbcc

File tree

7 files changed

+257
-182
lines changed

7 files changed

+257
-182
lines changed

dll/win32/shell32/CFolder.cpp

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
/*
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
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 ([email protected])
196
*/
207

218
#include "precomp.h"
@@ -31,9 +18,10 @@ CFolder::~CFolder()
3118
{
3219
}
3320

34-
void CFolder::Init(LPITEMIDLIST idlist)
21+
HRESULT CFolder::Initialize(LPITEMIDLIST idlist)
3522
{
36-
m_idlist.Attach(idlist);
23+
m_idlist.Attach(ILClone(idlist));
24+
return CShellDispatch_Constructor(IID_PPV_ARG(IShellDispatch, &m_Application));
3725
}
3826

3927
HRESULT CFolder::GetShellFolder(CComPtr<IShellFolder>& psfCurrent)
@@ -65,35 +53,39 @@ HRESULT STDMETHODCALLTYPE CFolder::get_Title(BSTR *pbs)
6553
HRESULT STDMETHODCALLTYPE CFolder::get_Application(IDispatch **ppid)
6654
{
6755
TRACE("(%p, %p)\n", this, ppid);
68-
return E_NOTIMPL;
56+
57+
if (!ppid)
58+
return E_INVALIDARG;
59+
60+
*ppid = m_Application;
61+
(*ppid)->AddRef();
62+
63+
return S_OK;
6964
}
7065

7166
HRESULT STDMETHODCALLTYPE CFolder::get_Parent(IDispatch **ppid)
7267
{
7368
TRACE("(%p %p)\n", this, ppid);
69+
70+
if (ppid)
71+
*ppid = NULL;
72+
7473
return E_NOTIMPL;
7574
}
7675

7776
HRESULT STDMETHODCALLTYPE CFolder::get_ParentFolder(Folder **ppsf)
7877
{
7978
TRACE("(%p, %p)\n", this);
79+
80+
*ppsf = NULL;
81+
8082
return E_NOTIMPL;
8183
}
8284

8385
HRESULT STDMETHODCALLTYPE CFolder::Items(FolderItems **ppid)
8486
{
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;
87+
/* FolderItems_Constructor */
88+
return ShellObjectCreatorInit<CFolderItems>(static_cast<LPITEMIDLIST>(m_idlist), this, IID_PPV_ARG(FolderItems, ppid));
9789
}
9890

9991
HRESULT STDMETHODCALLTYPE CFolder::ParseName(BSTR bName, FolderItem **ppid)
@@ -113,11 +105,10 @@ HRESULT STDMETHODCALLTYPE CFolder::ParseName(BSTR bName, FolderItem **ppid)
113105
if (!SUCCEEDED(hr))
114106
return S_FALSE;
115107

116-
CFolderItem* item = new CComObject<CFolderItem>();
117-
item->AddRef();
118-
item->Init(ILCombine(m_idlist, relativePidl));
119-
*ppid = item;
120-
return S_OK;
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));
121112
}
122113

123114
HRESULT STDMETHODCALLTYPE CFolder::NewFolder(BSTR bName, VARIANT vOptions)
@@ -151,11 +142,8 @@ HRESULT STDMETHODCALLTYPE CFolder::get_Self(FolderItem **ppfi)
151142
TRACE("(%p, %p)\n", this, ppfi);
152143
if (!ppfi)
153144
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;
145+
146+
return ShellObjectCreatorInit<CFolderItem>(this, static_cast<LPITEMIDLIST>(m_idlist), IID_PPV_ARG(FolderItem, ppfi));
159147
}
160148

161149
HRESULT STDMETHODCALLTYPE CFolder::get_OfflineStatus(LONG *pul)

dll/win32/shell32/CFolder.h

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
/*
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
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 ([email protected])
196
*/
207

218
#ifndef _FOLDER_H_
@@ -31,12 +18,13 @@ class CFolder:
3118
HRESULT GetShellFolder(CComPtr<IShellFolder>& psfCurrent);
3219

3320
CComHeapPtr<ITEMIDLIST> m_idlist;
21+
CComPtr<IShellDispatch> m_Application;
3422

3523
public:
3624
CFolder();
3725
~CFolder();
3826

39-
void Init(LPITEMIDLIST idlist);
27+
HRESULT Initialize(LPITEMIDLIST idlist);
4028

4129
// *** Folder methods ***
4230
virtual HRESULT STDMETHODCALLTYPE get_Title(BSTR *pbs);

dll/win32/shell32/CFolderItemVerbs.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,28 @@ HRESULT CFolderItemVerbs::Init(LPITEMIDLIST idlist)
107107
HRESULT STDMETHODCALLTYPE CFolderItemVerbs::get_Count(LONG *plCount)
108108
{
109109
if (!plCount)
110-
return E_POINTER;
110+
return E_INVALIDARG;
111111
*plCount = m_count;
112112
return S_OK;
113113
}
114114

115115
HRESULT STDMETHODCALLTYPE CFolderItemVerbs::get_Application(IDispatch **ppid)
116116
{
117117
TRACE("(%p, %p)\n", this, ppid);
118+
119+
if (ppid)
120+
*ppid = NULL;
121+
118122
return E_NOTIMPL;
119123
}
120124

121125
HRESULT STDMETHODCALLTYPE CFolderItemVerbs::get_Parent(IDispatch **ppid)
122126
{
123127
TRACE("(%p, %p)\n", this, ppid);
128+
129+
if (ppid)
130+
*ppid = NULL;
131+
124132
return E_NOTIMPL;
125133
}
126134

@@ -130,9 +138,8 @@ HRESULT STDMETHODCALLTYPE CFolderItemVerbs::Item(VARIANT indexVar, FolderItemVer
130138
return E_POINTER;
131139

132140
CComVariant var;
133-
VariantCopyInd(&var, &indexVar);
134141

135-
HRESULT hr = VariantChangeType(&var, &var, 0, VT_I4);
142+
HRESULT hr = VariantChangeType(&var, &indexVar, 0, VT_I4);
136143
if (FAILED_UNEXPECTEDLY(hr))
137144
return E_INVALIDARG;
138145

@@ -144,7 +151,9 @@ HRESULT STDMETHODCALLTYPE CFolderItemVerbs::Item(VARIANT indexVar, FolderItemVer
144151
BSTR name = NULL;
145152

146153
if(index == m_count)
154+
{
147155
name = SysAllocStringLen(NULL, 0);
156+
}
148157
else
149158
{
150159
MENUITEMINFOW info = { sizeof(info), 0 };

0 commit comments

Comments
 (0)