winex11: add owned windows to taskbar if owner is not mapped
[wine] / dlls / mshtml / dispex.c
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27
28 #include "wine/debug.h"
29
30 #include "mshtml_private.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
33
34 static ITypeLib *typelib;
35 static ITypeInfo *typeinfos[LAST_tid];
36
37 static REFIID tid_ids[] = {
38     &IID_IHTMLWindow2,
39 };
40
41 HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
42 {
43     HRESULT hres;
44
45     if(!typelib) {
46         ITypeLib *tl;
47
48         hres = LoadRegTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, &tl);
49         if(FAILED(hres)) {
50             ERR("LoadRegTypeLib failed: %08x\n", hres);
51             return hres;
52         }
53
54         if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
55             ITypeLib_Release(tl);
56     }
57
58     if(!typeinfos[tid]) {
59         ITypeInfo *typeinfo;
60
61         hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
62         if(FAILED(hres)) {
63             ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
64             return hres;
65         }
66
67         if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
68             ITypeInfo_Release(typeinfo);
69     }
70
71     *typeinfo = typeinfos[tid];
72     return S_OK;
73 }
74
75 void release_typelib(void)
76 {
77     unsigned i;
78
79     if(!typelib)
80         return;
81
82     for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
83         if(typeinfos[i])
84             ITypeInfo_Release(typeinfos[i]);
85
86     ITypeLib_Release(typelib);
87 }
88
89 #define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface)
90
91 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
92 {
93     DispatchEx *This = DISPATCHEX_THIS(iface);
94
95     return IUnknown_QueryInterface(This->outer, riid, ppv);
96 }
97
98 static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
99 {
100     DispatchEx *This = DISPATCHEX_THIS(iface);
101
102     return IUnknown_AddRef(This->outer);
103 }
104
105 static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
106 {
107     DispatchEx *This = DISPATCHEX_THIS(iface);
108
109     return IUnknown_Release(This->outer);
110 }
111
112 static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
113 {
114     DispatchEx *This = DISPATCHEX_THIS(iface);
115
116     TRACE("(%p)->(%p)\n", This, pctinfo);
117
118     *pctinfo = 1;
119     return S_OK;
120 }
121
122 static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
123                                               LCID lcid, ITypeInfo **ppTInfo)
124 {
125     DispatchEx *This = DISPATCHEX_THIS(iface);
126     FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127     return E_NOTIMPL;
128 }
129
130 static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
131                                                 LPOLESTR *rgszNames, UINT cNames,
132                                                 LCID lcid, DISPID *rgDispId)
133 {
134     DispatchEx *This = DISPATCHEX_THIS(iface);
135     FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
136           lcid, rgDispId);
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
141                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
142                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
143 {
144     DispatchEx *This = DISPATCHEX_THIS(iface);
145     FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
146           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
147     return E_NOTIMPL;
148 }
149
150 static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
151 {
152     DispatchEx *This = DISPATCHEX_THIS(iface);
153     FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
154     return E_NOTIMPL;
155 }
156
157 static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
158         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
159 {
160     DispatchEx *This = DISPATCHEX_THIS(iface);
161     FIXME("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
162     return E_NOTIMPL;
163 }
164
165 static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
166 {
167     DispatchEx *This = DISPATCHEX_THIS(iface);
168     FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
169     return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
173 {
174     DispatchEx *This = DISPATCHEX_THIS(iface);
175     FIXME("(%p)->(%x)\n", This, id);
176     return E_NOTIMPL;
177 }
178
179 static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
180 {
181     DispatchEx *This = DISPATCHEX_THIS(iface);
182     FIXME("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
183     return E_NOTIMPL;
184 }
185
186 static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
187 {
188     DispatchEx *This = DISPATCHEX_THIS(iface);
189     FIXME("(%p)->(%x %p)\n", This, id, pbstrName);
190     return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
194 {
195     DispatchEx *This = DISPATCHEX_THIS(iface);
196     FIXME("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
197     return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
201 {
202     DispatchEx *This = DISPATCHEX_THIS(iface);
203     FIXME("(%p)->(%p)\n", This, ppunk);
204     return E_NOTIMPL;
205 }
206
207 #undef DISPATCHEX_THIS
208
209 static IDispatchExVtbl DispatchExVtbl = {
210     DispatchEx_QueryInterface,
211     DispatchEx_AddRef,
212     DispatchEx_Release,
213     DispatchEx_GetTypeInfoCount,
214     DispatchEx_GetTypeInfo,
215     DispatchEx_GetIDsOfNames,
216     DispatchEx_Invoke,
217     DispatchEx_GetDispID,
218     DispatchEx_InvokeEx,
219     DispatchEx_DeleteMemberByName,
220     DispatchEx_DeleteMemberByDispID,
221     DispatchEx_GetMemberProperties,
222     DispatchEx_GetMemberName,
223     DispatchEx_GetNextDispID,
224     DispatchEx_GetNameSpaceParent
225 };
226
227 void init_dispex(DispatchEx *dispex, IUnknown *outer)
228 {
229     dispex->lpIDispatchExVtbl = &DispatchExVtbl;
230     dispex->outer = outer;
231 }