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

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

merged with Corel WINE 20000324

File size: 12.0 KB
Line 
1/* $Id: folders.cpp,v 1.2 2000-03-26 16:34:41 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 && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
221 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
222 {
223 if (!strcmp("%1",sTemp)) /* icon is in the file */
224 {
225 SHGetPathFromIDListA(This->pidl, sTemp);
226 dwNr = 0;
227 }
228 lstrcpynA(szIconFile, sTemp, cchMax);
229 *piIndex = dwNr;
230 }
231 else /* default icon */
232 {
233 lstrcpynA(szIconFile, "shell32.dll", cchMax);
234 *piIndex = 0;
235 }
236 }
237
238 dprintf(("SHELL32:folders IExtractIconA_fnGetIconLocation -- %s %x\n",
239 szIconFile,
240 *piIndex));
241 return NOERROR;
242}
243/**************************************************************************
244* IExtractIconA_Extract
245*/
246static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
247{
248 ICOM_THIS(IExtractIconAImpl,iface);
249
250 dprintf(("SHELL32:folders IExtractIconA_fnExtract (%p) (file=%p index=%u %p %p size=%u) semi-stub\n",
251 This,
252 pszFile,
253 nIconIndex,
254 phiconLarge,
255 phiconSmall,
256 nIconSize));
257
258 if (phiconLarge)
259 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
260
261 if (phiconSmall)
262 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
263
264 return S_OK;
265}
266
267static struct ICOM_VTABLE(IExtractIconA) eivt =
268{
269 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
270 IExtractIconA_fnQueryInterface,
271 IExtractIconA_fnAddRef,
272 IExtractIconA_fnRelease,
273 IExtractIconA_fnGetIconLocation,
274 IExtractIconA_fnExtract
275};
276
277
278/************************************************************************
279 * IEIPersistFile_QueryInterface (IUnknown)
280 */
281static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
282 IPersistFile *iface,
283 REFIID iid,
284 LPVOID *ppvObj)
285{
286 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
287
288 return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
289}
290
291/************************************************************************
292 * IEIPersistFile_AddRef (IUnknown)
293 */
294static ULONG WINAPI IEIPersistFile_fnAddRef(
295 IPersistFile *iface)
296{
297 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
298
299 return IExtractIconA_AddRef((IExtractIconA*)This);
300}
301
302/************************************************************************
303 * IEIPersistFile_Release (IUnknown)
304 */
305static ULONG WINAPI IEIPersistFile_fnRelease(
306 IPersistFile *iface)
307{
308 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
309
310 return IExtractIconA_Release((IExtractIconA*)This);
311}
312
313/************************************************************************
314 * IEIPersistFile_GetClassID (IPersist)
315 */
316static HRESULT WINAPI IEIPersistFile_fnGetClassID(
317 IPersistFile *iface,
318 LPCLSID lpClassId)
319{
320 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
321
322 if (lpClassId==NULL)
323 return E_POINTER;
324
325 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
326
327 return S_OK;
328}
329
330/************************************************************************
331 * IEIPersistFile_IsDirty (IPersistFile)
332 */
333static HRESULT WINAPI IEIPersistFile_fnIsDirty(IPersistFile* iface)
334{
335 dprintf(("SHELL32: Folders: IEIPersistFile_fnIsDirty not implemented.\n"));
336 return E_NOTIMPL;
337}
338
339
340/************************************************************************
341 * IEIPersistFile_Load (IPersistFile)
342 */
343static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
344{
345 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
346 FIXME("%p\n", This);
347 return E_NOTIMPL;
348
349}
350
351
352/************************************************************************
353 * IEIPersistFile_Save (IPersistFile)
354 */
355static HRESULT WINAPI IEIPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
356{
357 dprintf(("SHELL32: Folders: IEIPersistFile_fnSave not implemented.\n"));
358 return E_NOTIMPL;
359}
360
361
362/************************************************************************
363 * IEIPersistFile_SaveCompleted (IPersistFile)
364 */
365static HRESULT WINAPI IEIPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
366{
367 dprintf(("SHELL32: Folders: IEIPersistFile_fnSaveCompleted not implemented.\n"));
368 return E_NOTIMPL;
369}
370
371
372/************************************************************************
373 * IEIPersistFile_GetCurFile (IPersistFile)
374 */
375static HRESULT WINAPI IEIPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR* pszFileName)
376{
377 dprintf(("SHELL32: Folders: IEIPersistFile_fnGetCurFile not implemented.\n"));
378 return E_NOTIMPL;
379}
380
381static struct ICOM_VTABLE(IPersistFile) pfvt =
382{
383 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
384 IEIPersistFile_fnQueryInterface,
385 IEIPersistFile_fnAddRef,
386 IEIPersistFile_fnRelease,
387 IEIPersistFile_fnGetClassID,
388 IEIPersistFile_fnIsDirty, /* IEIPersistFile_fnIsDirty */
389 IEIPersistFile_fnLoad,
390 IEIPersistFile_fnSave, /* IEIPersistFile_fnSave */
391 IEIPersistFile_fnSaveCompleted, /* IEIPersistFile_fnSaveCompleted */
392 IEIPersistFile_fnGetCurFile /* IEIPersistFile_fnGetCurFile */
393};
394
395/**************************************************************************
396* IExtractIconA_Constructor
397*/
398IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
399{
400 IExtractIconAImpl* ei;
401
402 ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
403 ei->ref=1;
404 ei->lpvtbl = &eivt;
405 ei->lpvtblPersistFile = &pfvt;
406 ei->pidl=ILClone(pidl);
407
408 pdump(pidl);
409
410 dprintf(("SHELL32:folders IExtractIconA_Constructor(%p)\n",
411 ei));
412 shell32_ObjCount++;
413 return (IExtractIconA *)ei;
414}
415
416
Note: See TracBrowser for help on using the repository browser.