Changed // comments to /* */ so WINE compiles with non-gcc compilers
[wine] / dlls / shell32 / folders.c
1 /*
2  *      Copyright 1997  Marcus Meissner
3  *      Copyright 1998  Juergen Schmied
4  *
5  */
6
7 #include <ctype.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include "ole.h"
11 #include "ole2.h"
12 #include "debug.h"
13 #include "compobj.h"
14 #include "interfaces.h"
15 #include "shlobj.h"
16 #include "shell.h"
17 #include "winerror.h"
18 #include "winnls.h"
19 #include "winproc.h"
20 #include "commctrl.h"
21 #include "pidl.h"
22
23 #include "shell32_main.h"
24
25
26 /******************************************************************************
27 * foreward declaration
28 */
29
30 /* IExtractIcon implementation*/
31 static HRESULT WINAPI IExtractIcon_QueryInterface(LPEXTRACTICON, REFIID, LPVOID *);
32 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON);
33 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON);
34 static ULONG WINAPI IExtractIcon_Release(LPEXTRACTICON);
35 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON, UINT32, LPSTR, UINT32, int *, UINT32 *);
36 static HRESULT WINAPI IExtractIcon_Extract(LPEXTRACTICON, LPCSTR, UINT32, HICON32 *, HICON32 *, UINT32);
37
38
39 /***********************************************************************
40 *   IExtractIcon implementation
41 */
42 static struct IExtractIcon_VTable eivt = 
43 { IExtractIcon_QueryInterface,
44   IExtractIcon_AddRef,
45   IExtractIcon_Release,
46   IExtractIcon_GetIconLocation,
47   IExtractIcon_Extract
48 };
49 /**************************************************************************
50 *  IExtractIcon_Constructor
51 */
52 LPEXTRACTICON IExtractIcon_Constructor(LPCITEMIDLIST pidl)
53 { LPEXTRACTICON ei;
54
55   ei=(LPEXTRACTICON)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIcon));
56   ei->ref=1;
57   ei->lpvtbl=&eivt;
58   ei->pidl=ILClone(pidl);
59
60   pdump(pidl);
61
62   TRACE(shell,"(%p)\n",ei);
63   return ei;
64 }
65 /**************************************************************************
66  *  IExtractIcon_QueryInterface
67  */
68 static HRESULT WINAPI IExtractIcon_QueryInterface( LPEXTRACTICON this, REFIID riid, LPVOID *ppvObj)
69 {  char xriid[50];
70    WINE_StringFromCLSID((LPCLSID)riid,xriid);
71    TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
72
73   *ppvObj = NULL;
74
75   if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
76   { *ppvObj = this; 
77   }
78   else if(IsEqualIID(riid, &IID_IExtractIcon))  /*IExtractIcon*/
79   {    *ppvObj = (IExtractIcon*)this;
80   }   
81
82   if(*ppvObj)
83   { (*(LPEXTRACTICON*)ppvObj)->lpvtbl->fnAddRef(this);          
84     TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
85     return S_OK;
86   }
87         TRACE(shell,"-- Interface: E_NOINTERFACE\n");
88         return E_NOINTERFACE;
89 }   
90
91 /**************************************************************************
92 *  IExtractIcon_AddRef
93 */
94 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON this)
95 { TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
96   return ++(this->ref);
97 }
98 /**************************************************************************
99 *  IExtractIcon_Release
100 */
101 static ULONG WINAPI IExtractIcon_Release(LPEXTRACTICON this)
102 { TRACE(shell,"(%p)->()\n",this);
103   if (!--(this->ref)) 
104   { TRACE(shell," destroying IExtractIcon(%p)\n",this);
105     SHFree(this->pidl);
106     HeapFree(GetProcessHeap(),0,this);
107     return 0;
108   }
109   return this->ref;
110 }
111 /**************************************************************************
112 *  IExtractIcon_GetIconLocation
113 */
114 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON this, UINT32 uFlags, LPSTR szIconFile, UINT32 cchMax, int * piIndex, UINT32 * pwFlags)
115 {       WARN (shell,"(%p) (flags=%u file=%s max=%u %p %p) semi-stub\n", this, uFlags, szIconFile, cchMax, piIndex, pwFlags);
116
117         *piIndex = (int) SHMapPIDLToSystemImageListIndex(0, this->pidl,0);
118         *pwFlags = GIL_NOTFILENAME;
119
120         WARN (shell,"-- %x\n",*piIndex);
121
122         return NOERROR;
123 }
124 /**************************************************************************
125 *  IExtractIcon_Extract
126 */
127 static HRESULT WINAPI IExtractIcon_Extract(LPEXTRACTICON this, LPCSTR pszFile, UINT32 nIconIndex, HICON32 *phiconLarge, HICON32 *phiconSmall, UINT32 nIconSize)
128 { FIXME (shell,"(%p) (file=%s index=%u %p %p size=%u) semi-stub\n", this, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
129   *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
130   *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
131   return S_OK;
132 }
133