Fixed the list of accepted types passed to HttpOpenRequestA.
[wine/dcerpc.git] / dlls / shell32 / folders.c
blob49ab0f9d2f7e9ade81b788874eda7dce1b81d57d
1 /*
2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
24 #include "windef.h"
25 #include "objbase.h"
26 #include "undocshell.h"
27 #include "shlguid.h"
29 #include "wine/debug.h"
30 #include "winerror.h"
32 #include "pidl.h"
33 #include "shell32_main.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(shell);
38 /***********************************************************************
39 * IExtractIconA implementation
42 typedef struct
43 { ICOM_VFIELD(IExtractIconA);
44 DWORD ref;
45 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
46 LPITEMIDLIST pidl;
47 } IExtractIconAImpl;
49 static struct ICOM_VTABLE(IExtractIconA) eivt;
50 static struct ICOM_VTABLE(IPersistFile) pfvt;
52 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
53 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
55 /**************************************************************************
56 * IExtractIconA_Constructor
58 IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
60 IExtractIconAImpl* ei;
62 ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
63 ei->ref=1;
64 ICOM_VTBL(ei) = &eivt;
65 ei->lpvtblPersistFile = &pfvt;
66 ei->pidl=ILClone(pidl);
68 pdump(pidl);
70 TRACE("(%p)\n",ei);
71 return (IExtractIconA *)ei;
73 /**************************************************************************
74 * IExtractIconA_QueryInterface
76 static HRESULT WINAPI IExtractIconA_fnQueryInterface( IExtractIconA * iface, REFIID riid, LPVOID *ppvObj)
78 ICOM_THIS(IExtractIconAImpl,iface);
80 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
82 *ppvObj = NULL;
84 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
85 { *ppvObj = This;
87 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/
88 { *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile);
90 else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
91 { *ppvObj = (IExtractIconA*)This;
94 if(*ppvObj)
95 { IExtractIconA_AddRef((IExtractIconA*) *ppvObj);
96 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
97 return S_OK;
99 TRACE("-- Interface: E_NOINTERFACE\n");
100 return E_NOINTERFACE;
103 /**************************************************************************
104 * IExtractIconA_AddRef
106 static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
108 ICOM_THIS(IExtractIconAImpl,iface);
110 TRACE("(%p)->(count=%lu)\n",This, This->ref );
112 return ++(This->ref);
114 /**************************************************************************
115 * IExtractIconA_Release
117 static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
119 ICOM_THIS(IExtractIconAImpl,iface);
121 TRACE("(%p)->()\n",This);
123 if (!--(This->ref))
124 { TRACE(" destroying IExtractIcon(%p)\n",This);
125 SHFree(This->pidl);
126 HeapFree(GetProcessHeap(),0,This);
127 return 0;
129 return This->ref;
131 /**************************************************************************
132 * IExtractIconA_GetIconLocation
134 * mapping filetype to icon
136 static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
137 IExtractIconA * iface,
138 UINT uFlags,
139 LPSTR szIconFile,
140 UINT cchMax,
141 int * piIndex,
142 UINT * pwFlags)
144 ICOM_THIS(IExtractIconAImpl,iface);
146 char sTemp[MAX_PATH];
147 DWORD dwNr;
148 GUID const * riid;
149 LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
151 TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
153 if (pwFlags)
154 *pwFlags = 0;
156 if (_ILIsDesktop(pSimplePidl))
158 lstrcpynA(szIconFile, "shell32.dll", cchMax);
159 *piIndex = 34;
162 /* my computer and other shell extensions */
163 else if ( (riid = _ILGetGUIDPointer(pSimplePidl)) )
165 char xriid[50];
166 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
167 riid->Data1, riid->Data2, riid->Data3,
168 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
169 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
171 if (HCR_GetDefaultIcon(xriid, sTemp, MAX_PATH, &dwNr))
173 lstrcpynA(szIconFile, sTemp, cchMax);
174 *piIndex = dwNr;
176 else
178 lstrcpynA(szIconFile, "shell32.dll", cchMax);
179 *piIndex = 15;
183 else if (_ILIsDrive (pSimplePidl))
185 if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
187 lstrcpynA(szIconFile, sTemp, cchMax);
188 *piIndex = dwNr;
190 else
192 lstrcpynA(szIconFile, "shell32.dll", cchMax);
193 *piIndex = 8;
196 else if (_ILIsFolder (pSimplePidl))
198 if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
200 lstrcpynA(szIconFile, sTemp, cchMax);
201 *piIndex = dwNr;
203 else
205 lstrcpynA(szIconFile, "shell32.dll", cchMax);
206 *piIndex = (uFlags & GIL_OPENICON)? 4 : 3;
209 else /* object is file */
211 if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)
212 && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
213 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
215 if (!strcmp("%1",sTemp)) /* icon is in the file */
217 SHGetPathFromIDListA(This->pidl, sTemp);
218 dwNr = 0;
220 lstrcpynA(szIconFile, sTemp, cchMax);
221 *piIndex = dwNr;
223 else /* default icon */
225 lstrcpynA(szIconFile, "shell32.dll", cchMax);
226 *piIndex = 0;
230 TRACE("-- %s %x\n", szIconFile, *piIndex);
231 return NOERROR;
233 /**************************************************************************
234 * IExtractIconA_Extract
236 static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
238 ICOM_THIS(IExtractIconAImpl,iface);
240 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
242 if (phiconLarge)
243 *phiconLarge = ImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
245 if (phiconSmall)
246 *phiconSmall = ImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
248 return S_OK;
251 static struct ICOM_VTABLE(IExtractIconA) eivt =
253 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
254 IExtractIconA_fnQueryInterface,
255 IExtractIconA_fnAddRef,
256 IExtractIconA_fnRelease,
257 IExtractIconA_fnGetIconLocation,
258 IExtractIconA_fnExtract
261 /************************************************************************
262 * IEIPersistFile_QueryInterface (IUnknown)
264 static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
265 IPersistFile *iface,
266 REFIID iid,
267 LPVOID *ppvObj)
269 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
271 return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
274 /************************************************************************
275 * IEIPersistFile_AddRef (IUnknown)
277 static ULONG WINAPI IEIPersistFile_fnAddRef(
278 IPersistFile *iface)
280 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
282 return IExtractIconA_AddRef((IExtractIconA*)This);
285 /************************************************************************
286 * IEIPersistFile_Release (IUnknown)
288 static ULONG WINAPI IEIPersistFile_fnRelease(
289 IPersistFile *iface)
291 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
293 return IExtractIconA_Release((IExtractIconA*)This);
296 /************************************************************************
297 * IEIPersistFile_GetClassID (IPersist)
299 static HRESULT WINAPI IEIPersistFile_fnGetClassID(
300 IPersistFile *iface,
301 LPCLSID lpClassId)
303 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
305 if (lpClassId==NULL)
306 return E_POINTER;
308 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
310 return S_OK;
313 /************************************************************************
314 * IEIPersistFile_Load (IPersistFile)
316 static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
318 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
319 FIXME("%p\n", This);
320 return E_NOTIMPL;
324 static struct ICOM_VTABLE(IPersistFile) pfvt =
326 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
327 IEIPersistFile_fnQueryInterface,
328 IEIPersistFile_fnAddRef,
329 IEIPersistFile_fnRelease,
330 IEIPersistFile_fnGetClassID,
331 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
332 IEIPersistFile_fnLoad,
333 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
334 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
335 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */