source: trunk/src/shell32/new/folders.cpp@ 1036

Last change on this file since 1036 was 791, checked in by phaller, 26 years ago

Add: shell32/new - a direct port of WINE's Shell32 implmentation

File size: 9.5 KB
Line 
1/*
2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
4 *
5 */
6
7#include <stdlib.h>
8#include <string.h>
9
10#include <odin.h>
11
12#define ICOM_CINTERFACE 1
13#define CINTERFACE 1
14
15#include "wine/obj_base.h"
16#include "wine/obj_extracticon.h"
17#include "wine/undocshell.h"
18
19#include "debugtools.h"
20#include "winerror.h"
21
22#include "pidl.h"
23#include "shell32_main.h"
24
25#include <misc.h>
26
27DEFAULT_DEBUG_CHANNEL(shell)
28
29
30/***********************************************************************
31* IExtractIconA implementation
32*/
33
34typedef struct
35{ ICOM_VTABLE(IExtractIconA)* lpvtbl;
36 DWORD ref;
37 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
38 LPITEMIDLIST pidl;
39} IExtractIconAImpl;
40
41//static struct ICOM_VTABLE(IExtractIconA) eivt;
42//static struct ICOM_VTABLE(IPersistFile) pfvt;
43
44#define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
45#define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
46
47/**************************************************************************
48 * IExtractIconA_QueryInterface
49 */
50static HRESULT WINAPI IExtractIconA_fnQueryInterface( IExtractIconA * iface, REFIID riid, LPVOID *ppvObj)
51{
52 ICOM_THIS(IExtractIconAImpl,iface);
53
54 char xriid[50];
55 WINE_StringFromCLSID((LPCLSID)riid,xriid);
56 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
57
58 *ppvObj = NULL;
59
60 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
61 { *ppvObj = This;
62 }
63 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/
64 { *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile);
65 }
66 else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
67 { *ppvObj = (IExtractIconA*)This;
68 }
69
70 if(*ppvObj)
71 { IExtractIconA_AddRef((IExtractIconA*) *ppvObj);
72 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
73 return S_OK;
74 }
75 TRACE("-- Interface: E_NOINTERFACE\n");
76 return E_NOINTERFACE;
77}
78
79/**************************************************************************
80* IExtractIconA_AddRef
81*/
82static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
83{
84 ICOM_THIS(IExtractIconAImpl,iface);
85
86 TRACE("(%p)->(count=%lu)\n",This, This->ref );
87
88 shell32_ObjCount++;
89
90 return ++(This->ref);
91}
92/**************************************************************************
93* IExtractIconA_Release
94*/
95static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
96{
97 ICOM_THIS(IExtractIconAImpl,iface);
98
99 TRACE("(%p)->()\n",This);
100
101 shell32_ObjCount--;
102
103 if (!--(This->ref))
104 { TRACE(" destroying IExtractIcon(%p)\n",This);
105 SHFree(This->pidl);
106 HeapFree(GetProcessHeap(),0,This);
107 return 0;
108 }
109 return This->ref;
110}
111/**************************************************************************
112* IExtractIconA_GetIconLocation
113*
114* mapping filetype to icon
115*/
116static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
117 IExtractIconA * iface,
118 UINT uFlags,
119 LPSTR szIconFile,
120 UINT cchMax,
121 int * piIndex,
122 UINT * pwFlags)
123{
124 ICOM_THIS(IExtractIconAImpl,iface);
125
126 char sTemp[MAX_PATH];
127 DWORD dwNr;
128 GUID const * riid;
129 LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
130
131 TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
132
133 if (pwFlags)
134 *pwFlags = 0;
135
136 if (_ILIsDesktop(pSimplePidl))
137 {
138 lstrcpynA(szIconFile, "shell32.dll", cchMax);
139 *piIndex = 34;
140 }
141
142 /* my computer and other shell extensions */
143 else if ( (riid = _ILGetGUIDPointer(pSimplePidl)) )
144 {
145 char xriid[50];
146 strcpy(xriid,"CLSID\\");
147 WINE_StringFromCLSID((LPCLSID)riid,&xriid[strlen(xriid)]);
148
149 if (HCR_GetDefaultIcon(xriid, sTemp, MAX_PATH, &dwNr))
150 {
151 lstrcpynA(szIconFile, sTemp, cchMax);
152 *piIndex = dwNr;
153 }
154 else
155 {
156 lstrcpynA(szIconFile, "shell32.dll", cchMax);
157 *piIndex = 15;
158 }
159 }
160
161 else if (_ILIsDrive (pSimplePidl))
162 {
163 if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
164 {
165 lstrcpynA(szIconFile, sTemp, cchMax);
166 *piIndex = dwNr;
167 }
168 else
169 {
170 lstrcpynA(szIconFile, "shell32.dll", cchMax);
171 *piIndex = 8;
172 }
173 }
174 else if (_ILIsFolder (pSimplePidl))
175 {
176 if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
177 {
178 lstrcpynA(szIconFile, sTemp, cchMax);
179 *piIndex = dwNr;
180 }
181 else
182 {
183 lstrcpynA(szIconFile, "shell32.dll", cchMax);
184 *piIndex = 3;
185 }
186 }
187 else /* object is file */
188 {
189 if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)
190 && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
191 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
192 {
193 if (!strcmp("%1",sTemp)) /* icon is in the file */
194 {
195 SHGetPathFromIDListA(This->pidl, sTemp);
196 dwNr = 0;
197 }
198 lstrcpynA(szIconFile, sTemp, cchMax);
199 *piIndex = dwNr;
200 }
201 else /* default icon */
202 {
203 lstrcpynA(szIconFile, "shell32.dll", cchMax);
204 *piIndex = 0;
205 }
206 }
207
208 TRACE("-- %s %x\n", szIconFile, *piIndex);
209 return NOERROR;
210}
211/**************************************************************************
212* IExtractIconA_Extract
213*/
214static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
215{
216 ICOM_THIS(IExtractIconAImpl,iface);
217
218 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
219
220 if (phiconLarge)
221 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
222
223 if (phiconSmall)
224 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
225
226 return S_OK;
227}
228
229static struct ICOM_VTABLE(IExtractIconA) eivt =
230{
231 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
232 IExtractIconA_fnQueryInterface,
233 IExtractIconA_fnAddRef,
234 IExtractIconA_fnRelease,
235 IExtractIconA_fnGetIconLocation,
236 IExtractIconA_fnExtract
237};
238
239
240/************************************************************************
241 * IEIPersistFile_QueryInterface (IUnknown)
242 */
243static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
244 IPersistFile *iface,
245 REFIID iid,
246 LPVOID *ppvObj)
247{
248 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
249
250 return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
251}
252
253/************************************************************************
254 * IEIPersistFile_AddRef (IUnknown)
255 */
256static ULONG WINAPI IEIPersistFile_fnAddRef(
257 IPersistFile *iface)
258{
259 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
260
261 return IExtractIconA_AddRef((IExtractIconA*)This);
262}
263
264/************************************************************************
265 * IEIPersistFile_Release (IUnknown)
266 */
267static ULONG WINAPI IEIPersistFile_fnRelease(
268 IPersistFile *iface)
269{
270 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
271
272 return IExtractIconA_Release((IExtractIconA*)This);
273}
274
275/************************************************************************
276 * IEIPersistFile_GetClassID (IPersist)
277 */
278static HRESULT WINAPI IEIPersistFile_fnGetClassID(
279 IPersistFile *iface,
280 LPCLSID lpClassId)
281{
282 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
283
284 if (lpClassId==NULL)
285 return E_POINTER;
286
287 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
288
289 return S_OK;
290}
291
292/************************************************************************
293 * IEIPersistFile_IsDirty (IPersistFile)
294 */
295static HRESULT WINAPI IEIPersistFile_fnIsDirty(IPersistFile* iface)
296{
297 dprintf(("SHELL32: Folders: IEIPersistFile_fnIsDirty not implemented.\n"));
298 return E_NOTIMPL;
299}
300
301
302/************************************************************************
303 * IEIPersistFile_Load (IPersistFile)
304 */
305static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
306{
307 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
308 FIXME("%p\n", This);
309 return E_NOTIMPL;
310
311}
312
313
314/************************************************************************
315 * IEIPersistFile_Save (IPersistFile)
316 */
317static HRESULT WINAPI IEIPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
318{
319 dprintf(("SHELL32: Folders: IEIPersistFile_fnSave not implemented.\n"));
320 return E_NOTIMPL;
321}
322
323
324/************************************************************************
325 * IEIPersistFile_SaveCompleted (IPersistFile)
326 */
327static HRESULT WINAPI IEIPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
328{
329 dprintf(("SHELL32: Folders: IEIPersistFile_fnSaveCompleted not implemented.\n"));
330 return E_NOTIMPL;
331}
332
333
334/************************************************************************
335 * IEIPersistFile_GetCurFile (IPersistFile)
336 */
337static HRESULT WINAPI IEIPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR* pszFileName)
338{
339 dprintf(("SHELL32: Folders: IEIPersistFile_fnGetCurFile not implemented.\n"));
340 return E_NOTIMPL;
341}
342
343static struct ICOM_VTABLE(IPersistFile) pfvt =
344{
345 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
346 IEIPersistFile_fnQueryInterface,
347 IEIPersistFile_fnAddRef,
348 IEIPersistFile_fnRelease,
349 IEIPersistFile_fnGetClassID,
350 IEIPersistFile_fnIsDirty, /* IEIPersistFile_fnIsDirty */
351 IEIPersistFile_fnLoad,
352 IEIPersistFile_fnSave, /* IEIPersistFile_fnSave */
353 IEIPersistFile_fnSaveCompleted, /* IEIPersistFile_fnSaveCompleted */
354 IEIPersistFile_fnGetCurFile /* IEIPersistFile_fnGetCurFile */
355};
356
357/**************************************************************************
358* IExtractIconA_Constructor
359*/
360IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
361{
362 IExtractIconAImpl* ei;
363
364 ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
365 ei->ref=1;
366 ei->lpvtbl = &eivt;
367 ei->lpvtblPersistFile = &pfvt;
368 ei->pidl=ILClone(pidl);
369
370 pdump(pidl);
371
372 TRACE("(%p)\n",ei);
373 shell32_ObjCount++;
374 return (IExtractIconA *)ei;
375}
376
377
Note: See TracBrowser for help on using the repository browser.