source: trunk/src/shell32/folders.c@ 4121

Last change on this file since 4121 was 4121, checked in by sandervl, 25 years ago

complete merge with shell32 from wine 20000801

File size: 8.4 KB
Line 
1/* $Id: folders.c,v 1.1 2000-08-30 13:52:51 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
27DEFAULT_DEBUG_CHANNEL(shell)
28
29
30/***********************************************************************
31* IExtractIconA implementation
32*/
33
34typedef struct
35{ ICOM_VFIELD(IExtractIconA);
36 DWORD ref;
37 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
38 LPITEMIDLIST pidl;
39} IExtractIconAImpl;
40
41static struct ICOM_VTABLE(IExtractIconA) eivt;
42static 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*/
50IExtractIconA* 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 */
69static 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*/
99static 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*/
112static 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*/
133static 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 if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)
209 && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
210 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
211 {
212 if (!strcmp("%1",sTemp)) /* icon is in the file */
213 {
214 SHGetPathFromIDListA(This->pidl, sTemp);
215 dwNr = 0;
216 }
217 lstrcpynA(szIconFile, sTemp, cchMax);
218 *piIndex = dwNr;
219 }
220 else /* default icon */
221 {
222 lstrcpynA(szIconFile, "shell32.dll", cchMax);
223 *piIndex = 0;
224 }
225 }
226
227 TRACE("-- %s %x\n", szIconFile, *piIndex);
228 return NOERROR;
229}
230/**************************************************************************
231* IExtractIconA_Extract
232*/
233static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
234{
235 ICOM_THIS(IExtractIconAImpl,iface);
236
237 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
238
239 if (phiconLarge)
240 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
241
242 if (phiconSmall)
243 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
244
245 return S_OK;
246}
247
248static struct ICOM_VTABLE(IExtractIconA) eivt =
249{
250 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
251 IExtractIconA_fnQueryInterface,
252 IExtractIconA_fnAddRef,
253 IExtractIconA_fnRelease,
254 IExtractIconA_fnGetIconLocation,
255 IExtractIconA_fnExtract
256};
257
258/************************************************************************
259 * IEIPersistFile_QueryInterface (IUnknown)
260 */
261static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
262 IPersistFile *iface,
263 REFIID iid,
264 LPVOID *ppvObj)
265{
266 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
267
268 return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
269}
270
271/************************************************************************
272 * IEIPersistFile_AddRef (IUnknown)
273 */
274static ULONG WINAPI IEIPersistFile_fnAddRef(
275 IPersistFile *iface)
276{
277 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
278
279 return IExtractIconA_AddRef((IExtractIconA*)This);
280}
281
282/************************************************************************
283 * IEIPersistFile_Release (IUnknown)
284 */
285static ULONG WINAPI IEIPersistFile_fnRelease(
286 IPersistFile *iface)
287{
288 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
289
290 return IExtractIconA_Release((IExtractIconA*)This);
291}
292
293/************************************************************************
294 * IEIPersistFile_GetClassID (IPersist)
295 */
296static HRESULT WINAPI IEIPersistFile_fnGetClassID(
297 IPersistFile *iface,
298 LPCLSID lpClassId)
299{
300 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
301
302 if (lpClassId==NULL)
303 return E_POINTER;
304
305 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
306
307 return S_OK;
308}
309
310/************************************************************************
311 * IEIPersistFile_Load (IPersistFile)
312 */
313static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
314{
315 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
316 FIXME("%p\n", This);
317 return E_NOTIMPL;
318
319}
320
321static struct ICOM_VTABLE(IPersistFile) pfvt =
322{
323 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
324 IEIPersistFile_fnQueryInterface,
325 IEIPersistFile_fnAddRef,
326 IEIPersistFile_fnRelease,
327 IEIPersistFile_fnGetClassID,
328 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
329 IEIPersistFile_fnLoad,
330 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
331 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
332 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */
333};
334
Note: See TracBrowser for help on using the repository browser.