Ensure MSSTYLES_SetActiveTheme fails properly when theme is invalid.
[wine] / dlls / dmstyle / dmstyle_main.c
1 /* DirectMusicStyle Main
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program 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
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "dmstyle_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
23
24 typedef struct {
25     /* IUnknown fields */
26     ICOM_VFIELD(IClassFactory);
27     DWORD                       ref;
28 } IClassFactoryImpl;
29
30 /******************************************************************
31  *              DirectMusicSection ClassFactory
32  */
33 static HRESULT WINAPI SectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
34         ICOM_THIS(IClassFactoryImpl,iface);
35         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
36         return E_NOINTERFACE;
37 }
38
39 static ULONG WINAPI SectionCF_AddRef(LPCLASSFACTORY iface) {
40         ICOM_THIS(IClassFactoryImpl,iface);
41         return ++(This->ref);
42 }
43
44 static ULONG WINAPI SectionCF_Release(LPCLASSFACTORY iface) {
45         ICOM_THIS(IClassFactoryImpl,iface);
46         /* static class, won't be  freed */
47         return --(This->ref);
48 }
49
50 static HRESULT WINAPI SectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
51         ICOM_THIS(IClassFactoryImpl,iface);
52         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
53         /* nothing here yet */
54         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
55         return E_NOINTERFACE;
56 }
57
58 static HRESULT WINAPI SectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
59         ICOM_THIS(IClassFactoryImpl,iface);
60         FIXME("(%p)->(%d),stub!\n", This, dolock);
61         return S_OK;
62 }
63
64 static ICOM_VTABLE(IClassFactory) SectionCF_Vtbl = {
65         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
66         SectionCF_QueryInterface,
67         SectionCF_AddRef,
68         SectionCF_Release,
69         SectionCF_CreateInstance,
70         SectionCF_LockServer
71 };
72
73 static IClassFactoryImpl Section_CF = {&SectionCF_Vtbl, 1 };
74
75 /******************************************************************
76  *              DirectMusicStyle ClassFactory
77  */
78 static HRESULT WINAPI StyleCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
79         ICOM_THIS(IClassFactoryImpl,iface);
80         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
81         return E_NOINTERFACE;
82 }
83
84 static ULONG WINAPI StyleCF_AddRef(LPCLASSFACTORY iface) {
85         ICOM_THIS(IClassFactoryImpl,iface);
86         return ++(This->ref);
87 }
88
89 static ULONG WINAPI StyleCF_Release(LPCLASSFACTORY iface) {
90         ICOM_THIS(IClassFactoryImpl,iface);
91         /* static class, won't be  freed */
92         return --(This->ref);
93 }
94
95 static HRESULT WINAPI StyleCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
96         ICOM_THIS(IClassFactoryImpl,iface);
97         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
98         return DMUSIC_CreateDirectMusicStyleImpl (riid, ppobj, pOuter);
99 }
100
101 static HRESULT WINAPI StyleCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
102         ICOM_THIS(IClassFactoryImpl,iface);
103         FIXME("(%p)->(%d),stub!\n", This, dolock);
104         return S_OK;
105 }
106
107 static ICOM_VTABLE(IClassFactory) StyleCF_Vtbl = {
108         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
109         StyleCF_QueryInterface,
110         StyleCF_AddRef,
111         StyleCF_Release,
112         StyleCF_CreateInstance,
113         StyleCF_LockServer
114 };
115
116 static IClassFactoryImpl Style_CF = {&StyleCF_Vtbl, 1 };
117
118 /******************************************************************
119  *              DirectMusicChordTrack ClassFactory
120  */
121 static HRESULT WINAPI ChordTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
122         ICOM_THIS(IClassFactoryImpl,iface);
123         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
124         return E_NOINTERFACE;
125 }
126
127 static ULONG WINAPI ChordTrackCF_AddRef(LPCLASSFACTORY iface) {
128         ICOM_THIS(IClassFactoryImpl,iface);
129         return ++(This->ref);
130 }
131
132 static ULONG WINAPI ChordTrackCF_Release(LPCLASSFACTORY iface) {
133         ICOM_THIS(IClassFactoryImpl,iface);
134         /* static class, won't be  freed */
135         return --(This->ref);
136 }
137
138 static HRESULT WINAPI ChordTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
139         ICOM_THIS(IClassFactoryImpl,iface);
140         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
141         return DMUSIC_CreateDirectMusicChordTrack (riid, ppobj, pOuter);
142 }
143
144 static HRESULT WINAPI ChordTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
145         ICOM_THIS(IClassFactoryImpl,iface);
146         FIXME("(%p)->(%d),stub!\n", This, dolock);
147         return S_OK;
148 }
149
150 static ICOM_VTABLE(IClassFactory) ChordTrackCF_Vtbl = {
151         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
152         ChordTrackCF_QueryInterface,
153         ChordTrackCF_AddRef,
154         ChordTrackCF_Release,
155         ChordTrackCF_CreateInstance,
156         ChordTrackCF_LockServer
157 };
158
159 static IClassFactoryImpl ChordTrack_CF = {&ChordTrackCF_Vtbl, 1 };
160
161 /******************************************************************
162  *              DirectMusicCommandTrack ClassFactory
163  */
164 static HRESULT WINAPI CommandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
165         ICOM_THIS(IClassFactoryImpl,iface);
166         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
167         return E_NOINTERFACE;
168 }
169
170 static ULONG WINAPI CommandTrackCF_AddRef(LPCLASSFACTORY iface) {
171         ICOM_THIS(IClassFactoryImpl,iface);
172         return ++(This->ref);
173 }
174
175 static ULONG WINAPI CommandTrackCF_Release(LPCLASSFACTORY iface) {
176         ICOM_THIS(IClassFactoryImpl,iface);
177         /* static class, won't be  freed */
178         return --(This->ref);
179 }
180
181 static HRESULT WINAPI CommandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
182         ICOM_THIS(IClassFactoryImpl,iface);
183         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
184         return DMUSIC_CreateDirectMusicCommandTrack (riid, ppobj, pOuter);
185 }
186
187 static HRESULT WINAPI CommandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
188         ICOM_THIS(IClassFactoryImpl,iface);
189         FIXME("(%p)->(%d),stub!\n", This, dolock);
190         return S_OK;
191 }
192
193 static ICOM_VTABLE(IClassFactory) CommandTrackCF_Vtbl = {
194         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
195         CommandTrackCF_QueryInterface,
196         CommandTrackCF_AddRef,
197         CommandTrackCF_Release,
198         CommandTrackCF_CreateInstance,
199         CommandTrackCF_LockServer
200 };
201
202 static IClassFactoryImpl CommandTrack_CF = {&CommandTrackCF_Vtbl, 1 };
203
204 /******************************************************************
205  *              DirectMusicStyleTrack ClassFactory
206  */
207 static HRESULT WINAPI StyleTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
208         ICOM_THIS(IClassFactoryImpl,iface);
209         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
210         return E_NOINTERFACE;
211 }
212
213 static ULONG WINAPI StyleTrackCF_AddRef(LPCLASSFACTORY iface) {
214         ICOM_THIS(IClassFactoryImpl,iface);
215         return ++(This->ref);
216 }
217
218 static ULONG WINAPI StyleTrackCF_Release(LPCLASSFACTORY iface) {
219         ICOM_THIS(IClassFactoryImpl,iface);
220         /* static class, won't be  freed */
221         return --(This->ref);
222 }
223
224 static HRESULT WINAPI StyleTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
225         ICOM_THIS(IClassFactoryImpl,iface);
226         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
227         return DMUSIC_CreateDirectMusicStyleTrack (riid, ppobj, pOuter);
228 }
229
230 static HRESULT WINAPI StyleTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
231         ICOM_THIS(IClassFactoryImpl,iface);
232         FIXME("(%p)->(%d),stub!\n", This, dolock);
233         return S_OK;
234 }
235
236 static ICOM_VTABLE(IClassFactory) StyleTrackCF_Vtbl = {
237         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
238         StyleTrackCF_QueryInterface,
239         StyleTrackCF_AddRef,
240         StyleTrackCF_Release,
241         StyleTrackCF_CreateInstance,
242         StyleTrackCF_LockServer
243 };
244
245 static IClassFactoryImpl StyleTrack_CF = {&StyleTrackCF_Vtbl, 1 };
246
247 /******************************************************************
248  *              DirectMusicMotifTrack ClassFactory
249  */
250 static HRESULT WINAPI MotifTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
251         ICOM_THIS(IClassFactoryImpl,iface);
252         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
253         return E_NOINTERFACE;
254 }
255
256 static ULONG WINAPI MotifTrackCF_AddRef(LPCLASSFACTORY iface) {
257         ICOM_THIS(IClassFactoryImpl,iface);
258         return ++(This->ref);
259 }
260
261 static ULONG WINAPI MotifTrackCF_Release(LPCLASSFACTORY iface) {
262         ICOM_THIS(IClassFactoryImpl,iface);
263         /* static class, won't be  freed */
264         return --(This->ref);
265 }
266
267 static HRESULT WINAPI MotifTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
268         ICOM_THIS(IClassFactoryImpl,iface);
269         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
270         return DMUSIC_CreateDirectMusicMotifTrack (riid, ppobj, pOuter);
271 }
272
273 static HRESULT WINAPI MotifTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
274         ICOM_THIS(IClassFactoryImpl,iface);
275         FIXME("(%p)->(%d),stub!\n", This, dolock);
276         return S_OK;
277 }
278
279 static ICOM_VTABLE(IClassFactory) MotifTrackCF_Vtbl = {
280         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
281         MotifTrackCF_QueryInterface,
282         MotifTrackCF_AddRef,
283         MotifTrackCF_Release,
284         MotifTrackCF_CreateInstance,
285         MotifTrackCF_LockServer
286 };
287
288 static IClassFactoryImpl MotifTrack_CF = {&MotifTrackCF_Vtbl, 1 };
289
290 /******************************************************************
291  *              DirectMusicAuditionTrack ClassFactory
292  */
293 static HRESULT WINAPI AuditionTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
294         ICOM_THIS(IClassFactoryImpl,iface);
295         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
296         return E_NOINTERFACE;
297 }
298
299 static ULONG WINAPI AuditionTrackCF_AddRef(LPCLASSFACTORY iface) {
300         ICOM_THIS(IClassFactoryImpl,iface);
301         return ++(This->ref);
302 }
303
304 static ULONG WINAPI AuditionTrackCF_Release(LPCLASSFACTORY iface) {
305         ICOM_THIS(IClassFactoryImpl,iface);
306         /* static class, won't be  freed */
307         return --(This->ref);
308 }
309
310 static HRESULT WINAPI AuditionTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
311         ICOM_THIS(IClassFactoryImpl,iface);
312         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
313         return DMUSIC_CreateDirectMusicAuditionTrack (riid, ppobj, pOuter);
314 }
315
316 static HRESULT WINAPI AuditionTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
317         ICOM_THIS(IClassFactoryImpl,iface);
318         FIXME("(%p)->(%d),stub!\n", This, dolock);
319         return S_OK;
320 }
321
322 static ICOM_VTABLE(IClassFactory) AuditionTrackCF_Vtbl = {
323         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
324         AuditionTrackCF_QueryInterface,
325         AuditionTrackCF_AddRef,
326         AuditionTrackCF_Release,
327         AuditionTrackCF_CreateInstance,
328         AuditionTrackCF_LockServer
329 };
330
331 static IClassFactoryImpl AuditionTrack_CF = {&AuditionTrackCF_Vtbl, 1 };
332
333 /******************************************************************
334  *              DirectMusicMuteTrack ClassFactory
335  */
336 static HRESULT WINAPI MuteTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
337         ICOM_THIS(IClassFactoryImpl,iface);
338         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
339         return E_NOINTERFACE;
340 }
341
342 static ULONG WINAPI MuteTrackCF_AddRef(LPCLASSFACTORY iface) {
343         ICOM_THIS(IClassFactoryImpl,iface);
344         return ++(This->ref);
345 }
346
347 static ULONG WINAPI MuteTrackCF_Release(LPCLASSFACTORY iface) {
348         ICOM_THIS(IClassFactoryImpl,iface);
349         /* static class, won't be  freed */
350         return --(This->ref);
351 }
352
353 static HRESULT WINAPI MuteTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
354         ICOM_THIS(IClassFactoryImpl,iface);
355         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
356         return DMUSIC_CreateDirectMusicMuteTrack (riid, ppobj, pOuter);
357 }
358
359 static HRESULT WINAPI MuteTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
360         ICOM_THIS(IClassFactoryImpl,iface);
361         FIXME("(%p)->(%d),stub!\n", This, dolock);
362         return S_OK;
363 }
364
365 static ICOM_VTABLE(IClassFactory) MuteTrackCF_Vtbl = {
366         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
367         MuteTrackCF_QueryInterface,
368         MuteTrackCF_AddRef,
369         MuteTrackCF_Release,
370         MuteTrackCF_CreateInstance,
371         MuteTrackCF_LockServer
372 };
373
374 static IClassFactoryImpl MuteTrack_CF = {&MuteTrackCF_Vtbl, 1 };
375
376 /******************************************************************
377  *              DllMain
378  *
379  *
380  */
381 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
382         if (fdwReason == DLL_PROCESS_ATTACH) {
383             DisableThreadLibraryCalls(hinstDLL);
384                 /* FIXME: Initialisation */
385         } else if (fdwReason == DLL_PROCESS_DETACH) {
386                 /* FIXME: Cleanup */
387         }
388
389         return TRUE;
390 }
391
392
393 /******************************************************************
394  *              DllCanUnloadNow (DMSTYLE.1)
395  *
396  *
397  */
398 HRESULT WINAPI DMSTYLE_DllCanUnloadNow(void) {
399     FIXME("(void): stub\n");
400     return S_FALSE;
401 }
402
403
404 /******************************************************************
405  *              DllGetClassObject (DMSTYLE.2)
406  *
407  *
408  */
409 HRESULT WINAPI DMSTYLE_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
410     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
411     
412         if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSection) && IsEqualIID (riid, &IID_IClassFactory)) {
413                 *ppv = (LPVOID) &Section_CF;
414                 IClassFactory_AddRef((IClassFactory*)*ppv);
415                 return S_OK;
416         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyle) && IsEqualIID (riid, &IID_IClassFactory)) {
417                 *ppv = (LPVOID) &Style_CF;
418                 IClassFactory_AddRef((IClassFactory*)*ppv);
419                 return S_OK;            
420         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
421                 *ppv = (LPVOID) &ChordTrack_CF;
422                 IClassFactory_AddRef((IClassFactory*)*ppv);
423                 return S_OK;    
424         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCommandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
425                 *ppv = (LPVOID) &CommandTrack_CF;
426                 IClassFactory_AddRef((IClassFactory*)*ppv);
427                 return S_OK;            
428         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyleTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
429                 *ppv = (LPVOID) &StyleTrack_CF;
430                 IClassFactory_AddRef((IClassFactory*)*ppv);
431                 return S_OK;            
432         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMotifTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
433                 *ppv = (LPVOID) &MotifTrack_CF;
434                 IClassFactory_AddRef((IClassFactory*)*ppv);
435                 return S_OK;            
436         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAuditionTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
437                 *ppv = (LPVOID) &AuditionTrack_CF;
438                 IClassFactory_AddRef((IClassFactory*)*ppv);
439                 return S_OK;            
440         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMuteTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
441                 *ppv = (LPVOID) &MuteTrack_CF;
442                 IClassFactory_AddRef((IClassFactory*)*ppv);
443                 return S_OK;            
444         }
445
446     WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
447     return CLASS_E_CLASSNOTAVAILABLE;
448 }