dmsynth: Correctly handle internal connections with controls.
[wine.git] / dlls / dmloader / dmloader_main.c
blob96d841e2b2dff165f99f54012ff38297a43ee967
1 /* DirectMusicLoader 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 "dmloader_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
39 typedef struct {
40 IClassFactory IClassFactory_iface;
41 HRESULT (*fnCreateInstance)(REFIID riid, void **ppv);
42 } IClassFactoryImpl;
44 /******************************************************************
45 * IClassFactory implementation
47 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
49 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
52 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
54 if (ppv == NULL)
55 return E_POINTER;
57 if (IsEqualGUID(&IID_IUnknown, riid))
58 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
59 else if (IsEqualGUID(&IID_IClassFactory, riid))
60 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
61 else {
62 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
63 *ppv = NULL;
64 return E_NOINTERFACE;
67 *ppv = iface;
68 IClassFactory_AddRef(iface);
69 return S_OK;
72 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
74 return 2; /* non-heap based object */
77 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
79 return 1; /* non-heap based object */
82 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
83 REFIID riid, void **ret_iface)
85 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
87 TRACE ("(%s, %p)\n", debugstr_dmguid(riid), ret_iface);
89 if (pUnkOuter) {
90 *ret_iface = NULL;
91 return CLASS_E_NOAGGREGATION;
94 return This->fnCreateInstance(riid, ret_iface);
97 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
99 TRACE("(%d)\n", dolock);
100 return S_OK;
103 static const IClassFactoryVtbl classfactory_vtbl = {
104 ClassFactory_QueryInterface,
105 ClassFactory_AddRef,
106 ClassFactory_Release,
107 ClassFactory_CreateInstance,
108 ClassFactory_LockServer
111 static IClassFactoryImpl dm_loader_CF = {{&classfactory_vtbl}, create_dmloader};
112 static IClassFactoryImpl dm_container_CF = {{&classfactory_vtbl}, create_dmcontainer};
115 /******************************************************************
116 * DllGetClassObject (DMLOADER.@)
118 HRESULT WINAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
120 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
121 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLoader) && IsEqualIID (riid, &IID_IClassFactory)) {
122 IClassFactory_AddRef(&dm_loader_CF.IClassFactory_iface);
123 *ppv = &dm_loader_CF.IClassFactory_iface;
124 return S_OK;
125 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicContainer) && IsEqualIID (riid, &IID_IClassFactory)) {
126 IClassFactory_AddRef(&dm_container_CF.IClassFactory_iface);
127 *ppv = &dm_container_CF.IClassFactory_iface;
128 return S_OK;
131 WARN(": no class found\n");
132 return CLASS_E_CLASSNOTAVAILABLE;