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