Print exe name when initialization fails.
[wine] / dlls / dmsynth / dmsynth_main.c
1 /* DirectMusicSynthesizer 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 "dmsynth_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
23
24 typedef struct
25 {
26     /* IUnknown fields */
27     ICOM_VFIELD(IClassFactory);
28     DWORD                       ref;
29 } IClassFactoryImpl;
30
31 /******************************************************************
32  *              DirectMusicSynth ClassFactory
33  */
34 static HRESULT WINAPI SynthCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
35 {
36         ICOM_THIS(IClassFactoryImpl,iface);
37
38         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
39         return E_NOINTERFACE;
40 }
41
42 static ULONG WINAPI SynthCF_AddRef(LPCLASSFACTORY iface)
43 {
44         ICOM_THIS(IClassFactoryImpl,iface);
45         return ++(This->ref);
46 }
47
48 static ULONG WINAPI SynthCF_Release(LPCLASSFACTORY iface)
49 {
50         ICOM_THIS(IClassFactoryImpl,iface);
51         /* static class, won't be  freed */
52         return --(This->ref);
53 }
54
55 static HRESULT WINAPI SynthCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
56 {
57         ICOM_THIS(IClassFactoryImpl,iface);
58
59         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
60         if (IsEqualIID (riid, &IID_IDirectMusicSynth) ||
61                 IsEqualIID (riid, &IID_IDirectMusicSynth8)) {
62                 return DMUSIC_CreateDirectMusicSynth (riid, (LPDIRECTMUSICSYNTH8*)ppobj, pOuter);
63                 }
64                 
65         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
66         return E_NOINTERFACE;
67 }
68
69 static HRESULT WINAPI SynthCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
70 {
71         ICOM_THIS(IClassFactoryImpl,iface);
72         FIXME("(%p)->(%d),stub!\n", This, dolock);
73         return S_OK;
74 }
75
76 static ICOM_VTABLE(IClassFactory) SynthCF_Vtbl = {
77         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
78         SynthCF_QueryInterface,
79         SynthCF_AddRef,
80         SynthCF_Release,
81         SynthCF_CreateInstance,
82         SynthCF_LockServer
83 };
84
85 static IClassFactoryImpl Synth_CF = {&SynthCF_Vtbl, 1 };
86
87 /******************************************************************
88  *              DirectMusicSynthSink ClassFactory
89  */
90 static HRESULT WINAPI SynthSinkCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
91 {
92         ICOM_THIS(IClassFactoryImpl,iface);
93
94         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
95         return E_NOINTERFACE;
96 }
97
98 static ULONG WINAPI SynthSinkCF_AddRef(LPCLASSFACTORY iface)
99 {
100         ICOM_THIS(IClassFactoryImpl,iface);
101         return ++(This->ref);
102 }
103
104 static ULONG WINAPI SynthSinkCF_Release(LPCLASSFACTORY iface)
105 {
106         ICOM_THIS(IClassFactoryImpl,iface);
107         /* static class, won't be  freed */
108         return --(This->ref);
109 }
110
111 static HRESULT WINAPI SynthSinkCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
112 {
113         ICOM_THIS(IClassFactoryImpl,iface);
114
115         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
116         if (IsEqualIID (riid, &IID_IDirectMusicSynthSink)) {
117                 return DMUSIC_CreateDirectMusicSynthSink (riid, (LPDIRECTMUSICSYNTHSINK*)ppobj, pOuter);
118         }
119                 
120         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
121         return E_NOINTERFACE;
122 }
123
124 static HRESULT WINAPI SynthSinkCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
125 {
126         ICOM_THIS(IClassFactoryImpl,iface);
127         FIXME("(%p)->(%d),stub!\n", This, dolock);
128         return S_OK;
129 }
130
131 static ICOM_VTABLE(IClassFactory) SynthSinkCF_Vtbl = {
132         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
133         SynthSinkCF_QueryInterface,
134         SynthSinkCF_AddRef,
135         SynthSinkCF_Release,
136         SynthSinkCF_CreateInstance,
137         SynthSinkCF_LockServer
138 };
139
140 static IClassFactoryImpl SynthSink_CF = {&SynthSinkCF_Vtbl, 1 };
141         
142 /******************************************************************
143  *              DllMain
144  *
145  *
146  */
147 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
148 {
149         if (fdwReason == DLL_PROCESS_ATTACH)
150         {
151             DisableThreadLibraryCalls(hinstDLL);
152                 /* FIXME: Initialisation */
153         }
154         else if (fdwReason == DLL_PROCESS_DETACH)
155         {
156                 /* FIXME: Cleanup */
157         }
158
159         return TRUE;
160 }
161
162
163 /******************************************************************
164  *              DllCanUnloadNow (DMSYNTH.1)
165  *
166  *
167  */
168 HRESULT WINAPI DMSYNTH_DllCanUnloadNow(void)
169 {
170     FIXME("(void): stub\n");
171
172     return S_FALSE;
173 }
174
175
176 /******************************************************************
177  *              DllGetClassObject (DMSYNTH.2)
178  *
179  *
180  */
181 HRESULT WINAPI DMSYNTH_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
182 {
183     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
184     if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSynth) && IsEqualIID (riid, &IID_IClassFactory)) {
185                 *ppv = (LPVOID) &Synth_CF;
186                 IClassFactory_AddRef((IClassFactory*)*ppv);
187                 return S_OK;            
188         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSynth) && IsEqualIID (riid, &IID_IClassFactory)) {
189                 *ppv = (LPVOID) &SynthSink_CF;
190                 IClassFactory_AddRef((IClassFactory*)*ppv);
191                 return S_OK;            
192         } 
193
194     WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
195     return CLASS_E_CLASSNOTAVAILABLE;
196 }