1 | /* $Id: folders.c,v 1.2 2000-09-07 18:13:50 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Copyright 1997 Marcus Meissner
|
---|
4 | * Copyright 1998 Juergen Schmied
|
---|
5 | *
|
---|
6 | */
|
---|
7 | #ifdef __WIN32OS2__
|
---|
8 | #define ICOM_CINTERFACE 1
|
---|
9 | #include <odin.h>
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | #include <stdlib.h>
|
---|
13 | #include <stdio.h>
|
---|
14 | #include <string.h>
|
---|
15 |
|
---|
16 | #include "wine/obj_base.h"
|
---|
17 | #include "wine/obj_extracticon.h"
|
---|
18 | #include "wine/undocshell.h"
|
---|
19 | #include "shlguid.h"
|
---|
20 |
|
---|
21 | #include "debugtools.h"
|
---|
22 | #include "winerror.h"
|
---|
23 |
|
---|
24 | #include "pidl.h"
|
---|
25 | #include "shell32_main.h"
|
---|
26 |
|
---|
27 | DEFAULT_DEBUG_CHANNEL(shell)
|
---|
28 |
|
---|
29 |
|
---|
30 | /***********************************************************************
|
---|
31 | * IExtractIconA implementation
|
---|
32 | */
|
---|
33 |
|
---|
34 | typedef struct
|
---|
35 | { ICOM_VFIELD(IExtractIconA);
|
---|
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_Constructor
|
---|
49 | */
|
---|
50 | IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
|
---|
51 | {
|
---|
52 | IExtractIconAImpl* ei;
|
---|
53 |
|
---|
54 | ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
|
---|
55 | ei->ref=1;
|
---|
56 | ICOM_VTBL(ei) = &eivt;
|
---|
57 | ei->lpvtblPersistFile = &pfvt;
|
---|
58 | ei->pidl=ILClone(pidl);
|
---|
59 |
|
---|
60 | pdump(pidl);
|
---|
61 |
|
---|
62 | TRACE("(%p)\n",ei);
|
---|
63 | shell32_ObjCount++;
|
---|
64 | return (IExtractIconA *)ei;
|
---|
65 | }
|
---|
66 | /**************************************************************************
|
---|
67 | * IExtractIconA_QueryInterface
|
---|
68 | */
|
---|
69 | static HRESULT WINAPI IExtractIconA_fnQueryInterface( IExtractIconA * iface, REFIID riid, LPVOID *ppvObj)
|
---|
70 | {
|
---|
71 | ICOM_THIS(IExtractIconAImpl,iface);
|
---|
72 |
|
---|
73 | TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
|
---|
74 |
|
---|
75 | *ppvObj = NULL;
|
---|
76 |
|
---|
77 | if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
|
---|
78 | { *ppvObj = This;
|
---|
79 | }
|
---|
80 | else if(IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/
|
---|
81 | { *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile);
|
---|
82 | }
|
---|
83 | else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
|
---|
84 | { *ppvObj = (IExtractIconA*)This;
|
---|
85 | }
|
---|
86 |
|
---|
87 | if(*ppvObj)
|
---|
88 | { IExtractIconA_AddRef((IExtractIconA*) *ppvObj);
|
---|
89 | TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
---|
90 | return S_OK;
|
---|
91 | }
|
---|
92 | TRACE("-- Interface: E_NOINTERFACE\n");
|
---|
93 | return E_NOINTERFACE;
|
---|
94 | }
|
---|
95 |
|
---|
96 | /**************************************************************************
|
---|
97 | * IExtractIconA_AddRef
|
---|
98 | */
|
---|
99 | static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
|
---|
100 | {
|
---|
101 | ICOM_THIS(IExtractIconAImpl,iface);
|
---|
102 |
|
---|
103 | TRACE("(%p)->(count=%lu)\n",This, This->ref );
|
---|
104 |
|
---|
105 | shell32_ObjCount++;
|
---|
106 |
|
---|
107 | return ++(This->ref);
|
---|
108 | }
|
---|
109 | /**************************************************************************
|
---|
110 | * IExtractIconA_Release
|
---|
111 | */
|
---|
112 | static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
|
---|
113 | {
|
---|
114 | ICOM_THIS(IExtractIconAImpl,iface);
|
---|
115 |
|
---|
116 | TRACE("(%p)->()\n",This);
|
---|
117 |
|
---|
118 | shell32_ObjCount--;
|
---|
119 |
|
---|
120 | if (!--(This->ref))
|
---|
121 | { TRACE(" destroying IExtractIcon(%p)\n",This);
|
---|
122 | SHFree(This->pidl);
|
---|
123 | HeapFree(GetProcessHeap(),0,This);
|
---|
124 | return 0;
|
---|
125 | }
|
---|
126 | return This->ref;
|
---|
127 | }
|
---|
128 | /**************************************************************************
|
---|
129 | * IExtractIconA_GetIconLocation
|
---|
130 | *
|
---|
131 | * mapping filetype to icon
|
---|
132 | */
|
---|
133 | static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
|
---|
134 | IExtractIconA * iface,
|
---|
135 | UINT uFlags,
|
---|
136 | LPSTR szIconFile,
|
---|
137 | UINT cchMax,
|
---|
138 | int * piIndex,
|
---|
139 | UINT * pwFlags)
|
---|
140 | {
|
---|
141 | ICOM_THIS(IExtractIconAImpl,iface);
|
---|
142 |
|
---|
143 | char sTemp[MAX_PATH];
|
---|
144 | DWORD dwNr;
|
---|
145 | GUID const * riid;
|
---|
146 | LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
|
---|
147 |
|
---|
148 | TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
|
---|
149 |
|
---|
150 | if (pwFlags)
|
---|
151 | *pwFlags = 0;
|
---|
152 |
|
---|
153 | if (_ILIsDesktop(pSimplePidl))
|
---|
154 | {
|
---|
155 | lstrcpynA(szIconFile, "shell32.dll", cchMax);
|
---|
156 | *piIndex = 34;
|
---|
157 | }
|
---|
158 |
|
---|
159 | /* my computer and other shell extensions */
|
---|
160 | else if ( (riid = _ILGetGUIDPointer(pSimplePidl)) )
|
---|
161 | {
|
---|
162 | char xriid[50];
|
---|
163 | sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
---|
164 | riid->Data1, riid->Data2, riid->Data3,
|
---|
165 | riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
|
---|
166 | riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
|
---|
167 |
|
---|
168 | if (HCR_GetDefaultIcon(xriid, sTemp, MAX_PATH, &dwNr))
|
---|
169 | {
|
---|
170 | lstrcpynA(szIconFile, sTemp, cchMax);
|
---|
171 | *piIndex = dwNr;
|
---|
172 | }
|
---|
173 | else
|
---|
174 | {
|
---|
175 | lstrcpynA(szIconFile, "shell32.dll", cchMax);
|
---|
176 | *piIndex = 15;
|
---|
177 | }
|
---|
178 | }
|
---|
179 |
|
---|
180 | else if (_ILIsDrive (pSimplePidl))
|
---|
181 | {
|
---|
182 | if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
|
---|
183 | {
|
---|
184 | lstrcpynA(szIconFile, sTemp, cchMax);
|
---|
185 | *piIndex = dwNr;
|
---|
186 | }
|
---|
187 | else
|
---|
188 | {
|
---|
189 | lstrcpynA(szIconFile, "shell32.dll", cchMax);
|
---|
190 | *piIndex = 8;
|
---|
191 | }
|
---|
192 | }
|
---|
193 | else if (_ILIsFolder (pSimplePidl))
|
---|
194 | {
|
---|
195 | if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
|
---|
196 | {
|
---|
197 | lstrcpynA(szIconFile, sTemp, cchMax);
|
---|
198 | *piIndex = dwNr;
|
---|
199 | }
|
---|
200 | else
|
---|
201 | {
|
---|
202 | lstrcpynA(szIconFile, "shell32.dll", cchMax);
|
---|
203 | *piIndex = (uFlags & GIL_OPENICON)? 4 : 3;
|
---|
204 | }
|
---|
205 | }
|
---|
206 | else /* object is file */
|
---|
207 | {
|
---|
208 | #ifdef __WIN32OS2__
|
---|
209 | if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH))
|
---|
210 | {
|
---|
211 | if (HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
|
---|
212 | && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
|
---|
213 | {
|
---|
214 | if (!strcmp("%1",sTemp)) /* icon is in the file */
|
---|
215 | {
|
---|
216 | SHGetPathFromIDListA(This->pidl, sTemp);
|
---|
217 | dwNr = 0;
|
---|
218 | }
|
---|
219 | lstrcpynA(szIconFile, sTemp, cchMax);
|
---|
220 | *piIndex = dwNr;
|
---|
221 | } else
|
---|
222 | {
|
---|
223 | //icon is in the file/file is icon
|
---|
224 | if (stricmp(sTemp,"EXE") == 0) //CB: add more
|
---|
225 | {
|
---|
226 | SHGetPathFromIDListA(This->pidl, sTemp);
|
---|
227 | dwNr = 0;
|
---|
228 | lstrcpynA(szIconFile, sTemp, cchMax);
|
---|
229 | *piIndex = dwNr;
|
---|
230 | } else //default icon
|
---|
231 | {
|
---|
232 | lstrcpynA(szIconFile, "shell32.dll", cchMax);
|
---|
233 | *piIndex = 0;
|
---|
234 | }
|
---|
235 | }
|
---|
236 | } else /* default icon */
|
---|
237 | {
|
---|
238 | lstrcpynA(szIconFile, "shell32.dll", cchMax);
|
---|
239 | *piIndex = 0;
|
---|
240 | }
|
---|
241 | }
|
---|
242 | #else
|
---|
243 | if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)
|
---|
244 | && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
|
---|
245 | && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
|
---|
246 | {
|
---|
247 | if (!strcmp("%1",sTemp)) /* icon is in the file */
|
---|
248 | {
|
---|
249 | SHGetPathFromIDListA(This->pidl, sTemp);
|
---|
250 | dwNr = 0;
|
---|
251 | }
|
---|
252 | lstrcpynA(szIconFile, sTemp, cchMax);
|
---|
253 | *piIndex = dwNr;
|
---|
254 | }
|
---|
255 | else /* default icon */
|
---|
256 | {
|
---|
257 | lstrcpynA(szIconFile, "shell32.dll", cchMax);
|
---|
258 | *piIndex = 0;
|
---|
259 | }
|
---|
260 | }
|
---|
261 | #endif
|
---|
262 | TRACE("-- %s %x\n", szIconFile, *piIndex);
|
---|
263 | return NOERROR;
|
---|
264 | }
|
---|
265 | /**************************************************************************
|
---|
266 | * IExtractIconA_Extract
|
---|
267 | */
|
---|
268 | static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
|
---|
269 | {
|
---|
270 | ICOM_THIS(IExtractIconAImpl,iface);
|
---|
271 |
|
---|
272 | FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
|
---|
273 |
|
---|
274 | if (phiconLarge)
|
---|
275 | *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
|
---|
276 |
|
---|
277 | if (phiconSmall)
|
---|
278 | *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
|
---|
279 |
|
---|
280 | return S_OK;
|
---|
281 | }
|
---|
282 |
|
---|
283 | static struct ICOM_VTABLE(IExtractIconA) eivt =
|
---|
284 | {
|
---|
285 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
286 | IExtractIconA_fnQueryInterface,
|
---|
287 | IExtractIconA_fnAddRef,
|
---|
288 | IExtractIconA_fnRelease,
|
---|
289 | IExtractIconA_fnGetIconLocation,
|
---|
290 | IExtractIconA_fnExtract
|
---|
291 | };
|
---|
292 |
|
---|
293 | /************************************************************************
|
---|
294 | * IEIPersistFile_QueryInterface (IUnknown)
|
---|
295 | */
|
---|
296 | static 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 | */
|
---|
309 | static 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 | */
|
---|
320 | static 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 | */
|
---|
331 | static 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_Load (IPersistFile)
|
---|
347 | */
|
---|
348 | static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
|
---|
349 | {
|
---|
350 | _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
|
---|
351 | FIXME("%p\n", This);
|
---|
352 | return E_NOTIMPL;
|
---|
353 |
|
---|
354 | }
|
---|
355 |
|
---|
356 | #ifdef __WIN32OS2__
|
---|
357 | /************************************************************************
|
---|
358 | * IEIPersistFile_IsDirty (IPersistFile)
|
---|
359 | */
|
---|
360 | static HRESULT WINAPI IEIPersistFile_fnIsDirty(IPersistFile* iface)
|
---|
361 | {
|
---|
362 | dprintf(("SHELL32: Folders: IEIPersistFile_fnIsDirty not implemented.\n"));
|
---|
363 | return E_NOTIMPL;
|
---|
364 | }
|
---|
365 |
|
---|
366 | /************************************************************************
|
---|
367 | * IEIPersistFile_Save (IPersistFile)
|
---|
368 | */
|
---|
369 | static HRESULT WINAPI IEIPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
|
---|
370 | {
|
---|
371 | dprintf(("SHELL32: Folders: IEIPersistFile_fnSave not implemented.\n"));
|
---|
372 | return E_NOTIMPL;
|
---|
373 | }
|
---|
374 |
|
---|
375 |
|
---|
376 | /************************************************************************
|
---|
377 | * IEIPersistFile_SaveCompleted (IPersistFile)
|
---|
378 | */
|
---|
379 | static HRESULT WINAPI IEIPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
|
---|
380 | {
|
---|
381 | dprintf(("SHELL32: Folders: IEIPersistFile_fnSaveCompleted not implemented.\n"));
|
---|
382 | return E_NOTIMPL;
|
---|
383 | }
|
---|
384 |
|
---|
385 |
|
---|
386 | /************************************************************************
|
---|
387 | * IEIPersistFile_GetCurFile (IPersistFile)
|
---|
388 | */
|
---|
389 | static HRESULT WINAPI IEIPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR* pszFileName)
|
---|
390 | {
|
---|
391 | dprintf(("SHELL32: Folders: IEIPersistFile_fnGetCurFile not implemented.\n"));
|
---|
392 | return E_NOTIMPL;
|
---|
393 | }
|
---|
394 | #endif
|
---|
395 |
|
---|
396 | static struct ICOM_VTABLE(IPersistFile) pfvt =
|
---|
397 | {
|
---|
398 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
399 | IEIPersistFile_fnQueryInterface,
|
---|
400 | IEIPersistFile_fnAddRef,
|
---|
401 | IEIPersistFile_fnRelease,
|
---|
402 | IEIPersistFile_fnGetClassID,
|
---|
403 | #ifdef __WIN32OS2__
|
---|
404 | IEIPersistFile_fnIsDirty, /* IEIPersistFile_fnIsDirty */
|
---|
405 | #else
|
---|
406 | (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
|
---|
407 | #endif
|
---|
408 | IEIPersistFile_fnLoad,
|
---|
409 | #ifdef __WIN32OS2__
|
---|
410 | IEIPersistFile_fnSave, /* IEIPersistFile_fnSave */
|
---|
411 | IEIPersistFile_fnSaveCompleted, /* IEIPersistFile_fnSaveCompleted */
|
---|
412 | IEIPersistFile_fnGetCurFile /* IEIPersistFile_fnGetCurFile */
|
---|
413 | #else
|
---|
414 | (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
|
---|
415 | (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
|
---|
416 | (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */
|
---|
417 | #endif
|
---|
418 | };
|
---|
419 |
|
---|