msctf: Spelling fix.
[wine.git] / dlls / dmstyle / dmstyle_main.c
blob11e3f62ea98455c17825982a728c35781ed2045b
1 /* DirectMusicStyle Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program 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.
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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winnt.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winreg.h"
30 #include "objbase.h"
31 #include "rpcproxy.h"
32 #include "initguid.h"
33 #include "dmusici.h"
35 #include "dmstyle_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
39 static HINSTANCE instance;
40 LONG DMSTYLE_refCount = 0;
42 typedef struct {
43 IClassFactory IClassFactory_iface;
44 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ret_iface);
45 } IClassFactoryImpl;
47 static HRESULT WINAPI create_direct_music_section(REFIID riid, void **ret_iface)
49 FIXME("(%s, %p) stub\n", debugstr_dmguid(riid), ret_iface);
51 return CLASS_E_CLASSNOTAVAILABLE;
54 /******************************************************************
55 * IClassFactory implementation
57 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
59 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
62 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
64 if (ppv == NULL)
65 return E_POINTER;
67 if (IsEqualGUID(&IID_IUnknown, riid))
68 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
69 else if (IsEqualGUID(&IID_IClassFactory, riid))
70 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
71 else {
72 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
73 *ppv = NULL;
74 return E_NOINTERFACE;
77 *ppv = iface;
78 IUnknown_AddRef((IUnknown*)*ppv);
79 return S_OK;
82 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
84 DMSTYLE_LockModule();
86 return 2; /* non-heap based object */
89 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
91 DMSTYLE_UnlockModule();
93 return 1; /* non-heap based object */
96 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
97 REFIID riid, void **ppv)
99 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
101 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
103 if (pUnkOuter) {
104 *ppv = NULL;
105 return CLASS_E_NOAGGREGATION;
108 return This->fnCreateInstance(riid, ppv);
111 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
113 TRACE("(%d)\n", dolock);
115 if (dolock)
116 DMSTYLE_LockModule();
117 else
118 DMSTYLE_UnlockModule();
120 return S_OK;
123 static const IClassFactoryVtbl classfactory_vtbl = {
124 ClassFactory_QueryInterface,
125 ClassFactory_AddRef,
126 ClassFactory_Release,
127 ClassFactory_CreateInstance,
128 ClassFactory_LockServer
131 static IClassFactoryImpl Section_CF = {{&classfactory_vtbl}, create_direct_music_section};
132 static IClassFactoryImpl Style_CF = {{&classfactory_vtbl}, create_dmstyle};
133 static IClassFactoryImpl ChordTrack_CF = {{&classfactory_vtbl}, create_dmchordtrack};
134 static IClassFactoryImpl CommandTrack_CF = {{&classfactory_vtbl}, create_dmcommandtrack};
135 static IClassFactoryImpl StyleTrack_CF = {{&classfactory_vtbl}, create_dmstyletrack};
136 static IClassFactoryImpl MotifTrack_CF = {{&classfactory_vtbl}, create_dmmotiftrack};
137 static IClassFactoryImpl AuditionTrack_CF = {{&classfactory_vtbl}, create_dmauditiontrack};
138 static IClassFactoryImpl MuteTrack_CF = {{&classfactory_vtbl}, create_dmmutetrack};
140 /******************************************************************
141 * DllMain
145 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
146 if (fdwReason == DLL_PROCESS_ATTACH) {
147 instance = hinstDLL;
148 DisableThreadLibraryCalls(hinstDLL);
151 return TRUE;
155 /******************************************************************
156 * DllCanUnloadNow (DMSTYLE.1)
160 HRESULT WINAPI DllCanUnloadNow(void) {
161 return DMSTYLE_refCount != 0 ? S_FALSE : S_OK;
165 /******************************************************************
166 * DllGetClassObject (DMSTYLE.@)
170 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
171 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
173 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSection) && IsEqualIID (riid, &IID_IClassFactory)) {
174 *ppv = &Section_CF;
175 IClassFactory_AddRef((IClassFactory*)*ppv);
176 return S_OK;
177 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyle) && IsEqualIID (riid, &IID_IClassFactory)) {
178 *ppv = &Style_CF;
179 IClassFactory_AddRef((IClassFactory*)*ppv);
180 return S_OK;
181 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
182 *ppv = &ChordTrack_CF;
183 IClassFactory_AddRef((IClassFactory*)*ppv);
184 return S_OK;
185 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCommandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
186 *ppv = &CommandTrack_CF;
187 IClassFactory_AddRef((IClassFactory*)*ppv);
188 return S_OK;
189 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyleTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
190 *ppv = &StyleTrack_CF;
191 IClassFactory_AddRef((IClassFactory*)*ppv);
192 return S_OK;
193 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMotifTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
194 *ppv = &MotifTrack_CF;
195 IClassFactory_AddRef((IClassFactory*)*ppv);
196 return S_OK;
197 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAuditionTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
198 *ppv = &AuditionTrack_CF;
199 IClassFactory_AddRef((IClassFactory*)*ppv);
200 return S_OK;
201 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMuteTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
202 *ppv = &MuteTrack_CF;
203 IClassFactory_AddRef((IClassFactory*)*ppv);
204 return S_OK;
207 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
208 return CLASS_E_CLASSNOTAVAILABLE;
211 /***********************************************************************
212 * DllRegisterServer (DMSTYLE.@)
214 HRESULT WINAPI DllRegisterServer(void)
216 return __wine_register_resources( instance );
219 /***********************************************************************
220 * DllUnregisterServer (DMSTYLE.@)
222 HRESULT WINAPI DllUnregisterServer(void)
224 return __wine_unregister_resources( instance );