comctl32/tests: Use CRT allocation functions.
[wine.git] / dlls / dmstyle / dmstyle_main.c
blob9d96ab3930ed68c5efcd210c1ab5b6d830a98268
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"
36 #include "dmobject.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
40 typedef struct {
41 IClassFactory IClassFactory_iface;
42 HRESULT (*fnCreateInstance)(REFIID riid, void **ret_iface);
43 } IClassFactoryImpl;
45 static HRESULT create_direct_music_section(REFIID riid, void **ret_iface)
47 FIXME("(%s, %p) stub\n", debugstr_dmguid(riid), ret_iface);
49 return CLASS_E_CLASSNOTAVAILABLE;
52 /******************************************************************
53 * IClassFactory implementation
55 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
57 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
60 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
62 if (ppv == NULL)
63 return E_POINTER;
65 if (IsEqualGUID(&IID_IUnknown, riid))
66 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
67 else if (IsEqualGUID(&IID_IClassFactory, riid))
68 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
69 else {
70 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
71 *ppv = NULL;
72 return E_NOINTERFACE;
75 *ppv = iface;
76 IUnknown_AddRef((IUnknown*)*ppv);
77 return S_OK;
80 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
82 return 2; /* non-heap based object */
85 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
87 return 1; /* non-heap based object */
90 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
91 REFIID riid, void **ppv)
93 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
95 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
97 if (pUnkOuter) {
98 *ppv = NULL;
99 return CLASS_E_NOAGGREGATION;
102 return This->fnCreateInstance(riid, ppv);
105 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
107 TRACE("(%d)\n", dolock);
108 return S_OK;
111 static const IClassFactoryVtbl classfactory_vtbl = {
112 ClassFactory_QueryInterface,
113 ClassFactory_AddRef,
114 ClassFactory_Release,
115 ClassFactory_CreateInstance,
116 ClassFactory_LockServer
119 static IClassFactoryImpl Section_CF = {{&classfactory_vtbl}, create_direct_music_section};
120 static IClassFactoryImpl Style_CF = {{&classfactory_vtbl}, create_dmstyle};
121 static IClassFactoryImpl ChordTrack_CF = {{&classfactory_vtbl}, create_dmchordtrack};
122 static IClassFactoryImpl CommandTrack_CF = {{&classfactory_vtbl}, create_dmcommandtrack};
123 static IClassFactoryImpl StyleTrack_CF = {{&classfactory_vtbl}, create_dmstyletrack};
124 static IClassFactoryImpl MotifTrack_CF = {{&classfactory_vtbl}, create_dmmotiftrack};
125 static IClassFactoryImpl AuditionTrack_CF = {{&classfactory_vtbl}, create_dmauditiontrack};
126 static IClassFactoryImpl MuteTrack_CF = {{&classfactory_vtbl}, create_dmmutetrack};
129 /******************************************************************
130 * DllGetClassObject (DMSTYLE.@)
134 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
135 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
137 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSection) && IsEqualIID (riid, &IID_IClassFactory)) {
138 *ppv = &Section_CF;
139 IClassFactory_AddRef((IClassFactory*)*ppv);
140 return S_OK;
141 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyle) && IsEqualIID (riid, &IID_IClassFactory)) {
142 *ppv = &Style_CF;
143 IClassFactory_AddRef((IClassFactory*)*ppv);
144 return S_OK;
145 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
146 *ppv = &ChordTrack_CF;
147 IClassFactory_AddRef((IClassFactory*)*ppv);
148 return S_OK;
149 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCommandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
150 *ppv = &CommandTrack_CF;
151 IClassFactory_AddRef((IClassFactory*)*ppv);
152 return S_OK;
153 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyleTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
154 *ppv = &StyleTrack_CF;
155 IClassFactory_AddRef((IClassFactory*)*ppv);
156 return S_OK;
157 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMotifTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
158 *ppv = &MotifTrack_CF;
159 IClassFactory_AddRef((IClassFactory*)*ppv);
160 return S_OK;
161 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAuditionTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
162 *ppv = &AuditionTrack_CF;
163 IClassFactory_AddRef((IClassFactory*)*ppv);
164 return S_OK;
165 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMuteTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
166 *ppv = &MuteTrack_CF;
167 IClassFactory_AddRef((IClassFactory*)*ppv);
168 return S_OK;
171 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
172 return CLASS_E_CLASSNOTAVAILABLE;