Moved libuuid to the dlls directory, and moved the DirectX GUIDs into
[wine] / dlls / dmloader / dmloader_main.c
1 /* DirectMusicLoader Main
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 #include "dmloader_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
23
24 typedef struct {
25     /* IUnknown fields */
26     ICOM_VFIELD(IClassFactory);
27     DWORD                       ref;
28 } IClassFactoryImpl;
29
30 /******************************************************************
31  *              DirectMusicLoader ClassFactory
32  */
33 static HRESULT WINAPI LoaderCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
34         ICOM_THIS(IClassFactoryImpl,iface);
35         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
36         return E_NOINTERFACE;
37 }
38
39 static ULONG WINAPI LoaderCF_AddRef(LPCLASSFACTORY iface) {
40         ICOM_THIS(IClassFactoryImpl,iface);
41         return ++(This->ref);
42 }
43
44 static ULONG WINAPI LoaderCF_Release(LPCLASSFACTORY iface) {
45         ICOM_THIS(IClassFactoryImpl,iface);
46         /* static class, won't be  freed */
47         return --(This->ref);
48 }
49
50 static HRESULT WINAPI LoaderCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
51         ICOM_THIS(IClassFactoryImpl,iface);
52         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
53         return DMUSIC_CreateDirectMusicLoaderImpl (riid, (LPVOID*) ppobj, pOuter);
54 }
55
56 static HRESULT WINAPI LoaderCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
57         ICOM_THIS(IClassFactoryImpl,iface);
58         FIXME("(%p)->(%d),stub!\n", This, dolock);
59         return S_OK;
60 }
61
62 static ICOM_VTABLE(IClassFactory) LoaderCF_Vtbl = {
63         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
64         LoaderCF_QueryInterface,
65         LoaderCF_AddRef,
66         LoaderCF_Release,
67         LoaderCF_CreateInstance,
68         LoaderCF_LockServer
69 };
70
71 static IClassFactoryImpl Loader_CF = {&LoaderCF_Vtbl, 1 };
72
73 /******************************************************************
74  *              DirectMusicContainer ClassFactory
75  */
76 static HRESULT WINAPI ContainerCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
77         ICOM_THIS(IClassFactoryImpl,iface);
78         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
79         return E_NOINTERFACE;
80 }
81
82 static ULONG WINAPI ContainerCF_AddRef(LPCLASSFACTORY iface) {
83         ICOM_THIS(IClassFactoryImpl,iface);
84         return ++(This->ref);
85 }
86
87 static ULONG WINAPI ContainerCF_Release(LPCLASSFACTORY iface) {
88         ICOM_THIS(IClassFactoryImpl,iface);
89         /* static class, won't be  freed */
90         return --(This->ref);
91 }
92
93 static HRESULT WINAPI ContainerCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
94         ICOM_THIS(IClassFactoryImpl,iface);
95         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
96         return DMUSIC_CreateDirectMusicContainerImpl (riid, (LPVOID*) ppobj, pOuter);
97 }
98
99 static HRESULT WINAPI ContainerCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
100         ICOM_THIS(IClassFactoryImpl,iface);
101         FIXME("(%p)->(%d),stub!\n", This, dolock);
102         return S_OK;
103 }
104
105 static ICOM_VTABLE(IClassFactory) ContainerCF_Vtbl = {
106         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
107         ContainerCF_QueryInterface,
108         ContainerCF_AddRef,
109         ContainerCF_Release,
110         ContainerCF_CreateInstance,
111         ContainerCF_LockServer
112 };
113
114 static IClassFactoryImpl Container_CF = {&ContainerCF_Vtbl, 1 };
115
116 /******************************************************************
117  *              DllMain
118  *
119  *
120  */
121 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
122         if (fdwReason == DLL_PROCESS_ATTACH) {
123             DisableThreadLibraryCalls(hinstDLL);
124                 /* FIXME: Initialisation */
125         }
126         else if (fdwReason == DLL_PROCESS_DETACH) {
127                 /* FIXME: Cleanup */
128         }
129         return TRUE;
130 }
131
132
133 /******************************************************************
134  *              DllCanUnloadNow (DMLOADER.1)
135  *
136  *
137  */
138 HRESULT WINAPI DMLOADER_DllCanUnloadNow(void) {
139     FIXME("(void): stub\n");
140     return S_FALSE;
141 }
142
143
144 /******************************************************************
145  *              DllGetClassObject (DMLOADER.2)
146  *
147  *
148  */
149 HRESULT WINAPI DMLOADER_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
150     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
151     if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLoader) && IsEqualIID (riid, &IID_IClassFactory)) {
152                 *ppv = (LPVOID) &Loader_CF;
153                 IClassFactory_AddRef((IClassFactory*)*ppv);
154                 return S_OK;
155         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicContainer) && IsEqualIID (riid, &IID_IClassFactory)) {
156                 *ppv = (LPVOID) &Container_CF;
157                 IClassFactory_AddRef((IClassFactory*)*ppv);
158                 return S_OK;
159         }
160         
161     WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
162     return CLASS_E_CLASSNOTAVAILABLE;
163 }