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
35 #include "dmstyle_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle
);
40 static HINSTANCE instance
;
41 LONG DMSTYLE_refCount
= 0;
44 IClassFactory IClassFactory_iface
;
45 HRESULT
WINAPI (*fnCreateInstance
)(REFIID riid
, void **ret_iface
);
48 static HRESULT WINAPI
create_direct_music_section(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
)
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
);
73 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
79 IUnknown_AddRef((IUnknown
*)*ppv
);
83 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
87 return 2; /* non-heap based object */
90 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
92 DMSTYLE_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
);
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
);
117 DMSTYLE_LockModule();
119 DMSTYLE_UnlockModule();
124 static const IClassFactoryVtbl classfactory_vtbl
= {
125 ClassFactory_QueryInterface
,
127 ClassFactory_Release
,
128 ClassFactory_CreateInstance
,
129 ClassFactory_LockServer
132 static IClassFactoryImpl Section_CF
= {{&classfactory_vtbl
}, create_direct_music_section
};
133 static IClassFactoryImpl Style_CF
= {{&classfactory_vtbl
}, create_dmstyle
};
134 static IClassFactoryImpl ChordTrack_CF
= {{&classfactory_vtbl
}, create_dmchordtrack
};
135 static IClassFactoryImpl CommandTrack_CF
= {{&classfactory_vtbl
}, create_dmcommandtrack
};
136 static IClassFactoryImpl StyleTrack_CF
= {{&classfactory_vtbl
}, create_dmstyletrack
};
137 static IClassFactoryImpl MotifTrack_CF
= {{&classfactory_vtbl
}, create_dmmotiftrack
};
138 static IClassFactoryImpl AuditionTrack_CF
= {{&classfactory_vtbl
}, create_dmauditiontrack
};
139 static IClassFactoryImpl MuteTrack_CF
= {{&classfactory_vtbl
}, create_dmmutetrack
};
141 /******************************************************************
146 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
) {
147 if (fdwReason
== DLL_PROCESS_ATTACH
) {
149 DisableThreadLibraryCalls(hinstDLL
);
156 /******************************************************************
157 * DllCanUnloadNow (DMSTYLE.1)
161 HRESULT WINAPI
DllCanUnloadNow(void) {
162 return DMSTYLE_refCount
!= 0 ? S_FALSE
: S_OK
;
166 /******************************************************************
167 * DllGetClassObject (DMSTYLE.@)
171 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
) {
172 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid
), debugstr_dmguid(riid
), ppv
);
174 if (IsEqualCLSID (rclsid
, &CLSID_DirectMusicSection
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
176 IClassFactory_AddRef((IClassFactory
*)*ppv
);
178 } else if (IsEqualCLSID (rclsid
, &CLSID_DirectMusicStyle
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
180 IClassFactory_AddRef((IClassFactory
*)*ppv
);
182 } else if (IsEqualCLSID (rclsid
, &CLSID_DirectMusicChordTrack
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
183 *ppv
= &ChordTrack_CF
;
184 IClassFactory_AddRef((IClassFactory
*)*ppv
);
186 } else if (IsEqualCLSID (rclsid
, &CLSID_DirectMusicCommandTrack
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
187 *ppv
= &CommandTrack_CF
;
188 IClassFactory_AddRef((IClassFactory
*)*ppv
);
190 } else if (IsEqualCLSID (rclsid
, &CLSID_DirectMusicStyleTrack
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
191 *ppv
= &StyleTrack_CF
;
192 IClassFactory_AddRef((IClassFactory
*)*ppv
);
194 } else if (IsEqualCLSID (rclsid
, &CLSID_DirectMusicMotifTrack
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
195 *ppv
= &MotifTrack_CF
;
196 IClassFactory_AddRef((IClassFactory
*)*ppv
);
198 } else if (IsEqualCLSID (rclsid
, &CLSID_DirectMusicAuditionTrack
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
199 *ppv
= &AuditionTrack_CF
;
200 IClassFactory_AddRef((IClassFactory
*)*ppv
);
202 } else if (IsEqualCLSID (rclsid
, &CLSID_DirectMusicMuteTrack
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
203 *ppv
= &MuteTrack_CF
;
204 IClassFactory_AddRef((IClassFactory
*)*ppv
);
208 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid
), debugstr_dmguid(riid
), ppv
);
209 return CLASS_E_CLASSNOTAVAILABLE
;
212 /***********************************************************************
213 * DllRegisterServer (DMSTYLE.@)
215 HRESULT WINAPI
DllRegisterServer(void)
217 return __wine_register_resources( instance
);
220 /***********************************************************************
221 * DllUnregisterServer (DMSTYLE.@)
223 HRESULT WINAPI
DllUnregisterServer(void)
225 return __wine_unregister_resources( instance
);