1
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
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] )
19
6
*/
20
7
21
8
#include " precomp.h"
@@ -31,9 +18,10 @@ CFolder::~CFolder()
31
18
{
32
19
}
33
20
34
- void CFolder::Init (LPITEMIDLIST idlist)
21
+ HRESULT CFolder::Initialize (LPITEMIDLIST idlist)
35
22
{
36
- m_idlist.Attach (idlist);
23
+ m_idlist.Attach (ILClone (idlist));
24
+ return CShellDispatch_Constructor (IID_PPV_ARG (IShellDispatch, &m_Application));
37
25
}
38
26
39
27
HRESULT CFolder::GetShellFolder (CComPtr<IShellFolder>& psfCurrent)
@@ -65,35 +53,39 @@ HRESULT STDMETHODCALLTYPE CFolder::get_Title(BSTR *pbs)
65
53
HRESULT STDMETHODCALLTYPE CFolder::get_Application (IDispatch **ppid)
66
54
{
67
55
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;
69
64
}
70
65
71
66
HRESULT STDMETHODCALLTYPE CFolder::get_Parent (IDispatch **ppid)
72
67
{
73
68
TRACE (" (%p %p)\n " , this , ppid);
69
+
70
+ if (ppid)
71
+ *ppid = NULL ;
72
+
74
73
return E_NOTIMPL;
75
74
}
76
75
77
76
HRESULT STDMETHODCALLTYPE CFolder::get_ParentFolder (Folder **ppsf)
78
77
{
79
78
TRACE (" (%p, %p)\n " , this );
79
+
80
+ *ppsf = NULL ;
81
+
80
82
return E_NOTIMPL;
81
83
}
82
84
83
85
HRESULT STDMETHODCALLTYPE CFolder::Items (FolderItems **ppid)
84
86
{
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));
97
89
}
98
90
99
91
HRESULT STDMETHODCALLTYPE CFolder::ParseName (BSTR bName, FolderItem **ppid)
@@ -113,11 +105,10 @@ HRESULT STDMETHODCALLTYPE CFolder::ParseName(BSTR bName, FolderItem **ppid)
113
105
if (!SUCCEEDED (hr))
114
106
return S_FALSE;
115
107
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));
121
112
}
122
113
123
114
HRESULT STDMETHODCALLTYPE CFolder::NewFolder (BSTR bName, VARIANT vOptions)
@@ -151,11 +142,8 @@ HRESULT STDMETHODCALLTYPE CFolder::get_Self(FolderItem **ppfi)
151
142
TRACE (" (%p, %p)\n " , this , ppfi);
152
143
if (!ppfi)
153
144
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));
159
147
}
160
148
161
149
HRESULT STDMETHODCALLTYPE CFolder::get_OfflineStatus (LONG *pul)
0 commit comments