Split the dmusic interfaces.
[wine/gsoc_dplay.git] / dlls / dmloader / loader.c
blob7132b03f6f8f8d0fb3accd72070155f0ad65e7cb
1 /* IDirectMusicLoader8 Implementation
3 * Copyright (C) 2003 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (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
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "windef.h"
21 #include "winbase.h"
22 #include "winuser.h"
23 #include "wingdi.h"
24 #include "wine/debug.h"
25 #include "wine/unicode.h"
27 #include "dmloader_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
31 /* IDirectMusicLoader8 IUnknown part follow: */
32 HRESULT WINAPI IDirectMusicLoader8Impl_QueryInterface (LPDIRECTMUSICLOADER8 iface, REFIID riid, LPVOID *ppobj)
34 ICOM_THIS(IDirectMusicLoader8Impl,iface);
36 if (IsEqualGUID(riid, &IID_IUnknown) ||
37 IsEqualGUID(riid, &IID_IDirectMusicLoader) ||
38 IsEqualGUID(riid, &IID_IDirectMusicLoader8))
40 IDirectMusicLoader8Impl_AddRef(iface);
41 *ppobj = This;
42 return S_OK;
44 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
45 return E_NOINTERFACE;
48 ULONG WINAPI IDirectMusicLoader8Impl_AddRef (LPDIRECTMUSICLOADER8 iface)
50 ICOM_THIS(IDirectMusicLoader8Impl,iface);
51 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
52 return ++(This->ref);
55 ULONG WINAPI IDirectMusicLoader8Impl_Release (LPDIRECTMUSICLOADER8 iface)
57 ICOM_THIS(IDirectMusicLoader8Impl,iface);
58 ULONG ref = --This->ref;
59 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
60 if (ref == 0)
62 HeapFree(GetProcessHeap(), 0, This);
64 return ref;
67 /* IDirectMusicLoader Interface part follow: */
68 HRESULT WINAPI IDirectMusicLoader8Impl_GetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID* ppv)
70 ICOM_THIS(IDirectMusicLoader8Impl,iface);
72 FIXME("(%p, %p, %s, %p): stub\n", This, pDesc, debugstr_guid(riid), ppv);
74 if (IsEqualGUID(riid, &IID_IDirectMusicScript)) {
75 IDirectMusicScript* script;
76 CoCreateInstance (&CLSID_DirectMusicScript, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicScript, (void**)&script);
77 *ppv = script;
80 return DS_OK;
83 HRESULT WINAPI IDirectMusicLoader8Impl_SetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc)
85 ICOM_THIS(IDirectMusicLoader8Impl,iface);
87 FIXME("(%p, %p): stub\n", This, pDesc);
89 return S_OK;
92 HRESULT WINAPI IDirectMusicLoader8Impl_SetSearchDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzPath, BOOL fClear)
94 ICOM_THIS(IDirectMusicLoader8Impl,iface);
96 FIXME("(%p, %s, %p, %d): to check\n", This, debugstr_guid(rguidClass), pwzPath, fClear);
98 if (0 == strncmpW(This->wzSearchPath, pwzPath, MAX_PATH)) {
99 return S_FALSE;
101 strncpyW(This->wzSearchPath, pwzPath, MAX_PATH);
102 return DS_OK;
105 HRESULT WINAPI IDirectMusicLoader8Impl_ScanDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzFileExtension, WCHAR* pwzScanFileName)
107 ICOM_THIS(IDirectMusicLoader8Impl,iface);
109 FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_guid(rguidClass), pwzFileExtension, pwzScanFileName);
111 return S_OK;
114 HRESULT WINAPI IDirectMusicLoader8Impl_CacheObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject)
116 ICOM_THIS(IDirectMusicLoader8Impl,iface);
118 FIXME("(%p, %p): stub\n", This, pObject);
120 return S_OK;
123 HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject)
125 ICOM_THIS(IDirectMusicLoader8Impl,iface);
127 FIXME("(%p, %p): stub\n", This, pObject);
129 return S_OK;
132 HRESULT WINAPI IDirectMusicLoader8Impl_ClearCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass)
134 ICOM_THIS(IDirectMusicLoader8Impl,iface);
136 FIXME("(%p, %s): stub\n", This, debugstr_guid(rguidClass));
138 return S_OK;
141 HRESULT WINAPI IDirectMusicLoader8Impl_EnableCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, BOOL fEnable)
143 ICOM_THIS(IDirectMusicLoader8Impl,iface);
145 FIXME("(%p, %s, %d): stub\n", This, debugstr_guid(rguidClass), fEnable);
147 return S_OK;
150 HRESULT WINAPI IDirectMusicLoader8Impl_EnumObject (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc)
152 ICOM_THIS(IDirectMusicLoader8Impl,iface);
154 FIXME("(%p, %s, %ld, %p): stub\n", This, debugstr_guid(rguidClass), dwIndex, pDesc);
156 return S_OK;
159 /* IDirectMusicLoader8 Interface part follow: */
160 void WINAPI IDirectMusicLoader8Impl_CollectGarbage (LPDIRECTMUSICLOADER8 iface)
162 ICOM_THIS(IDirectMusicLoader8Impl,iface);
164 FIXME("(%p): stub\n", This);
167 HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObjectByUnknown (LPDIRECTMUSICLOADER8 iface, IUnknown* pObject)
169 ICOM_THIS(IDirectMusicLoader8Impl,iface);
171 FIXME("(%p, %p): stub\n", This, pObject);
173 return S_OK;
176 HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface,
177 REFGUID rguidClassID,
178 REFIID iidInterfaceID,
179 WCHAR* pwzFilePath,
180 void** ppObject)
182 ICOM_THIS(IDirectMusicLoader8Impl,iface);
184 FIXME("(%p, %s, %s, %s, %p): stub\n", This, debugstr_guid(rguidClassID), debugstr_guid(iidInterfaceID), debugstr_w(pwzFilePath), ppObject);
186 if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicAudioPathConfig)) {
187 FIXME("wanted 'aud'\n");
188 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicBand)) {
189 FIXME("wanted 'bnd'\n");
190 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicContainer)) {
191 FIXME("wanted 'con'\n");
192 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicCollection)) {
193 FIXME("wanted 'dls'\n");
194 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicChordMap)) {
195 FIXME("wanted 'cdm'\n");
196 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicSegment)) {
197 FIXME("wanted 'sgt'\n");
198 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicScript)) {
199 FIXME("wanted 'spt'\n");
200 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicSong)) {
201 FIXME("wanted 'sng'\n");
202 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicStyle)) {
203 FIXME("wanted 'sty'\n");
204 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicSegment)) {
205 FIXME("wanted 'tpl'\n");
206 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicGraph)) {
207 FIXME("wanted 'tgr'\n");
208 } else if (IsEqualGUID(rguidClassID, &CLSID_DirectSoundWave)) {
209 FIXME("wanted 'wav'\n");
212 if (IsEqualGUID(iidInterfaceID, &IID_IDirectMusicSegment) ||
213 IsEqualGUID(iidInterfaceID, &IID_IDirectMusicSegment8)) {
214 IDirectMusicSegment8* segment;
215 CoCreateInstance (&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSegment8, (void**)&segment);
216 *ppObject = segment;
217 return S_OK;
218 } else if (IsEqualGUID(iidInterfaceID, &IID_IDirectMusicContainer)) {
219 IDirectMusicContainer* container;
220 CoCreateInstance (&CLSID_DirectMusicContainer, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicContainer, (void**)&container);
221 *ppObject = container;
222 return S_OK;
223 } else if (IsEqualGUID(iidInterfaceID, &IID_IDirectMusicScript)) {
224 IDirectMusicScript* script;
225 CoCreateInstance (&CLSID_DirectMusicScript, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicScript, (void**)&script);
226 *ppObject = script;
227 return S_OK;
228 } else {
229 FIXME("bad iid\n");
232 /** for now alway return not supported for avoiding futur crash */
233 return DMUS_E_LOADER_FORMATNOTSUPPORTED;
236 ICOM_VTABLE(IDirectMusicLoader8) DirectMusicLoader8_Vtbl =
238 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
239 IDirectMusicLoader8Impl_QueryInterface,
240 IDirectMusicLoader8Impl_AddRef,
241 IDirectMusicLoader8Impl_Release,
242 IDirectMusicLoader8Impl_GetObject,
243 IDirectMusicLoader8Impl_SetObject,
244 IDirectMusicLoader8Impl_SetSearchDirectory,
245 IDirectMusicLoader8Impl_ScanDirectory,
246 IDirectMusicLoader8Impl_CacheObject,
247 IDirectMusicLoader8Impl_ReleaseObject,
248 IDirectMusicLoader8Impl_ClearCache,
249 IDirectMusicLoader8Impl_EnableCache,
250 IDirectMusicLoader8Impl_EnumObject,
251 IDirectMusicLoader8Impl_CollectGarbage,
252 IDirectMusicLoader8Impl_ReleaseObjectByUnknown,
253 IDirectMusicLoader8Impl_LoadObjectFromFile
256 /* for ClassFactory */
257 HRESULT WINAPI DMUSIC_CreateDirectMusicLoader (LPCGUID lpcGUID, LPDIRECTMUSICLOADER8 *ppDMLoad, LPUNKNOWN pUnkOuter)
259 IDirectMusicLoader8Impl *dmloader;
261 TRACE("(%p,%p,%p)\n",lpcGUID, ppDMLoad, pUnkOuter);
262 if (IsEqualGUID(lpcGUID, &IID_IDirectMusicLoader) ||
263 IsEqualGUID(lpcGUID, &IID_IDirectMusicLoader8))
265 dmloader = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoader8Impl));
266 if (NULL == dmloader) {
267 *ppDMLoad = (LPDIRECTMUSICLOADER8)NULL;
268 return E_OUTOFMEMORY;
270 dmloader->lpVtbl = &DirectMusicLoader8_Vtbl;
271 dmloader->ref = 1;
272 *ppDMLoad = (LPDIRECTMUSICLOADER8)dmloader;
273 return S_OK;
275 WARN("No interface found\n");
277 return E_NOINTERFACE;