2003-07-22 00:10:14 +02:00
/* IDirectMusicLoader8 Implementation
2003-04-08 23:42:00 +02:00
*
* Copyright ( C ) 2003 Rok Mandeljc
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Library General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
2003-09-06 01:08:26 +02:00
# include <stdarg.h>
2003-04-08 23:42:00 +02:00
# include "windef.h"
# include "winbase.h"
# include "winuser.h"
# include "wingdi.h"
# include "wine/debug.h"
2003-06-13 20:59:51 +02:00
# include "wine/unicode.h"
2003-08-23 01:53:27 +02:00
# include "winreg.h"
2003-04-08 23:42:00 +02:00
2003-07-22 00:10:14 +02:00
# include "dmloader_private.h"
2003-04-08 23:42:00 +02:00
2003-08-23 01:53:27 +02:00
WINE_DEFAULT_DEBUG_CHANNEL ( dmloader ) ;
2003-04-08 23:42:00 +02:00
2003-08-23 01:53:27 +02:00
HRESULT WINAPI DMUSIC_GetDefaultGMPath ( WCHAR wszPath [ MAX_PATH ] ) ;
/* IDirectMusicLoader8 IUnknown part: */
2003-04-08 23:42:00 +02:00
HRESULT WINAPI IDirectMusicLoader8Impl_QueryInterface ( LPDIRECTMUSICLOADER8 iface , REFIID riid , LPVOID * ppobj )
{
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
2003-08-23 01:53:27 +02:00
if ( IsEqualIID ( riid , & IID_IUnknown ) | |
IsEqualIID ( riid , & IID_IDirectMusicLoader ) | |
IsEqualIID ( riid , & IID_IDirectMusicLoader8 ) ) {
2003-04-08 23:42:00 +02:00
IDirectMusicLoader8Impl_AddRef ( iface ) ;
* ppobj = This ;
2003-06-07 02:39:18 +02:00
return S_OK ;
2003-04-08 23:42:00 +02:00
}
2003-08-23 01:53:27 +02:00
2003-04-08 23:42:00 +02:00
WARN ( " (%p)->(%s,%p),not found \n " , This , debugstr_guid ( riid ) , ppobj ) ;
return E_NOINTERFACE ;
}
ULONG WINAPI IDirectMusicLoader8Impl_AddRef ( LPDIRECTMUSICLOADER8 iface )
{
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
TRACE ( " (%p) : AddRef from %ld \n " , This , This - > ref ) ;
return + + ( This - > ref ) ;
}
ULONG WINAPI IDirectMusicLoader8Impl_Release ( LPDIRECTMUSICLOADER8 iface )
{
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
ULONG ref = - - This - > ref ;
TRACE ( " (%p) : ReleaseRef to %ld \n " , This , This - > ref ) ;
2003-08-23 01:53:27 +02:00
if ( ref = = 0 ) {
2003-04-08 23:42:00 +02:00
HeapFree ( GetProcessHeap ( ) , 0 , This ) ;
}
return ref ;
}
2003-08-23 01:53:27 +02:00
/* IDirectMusicLoader8 IDirectMusicLoader part: */
2003-06-27 21:43:13 +02:00
HRESULT WINAPI IDirectMusicLoader8Impl_GetObject ( LPDIRECTMUSICLOADER8 iface , LPDMUS_OBJECTDESC pDesc , REFIID riid , LPVOID * ppv )
2003-04-08 23:42:00 +02:00
{
2003-08-23 01:53:27 +02:00
IDirectMusicObject * pObject ;
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
2003-08-23 01:53:27 +02:00
HRESULT result ;
2003-09-22 21:37:33 +02:00
struct list * listEntry ;
DMUS_PRIVATE_CACHE_ENTRY * cacheEntry ;
LPDMUS_PRIVATE_CACHE_ENTRY newEntry ;
2003-08-23 01:53:27 +02:00
2003-10-31 01:08:02 +01:00
TRACE ( " (%p, %p(dwValidData:0x%08lx), %s, %p) \n " , This , pDesc , pDesc - > dwValidData , debugstr_guid ( riid ) , ppv ) ;
2003-09-22 21:37:33 +02:00
TRACE ( " looking up cache... \n " ) ;
LIST_FOR_EACH ( listEntry , & This - > CacheList ) {
cacheEntry = LIST_ENTRY ( listEntry , DMUS_PRIVATE_CACHE_ENTRY , entry ) ;
if ( ( pDesc - > dwValidData & DMUS_OBJ_OBJECT ) | | ( pDesc - > dwValidData & DMUS_OBJ_FILENAME ) ) {
if ( pDesc - > dwValidData & DMUS_OBJ_OBJECT ) {
if ( IsEqualGUID ( & cacheEntry - > guidObject , & pDesc - > guidObject ) ) {
TRACE ( " : found it by GUID \n " ) ;
if ( cacheEntry - > pObject )
2003-10-31 01:08:02 +01:00
return IDirectMusicObject_QueryInterface ( ( LPDIRECTMUSICOBJECT ) cacheEntry - > pObject , riid , ppv ) ;
2003-08-23 01:53:27 +02:00
}
}
2003-09-22 21:37:33 +02:00
if ( pDesc - > dwValidData & DMUS_OBJ_FILENAME ) {
if ( cacheEntry - > wzFileName & & ! strncmpW ( pDesc - > wszFileName , cacheEntry - > wzFileName , MAX_PATH ) ) {
TRACE ( " : found it by FileName \n " ) ;
if ( cacheEntry - > pObject )
2003-10-31 01:08:02 +01:00
return IDirectMusicObject_QueryInterface ( ( LPDIRECTMUSICOBJECT ) cacheEntry - > pObject , riid , ppv ) ;
2003-08-23 01:53:27 +02:00
}
}
2003-10-31 01:08:02 +01:00
} else if ( pDesc - > dwValidData & DMUS_OBJ_NAME ) {
/**
* Usually search by name ( for example main procedure name for scripts ) after containers loading
* TODO : container loading code
*/
TRACE ( " comparing %s with cached %s (file:%s) \n " , debugstr_w ( pDesc - > wszName ) , debugstr_w ( cacheEntry - > wzName ) , debugstr_w ( cacheEntry - > wzFileName ) ) ;
if ( cacheEntry - > wzName & & ! strncmpW ( pDesc - > wszName , cacheEntry - > wzName , 256 ) ) {
TRACE ( " : found it by Name \n " ) ;
if ( NULL ! = cacheEntry - > pObject )
return IDirectMusicObject_QueryInterface ( ( LPDIRECTMUSICOBJECT ) cacheEntry - > pObject , riid , ppv ) ;
}
2003-08-23 01:53:27 +02:00
}
}
2003-09-22 21:37:33 +02:00
2003-08-23 01:53:27 +02:00
/* object doesn't exist in cache... guess we'll have to load it */
TRACE ( " : object does not exist in cache \n " ) ;
2003-10-31 01:08:02 +01:00
if ( pDesc - > dwValidData & DMUS_OBJ_LOADED ) {
ERR ( " Wanted a on-memory (cached) entry, but not found. Active Hack (waiting for Load code) \n " ) ;
/* ugly hack waiting for Load impl */
result = CoCreateInstance ( & pDesc - > guidClass , NULL , CLSCTX_INPROC_SERVER , & IID_IDirectMusicObject , ( LPVOID * ) & pObject ) ;
if ( SUCCEEDED ( result ) ) {
/* add object to cache */
result = IDirectMusicObject_QueryInterface ( pObject , riid , ppv ) ;
if ( SUCCEEDED ( result ) ) {
newEntry = ( LPDMUS_PRIVATE_CACHE_ENTRY ) HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( DMUS_PRIVATE_CACHE_ENTRY ) ) ;
if ( pDesc - > dwValidData & DMUS_OBJ_NAME )
strncpyW ( newEntry - > wzName , pDesc - > wszName , 256 ) ;
newEntry - > pObject = pObject ;
list_add_tail ( & This - > CacheList , & newEntry - > entry ) ;
TRACE ( " : filled in cache entry \n " ) ;
} else {
IDirectMusicObject_Release ( pObject ) ;
}
}
return result ;
/*
* Normal code
* ppv = NULL ;
return E_FAIL ;
*/
}
if ( ! ( pDesc - > dwValidData & DMUS_OBJ_CLASS ) ) {
WARN ( " guidClass not valid but needed. What they want to do ? \n " ) ;
* ppv = NULL ;
return DMUS_E_LOADER_NOCLASSID ;
}
result = CoCreateInstance ( & pDesc - > guidClass , NULL , CLSCTX_INPROC_SERVER , & IID_IDirectMusicObject , ( LPVOID * ) & pObject ) ;
2003-08-23 01:53:27 +02:00
if ( FAILED ( result ) ) return result ;
if ( pDesc - > dwValidData & DMUS_OBJ_FILENAME ) {
/* load object from file */
WCHAR wzFileName [ MAX_PATH ] ;
ILoaderStream * pStream ;
2003-10-31 01:08:02 +01:00
IPersistStream * pPersistStream = NULL ;
2003-08-23 01:53:27 +02:00
/* if it's full path, don't add search directory path, otherwise do */
if ( pDesc - > dwValidData & DMUS_OBJ_FULLPATH ) {
2003-10-31 01:08:02 +01:00
lstrcpyW ( wzFileName , pDesc - > wszFileName ) ;
2003-08-23 01:53:27 +02:00
} else {
2003-09-22 21:37:33 +02:00
WCHAR * p ;
2003-10-31 01:08:02 +01:00
lstrcpyW ( wzFileName , This - > wzSearchPath ) ;
2003-09-22 21:37:33 +02:00
p = wzFileName + lstrlenW ( wzFileName ) ;
if ( p > wzFileName & & p [ - 1 ] ! = ' \\ ' ) * p + + = ' \\ ' ;
2003-10-31 01:08:02 +01:00
strcpyW ( p , pDesc - > wszFileName ) ;
2003-08-23 01:53:27 +02:00
}
TRACE ( " : loading from file (%s) \n " , debugstr_w ( wzFileName ) ) ;
2003-10-31 01:08:02 +01:00
result = DMUSIC_CreateLoaderStream ( ( LPSTREAM * ) & pStream ) ;
2003-08-23 01:53:27 +02:00
if ( FAILED ( result ) ) return result ;
2003-10-31 01:08:02 +01:00
result = ILoaderStream_Attach ( pStream , wzFileName , ( LPDIRECTMUSICLOADER ) iface ) ;
2003-08-23 01:53:27 +02:00
if ( FAILED ( result ) ) return result ;
2003-10-31 01:08:02 +01:00
result = IDirectMusicObject_QueryInterface ( pObject , & IID_IPersistStream , ( LPVOID * ) & pPersistStream ) ;
2003-09-22 21:37:33 +02:00
if ( FAILED ( result ) ) return result ;
2003-08-23 01:53:27 +02:00
2003-10-31 01:08:02 +01:00
result = IPersistStream_Load ( pPersistStream , ( LPSTREAM ) pStream ) ;
2003-09-22 21:37:33 +02:00
if ( FAILED ( result ) ) return result ;
2003-08-23 01:53:27 +02:00
2003-10-31 01:08:02 +01:00
ILoaderStream_IStream_Release ( ( LPSTREAM ) pStream ) ;
2003-09-22 21:37:33 +02:00
IPersistStream_Release ( pPersistStream ) ;
2003-08-23 01:53:27 +02:00
} else if ( pDesc - > dwValidData & DMUS_OBJ_STREAM ) {
/* load object from stream */
IStream * pClonedStream = NULL ;
IPersistStream * pPersistStream = NULL ;
TRACE ( " : loading from stream \n " ) ;
2003-10-31 01:08:02 +01:00
result = IDirectMusicObject_QueryInterface ( pObject , & IID_IPersistStream , ( LPVOID * ) & pPersistStream ) ;
2003-09-22 21:37:33 +02:00
if ( FAILED ( result ) ) return result ;
2003-08-23 01:53:27 +02:00
2003-09-22 21:37:33 +02:00
result = IStream_Clone ( pDesc - > pStream , & pClonedStream ) ;
if ( FAILED ( result ) ) return result ;
2003-06-07 02:39:18 +02:00
2003-09-22 21:37:33 +02:00
result = IPersistStream_Load ( pPersistStream , pClonedStream ) ;
if ( FAILED ( result ) ) return result ;
2003-08-23 01:53:27 +02:00
IPersistStream_Release ( pPersistStream ) ;
IStream_Release ( pClonedStream ) ;
} else if ( pDesc - > dwValidData & DMUS_OBJ_OBJECT ) {
/* load object by GUID */
TRACE ( " : loading by GUID (only default DLS supported) \n " ) ;
if ( IsEqualGUID ( & pDesc - > guidObject , & GUID_DefaultGMCollection ) ) {
2003-09-22 21:37:33 +02:00
WCHAR wzFileName [ MAX_PATH ] ;
IPersistStream * pPersistStream = NULL ;
ILoaderStream * pStream ;
if ( FAILED ( DMUSIC_GetDefaultGMPath ( wzFileName ) ) )
2003-08-23 01:53:27 +02:00
return E_FAIL ;
2003-09-22 21:37:33 +02:00
/* load object from file */
2003-10-31 01:08:02 +01:00
result = DMUSIC_CreateLoaderStream ( ( LPSTREAM * ) & pStream ) ;
2003-09-22 21:37:33 +02:00
if ( FAILED ( result ) ) return result ;
2003-10-31 01:08:02 +01:00
result = ILoaderStream_Attach ( pStream , wzFileName , ( LPDIRECTMUSICLOADER ) iface ) ;
2003-09-22 21:37:33 +02:00
if ( FAILED ( result ) ) return result ;
2003-10-31 01:08:02 +01:00
result = IDirectMusicObject_QueryInterface ( pObject , & IID_IPersistStream , ( LPVOID * ) & pPersistStream ) ;
2003-09-22 21:37:33 +02:00
if ( FAILED ( result ) ) return result ;
2003-10-31 01:08:02 +01:00
result = IPersistStream_Load ( pPersistStream , ( LPSTREAM ) pStream ) ;
2003-09-22 21:37:33 +02:00
if ( FAILED ( result ) ) return result ;
2003-10-31 01:08:02 +01:00
ILoaderStream_IStream_Release ( ( LPSTREAM ) pStream ) ;
2003-09-22 21:37:33 +02:00
IPersistStream_Release ( pPersistStream ) ;
2003-08-23 01:53:27 +02:00
} else {
return E_FAIL ;
}
} else {
/* nowhere to load from */
FIXME ( " : unknown/unsupported way of loading \n " ) ;
return E_FAIL ;
}
2003-09-22 21:37:33 +02:00
/* add object to cache */
newEntry = ( LPDMUS_PRIVATE_CACHE_ENTRY ) HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( DMUS_PRIVATE_CACHE_ENTRY ) ) ;
if ( pDesc - > dwValidData & DMUS_OBJ_OBJECT )
memcpy ( & newEntry - > guidObject , & pDesc - > guidObject , sizeof ( pDesc - > guidObject ) ) ;
if ( pDesc - > dwValidData & DMUS_OBJ_FILENAME )
strncpyW ( newEntry - > wzFileName , pDesc - > wszFileName , MAX_PATH ) ;
if ( pObject )
newEntry - > pObject = pObject ;
list_add_tail ( & This - > CacheList , & newEntry - > entry ) ;
TRACE ( " : filled in cache entry \n " ) ;
2003-08-23 01:53:27 +02:00
2003-09-22 21:37:33 +02:00
/* for debug purposes (e.g. to check if all files are cached) */
#if 0
int i = 0 ;
LIST_FOR_EACH ( listEntry , & This - > CacheList ) {
i + + ;
cacheEntry = LIST_ENTRY ( listEntry , DMUS_PRIVATE_CACHE_ENTRY , entry ) ;
TRACE ( " Entry nr. %i: GUID = %s, FileName = %s \n " , i , debugstr_guid ( & cacheEntry - > guidObject ) , debugstr_w ( cacheEntry - > wzFileName ) ) ;
2003-08-23 01:53:27 +02:00
}
2003-09-22 21:37:33 +02:00
# endif
2003-08-23 01:53:27 +02:00
return IDirectMusicObject_QueryInterface ( pObject , riid , ppv ) ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_SetObject ( LPDIRECTMUSICLOADER8 iface , LPDMUS_OBJECTDESC pDesc )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p, %p): stub \n " , This , pDesc ) ;
return S_OK ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_SetSearchDirectory ( LPDIRECTMUSICLOADER8 iface , REFGUID rguidClass , WCHAR * pwzPath , BOOL fClear )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
2003-10-27 23:08:37 +01:00
TRACE ( " (%p, %s, %s, %d) \n " , This , debugstr_guid ( rguidClass ) , debugstr_w ( pwzPath ) , fClear ) ;
2003-08-23 01:53:27 +02:00
if ( 0 = = strncmpW ( This - > wzSearchPath , pwzPath , MAX_PATH ) ) {
2003-06-27 21:43:13 +02:00
return S_FALSE ;
}
2003-07-22 00:10:14 +02:00
strncpyW ( This - > wzSearchPath , pwzPath , MAX_PATH ) ;
2003-08-23 01:53:27 +02:00
return S_OK ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_ScanDirectory ( LPDIRECTMUSICLOADER8 iface , REFGUID rguidClass , WCHAR * pwzFileExtension , WCHAR * pwzScanFileName )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p, %s, %p, %p): stub \n " , This , debugstr_guid ( rguidClass ) , pwzFileExtension , pwzScanFileName ) ;
return S_OK ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_CacheObject ( LPDIRECTMUSICLOADER8 iface , IDirectMusicObject * pObject )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p, %p): stub \n " , This , pObject ) ;
return S_OK ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObject ( LPDIRECTMUSICLOADER8 iface , IDirectMusicObject * pObject )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p, %p): stub \n " , This , pObject ) ;
return S_OK ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_ClearCache ( LPDIRECTMUSICLOADER8 iface , REFGUID rguidClass )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p, %s): stub \n " , This , debugstr_guid ( rguidClass ) ) ;
return S_OK ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_EnableCache ( LPDIRECTMUSICLOADER8 iface , REFGUID rguidClass , BOOL fEnable )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p, %s, %d): stub \n " , This , debugstr_guid ( rguidClass ) , fEnable ) ;
return S_OK ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_EnumObject ( LPDIRECTMUSICLOADER8 iface , REFGUID rguidClass , DWORD dwIndex , LPDMUS_OBJECTDESC pDesc )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p, %s, %ld, %p): stub \n " , This , debugstr_guid ( rguidClass ) , dwIndex , pDesc ) ;
return S_OK ;
2003-04-08 23:42:00 +02:00
}
/* IDirectMusicLoader8 Interface part follow: */
void WINAPI IDirectMusicLoader8Impl_CollectGarbage ( LPDIRECTMUSICLOADER8 iface )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p): stub \n " , This ) ;
2003-04-08 23:42:00 +02:00
}
HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObjectByUnknown ( LPDIRECTMUSICLOADER8 iface , IUnknown * pObject )
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
FIXME ( " (%p, %p): stub \n " , This , pObject ) ;
return S_OK ;
2003-04-08 23:42:00 +02:00
}
2003-06-13 20:59:51 +02:00
HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile ( LPDIRECTMUSICLOADER8 iface ,
REFGUID rguidClassID ,
REFIID iidInterfaceID ,
WCHAR * pwzFilePath ,
void * * ppObject )
2003-04-08 23:42:00 +02:00
{
2003-06-07 02:39:18 +02:00
ICOM_THIS ( IDirectMusicLoader8Impl , iface ) ;
2003-08-23 01:53:27 +02:00
DMUS_OBJECTDESC ObjDesc ;
2003-06-24 04:26:07 +02:00
2003-08-23 01:53:27 +02:00
TRACE ( " (%p, %s, %s, %s, %p): wrapping to IDirectMusicLoader8Impl_GetObject \n " , This , debugstr_guid ( rguidClassID ) , debugstr_guid ( iidInterfaceID ) , debugstr_w ( pwzFilePath ) , ppObject ) ;
2003-06-13 20:59:51 +02:00
2003-08-23 01:53:27 +02:00
ObjDesc . dwSize = sizeof ( DMUS_OBJECTDESC ) ;
ObjDesc . dwValidData = DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH | DMUS_OBJ_CLASS ; /* I believe I've read somewhere in MSDN that this function requires either full path or relative path */
ObjDesc . guidClass = * rguidClassID ;
2003-10-28 01:10:38 +01:00
/* OK, MSDN says that search order is the following:
- current directory ( DONE )
- windows search path ( FIXME : how do I get that ? )
- loader ' s search path ( DONE )
*/
/* search in current directory */
if ( ! SearchPathW ( NULL , pwzFilePath , NULL ,
sizeof ( ObjDesc . wszFileName ) / sizeof ( WCHAR ) , ObjDesc . wszFileName , NULL ) & &
/* search in loader's search path */
! SearchPathW ( This - > wzSearchPath , pwzFilePath , NULL ,
sizeof ( ObjDesc . wszFileName ) / sizeof ( WCHAR ) , ObjDesc . wszFileName , NULL ) )
{
/* cannot find file */
TRACE ( " cannot find file \n " ) ;
return DMUS_E_LOADER_FAILEDOPEN ;
}
TRACE ( " full file path = %s \n " , debugstr_w ( ObjDesc . wszFileName ) ) ;
2003-08-23 01:53:27 +02:00
return IDirectMusicLoader8Impl_GetObject ( iface , & ObjDesc , iidInterfaceID , ppObject ) ;
2003-04-08 23:42:00 +02:00
}
ICOM_VTABLE ( IDirectMusicLoader8 ) DirectMusicLoader8_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectMusicLoader8Impl_QueryInterface ,
IDirectMusicLoader8Impl_AddRef ,
IDirectMusicLoader8Impl_Release ,
IDirectMusicLoader8Impl_GetObject ,
IDirectMusicLoader8Impl_SetObject ,
IDirectMusicLoader8Impl_SetSearchDirectory ,
IDirectMusicLoader8Impl_ScanDirectory ,
IDirectMusicLoader8Impl_CacheObject ,
IDirectMusicLoader8Impl_ReleaseObject ,
IDirectMusicLoader8Impl_ClearCache ,
IDirectMusicLoader8Impl_EnableCache ,
IDirectMusicLoader8Impl_EnumObject ,
IDirectMusicLoader8Impl_CollectGarbage ,
IDirectMusicLoader8Impl_ReleaseObjectByUnknown ,
IDirectMusicLoader8Impl_LoadObjectFromFile
} ;
2003-07-22 00:10:14 +02:00
/* for ClassFactory */
HRESULT WINAPI DMUSIC_CreateDirectMusicLoader ( LPCGUID lpcGUID , LPDIRECTMUSICLOADER8 * ppDMLoad , LPUNKNOWN pUnkOuter )
2003-05-04 04:26:03 +02:00
{
2003-07-22 00:10:14 +02:00
IDirectMusicLoader8Impl * dmloader ;
2003-05-04 04:26:03 +02:00
2003-07-22 00:10:14 +02:00
TRACE ( " (%p,%p,%p) \n " , lpcGUID , ppDMLoad , pUnkOuter ) ;
2003-08-23 01:53:27 +02:00
if ( IsEqualIID ( lpcGUID , & IID_IDirectMusicLoader ) | |
IsEqualIID ( lpcGUID , & IID_IDirectMusicLoader8 ) ) {
2003-07-22 00:10:14 +02:00
dmloader = HeapAlloc ( GetProcessHeap ( ) , HEAP_ZERO_MEMORY , sizeof ( IDirectMusicLoader8Impl ) ) ;
if ( NULL = = dmloader ) {
* ppDMLoad = ( LPDIRECTMUSICLOADER8 ) NULL ;
2003-05-04 04:26:03 +02:00
return E_OUTOFMEMORY ;
}
2003-07-22 00:10:14 +02:00
dmloader - > lpVtbl = & DirectMusicLoader8_Vtbl ;
dmloader - > ref = 1 ;
2003-10-28 01:10:38 +01:00
MultiByteToWideChar ( CP_ACP , 0 , " . \\ " , - 1 , dmloader - > wzSearchPath , MAX_PATH ) ;
2003-09-22 21:37:33 +02:00
list_init ( & dmloader - > CacheList ) ;
2003-07-22 00:10:14 +02:00
* ppDMLoad = ( LPDIRECTMUSICLOADER8 ) dmloader ;
2003-05-04 04:26:03 +02:00
return S_OK ;
}
2003-08-23 01:53:27 +02:00
WARN ( " No interface found \n " ) ;
2003-05-04 04:26:03 +02:00
return E_NOINTERFACE ;
}
2003-08-23 01:53:27 +02:00
/* help function for IDirectMusicLoader8Impl_GetObject */
HRESULT WINAPI DMUSIC_GetDefaultGMPath ( WCHAR wszPath [ MAX_PATH ] )
{
HKEY hkDM ;
DWORD returnType , sizeOfReturnBuffer = MAX_PATH ;
char szPath [ MAX_PATH ] ;
if ( ( RegOpenKeyExA ( HKEY_LOCAL_MACHINE , " Software \\ Microsoft \\ DirectMusic " , 0 , KEY_READ , & hkDM ) ! = ERROR_SUCCESS ) | |
( RegQueryValueExA ( hkDM , " GMFilePath " , NULL , & returnType , szPath , & sizeOfReturnBuffer ) ! = ERROR_SUCCESS ) ) {
WARN ( " : registry entry missing \n " ) ;
return E_FAIL ;
}
/* FIXME: Check return types to ensure we're interpreting data right */
MultiByteToWideChar ( CP_ACP , 0 , szPath , - 1 , wszPath , MAX_PATH ) ;
return S_OK ;
}