dinput: Clear action mapping with SetDataFormat().
[wine.git] / dlls / dmcompos / dmcompos_main.c
blobb8b3c5d6d23bfe8b20f26c1f1f6279e3b3411ca1
1 /* DirectMusicComposer 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
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnt.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winreg.h"
31 #include "objbase.h"
32 #include "initguid.h"
33 #include "dmusici.h"
35 #include "dmcompos_private.h"
36 #include "dmobject.h"
37 #include "rpcproxy.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
41 static HINSTANCE instance;
42 LONG DMCOMPOS_refCount = 0;
44 typedef struct {
45 IClassFactory IClassFactory_iface;
46 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ret_iface);
47 } IClassFactoryImpl;
49 static HRESULT WINAPI create_direct_music_template(REFIID riid, void **ret_iface)
51 FIXME("(%s, %p) stub\n", debugstr_dmguid(riid), ret_iface);
53 return CLASS_E_CLASSNOTAVAILABLE;
56 /******************************************************************
57 * IClassFactory implementation
59 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
61 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
64 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
66 if (ppv == NULL)
67 return E_POINTER;
69 if (IsEqualGUID(&IID_IUnknown, riid))
70 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
71 else if (IsEqualGUID(&IID_IClassFactory, riid))
72 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
73 else {
74 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
75 *ppv = NULL;
76 return E_NOINTERFACE;
79 *ppv = iface;
80 IUnknown_AddRef((IUnknown*)*ppv);
81 return S_OK;
84 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
86 DMCOMPOS_LockModule();
88 return 2; /* non-heap based object */
91 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
93 DMCOMPOS_UnlockModule();
95 return 1; /* non-heap based object */
98 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
99 REFIID riid, void **ppv)
101 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
103 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
105 if (pUnkOuter) {
106 *ppv = NULL;
107 return CLASS_E_NOAGGREGATION;
110 return This->fnCreateInstance(riid, ppv);
113 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
115 TRACE("(%d)\n", dolock);
117 if (dolock)
118 DMCOMPOS_LockModule();
119 else
120 DMCOMPOS_UnlockModule();
122 return S_OK;
125 static const IClassFactoryVtbl classfactory_vtbl = {
126 ClassFactory_QueryInterface,
127 ClassFactory_AddRef,
128 ClassFactory_Release,
129 ClassFactory_CreateInstance,
130 ClassFactory_LockServer
133 static IClassFactoryImpl ChordMap_CF = {{&classfactory_vtbl}, create_dmchordmap};
134 static IClassFactoryImpl Composer_CF = {{&classfactory_vtbl}, create_dmcomposer};
135 static IClassFactoryImpl ChordMapTrack_CF = {{&classfactory_vtbl}, create_dmchordmaptrack};
136 static IClassFactoryImpl Template_CF = {{&classfactory_vtbl}, create_direct_music_template};
137 static IClassFactoryImpl SignPostTrack_CF = {{&classfactory_vtbl}, create_dmsignposttrack};
139 /******************************************************************
140 * DllMain
144 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
145 if (fdwReason == DLL_PROCESS_ATTACH) {
146 instance = hinstDLL;
147 DisableThreadLibraryCalls(hinstDLL);
149 return TRUE;
153 /******************************************************************
154 * DllCanUnloadNow (DMCOMPOS.@)
158 HRESULT WINAPI DllCanUnloadNow(void) {
159 return DMCOMPOS_refCount != 0 ? S_FALSE : S_OK;
163 /******************************************************************
164 * DllGetClassObject (DMCOMPOS.@)
168 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
169 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
170 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordMap) && IsEqualIID (riid, &IID_IClassFactory)) {
171 *ppv = &ChordMap_CF;
172 IClassFactory_AddRef((IClassFactory*)*ppv);
173 return S_OK;
174 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicComposer) && IsEqualIID (riid, &IID_IClassFactory)) {
175 *ppv = &Composer_CF;
176 IClassFactory_AddRef((IClassFactory*)*ppv);
177 return S_OK;
178 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordMapTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
179 *ppv = &ChordMapTrack_CF;
180 IClassFactory_AddRef((IClassFactory*)*ppv);
181 return S_OK;
182 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTemplate) && IsEqualIID (riid, &IID_IClassFactory)) {
183 *ppv = &Template_CF;
184 IClassFactory_AddRef((IClassFactory*)*ppv);
185 return S_OK;
186 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSignPostTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
187 *ppv = &SignPostTrack_CF;
188 IClassFactory_AddRef((IClassFactory*)*ppv);
189 return S_OK;
192 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
193 return CLASS_E_CLASSNOTAVAILABLE;
196 /***********************************************************************
197 * DllRegisterServer (DMCOMPOS.@)
199 HRESULT WINAPI DllRegisterServer(void)
201 return __wine_register_resources( instance );
204 /***********************************************************************
205 * DllUnregisterServer (DMCOMPOS.@)
207 HRESULT WINAPI DllUnregisterServer(void)
209 return __wine_unregister_resources( instance );
212 /******************************************************************
213 * Helper functions