imm32/tests: Test ImmTranslateMessage / ImeToAsciiEx calls.
[wine.git] / dlls / dmcompos / dmcompos_main.c
blobdff77aa4d3294200aee3b1ad4c0a77c5f7cb0443
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 LONG DMCOMPOS_refCount = 0;
43 typedef struct {
44 IClassFactory IClassFactory_iface;
45 HRESULT (*fnCreateInstance)(REFIID riid, void **ret_iface);
46 } IClassFactoryImpl;
48 static HRESULT create_direct_music_template(REFIID riid, void **ret_iface)
50 FIXME("(%s, %p) stub\n", debugstr_dmguid(riid), ret_iface);
52 return CLASS_E_CLASSNOTAVAILABLE;
55 /******************************************************************
56 * IClassFactory implementation
58 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
60 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
63 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
65 if (ppv == NULL)
66 return E_POINTER;
68 if (IsEqualGUID(&IID_IUnknown, riid))
69 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
70 else if (IsEqualGUID(&IID_IClassFactory, riid))
71 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
72 else {
73 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
74 *ppv = NULL;
75 return E_NOINTERFACE;
78 *ppv = iface;
79 IUnknown_AddRef((IUnknown*)*ppv);
80 return S_OK;
83 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
85 DMCOMPOS_LockModule();
87 return 2; /* non-heap based object */
90 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
92 DMCOMPOS_UnlockModule();
94 return 1; /* non-heap based object */
97 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
98 REFIID riid, void **ppv)
100 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
102 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
104 if (pUnkOuter) {
105 *ppv = NULL;
106 return CLASS_E_NOAGGREGATION;
109 return This->fnCreateInstance(riid, ppv);
112 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
114 TRACE("(%d)\n", dolock);
116 if (dolock)
117 DMCOMPOS_LockModule();
118 else
119 DMCOMPOS_UnlockModule();
121 return S_OK;
124 static const IClassFactoryVtbl classfactory_vtbl = {
125 ClassFactory_QueryInterface,
126 ClassFactory_AddRef,
127 ClassFactory_Release,
128 ClassFactory_CreateInstance,
129 ClassFactory_LockServer
132 static IClassFactoryImpl ChordMap_CF = {{&classfactory_vtbl}, create_dmchordmap};
133 static IClassFactoryImpl Composer_CF = {{&classfactory_vtbl}, create_dmcomposer};
134 static IClassFactoryImpl ChordMapTrack_CF = {{&classfactory_vtbl}, create_dmchordmaptrack};
135 static IClassFactoryImpl Template_CF = {{&classfactory_vtbl}, create_direct_music_template};
136 static IClassFactoryImpl SignPostTrack_CF = {{&classfactory_vtbl}, create_dmsignposttrack};
138 /******************************************************************
139 * DllCanUnloadNow (DMCOMPOS.@)
143 HRESULT WINAPI DllCanUnloadNow(void) {
144 return DMCOMPOS_refCount != 0 ? S_FALSE : S_OK;
148 /******************************************************************
149 * DllGetClassObject (DMCOMPOS.@)
153 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
154 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
155 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordMap) && IsEqualIID (riid, &IID_IClassFactory)) {
156 *ppv = &ChordMap_CF;
157 IClassFactory_AddRef((IClassFactory*)*ppv);
158 return S_OK;
159 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicComposer) && IsEqualIID (riid, &IID_IClassFactory)) {
160 *ppv = &Composer_CF;
161 IClassFactory_AddRef((IClassFactory*)*ppv);
162 return S_OK;
163 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordMapTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
164 *ppv = &ChordMapTrack_CF;
165 IClassFactory_AddRef((IClassFactory*)*ppv);
166 return S_OK;
167 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTemplate) && IsEqualIID (riid, &IID_IClassFactory)) {
168 *ppv = &Template_CF;
169 IClassFactory_AddRef((IClassFactory*)*ppv);
170 return S_OK;
171 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSignPostTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
172 *ppv = &SignPostTrack_CF;
173 IClassFactory_AddRef((IClassFactory*)*ppv);
174 return S_OK;
177 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
178 return CLASS_E_CLASSNOTAVAILABLE;