reg/tests: Test import with non-standard registry file headers.
[wine.git] / dlls / mshtml / htmlstorage.c
blobbc4b59b7f05642777b291d3efe0399858070c851
1 /*
2 * Copyright 2012 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct {
35 DispatchEx dispex;
36 IHTMLStorage IHTMLStorage_iface;
37 LONG ref;
38 } HTMLStorage;
40 static inline HTMLStorage *impl_from_IHTMLStorage(IHTMLStorage *iface)
42 return CONTAINING_RECORD(iface, HTMLStorage, IHTMLStorage_iface);
45 static HRESULT WINAPI HTMLStorage_QueryInterface(IHTMLStorage *iface, REFIID riid, void **ppv)
47 HTMLStorage *This = impl_from_IHTMLStorage(iface);
49 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
51 if(IsEqualGUID(&IID_IUnknown, riid)) {
52 *ppv = &This->IHTMLStorage_iface;
53 }else if(IsEqualGUID(&IID_IHTMLStorage, riid)) {
54 *ppv = &This->IHTMLStorage_iface;
55 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
56 return *ppv ? S_OK : E_NOINTERFACE;
57 }else {
58 *ppv = NULL;
59 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
60 return E_NOINTERFACE;
63 IUnknown_AddRef((IUnknown*)*ppv);
64 return S_OK;
67 static ULONG WINAPI HTMLStorage_AddRef(IHTMLStorage *iface)
69 HTMLStorage *This = impl_from_IHTMLStorage(iface);
70 LONG ref = InterlockedIncrement(&This->ref);
72 TRACE("(%p) ref=%d\n", This, ref);
74 return ref;
77 static ULONG WINAPI HTMLStorage_Release(IHTMLStorage *iface)
79 HTMLStorage *This = impl_from_IHTMLStorage(iface);
80 LONG ref = InterlockedDecrement(&This->ref);
82 TRACE("(%p) ref=%d\n", This, ref);
84 if(!ref) {
85 release_dispex(&This->dispex);
86 heap_free(This);
89 return ref;
92 static HRESULT WINAPI HTMLStorage_GetTypeInfoCount(IHTMLStorage *iface, UINT *pctinfo)
94 HTMLStorage *This = impl_from_IHTMLStorage(iface);
95 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
98 static HRESULT WINAPI HTMLStorage_GetTypeInfo(IHTMLStorage *iface, UINT iTInfo,
99 LCID lcid, ITypeInfo **ppTInfo)
101 HTMLStorage *This = impl_from_IHTMLStorage(iface);
103 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
106 static HRESULT WINAPI HTMLStorage_GetIDsOfNames(IHTMLStorage *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
107 LCID lcid, DISPID *rgDispId)
109 HTMLStorage *This = impl_from_IHTMLStorage(iface);
111 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
112 lcid, rgDispId);
115 static HRESULT WINAPI HTMLStorage_Invoke(IHTMLStorage *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
116 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
118 HTMLStorage *This = impl_from_IHTMLStorage(iface);
120 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
121 pDispParams, pVarResult, pExcepInfo, puArgErr);
124 static HRESULT WINAPI HTMLStorage_get_length(IHTMLStorage *iface, LONG *p)
126 HTMLStorage *This = impl_from_IHTMLStorage(iface);
127 FIXME("(%p)->(%p)\n", This, p);
128 return E_NOTIMPL;
131 static HRESULT WINAPI HTMLStorage_get_remainingSpace(IHTMLStorage *iface, LONG *p)
133 HTMLStorage *This = impl_from_IHTMLStorage(iface);
134 FIXME("(%p)->(%p)\n", This, p);
135 return E_NOTIMPL;
138 static HRESULT WINAPI HTMLStorage_key(IHTMLStorage *iface, LONG lIndex, BSTR *p)
140 HTMLStorage *This = impl_from_IHTMLStorage(iface);
141 FIXME("(%p)->(%d %p)\n", This, lIndex, p);
142 return E_NOTIMPL;
145 static HRESULT WINAPI HTMLStorage_getItem(IHTMLStorage *iface, BSTR bstrKey, VARIANT *p)
147 HTMLStorage *This = impl_from_IHTMLStorage(iface);
148 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrKey), p);
149 return E_NOTIMPL;
152 static HRESULT WINAPI HTMLStorage_setItem(IHTMLStorage *iface, BSTR bstrKey, BSTR bstrValue)
154 HTMLStorage *This = impl_from_IHTMLStorage(iface);
155 FIXME("(%p)->(%s %s)\n", This, debugstr_w(bstrKey), debugstr_w(bstrValue));
156 return E_NOTIMPL;
159 static HRESULT WINAPI HTMLStorage_removeItem(IHTMLStorage *iface, BSTR bstrKey)
161 HTMLStorage *This = impl_from_IHTMLStorage(iface);
162 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrKey));
163 return E_NOTIMPL;
166 static HRESULT WINAPI HTMLStorage_clear(IHTMLStorage *iface)
168 HTMLStorage *This = impl_from_IHTMLStorage(iface);
169 FIXME("(%p)->()\n", This);
170 return E_NOTIMPL;
173 static const IHTMLStorageVtbl HTMLStorageVtbl = {
174 HTMLStorage_QueryInterface,
175 HTMLStorage_AddRef,
176 HTMLStorage_Release,
177 HTMLStorage_GetTypeInfoCount,
178 HTMLStorage_GetTypeInfo,
179 HTMLStorage_GetIDsOfNames,
180 HTMLStorage_Invoke,
181 HTMLStorage_get_length,
182 HTMLStorage_get_remainingSpace,
183 HTMLStorage_key,
184 HTMLStorage_getItem,
185 HTMLStorage_setItem,
186 HTMLStorage_removeItem,
187 HTMLStorage_clear
190 static const tid_t HTMLStorage_iface_tids[] = {
191 IHTMLStorage_tid,
194 static dispex_static_data_t HTMLStorage_dispex = {
195 NULL,
196 IHTMLStorage_tid,
197 HTMLStorage_iface_tids
200 HRESULT create_storage(IHTMLStorage **p)
202 HTMLStorage *storage;
204 storage = heap_alloc_zero(sizeof(*storage));
205 if(!storage)
206 return E_OUTOFMEMORY;
208 storage->IHTMLStorage_iface.lpVtbl = &HTMLStorageVtbl;
209 storage->ref = 1;
210 init_dispex(&storage->dispex, (IUnknown*)&storage->IHTMLStorage_iface, &HTMLStorage_dispex);
212 *p = &storage->IHTMLStorage_iface;
213 return S_OK;