shdocvw: Convert coclass registration to the IRegistrar mechanism.
[wine] / dlls / shdocvw / persist.c
1 /*
2  * Implementation of IPersist interfaces for WebBrowser control
3  *
4  * Copyright 2001 John R. Sheets (for CodeWeavers)
5  * Copyright 2005 Jacek Caban
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include "wine/debug.h"
23 #include "shdocvw.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
26
27 /**********************************************************************
28  * Implement the IPersistStorage interface
29  */
30
31 static inline WebBrowser *impl_from_IPersistStorage(IPersistStorage *iface)
32 {
33     return CONTAINING_RECORD(iface, WebBrowser, IPersistStorage_iface);
34 }
35
36 static HRESULT WINAPI PersistStorage_QueryInterface(IPersistStorage *iface,
37         REFIID riid, LPVOID *ppobj)
38 {
39     WebBrowser *This = impl_from_IPersistStorage(iface);
40     return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
41 }
42
43 static ULONG WINAPI PersistStorage_AddRef(IPersistStorage *iface)
44 {
45     WebBrowser *This = impl_from_IPersistStorage(iface);
46     return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
47 }
48
49 static ULONG WINAPI PersistStorage_Release(IPersistStorage *iface)
50 {
51     WebBrowser *This = impl_from_IPersistStorage(iface);
52     return IWebBrowser_Release(&This->IWebBrowser2_iface);
53 }
54
55 static HRESULT WINAPI PersistStorage_GetClassID(IPersistStorage *iface, CLSID *pClassID)
56 {
57     WebBrowser *This = impl_from_IPersistStorage(iface);
58     FIXME("(%p)->(%p)\n", This, pClassID);
59     return E_NOTIMPL;
60 }
61
62 static HRESULT WINAPI PersistStorage_IsDirty(IPersistStorage *iface)
63 {
64     WebBrowser *This = impl_from_IPersistStorage(iface);
65     FIXME("(%p)\n", This);
66     return E_NOTIMPL;
67 }
68
69 static HRESULT WINAPI PersistStorage_InitNew(IPersistStorage *iface, LPSTORAGE pStg)
70 {
71     WebBrowser *This = impl_from_IPersistStorage(iface);
72     FIXME("(%p)->(%p)\n", This, pStg);
73     return S_OK;
74 }
75
76 static HRESULT WINAPI PersistStorage_Load(IPersistStorage *iface, LPSTORAGE pStg)
77 {
78     WebBrowser *This = impl_from_IPersistStorage(iface);
79     FIXME("(%p)->(%p)\n", This, pStg);
80     return E_NOTIMPL;
81 }
82
83 static HRESULT WINAPI PersistStorage_Save(IPersistStorage *iface, LPSTORAGE pStg,
84         BOOL fSameAsLoad)
85 {
86     WebBrowser *This = impl_from_IPersistStorage(iface);
87     FIXME("(%p)->(%p %x)\n", This, pStg, fSameAsLoad);
88     return E_NOTIMPL;
89 }
90
91 static HRESULT WINAPI PersistStorage_SaveCompleted(IPersistStorage *iface, LPSTORAGE pStgNew)
92 {
93     WebBrowser *This = impl_from_IPersistStorage(iface);
94     FIXME("(%p)->(%p)\n", This, pStgNew);
95     return E_NOTIMPL;
96 }
97
98 static const IPersistStorageVtbl PersistStorageVtbl =
99 {
100     PersistStorage_QueryInterface,
101     PersistStorage_AddRef,
102     PersistStorage_Release,
103     PersistStorage_GetClassID,
104     PersistStorage_IsDirty,
105     PersistStorage_InitNew,
106     PersistStorage_Load,
107     PersistStorage_Save,
108     PersistStorage_SaveCompleted
109 };
110
111 /**********************************************************************
112  * Implement the IPersistMemory interface
113  */
114
115 static inline WebBrowser *impl_from_IPersistMemory(IPersistMemory *iface)
116 {
117     return CONTAINING_RECORD(iface, WebBrowser, IPersistMemory_iface);
118 }
119
120 static HRESULT WINAPI PersistMemory_QueryInterface(IPersistMemory *iface,
121         REFIID riid, LPVOID *ppobj)
122 {
123     WebBrowser *This = impl_from_IPersistMemory(iface);
124     return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
125 }
126
127 static ULONG WINAPI PersistMemory_AddRef(IPersistMemory *iface)
128 {
129     WebBrowser *This = impl_from_IPersistMemory(iface);
130     return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
131 }
132
133 static ULONG WINAPI PersistMemory_Release(IPersistMemory *iface)
134 {
135     WebBrowser *This = impl_from_IPersistMemory(iface);
136     return IWebBrowser_Release(&This->IWebBrowser2_iface);
137 }
138
139 static HRESULT WINAPI PersistMemory_GetClassID(IPersistMemory *iface, CLSID *pClassID)
140 {
141     WebBrowser *This = impl_from_IPersistMemory(iface);
142     FIXME("(%p)->(%p)\n", This, pClassID);
143     return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI PersistMemory_IsDirty(IPersistMemory *iface)
147 {
148     WebBrowser *This = impl_from_IPersistMemory(iface);
149     FIXME("(%p)\n", This);
150     return E_NOTIMPL;
151 }
152
153 static HRESULT WINAPI PersistMemory_InitNew(IPersistMemory *iface)
154 {
155     WebBrowser *This = impl_from_IPersistMemory(iface);
156     FIXME("(%p)\n", This);
157     return S_OK;
158 }
159
160 static HRESULT WINAPI PersistMemory_Load(IPersistMemory *iface, LPVOID pMem, ULONG cbSize)
161 {
162     WebBrowser *This = impl_from_IPersistMemory(iface);
163     FIXME("(%p)->(%p %x)\n", This, pMem, cbSize);
164     return S_OK;
165 }
166
167 static HRESULT WINAPI PersistMemory_Save(IPersistMemory *iface, LPVOID pMem,
168         BOOL fClearDirty, ULONG cbSize)
169 {
170     WebBrowser *This = impl_from_IPersistMemory(iface);
171     FIXME("(%p)->(%p %x %x)\n", This, pMem, fClearDirty, cbSize);
172     return E_NOTIMPL;
173 }
174
175 static HRESULT WINAPI PersistMemory_GetSizeMax(IPersistMemory *iface, ULONG *pCbSize)
176 {
177     WebBrowser *This = impl_from_IPersistMemory(iface);
178     FIXME("(%p)->(%p)\n", This, pCbSize);
179     return E_NOTIMPL;
180 }
181
182 static const IPersistMemoryVtbl PersistMemoryVtbl =
183 {
184     PersistMemory_QueryInterface,
185     PersistMemory_AddRef,
186     PersistMemory_Release,
187     PersistMemory_GetClassID,
188     PersistMemory_IsDirty,
189     PersistMemory_Load,
190     PersistMemory_Save,
191     PersistMemory_GetSizeMax,
192     PersistMemory_InitNew
193 };
194
195 /**********************************************************************
196  * Implement the IPersistStreamInit interface
197  */
198
199 static inline WebBrowser *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
200 {
201     return CONTAINING_RECORD(iface, WebBrowser, IPersistStreamInit_iface);
202 }
203
204 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
205         REFIID riid, LPVOID *ppobj)
206 {
207     WebBrowser *This = impl_from_IPersistStreamInit(iface);
208     return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
209 }
210
211 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
212 {
213     WebBrowser *This = impl_from_IPersistStreamInit(iface);
214     return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
215 }
216
217 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
218 {
219     WebBrowser *This = impl_from_IPersistStreamInit(iface);
220     return IWebBrowser_Release(&This->IWebBrowser2_iface);
221 }
222
223 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
224 {
225     WebBrowser *This = impl_from_IPersistStreamInit(iface);
226     return IPersistStorage_GetClassID(&This->IPersistStorage_iface, pClassID);
227 }
228
229 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
230 {
231     WebBrowser *This = impl_from_IPersistStreamInit(iface);
232     return IPersistStorage_IsDirty(&This->IPersistStorage_iface);
233 }
234
235 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStg)
236 {
237     WebBrowser *This = impl_from_IPersistStreamInit(iface);
238     FIXME("(%p)->(%p)\n", This, pStg);
239     return S_OK;
240 }
241
242 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStg,
243         BOOL fSameAsLoad)
244 {
245     WebBrowser *This = impl_from_IPersistStreamInit(iface);
246     FIXME("(%p)->(%p %x)\n", This, pStg, fSameAsLoad);
247     return E_NOTIMPL;
248 }
249
250 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
251         ULARGE_INTEGER *pcbSize)
252 {
253     WebBrowser *This = impl_from_IPersistStreamInit(iface);
254     FIXME("(%p)->(%p)\n", This, pcbSize);
255     return E_NOTIMPL;
256 }
257
258 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
259 {
260     WebBrowser *This = impl_from_IPersistStreamInit(iface);
261     FIXME("(%p)\n", This);
262     return S_OK;
263 }
264
265 static const IPersistStreamInitVtbl PersistStreamInitVtbl =
266 {
267     PersistStreamInit_QueryInterface,
268     PersistStreamInit_AddRef,
269     PersistStreamInit_Release,
270     PersistStreamInit_GetClassID,
271     PersistStreamInit_IsDirty,
272     PersistStreamInit_Load,
273     PersistStreamInit_Save,
274     PersistStreamInit_GetSizeMax,
275     PersistStreamInit_InitNew
276 };
277
278 void WebBrowser_Persist_Init(WebBrowser *This)
279 {
280     This->IPersistStorage_iface.lpVtbl    = &PersistStorageVtbl;
281     This->IPersistMemory_iface.lpVtbl     = &PersistMemoryVtbl;
282     This->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl;
283 }