Split the dmusic interfaces.
[wine] / dlls / dmime / dmime_main.c
1 /* DirectMusicInteractiveEngine Main
2  *
3  * Copyright (C) 2003 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 "dmime_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
23
24
25 /******************************************************************
26  *              DirectMusicInteractiveEngine ClassFactory
27  *
28  *
29  */
30  
31 typedef struct
32 {
33     /* IUnknown fields */
34     ICOM_VFIELD(IClassFactory);
35     DWORD                       ref;
36 } IClassFactoryImpl;
37
38 static HRESULT WINAPI DMIMECF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
39 {
40         ICOM_THIS(IClassFactoryImpl,iface);
41
42         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
43         return E_NOINTERFACE;
44 }
45
46 static ULONG WINAPI DMIMECF_AddRef(LPCLASSFACTORY iface)
47 {
48         ICOM_THIS(IClassFactoryImpl,iface);
49         return ++(This->ref);
50 }
51
52 static ULONG WINAPI DMIMECF_Release(LPCLASSFACTORY iface)
53 {
54         ICOM_THIS(IClassFactoryImpl,iface);
55         /* static class, won't be  freed */
56         return --(This->ref);
57 }
58
59 static HRESULT WINAPI DMIMECF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
60 {
61         ICOM_THIS(IClassFactoryImpl,iface);
62
63         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
64         if (IsEqualGUID (riid, &IID_IDirectMusicPerformance) ||
65             IsEqualGUID (riid, &IID_IDirectMusicPerformance8)) {
66                 return DMUSIC_CreateDirectMusicPerformance (riid, (LPDIRECTMUSICPERFORMANCE8*) ppobj, pOuter);
67         } else if (IsEqualGUID (riid, &IID_IDirectMusicSegment) ||
68                 IsEqualGUID (riid, &IID_IDirectMusicSegment8)) {
69                 return DMUSIC_CreateDirectMusicSegment (riid, (LPDIRECTMUSICSEGMENT8*) ppobj, pOuter);
70         } else if (IsEqualGUID (riid, &IID_IDirectMusicSegmentState) ||
71                 IsEqualGUID (riid, &IID_IDirectMusicSegmentState8)) {
72                 return DMUSIC_CreateDirectMusicSegmentState (riid, (LPDIRECTMUSICSEGMENTSTATE8*) ppobj, pOuter);
73         } else if (IsEqualGUID (riid, &IID_IDirectMusicGraph)) {
74                 return DMUSIC_CreateDirectMusicGraph (riid, (LPDIRECTMUSICGRAPH*) ppobj, pOuter);
75         } else if (IsEqualGUID (riid, &IID_IDirectMusicAudioPath)) {
76                 return DMUSIC_CreateDirectMusicSong (riid, (LPDIRECTMUSICSONG*) ppobj, pOuter);
77         } else if (IsEqualGUID (riid, &IID_IDirectMusicAudioPath)) {
78                 return DMUSIC_CreateDirectMusicAudioPath (riid, (LPDIRECTMUSICAUDIOPATH*) ppobj, pOuter);
79         } else if (IsEqualGUID (riid, &IID_IDirectMusicTool) ||
80                 IsEqualGUID (riid, &IID_IDirectMusicTool8)) {
81                 return DMUSIC_CreateDirectMusicTool (riid, (LPDIRECTMUSICTOOL8*) ppobj, pOuter);
82         } else if (IsEqualGUID (riid, &IID_IDirectMusicTrack) ||
83                 IsEqualGUID (riid, &IID_IDirectMusicTrack8)) {
84                 return DMUSIC_CreateDirectMusicTrack (riid, (LPDIRECTMUSICTRACK8*) ppobj, pOuter);
85         } else if (IsEqualGUID (riid, &IID_IDirectMusicPatternTrack)) {
86                 return DMUSIC_CreateDirectMusicPatternTrack (riid, (LPDIRECTMUSICPATTERNTRACK*) ppobj, pOuter);
87         }
88
89         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);    
90         return E_NOINTERFACE;
91 }
92
93 static HRESULT WINAPI DMIMECF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
94 {
95         ICOM_THIS(IClassFactoryImpl,iface);
96         FIXME("(%p)->(%d),stub!\n", This, dolock);
97         return S_OK;
98 }
99
100 static ICOM_VTABLE(IClassFactory) DMIMECF_Vtbl = {
101         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
102         DMIMECF_QueryInterface,
103         DMIMECF_AddRef,
104         DMIMECF_Release,
105         DMIMECF_CreateInstance,
106         DMIMECF_LockServer
107 };
108
109 static IClassFactoryImpl DMIME_CF = {&DMIMECF_Vtbl, 1 };
110
111 /******************************************************************
112  *              DllMain
113  *
114  *
115  */
116 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
117 {
118         if (fdwReason == DLL_PROCESS_ATTACH)
119         {
120             DisableThreadLibraryCalls(hinstDLL);
121                 /* FIXME: Initialisation */
122         }
123         else if (fdwReason == DLL_PROCESS_DETACH)
124         {
125                 /* FIXME: Cleanup */
126         }
127
128         return TRUE;
129 }
130
131
132 /******************************************************************
133  *              DllCanUnloadNow (DMIME.1)
134  *
135  *
136  */
137 HRESULT WINAPI DMIME_DllCanUnloadNow(void)
138 {
139     FIXME("(void): stub\n");
140
141     return S_FALSE;
142 }
143
144
145 /******************************************************************
146  *              DllGetClassObject (DMIME.2)
147  *
148  *
149  */
150 HRESULT WINAPI DMIME_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
151 {
152     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
153     if (IsEqualCLSID (&IID_IClassFactory, riid)) {
154       *ppv = (LPVOID) &DMIME_CF;
155       IClassFactory_AddRef((IClassFactory*)*ppv);
156       return S_OK;
157     }
158     WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
159     return CLASS_E_CLASSNOTAVAILABLE;
160 }