xref: /reactos/dll/win32/ieframe/persist.c (revision 40462c92)
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 "ieframe.h"
23 
24 #include "wine/debug.h"
25 
26 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
27 
28 /**********************************************************************
29  * Implement the IPersistStorage interface
30  */
31 
32 static inline WebBrowser *impl_from_IPersistStorage(IPersistStorage *iface)
33 {
34     return CONTAINING_RECORD(iface, WebBrowser, IPersistStorage_iface);
35 }
36 
37 static HRESULT WINAPI PersistStorage_QueryInterface(IPersistStorage *iface,
38         REFIID riid, LPVOID *ppobj)
39 {
40     WebBrowser *This = impl_from_IPersistStorage(iface);
41     return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
42 }
43 
44 static ULONG WINAPI PersistStorage_AddRef(IPersistStorage *iface)
45 {
46     WebBrowser *This = impl_from_IPersistStorage(iface);
47     return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
48 }
49 
50 static ULONG WINAPI PersistStorage_Release(IPersistStorage *iface)
51 {
52     WebBrowser *This = impl_from_IPersistStorage(iface);
53     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
54 }
55 
56 static HRESULT WINAPI PersistStorage_GetClassID(IPersistStorage *iface, CLSID *pClassID)
57 {
58     WebBrowser *This = impl_from_IPersistStorage(iface);
59     FIXME("(%p)->(%p)\n", This, pClassID);
60     return E_NOTIMPL;
61 }
62 
63 static HRESULT WINAPI PersistStorage_IsDirty(IPersistStorage *iface)
64 {
65     WebBrowser *This = impl_from_IPersistStorage(iface);
66     FIXME("(%p)\n", This);
67     return E_NOTIMPL;
68 }
69 
70 static HRESULT WINAPI PersistStorage_InitNew(IPersistStorage *iface, LPSTORAGE pStg)
71 {
72     WebBrowser *This = impl_from_IPersistStorage(iface);
73     FIXME("(%p)->(%p)\n", This, pStg);
74     return S_OK;
75 }
76 
77 static HRESULT WINAPI PersistStorage_Load(IPersistStorage *iface, LPSTORAGE pStg)
78 {
79     WebBrowser *This = impl_from_IPersistStorage(iface);
80     FIXME("(%p)->(%p)\n", This, pStg);
81     return E_NOTIMPL;
82 }
83 
84 static HRESULT WINAPI PersistStorage_Save(IPersistStorage *iface, LPSTORAGE pStg,
85         BOOL fSameAsLoad)
86 {
87     WebBrowser *This = impl_from_IPersistStorage(iface);
88     FIXME("(%p)->(%p %x)\n", This, pStg, fSameAsLoad);
89     return E_NOTIMPL;
90 }
91 
92 static HRESULT WINAPI PersistStorage_SaveCompleted(IPersistStorage *iface, LPSTORAGE pStgNew)
93 {
94     WebBrowser *This = impl_from_IPersistStorage(iface);
95     FIXME("(%p)->(%p)\n", This, pStgNew);
96     return E_NOTIMPL;
97 }
98 
99 static const IPersistStorageVtbl PersistStorageVtbl =
100 {
101     PersistStorage_QueryInterface,
102     PersistStorage_AddRef,
103     PersistStorage_Release,
104     PersistStorage_GetClassID,
105     PersistStorage_IsDirty,
106     PersistStorage_InitNew,
107     PersistStorage_Load,
108     PersistStorage_Save,
109     PersistStorage_SaveCompleted
110 };
111 
112 /**********************************************************************
113  * Implement the IPersistMemory interface
114  */
115 
116 static inline WebBrowser *impl_from_IPersistMemory(IPersistMemory *iface)
117 {
118     return CONTAINING_RECORD(iface, WebBrowser, IPersistMemory_iface);
119 }
120 
121 static HRESULT WINAPI PersistMemory_QueryInterface(IPersistMemory *iface,
122         REFIID riid, LPVOID *ppobj)
123 {
124     WebBrowser *This = impl_from_IPersistMemory(iface);
125     return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
126 }
127 
128 static ULONG WINAPI PersistMemory_AddRef(IPersistMemory *iface)
129 {
130     WebBrowser *This = impl_from_IPersistMemory(iface);
131     return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
132 }
133 
134 static ULONG WINAPI PersistMemory_Release(IPersistMemory *iface)
135 {
136     WebBrowser *This = impl_from_IPersistMemory(iface);
137     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
138 }
139 
140 static HRESULT WINAPI PersistMemory_GetClassID(IPersistMemory *iface, CLSID *pClassID)
141 {
142     WebBrowser *This = impl_from_IPersistMemory(iface);
143     FIXME("(%p)->(%p)\n", This, pClassID);
144     return E_NOTIMPL;
145 }
146 
147 static HRESULT WINAPI PersistMemory_IsDirty(IPersistMemory *iface)
148 {
149     WebBrowser *This = impl_from_IPersistMemory(iface);
150     FIXME("(%p)\n", This);
151     return E_NOTIMPL;
152 }
153 
154 static HRESULT WINAPI PersistMemory_InitNew(IPersistMemory *iface)
155 {
156     WebBrowser *This = impl_from_IPersistMemory(iface);
157     FIXME("(%p)\n", This);
158     return S_OK;
159 }
160 
161 static HRESULT WINAPI PersistMemory_Load(IPersistMemory *iface, LPVOID pMem, ULONG cbSize)
162 {
163     WebBrowser *This = impl_from_IPersistMemory(iface);
164     FIXME("(%p)->(%p %x)\n", This, pMem, cbSize);
165     return S_OK;
166 }
167 
168 static HRESULT WINAPI PersistMemory_Save(IPersistMemory *iface, LPVOID pMem,
169         BOOL fClearDirty, ULONG cbSize)
170 {
171     WebBrowser *This = impl_from_IPersistMemory(iface);
172     FIXME("(%p)->(%p %x %x)\n", This, pMem, fClearDirty, cbSize);
173     return E_NOTIMPL;
174 }
175 
176 static HRESULT WINAPI PersistMemory_GetSizeMax(IPersistMemory *iface, ULONG *pCbSize)
177 {
178     WebBrowser *This = impl_from_IPersistMemory(iface);
179     FIXME("(%p)->(%p)\n", This, pCbSize);
180     return E_NOTIMPL;
181 }
182 
183 static const IPersistMemoryVtbl PersistMemoryVtbl =
184 {
185     PersistMemory_QueryInterface,
186     PersistMemory_AddRef,
187     PersistMemory_Release,
188     PersistMemory_GetClassID,
189     PersistMemory_IsDirty,
190     PersistMemory_Load,
191     PersistMemory_Save,
192     PersistMemory_GetSizeMax,
193     PersistMemory_InitNew
194 };
195 
196 /**********************************************************************
197  * Implement the IPersistStreamInit interface
198  */
199 
200 static inline WebBrowser *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
201 {
202     return CONTAINING_RECORD(iface, WebBrowser, IPersistStreamInit_iface);
203 }
204 
205 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
206         REFIID riid, LPVOID *ppobj)
207 {
208     WebBrowser *This = impl_from_IPersistStreamInit(iface);
209     return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
210 }
211 
212 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
213 {
214     WebBrowser *This = impl_from_IPersistStreamInit(iface);
215     return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
216 }
217 
218 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
219 {
220     WebBrowser *This = impl_from_IPersistStreamInit(iface);
221     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
222 }
223 
224 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
225 {
226     WebBrowser *This = impl_from_IPersistStreamInit(iface);
227     return IPersistStorage_GetClassID(&This->IPersistStorage_iface, pClassID);
228 }
229 
230 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
231 {
232     WebBrowser *This = impl_from_IPersistStreamInit(iface);
233     return IPersistStorage_IsDirty(&This->IPersistStorage_iface);
234 }
235 
236 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStg)
237 {
238     WebBrowser *This = impl_from_IPersistStreamInit(iface);
239     FIXME("(%p)->(%p)\n", This, pStg);
240     return S_OK;
241 }
242 
243 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStg,
244         BOOL fSameAsLoad)
245 {
246     WebBrowser *This = impl_from_IPersistStreamInit(iface);
247     FIXME("(%p)->(%p %x)\n", This, pStg, fSameAsLoad);
248     return E_NOTIMPL;
249 }
250 
251 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
252         ULARGE_INTEGER *pcbSize)
253 {
254     WebBrowser *This = impl_from_IPersistStreamInit(iface);
255     FIXME("(%p)->(%p)\n", This, pcbSize);
256     return E_NOTIMPL;
257 }
258 
259 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
260 {
261     WebBrowser *This = impl_from_IPersistStreamInit(iface);
262     FIXME("(%p)\n", This);
263     return S_OK;
264 }
265 
266 static const IPersistStreamInitVtbl PersistStreamInitVtbl =
267 {
268     PersistStreamInit_QueryInterface,
269     PersistStreamInit_AddRef,
270     PersistStreamInit_Release,
271     PersistStreamInit_GetClassID,
272     PersistStreamInit_IsDirty,
273     PersistStreamInit_Load,
274     PersistStreamInit_Save,
275     PersistStreamInit_GetSizeMax,
276     PersistStreamInit_InitNew
277 };
278 
279 void WebBrowser_Persist_Init(WebBrowser *This)
280 {
281     This->IPersistStorage_iface.lpVtbl    = &PersistStorageVtbl;
282     This->IPersistMemory_iface.lpVtbl     = &PersistMemoryVtbl;
283     This->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl;
284 }
285