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