Rename MODULENAME_Dll* functions to Dll* for better consistency and
[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 LONG DMSTYLE_refCount = 0;
25
26 typedef struct {
27     IClassFactoryVtbl          *lpVtbl;
28 } IClassFactoryImpl;
29
30 /******************************************************************
31  *              DirectMusicSection ClassFactory
32  */
33 static HRESULT WINAPI SectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
34         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
35
36         if (ppobj == NULL) return E_POINTER;
37         
38         return E_NOINTERFACE;
39 }
40
41 static ULONG WINAPI SectionCF_AddRef(LPCLASSFACTORY iface) {
42         DMSTYLE_LockModule();
43
44         return 2; /* non-heap based object */
45 }
46
47 static ULONG WINAPI SectionCF_Release(LPCLASSFACTORY iface) {
48         DMSTYLE_UnlockModule();
49
50         return 1; /* non-heap based object */
51 }
52
53 static HRESULT WINAPI SectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
54         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
55
56         /* nothing here yet */
57         WARN("(%s, %p): not found\n", debugstr_dmguid(riid), ppobj);
58         
59         return E_NOINTERFACE;
60 }
61
62 static HRESULT WINAPI SectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
63         TRACE("(%d)\n", dolock);
64
65         if (dolock)
66                 DMSTYLE_LockModule();
67         else
68                 DMSTYLE_UnlockModule();
69
70         return S_OK;
71 }
72
73 static IClassFactoryVtbl SectionCF_Vtbl = {
74         SectionCF_QueryInterface,
75         SectionCF_AddRef,
76         SectionCF_Release,
77         SectionCF_CreateInstance,
78         SectionCF_LockServer
79 };
80
81 static IClassFactoryImpl Section_CF = {&SectionCF_Vtbl};
82
83 /******************************************************************
84  *              DirectMusicStyle ClassFactory
85  */
86 static HRESULT WINAPI StyleCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
87         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
88
89         if (ppobj == NULL) return E_POINTER;
90         
91         return E_NOINTERFACE;
92 }
93
94 static ULONG WINAPI StyleCF_AddRef(LPCLASSFACTORY iface) {
95         DMSTYLE_LockModule();
96
97         return 2; /* non-heap based object */
98 }
99
100 static ULONG WINAPI StyleCF_Release(LPCLASSFACTORY iface) {
101         DMSTYLE_UnlockModule();
102
103         return 1; /* non-heap based object */
104 }
105
106 static HRESULT WINAPI StyleCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
107         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
108         
109         return DMUSIC_CreateDirectMusicStyleImpl (riid, ppobj, pOuter);
110 }
111
112 static HRESULT WINAPI StyleCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
113         TRACE("(%d)\n", dolock);
114
115         if (dolock)
116                 DMSTYLE_LockModule();
117         else
118                 DMSTYLE_UnlockModule();
119
120         return S_OK;
121 }
122
123 static IClassFactoryVtbl StyleCF_Vtbl = {
124         StyleCF_QueryInterface,
125         StyleCF_AddRef,
126         StyleCF_Release,
127         StyleCF_CreateInstance,
128         StyleCF_LockServer
129 };
130
131 static IClassFactoryImpl Style_CF = {&StyleCF_Vtbl};
132
133 /******************************************************************
134  *              DirectMusicChordTrack ClassFactory
135  */
136 static HRESULT WINAPI ChordTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
137         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
138
139         if (ppobj == NULL) return E_POINTER;
140         
141         return E_NOINTERFACE;
142 }
143
144 static ULONG WINAPI ChordTrackCF_AddRef(LPCLASSFACTORY iface) {
145         DMSTYLE_LockModule();
146
147         return 2; /* non-heap based object */
148 }
149
150 static ULONG WINAPI ChordTrackCF_Release(LPCLASSFACTORY iface) {
151         DMSTYLE_UnlockModule();
152
153         return 1; /* non-heap based object */
154 }
155
156 static HRESULT WINAPI ChordTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
157         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
158
159         return DMUSIC_CreateDirectMusicChordTrack (riid, ppobj, pOuter);
160 }
161
162 static HRESULT WINAPI ChordTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
163         TRACE("(%d)\n", dolock);
164
165         if (dolock)
166                 DMSTYLE_LockModule();
167         else
168                 DMSTYLE_UnlockModule();
169         
170         return S_OK;
171 }
172
173 static IClassFactoryVtbl ChordTrackCF_Vtbl = {
174         ChordTrackCF_QueryInterface,
175         ChordTrackCF_AddRef,
176         ChordTrackCF_Release,
177         ChordTrackCF_CreateInstance,
178         ChordTrackCF_LockServer
179 };
180
181 static IClassFactoryImpl ChordTrack_CF = {&ChordTrackCF_Vtbl};
182
183 /******************************************************************
184  *              DirectMusicCommandTrack ClassFactory
185  */
186 static HRESULT WINAPI CommandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
187         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
188
189         if (ppobj == NULL) return E_POINTER;
190         
191         return E_NOINTERFACE;
192 }
193
194 static ULONG WINAPI CommandTrackCF_AddRef(LPCLASSFACTORY iface) {
195         DMSTYLE_LockModule();
196
197         return 2; /* non-heap based object */
198 }
199
200 static ULONG WINAPI CommandTrackCF_Release(LPCLASSFACTORY iface) {
201         DMSTYLE_UnlockModule();
202
203         return 1; /* non-heap based object */
204 }
205
206 static HRESULT WINAPI CommandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
207         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
208
209         return DMUSIC_CreateDirectMusicCommandTrack (riid, ppobj, pOuter);
210 }
211
212 static HRESULT WINAPI CommandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
213         TRACE("(%d)\n", dolock);
214
215         if (dolock)
216                 DMSTYLE_LockModule();
217         else
218                 DMSTYLE_UnlockModule();
219         
220         return S_OK;
221 }
222
223 static IClassFactoryVtbl CommandTrackCF_Vtbl = {
224         CommandTrackCF_QueryInterface,
225         CommandTrackCF_AddRef,
226         CommandTrackCF_Release,
227         CommandTrackCF_CreateInstance,
228         CommandTrackCF_LockServer
229 };
230
231 static IClassFactoryImpl CommandTrack_CF = {&CommandTrackCF_Vtbl};
232
233 /******************************************************************
234  *              DirectMusicStyleTrack ClassFactory
235  */
236 static HRESULT WINAPI StyleTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
237         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
238
239         if (ppobj == NULL) return E_POINTER;
240         
241         return E_NOINTERFACE;
242 }
243
244 static ULONG WINAPI StyleTrackCF_AddRef(LPCLASSFACTORY iface) {
245         DMSTYLE_LockModule();
246
247         return 2; /* non-heap based object */
248 }
249
250 static ULONG WINAPI StyleTrackCF_Release(LPCLASSFACTORY iface) {
251         DMSTYLE_UnlockModule();
252
253         return 1; /* non-heap based object */
254 }
255
256 static HRESULT WINAPI StyleTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
257         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
258         
259         return DMUSIC_CreateDirectMusicStyleTrack (riid, ppobj, pOuter);
260 }
261
262 static HRESULT WINAPI StyleTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
263         TRACE("(%d)\n", dolock);
264
265         if (dolock)
266                 DMSTYLE_LockModule();
267         else
268                 DMSTYLE_UnlockModule();
269         
270         return S_OK;
271 }
272
273 static IClassFactoryVtbl StyleTrackCF_Vtbl = {
274         StyleTrackCF_QueryInterface,
275         StyleTrackCF_AddRef,
276         StyleTrackCF_Release,
277         StyleTrackCF_CreateInstance,
278         StyleTrackCF_LockServer
279 };
280
281 static IClassFactoryImpl StyleTrack_CF = {&StyleTrackCF_Vtbl};
282
283 /******************************************************************
284  *              DirectMusicMotifTrack ClassFactory
285  */
286 static HRESULT WINAPI MotifTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
287         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
288
289         if (ppobj == NULL) return E_POINTER;
290         
291         return E_NOINTERFACE;
292 }
293
294 static ULONG WINAPI MotifTrackCF_AddRef(LPCLASSFACTORY iface) {
295         DMSTYLE_LockModule();
296
297         return 2; /* non-heap based object */
298 }
299
300 static ULONG WINAPI MotifTrackCF_Release(LPCLASSFACTORY iface) {
301         DMSTYLE_UnlockModule();
302
303         return 1; /* non-heap based object */
304 }
305
306 static HRESULT WINAPI MotifTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
307         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
308         
309         return DMUSIC_CreateDirectMusicMotifTrack (riid, ppobj, pOuter);
310 }
311
312 static HRESULT WINAPI MotifTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
313         TRACE("(%d)\n", dolock);
314
315         if (dolock)
316                 DMSTYLE_LockModule();
317         else
318                 DMSTYLE_UnlockModule();
319         
320         return S_OK;
321 }
322
323 static IClassFactoryVtbl MotifTrackCF_Vtbl = {
324         MotifTrackCF_QueryInterface,
325         MotifTrackCF_AddRef,
326         MotifTrackCF_Release,
327         MotifTrackCF_CreateInstance,
328         MotifTrackCF_LockServer
329 };
330
331 static IClassFactoryImpl MotifTrack_CF = {&MotifTrackCF_Vtbl};
332
333 /******************************************************************
334  *              DirectMusicAuditionTrack ClassFactory
335  */
336 static HRESULT WINAPI AuditionTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
337         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
338
339         if (ppobj == NULL) return E_POINTER;
340         
341         return E_NOINTERFACE;
342 }
343
344 static ULONG WINAPI AuditionTrackCF_AddRef(LPCLASSFACTORY iface) {
345         DMSTYLE_LockModule();
346
347         return 2; /* non-heap based object */
348 }
349
350 static ULONG WINAPI AuditionTrackCF_Release(LPCLASSFACTORY iface) {
351         DMSTYLE_UnlockModule();
352
353         return 1; /* non-heap based object */
354 }
355
356 static HRESULT WINAPI AuditionTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
357         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
358         
359         return DMUSIC_CreateDirectMusicAuditionTrack (riid, ppobj, pOuter);
360 }
361
362 static HRESULT WINAPI AuditionTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
363         TRACE("(%d)\n", dolock);
364
365         if (dolock)
366                 DMSTYLE_LockModule();
367         else
368                 DMSTYLE_UnlockModule();
369
370         return S_OK;
371 }
372
373 static IClassFactoryVtbl AuditionTrackCF_Vtbl = {
374         AuditionTrackCF_QueryInterface,
375         AuditionTrackCF_AddRef,
376         AuditionTrackCF_Release,
377         AuditionTrackCF_CreateInstance,
378         AuditionTrackCF_LockServer
379 };
380
381 static IClassFactoryImpl AuditionTrack_CF = {&AuditionTrackCF_Vtbl};
382
383 /******************************************************************
384  *              DirectMusicMuteTrack ClassFactory
385  */
386 static HRESULT WINAPI MuteTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
387         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
388
389         if (ppobj == NULL) return E_POINTER;
390         
391         return E_NOINTERFACE;
392 }
393
394 static ULONG WINAPI MuteTrackCF_AddRef(LPCLASSFACTORY iface) {
395         DMSTYLE_LockModule();
396
397         return 2; /* non-heap based object */
398 }
399
400 static ULONG WINAPI MuteTrackCF_Release(LPCLASSFACTORY iface) {
401         DMSTYLE_UnlockModule();
402
403         return 1; /* non-heap based object */
404 }
405
406 static HRESULT WINAPI MuteTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
407         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
408
409         return DMUSIC_CreateDirectMusicMuteTrack (riid, ppobj, pOuter);
410 }
411
412 static HRESULT WINAPI MuteTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
413         TRACE("(%d)\n", dolock);
414
415         if (dolock)
416                 DMSTYLE_LockModule();
417         else
418                 DMSTYLE_UnlockModule();
419         
420         return S_OK;
421 }
422
423 static IClassFactoryVtbl MuteTrackCF_Vtbl = {
424         MuteTrackCF_QueryInterface,
425         MuteTrackCF_AddRef,
426         MuteTrackCF_Release,
427         MuteTrackCF_CreateInstance,
428         MuteTrackCF_LockServer
429 };
430
431 static IClassFactoryImpl MuteTrack_CF = {&MuteTrackCF_Vtbl};
432
433 /******************************************************************
434  *              DllMain
435  *
436  *
437  */
438 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
439         if (fdwReason == DLL_PROCESS_ATTACH) {
440             DisableThreadLibraryCalls(hinstDLL);
441                 /* FIXME: Initialisation */
442         } else if (fdwReason == DLL_PROCESS_DETACH) {
443                 /* FIXME: Cleanup */
444         }
445
446         return TRUE;
447 }
448
449
450 /******************************************************************
451  *              DllCanUnloadNow (DMSTYLE.1)
452  *
453  *
454  */
455 HRESULT WINAPI DllCanUnloadNow(void) {
456         return DMSTYLE_refCount != 0 ? S_FALSE : S_OK;
457 }
458
459
460 /******************************************************************
461  *              DllGetClassObject (DMSTYLE.2)
462  *
463  *
464  */
465 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
466     TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
467     
468         if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSection) && IsEqualIID (riid, &IID_IClassFactory)) {
469                 *ppv = (LPVOID) &Section_CF;
470                 IClassFactory_AddRef((IClassFactory*)*ppv);
471                 return S_OK;
472         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyle) && IsEqualIID (riid, &IID_IClassFactory)) {
473                 *ppv = (LPVOID) &Style_CF;
474                 IClassFactory_AddRef((IClassFactory*)*ppv);
475                 return S_OK;            
476         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
477                 *ppv = (LPVOID) &ChordTrack_CF;
478                 IClassFactory_AddRef((IClassFactory*)*ppv);
479                 return S_OK;    
480         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCommandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
481                 *ppv = (LPVOID) &CommandTrack_CF;
482                 IClassFactory_AddRef((IClassFactory*)*ppv);
483                 return S_OK;            
484         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyleTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
485                 *ppv = (LPVOID) &StyleTrack_CF;
486                 IClassFactory_AddRef((IClassFactory*)*ppv);
487                 return S_OK;            
488         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMotifTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
489                 *ppv = (LPVOID) &MotifTrack_CF;
490                 IClassFactory_AddRef((IClassFactory*)*ppv);
491                 return S_OK;            
492         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAuditionTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
493                 *ppv = (LPVOID) &AuditionTrack_CF;
494                 IClassFactory_AddRef((IClassFactory*)*ppv);
495                 return S_OK;            
496         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMuteTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
497                 *ppv = (LPVOID) &MuteTrack_CF;
498                 IClassFactory_AddRef((IClassFactory*)*ppv);
499                 return S_OK;            
500         }
501
502     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
503     return CLASS_E_CLASSNOTAVAILABLE;
504 }