hidclass.sys: Support parsing of explicit usage page.
[wine.git] / dlls / mshtml / htmlstorage.c
blobc389647527093d8b43e6e8de3f71d0a84874e836
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);
149 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrKey), p);
151 V_VT(p) = VT_NULL;
152 return S_OK;
155 static HRESULT WINAPI HTMLStorage_setItem(IHTMLStorage *iface, BSTR bstrKey, BSTR bstrValue)
157 HTMLStorage *This = impl_from_IHTMLStorage(iface);
158 FIXME("(%p)->(%s %s)\n", This, debugstr_w(bstrKey), debugstr_w(bstrValue));
159 return E_NOTIMPL;
162 static HRESULT WINAPI HTMLStorage_removeItem(IHTMLStorage *iface, BSTR bstrKey)
164 HTMLStorage *This = impl_from_IHTMLStorage(iface);
165 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrKey));
166 return E_NOTIMPL;
169 static HRESULT WINAPI HTMLStorage_clear(IHTMLStorage *iface)
171 HTMLStorage *This = impl_from_IHTMLStorage(iface);
172 FIXME("(%p)->()\n", This);
173 return E_NOTIMPL;
176 static const IHTMLStorageVtbl HTMLStorageVtbl = {
177 HTMLStorage_QueryInterface,
178 HTMLStorage_AddRef,
179 HTMLStorage_Release,
180 HTMLStorage_GetTypeInfoCount,
181 HTMLStorage_GetTypeInfo,
182 HTMLStorage_GetIDsOfNames,
183 HTMLStorage_Invoke,
184 HTMLStorage_get_length,
185 HTMLStorage_get_remainingSpace,
186 HTMLStorage_key,
187 HTMLStorage_getItem,
188 HTMLStorage_setItem,
189 HTMLStorage_removeItem,
190 HTMLStorage_clear
193 static const tid_t HTMLStorage_iface_tids[] = {
194 IHTMLStorage_tid,
197 static dispex_static_data_t HTMLStorage_dispex = {
198 NULL,
199 IHTMLStorage_tid,
200 HTMLStorage_iface_tids
203 HRESULT create_html_storage(compat_mode_t compat_mode, IHTMLStorage **p)
205 HTMLStorage *storage;
207 storage = heap_alloc_zero(sizeof(*storage));
208 if(!storage)
209 return E_OUTOFMEMORY;
211 storage->IHTMLStorage_iface.lpVtbl = &HTMLStorageVtbl;
212 storage->ref = 1;
213 init_dispatch(&storage->dispex, (IUnknown*)&storage->IHTMLStorage_iface, &HTMLStorage_dispex, compat_mode);
215 *p = &storage->IHTMLStorage_iface;
216 return S_OK;