mshtml: Rename call_event to fire_event.
[wine] / dlls / ieframe / taskbarlist.c
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  * Copyright 2011 AndrĂ© Hentschel
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  *
19  */
20
21 #include "ieframe.h"
22
23 #include "wine/debug.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
26
27 struct taskbar_list
28 {
29     ITaskbarList4 ITaskbarList4_iface;
30     LONG refcount;
31 };
32
33 static inline struct taskbar_list *impl_from_ITaskbarList4(ITaskbarList4 *iface)
34 {
35     return CONTAINING_RECORD(iface, struct taskbar_list, ITaskbarList4_iface);
36 }
37
38 /* IUnknown methods */
39
40 static HRESULT STDMETHODCALLTYPE taskbar_list_QueryInterface(ITaskbarList4 *iface, REFIID riid, void **object)
41 {
42     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
43
44     if (IsEqualGUID(riid, &IID_ITaskbarList) ||
45         IsEqualGUID(riid, &IID_ITaskbarList2) ||
46         IsEqualGUID(riid, &IID_ITaskbarList3) ||
47         IsEqualGUID(riid, &IID_ITaskbarList4) ||
48         IsEqualGUID(riid, &IID_IUnknown))
49     {
50         IUnknown_AddRef(iface);
51         *object = iface;
52         return S_OK;
53     }
54
55     WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
56
57     *object = NULL;
58     return E_NOINTERFACE;
59 }
60
61 static ULONG STDMETHODCALLTYPE taskbar_list_AddRef(ITaskbarList4 *iface)
62 {
63     struct taskbar_list *This = impl_from_ITaskbarList4(iface);
64     ULONG refcount = InterlockedIncrement(&This->refcount);
65
66     TRACE("%p increasing refcount to %u\n", This, refcount);
67
68     return refcount;
69 }
70
71 static ULONG STDMETHODCALLTYPE taskbar_list_Release(ITaskbarList4 *iface)
72 {
73     struct taskbar_list *This = impl_from_ITaskbarList4(iface);
74     ULONG refcount = InterlockedDecrement(&This->refcount);
75
76     TRACE("%p decreasing refcount to %u\n", This, refcount);
77
78     if (!refcount)
79     {
80         heap_free(This);
81         unlock_module();
82     }
83
84     return refcount;
85 }
86
87 /* ITaskbarList methods */
88
89 static HRESULT STDMETHODCALLTYPE taskbar_list_HrInit(ITaskbarList4 *iface)
90 {
91     TRACE("iface %p\n", iface);
92
93     return S_OK;
94 }
95
96 static HRESULT STDMETHODCALLTYPE taskbar_list_AddTab(ITaskbarList4 *iface, HWND hwnd)
97 {
98     FIXME("iface %p, hwnd %p stub!\n", iface, hwnd);
99
100     return E_NOTIMPL;
101 }
102
103 static HRESULT STDMETHODCALLTYPE taskbar_list_DeleteTab(ITaskbarList4 *iface, HWND hwnd)
104 {
105     FIXME("iface %p, hwnd %p stub!\n", iface, hwnd);
106
107     return E_NOTIMPL;
108 }
109
110 static HRESULT STDMETHODCALLTYPE taskbar_list_ActivateTab(ITaskbarList4 *iface, HWND hwnd)
111 {
112     FIXME("iface %p, hwnd %p stub!\n", iface, hwnd);
113
114     return E_NOTIMPL;
115 }
116
117 static HRESULT STDMETHODCALLTYPE taskbar_list_SetActiveAlt(ITaskbarList4 *iface, HWND hwnd)
118 {
119     FIXME("iface %p, hwnd %p stub!\n", iface, hwnd);
120
121     return E_NOTIMPL;
122 }
123
124 /* ITaskbarList2 method */
125
126 static HRESULT STDMETHODCALLTYPE taskbar_list_MarkFullscreenWindow(ITaskbarList4 *iface,
127                                                                    HWND hwnd,
128                                                                    BOOL fullscreen)
129 {
130     FIXME("iface %p, hwnd %p, fullscreen %s stub!\n", iface, hwnd, (fullscreen)?"true":"false");
131
132     return E_NOTIMPL;
133 }
134
135 /* ITaskbarList3 methods */
136
137 static HRESULT STDMETHODCALLTYPE taskbar_list_SetProgressValue(ITaskbarList4 *iface,
138                                                                HWND hwnd,
139                                                                ULONGLONG ullCompleted,
140                                                                ULONGLONG ullTotal)
141 {
142     FIXME("iface %p, hwnd %p, ullCompleted %s, ullTotal %s stub!\n", iface, hwnd,
143           wine_dbgstr_longlong(ullCompleted), wine_dbgstr_longlong(ullTotal));
144
145     return S_OK;
146 }
147
148 static HRESULT STDMETHODCALLTYPE taskbar_list_SetProgressState(ITaskbarList4 *iface,
149                                                                HWND hwnd,
150                                                                TBPFLAG tbpFlags)
151 {
152     FIXME("iface %p, hwnd %p, flags %x stub!\n", iface, hwnd, tbpFlags);
153
154     return S_OK;
155 }
156
157 static HRESULT STDMETHODCALLTYPE taskbar_list_RegisterTab(ITaskbarList4 *iface, HWND hwndTab, HWND hwndMDI)
158 {
159     FIXME("iface %p, hwndTab %p, hwndMDI %p stub!\n", iface, hwndTab, hwndMDI);
160
161     return E_NOTIMPL;
162 }
163
164 static HRESULT STDMETHODCALLTYPE taskbar_list_UnregisterTab(ITaskbarList4 *iface, HWND hwndTab)
165 {
166     FIXME("iface %p, hwndTab %p stub!\n", iface, hwndTab);
167
168     return E_NOTIMPL;
169 }
170
171 static HRESULT STDMETHODCALLTYPE taskbar_list_SetTabOrder(ITaskbarList4 *iface,
172                                                           HWND hwndTab,
173                                                           HWND hwndInsertBefore)
174 {
175     FIXME("iface %p, hwndTab %p, hwndInsertBefore %p stub!\n", iface, hwndTab, hwndInsertBefore);
176
177     return E_NOTIMPL;
178 }
179
180 static HRESULT STDMETHODCALLTYPE taskbar_list_SetTabActive(ITaskbarList4 *iface,
181                                                           HWND hwndTab,
182                                                           HWND hwndMDI,
183                                                           DWORD dwReserved)
184 {
185     FIXME("iface %p, hwndTab %p, hwndMDI %p, dwReserved %x stub!\n", iface, hwndTab, hwndMDI, dwReserved);
186
187     return E_NOTIMPL;
188 }
189
190 static HRESULT STDMETHODCALLTYPE taskbar_list_ThumbBarAddButtons(ITaskbarList4 *iface,
191                                                                  HWND hwnd,
192                                                                  UINT cButtons,
193                                                                  LPTHUMBBUTTON pButton)
194 {
195     FIXME("iface %p, hwnd %p, cButtons %u, pButton %p stub!\n", iface, hwnd, cButtons, pButton);
196
197     return E_NOTIMPL;
198 }
199
200 static HRESULT STDMETHODCALLTYPE taskbar_list_ThumbBarUpdateButtons(ITaskbarList4 *iface,
201                                                                    HWND hwnd,
202                                                                    UINT cButtons,
203                                                                    LPTHUMBBUTTON pButton)
204 {
205     FIXME("iface %p, hwnd %p, cButtons %u, pButton %p stub!\n", iface, hwnd, cButtons, pButton);
206
207     return E_NOTIMPL;
208 }
209
210 static HRESULT STDMETHODCALLTYPE taskbar_list_ThumbBarSetImageList(ITaskbarList4 *iface,
211                                                                    HWND hwnd,
212                                                                    HIMAGELIST himl)
213 {
214     FIXME("iface %p, hwnd %p, himl %p stub!\n", iface, hwnd, himl);
215
216     return E_NOTIMPL;
217 }
218
219 static HRESULT STDMETHODCALLTYPE taskbar_list_SetOverlayIcon(ITaskbarList4 *iface,
220                                                              HWND hwnd,
221                                                              HICON hIcon,
222                                                              LPCWSTR pszDescription)
223 {
224     FIXME("iface %p, hwnd %p, hIcon %p, pszDescription %s stub!\n", iface, hwnd, hIcon,
225           debugstr_w(pszDescription));
226
227     return E_NOTIMPL;
228 }
229
230 static HRESULT STDMETHODCALLTYPE taskbar_list_SetThumbnailTooltip(ITaskbarList4 *iface,
231                                                                   HWND hwnd,
232                                                                   LPCWSTR pszTip)
233 {
234     FIXME("iface %p, hwnd %p, pszTip %s stub!\n", iface, hwnd, debugstr_w(pszTip));
235
236     return E_NOTIMPL;
237 }
238
239 static HRESULT STDMETHODCALLTYPE taskbar_list_SetThumbnailClip(ITaskbarList4 *iface,
240                                                                HWND hwnd,
241                                                                RECT *prcClip)
242 {
243     FIXME("iface %p, hwnd %p, prcClip %s stub!\n", iface, hwnd, wine_dbgstr_rect(prcClip));
244
245     return E_NOTIMPL;
246 }
247
248 /* ITaskbarList4 method */
249
250 static HRESULT STDMETHODCALLTYPE taskbar_list_SetTabProperties(ITaskbarList4 *iface,
251                                                                HWND hwndTab,
252                                                                STPFLAG stpFlags)
253 {
254     FIXME("iface %p, hwndTab %p, stpFlags %u stub!\n", iface, hwndTab, stpFlags);
255
256     return E_NOTIMPL;
257 }
258
259 static const struct ITaskbarList4Vtbl taskbar_list_vtbl =
260 {
261     /* IUnknown methods */
262     taskbar_list_QueryInterface,
263     taskbar_list_AddRef,
264     taskbar_list_Release,
265     /* ITaskbarList methods */
266     taskbar_list_HrInit,
267     taskbar_list_AddTab,
268     taskbar_list_DeleteTab,
269     taskbar_list_ActivateTab,
270     taskbar_list_SetActiveAlt,
271     /* ITaskbarList2 method */
272     taskbar_list_MarkFullscreenWindow,
273     /* ITaskbarList3 methods */
274     taskbar_list_SetProgressValue,
275     taskbar_list_SetProgressState,
276     taskbar_list_RegisterTab,
277     taskbar_list_UnregisterTab,
278     taskbar_list_SetTabOrder,
279     taskbar_list_SetTabActive,
280     taskbar_list_ThumbBarAddButtons,
281     taskbar_list_ThumbBarUpdateButtons,
282     taskbar_list_ThumbBarSetImageList,
283     taskbar_list_SetOverlayIcon,
284     taskbar_list_SetThumbnailTooltip,
285     taskbar_list_SetThumbnailClip,
286     /* ITaskbarList4 method */
287     taskbar_list_SetTabProperties,
288 };
289
290 HRESULT WINAPI TaskbarList_Create(IClassFactory *iface, IUnknown *outer, REFIID riid, void **taskbar_list)
291 {
292     struct taskbar_list *object;
293     HRESULT hres;
294
295     TRACE("outer %p, riid %s, taskbar_list %p\n", outer, debugstr_guid(riid), taskbar_list);
296
297     if (outer)
298     {
299         WARN("Aggregation not supported\n");
300         *taskbar_list = NULL;
301         return CLASS_E_NOAGGREGATION;
302     }
303
304     object = heap_alloc_zero(sizeof(*object));
305     if (!object)
306     {
307         ERR("Failed to allocate taskbar list object memory\n");
308         *taskbar_list = NULL;
309         return E_OUTOFMEMORY;
310     }
311
312     object->ITaskbarList4_iface.lpVtbl = &taskbar_list_vtbl;
313     object->refcount = 1;
314     lock_module();
315
316     TRACE("Created ITaskbarList4 %p\n", object);
317
318     hres = ITaskbarList4_QueryInterface(&object->ITaskbarList4_iface, riid, taskbar_list);
319     ITaskbarList4_Release(&object->ITaskbarList4_iface);
320     return hres;
321 }