mshtml: Implement IHTMLStorage GetTypeInfoCount.
[wine/multimedia.git] / dlls / mshtml / htmlstorage.c
blob544ab8aabb0c895357e1952e3f46b8c9b55032fc
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 *ppv = NULL;
51 if(IsEqualGUID(&IID_IUnknown, riid)) {
52 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
53 *ppv = &This->IHTMLStorage_iface;
54 }else if(IsEqualGUID(&IID_IHTMLStorage, riid)) {
55 TRACE("(%p)->(IID_IHTMLStorage %p)\n", This, ppv);
56 *ppv = &This->IHTMLStorage_iface;
57 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
58 return *ppv ? S_OK : E_NOINTERFACE;
61 if(*ppv) {
62 IUnknown_AddRef((IUnknown*)*ppv);
63 return S_OK;
66 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
67 return E_NOINTERFACE;
70 static ULONG WINAPI HTMLStorage_AddRef(IHTMLStorage *iface)
72 HTMLStorage *This = impl_from_IHTMLStorage(iface);
73 LONG ref = InterlockedIncrement(&This->ref);
75 TRACE("(%p) ref=%d\n", This, ref);
77 return ref;
80 static ULONG WINAPI HTMLStorage_Release(IHTMLStorage *iface)
82 HTMLStorage *This = impl_from_IHTMLStorage(iface);
83 LONG ref = InterlockedDecrement(&This->ref);
85 TRACE("(%p) ref=%d\n", This, ref);
87 if(!ref) {
88 release_dispex(&This->dispex);
89 heap_free(This);
92 return ref;
95 static HRESULT WINAPI HTMLStorage_GetTypeInfoCount(IHTMLStorage *iface, UINT *pctinfo)
97 HTMLStorage *This = impl_from_IHTMLStorage(iface);
98 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
101 static HRESULT WINAPI HTMLStorage_GetTypeInfo(IHTMLStorage *iface, UINT iTInfo,
102 LCID lcid, ITypeInfo **ppTInfo)
104 HTMLStorage *This = impl_from_IHTMLStorage(iface);
106 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
109 static HRESULT WINAPI HTMLStorage_GetIDsOfNames(IHTMLStorage *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
110 LCID lcid, DISPID *rgDispId)
112 HTMLStorage *This = impl_from_IHTMLStorage(iface);
114 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
115 lcid, rgDispId);
118 static HRESULT WINAPI HTMLStorage_Invoke(IHTMLStorage *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
119 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
121 HTMLStorage *This = impl_from_IHTMLStorage(iface);
123 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
124 pDispParams, pVarResult, pExcepInfo, puArgErr);
127 static HRESULT WINAPI HTMLStorage_get_length(IHTMLStorage *iface, LONG *p)
129 HTMLStorage *This = impl_from_IHTMLStorage(iface);
130 FIXME("(%p)->(%p)\n", This, p);
131 return E_NOTIMPL;
134 static HRESULT WINAPI HTMLStorage_get_remainingSpace(IHTMLStorage *iface, LONG *p)
136 HTMLStorage *This = impl_from_IHTMLStorage(iface);
137 FIXME("(%p)->(%p)\n", This, p);
138 return E_NOTIMPL;
141 static HRESULT WINAPI HTMLStorage_key(IHTMLStorage *iface, LONG lIndex, BSTR *p)
143 HTMLStorage *This = impl_from_IHTMLStorage(iface);
144 FIXME("(%p)->(%d %p)\n", This, lIndex, p);
145 return E_NOTIMPL;
148 static HRESULT WINAPI HTMLStorage_getItem(IHTMLStorage *iface, BSTR bstrKey, VARIANT *p)
150 HTMLStorage *This = impl_from_IHTMLStorage(iface);
151 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrKey), p);
152 return E_NOTIMPL;
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 NULL,
201 HTMLStorage_iface_tids
204 HRESULT create_storage(IHTMLStorage **p)
206 HTMLStorage *storage;
208 storage = heap_alloc_zero(sizeof(*storage));
209 if(!storage)
210 return E_OUTOFMEMORY;
212 storage->IHTMLStorage_iface.lpVtbl = &HTMLStorageVtbl;
213 storage->ref = 1;
214 init_dispex(&storage->dispex, (IUnknown*)&storage->IHTMLStorage_iface, &HTMLStorage_dispex);
216 *p = &storage->IHTMLStorage_iface;
217 return S_OK;