Added sample config file in the new format.
[wine/multimedia.git] / dlls / shell32 / folders.c
blobc783e3b0dcaf9b6e02d739235d281bb030b13a4c
1 /*
2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
5 */
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <string.h>
11 #include "windef.h"
12 #include "wine/obj_base.h"
13 #include "wine/obj_extracticon.h"
14 #include "wine/undocshell.h"
15 #include "shlguid.h"
17 #include "debugtools.h"
18 #include "winerror.h"
20 #include "pidl.h"
21 #include "shell32_main.h"
23 DEFAULT_DEBUG_CHANNEL(shell);
26 /***********************************************************************
27 * IExtractIconA implementation
30 typedef struct
31 { ICOM_VFIELD(IExtractIconA);
32 DWORD ref;
33 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
34 LPITEMIDLIST pidl;
35 } IExtractIconAImpl;
37 static struct ICOM_VTABLE(IExtractIconA) eivt;
38 static struct ICOM_VTABLE(IPersistFile) pfvt;
40 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
41 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
43 /**************************************************************************
44 * IExtractIconA_Constructor
46 IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
48 IExtractIconAImpl* ei;
50 ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
51 ei->ref=1;
52 ICOM_VTBL(ei) = &eivt;
53 ei->lpvtblPersistFile = &pfvt;
54 ei->pidl=ILClone(pidl);
56 pdump(pidl);
58 TRACE("(%p)\n",ei);
59 shell32_ObjCount++;
60 return (IExtractIconA *)ei;
62 /**************************************************************************
63 * IExtractIconA_QueryInterface
65 static HRESULT WINAPI IExtractIconA_fnQueryInterface( IExtractIconA * iface, REFIID riid, LPVOID *ppvObj)
67 ICOM_THIS(IExtractIconAImpl,iface);
69 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
71 *ppvObj = NULL;
73 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
74 { *ppvObj = This;
76 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/
77 { *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile);
79 else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
80 { *ppvObj = (IExtractIconA*)This;
83 if(*ppvObj)
84 { IExtractIconA_AddRef((IExtractIconA*) *ppvObj);
85 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
86 return S_OK;
88 TRACE("-- Interface: E_NOINTERFACE\n");
89 return E_NOINTERFACE;
92 /**************************************************************************
93 * IExtractIconA_AddRef
95 static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
97 ICOM_THIS(IExtractIconAImpl,iface);
99 TRACE("(%p)->(count=%lu)\n",This, This->ref );
101 shell32_ObjCount++;
103 return ++(This->ref);
105 /**************************************************************************
106 * IExtractIconA_Release
108 static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
110 ICOM_THIS(IExtractIconAImpl,iface);
112 TRACE("(%p)->()\n",This);
114 shell32_ObjCount--;
116 if (!--(This->ref))
117 { TRACE(" destroying IExtractIcon(%p)\n",This);
118 SHFree(This->pidl);
119 HeapFree(GetProcessHeap(),0,This);
120 return 0;
122 return This->ref;
124 /**************************************************************************
125 * IExtractIconA_GetIconLocation
127 * mapping filetype to icon
129 static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
130 IExtractIconA * iface,
131 UINT uFlags,
132 LPSTR szIconFile,
133 UINT cchMax,
134 int * piIndex,
135 UINT * pwFlags)
137 ICOM_THIS(IExtractIconAImpl,iface);
139 char sTemp[MAX_PATH];
140 DWORD dwNr;
141 GUID const * riid;
142 LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
144 TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
146 if (pwFlags)
147 *pwFlags = 0;
149 if (_ILIsDesktop(pSimplePidl))
151 lstrcpynA(szIconFile, "shell32.dll", cchMax);
152 *piIndex = 34;
155 /* my computer and other shell extensions */
156 else if ( (riid = _ILGetGUIDPointer(pSimplePidl)) )
158 char xriid[50];
159 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
160 riid->Data1, riid->Data2, riid->Data3,
161 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
162 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
164 if (HCR_GetDefaultIcon(xriid, sTemp, MAX_PATH, &dwNr))
166 lstrcpynA(szIconFile, sTemp, cchMax);
167 *piIndex = dwNr;
169 else
171 lstrcpynA(szIconFile, "shell32.dll", cchMax);
172 *piIndex = 15;
176 else if (_ILIsDrive (pSimplePidl))
178 if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
180 lstrcpynA(szIconFile, sTemp, cchMax);
181 *piIndex = dwNr;
183 else
185 lstrcpynA(szIconFile, "shell32.dll", cchMax);
186 *piIndex = 8;
189 else if (_ILIsFolder (pSimplePidl))
191 if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
193 lstrcpynA(szIconFile, sTemp, cchMax);
194 *piIndex = dwNr;
196 else
198 lstrcpynA(szIconFile, "shell32.dll", cchMax);
199 *piIndex = (uFlags & GIL_OPENICON)? 4 : 3;
202 else /* object is file */
204 if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)
205 && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
206 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
208 if (!strcmp("%1",sTemp)) /* icon is in the file */
210 SHGetPathFromIDListA(This->pidl, sTemp);
211 dwNr = 0;
213 lstrcpynA(szIconFile, sTemp, cchMax);
214 *piIndex = dwNr;
216 else /* default icon */
218 lstrcpynA(szIconFile, "shell32.dll", cchMax);
219 *piIndex = 0;
223 TRACE("-- %s %x\n", szIconFile, *piIndex);
224 return NOERROR;
226 /**************************************************************************
227 * IExtractIconA_Extract
229 static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
231 ICOM_THIS(IExtractIconAImpl,iface);
233 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
235 if (phiconLarge)
236 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
238 if (phiconSmall)
239 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
241 return S_OK;
244 static struct ICOM_VTABLE(IExtractIconA) eivt =
246 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
247 IExtractIconA_fnQueryInterface,
248 IExtractIconA_fnAddRef,
249 IExtractIconA_fnRelease,
250 IExtractIconA_fnGetIconLocation,
251 IExtractIconA_fnExtract
254 /************************************************************************
255 * IEIPersistFile_QueryInterface (IUnknown)
257 static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
258 IPersistFile *iface,
259 REFIID iid,
260 LPVOID *ppvObj)
262 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
264 return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
267 /************************************************************************
268 * IEIPersistFile_AddRef (IUnknown)
270 static ULONG WINAPI IEIPersistFile_fnAddRef(
271 IPersistFile *iface)
273 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
275 return IExtractIconA_AddRef((IExtractIconA*)This);
278 /************************************************************************
279 * IEIPersistFile_Release (IUnknown)
281 static ULONG WINAPI IEIPersistFile_fnRelease(
282 IPersistFile *iface)
284 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
286 return IExtractIconA_Release((IExtractIconA*)This);
289 /************************************************************************
290 * IEIPersistFile_GetClassID (IPersist)
292 static HRESULT WINAPI IEIPersistFile_fnGetClassID(
293 IPersistFile *iface,
294 LPCLSID lpClassId)
296 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
298 if (lpClassId==NULL)
299 return E_POINTER;
301 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
303 return S_OK;
306 /************************************************************************
307 * IEIPersistFile_Load (IPersistFile)
309 static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
311 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
312 FIXME("%p\n", This);
313 return E_NOTIMPL;
317 static struct ICOM_VTABLE(IPersistFile) pfvt =
319 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
320 IEIPersistFile_fnQueryInterface,
321 IEIPersistFile_fnAddRef,
322 IEIPersistFile_fnRelease,
323 IEIPersistFile_fnGetClassID,
324 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
325 IEIPersistFile_fnLoad,
326 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
327 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
328 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */