source: trunk/src/shell32/folders.cpp@ 3831

Last change on this file since 3831 was 3271, checked in by cbratschi, 25 years ago

onopen fix, FindFirstFileMultiA, "shell.dll" icon fix, load exe icons

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