Release 980301
[wine] / ole / folders.c
1 /*
2  *      Shell Folder stuff
3  *
4  *      Copyright 1997  Marcus Meissner
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
17 /******************************************************************************
18  * IEnumIDList implementation
19  */
20
21 static ULONG WINAPI IEnumIDList_AddRef(LPENUMIDLIST this) {
22         fprintf(stderr,"IEnumIDList(%p)->AddRef()\n",this);
23         return ++(this->ref);
24 }
25
26 static ULONG WINAPI IEnumIDList_Release(LPENUMIDLIST this) {
27         fprintf(stderr,"IEnumIDList(%p)->Release()\n",this);
28         if (!--(this->ref)) {
29                 fprintf(stderr,"        -> freeing IEnumIDList(%p)\n",this);
30                 HeapFree(GetProcessHeap(),0,this);
31                 return 0;
32         }
33         return this->ref;
34 }
35
36 static HRESULT WINAPI IEnumIDList_Next(
37         LPENUMIDLIST this,ULONG celt,LPITEMIDLIST *rgelt,ULONG *pceltFetched
38 ) {
39         fprintf(stderr,"IEnumIDList(%p)->Next(%ld,%p,%p),stub!\n",
40                 this,celt,rgelt,pceltFetched
41         );
42         *pceltFetched = 0; /* we don't have any ... */
43         return 0;
44 }
45
46 static IEnumIDList_VTable eidlvt = {
47         (void *)1,
48         IEnumIDList_AddRef,
49         IEnumIDList_Release,
50         IEnumIDList_Next,
51         (void *)5,
52         (void *)6,
53         (void *)7
54 };
55
56 LPENUMIDLIST IEnumIDList_Constructor() {
57         LPENUMIDLIST    lpeidl;
58
59         lpeidl= (LPENUMIDLIST)HeapAlloc(GetProcessHeap(),0,sizeof(IEnumIDList));
60         lpeidl->ref = 1;
61         lpeidl->lpvtbl = &eidlvt;
62         return lpeidl;
63 }
64
65 /******************************************************************************
66  * IShellFolder implementation
67  */
68 static ULONG WINAPI IShellFolder_Release(LPSHELLFOLDER this) {
69         fprintf(stderr,"IShellFolder(%p)->Release()\n",this);
70         if (!--(this->ref)) {
71                 fprintf(stderr,"        -> freeing IShellFolder(%p)\n",this);
72                 HeapFree(GetProcessHeap(),0,this);
73                 return 0;
74         }
75         return this->ref;
76 }
77
78 static ULONG WINAPI IShellFolder_AddRef(LPSHELLFOLDER this) {
79         fprintf(stderr,"IShellFolder(%p)->AddRef()\n",this);
80         return ++(this->ref);
81 }
82
83 static HRESULT WINAPI IShellFolder_GetAttributesOf(
84         LPSHELLFOLDER this,UINT32 cidl,LPCITEMIDLIST *apidl,DWORD *rgfInOut
85 ) {
86         fprintf(stderr,"IShellFolder(%p)->GetAttributesOf(%d,%p,%p),stub!\n",
87                 this,cidl,apidl,rgfInOut
88         );
89         return 0;
90 }
91
92 static HRESULT WINAPI IShellFolder_BindToObject(
93         LPSHELLFOLDER this,LPCITEMIDLIST pidl,LPBC pbcReserved,REFIID riid,LPVOID * ppvOut
94 ) {
95         char    xclsid[50];
96
97         WINE_StringFromCLSID(riid,xclsid);
98         fprintf(stderr,"IShellFolder(%p)->BindToObject(%p,%p,%s,%p),stub!\n",
99                 this,pidl,pbcReserved,xclsid,ppvOut
100         );
101         *ppvOut = IShellFolder_Constructor();
102         return 0;
103 }
104
105 static HRESULT WINAPI IShellFolder_ParseDisplayName(
106         LPSHELLFOLDER this,HWND32 hwndOwner,LPBC pbcReserved,
107         LPOLESTR32 lpszDisplayName,DWORD *pchEaten,LPITEMIDLIST *ppidl,
108         DWORD *pdwAttributes
109 ) {
110         fprintf(stderr,"IShellFolder(%p)->ParseDisplayName(%08x,%p,%p,%p,%p,%p),stub!\n",
111                 this,hwndOwner,pbcReserved,lpszDisplayName,pchEaten,ppidl,pdwAttributes
112         );
113         *(DWORD*)pbcReserved = 0;
114         return 0;
115 }
116
117 static HRESULT WINAPI IShellFolder_EnumObjects(
118         LPSHELLFOLDER this,HWND32 hwndOwner,DWORD grfFlags,
119         LPENUMIDLIST* ppenumIDList
120 ) {
121         fprintf(stderr,"IShellFolder(%p)->EnumObjects(0x%04x,0x%08lx,%p),stub!\n",
122                 this,hwndOwner,grfFlags,ppenumIDList
123         );
124         *ppenumIDList = IEnumIDList_Constructor();
125         return 0;
126 }
127
128 static HRESULT WINAPI IShellFolder_CreateViewObject(
129         LPSHELLFOLDER this,HWND32 hwndOwner,REFIID riid,LPVOID *ppv
130 ) {
131         char    xclsid[50];
132
133         WINE_StringFromCLSID(riid,xclsid);
134         fprintf(stderr,"IShellFolder(%p)->CreateViewObject(0x%04x,%s,%p),stub!\n",
135                 this,hwndOwner,xclsid,ppv
136         );
137         *(DWORD*)ppv = 0;
138         return 0;
139 }
140
141
142 static struct IShellFolder_VTable sfvt = {
143         (void *)1,
144         IShellFolder_AddRef,
145         IShellFolder_Release,
146         IShellFolder_ParseDisplayName,
147         IShellFolder_EnumObjects,
148         IShellFolder_BindToObject,
149         (void *)7,
150         (void *)8,
151         IShellFolder_CreateViewObject,
152         IShellFolder_GetAttributesOf,
153         (void *)11,
154         (void *)12,
155         (void *)13
156 };
157
158 LPSHELLFOLDER IShellFolder_Constructor() {
159         LPSHELLFOLDER   sf;
160
161         sf = (LPSHELLFOLDER)HeapAlloc(GetProcessHeap(),0,sizeof(IShellFolder));
162         sf->ref         = 1;
163         sf->lpvtbl      = &sfvt;
164         return sf;
165 }
166
167 static struct IShellLink_VTable slvt = {
168     (void *)1,
169     (void *)2,
170     (void *)3,
171     (void *)4,
172     (void *)5,
173     (void *)6,
174     (void *)7,
175     (void *)8,
176     (void *)9,
177     (void *)10,
178     (void *)11,
179     (void *)12,
180     (void *)13,
181     (void *)14,
182     (void *)15,
183     (void *)16,
184     (void *)17,
185     (void *)18,
186     (void *)19,
187     (void *)20,
188     (void *)21
189 };
190
191 LPSHELLLINK IShellLink_Constructor() {
192         LPSHELLLINK sl;
193
194         sl = (LPSHELLLINK)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLink));
195         sl->ref = 1;
196         sl->lpvtbl = &slvt;
197         return sl;
198 }