Authors: Martin Fuchs <martin-fuchs@gmx.net>, Ge van Geldorp <ge@gse.nl>
[wine] / dlls / dmband / dmband_main.c
1 /* DirectMusicBand 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 "dmband_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
23
24 typedef struct {
25     /* IUnknown fields */
26     ICOM_VFIELD(IClassFactory);
27     DWORD                       ref;
28 } IClassFactoryImpl;
29
30 /******************************************************************
31  *              DirectMusicBand ClassFactory
32  */
33  
34 static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
35         ICOM_THIS(IClassFactoryImpl,iface);
36
37         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
38         return E_NOINTERFACE;
39 }
40
41 static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface) {
42         ICOM_THIS(IClassFactoryImpl,iface);
43         return ++(This->ref);
44 }
45
46 static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface) {
47         ICOM_THIS(IClassFactoryImpl,iface);
48         /* static class, won't be  freed */
49         return --(This->ref);
50 }
51
52 static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
53         ICOM_THIS(IClassFactoryImpl,iface);
54         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
55         return DMUSIC_CreateDirectMusicBandImpl (riid, ppobj, pOuter);
56 }
57
58 static HRESULT WINAPI BandCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
59         ICOM_THIS(IClassFactoryImpl,iface);
60         FIXME("(%p)->(%d),stub!\n", This, dolock);
61         return S_OK;
62 }
63
64 static ICOM_VTABLE(IClassFactory) BandCF_Vtbl = {
65         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
66         BandCF_QueryInterface,
67         BandCF_AddRef,
68         BandCF_Release,
69         BandCF_CreateInstance,
70         BandCF_LockServer
71 };
72
73 static IClassFactoryImpl Band_CF = {&BandCF_Vtbl, 1 };
74
75
76 /******************************************************************
77  *              DirectMusicBandTrack ClassFactory
78  */
79  
80 static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
81         ICOM_THIS(IClassFactoryImpl,iface);
82
83         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
84         return E_NOINTERFACE;
85 }
86
87 static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface) {
88         ICOM_THIS(IClassFactoryImpl,iface);
89         return ++(This->ref);
90 }
91
92 static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface) {
93         ICOM_THIS(IClassFactoryImpl,iface);
94         /* static class, won't be  freed */
95         return --(This->ref);
96 }
97
98 static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
99         ICOM_THIS(IClassFactoryImpl,iface);
100         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
101         return DMUSIC_CreateDirectMusicBandTrack (riid, ppobj, pOuter);
102 }
103
104 static HRESULT WINAPI BandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
105         ICOM_THIS(IClassFactoryImpl,iface);
106         FIXME("(%p)->(%d),stub!\n", This, dolock);
107         return S_OK;
108 }
109
110 static ICOM_VTABLE(IClassFactory) BandTrackCF_Vtbl = {
111         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
112         BandTrackCF_QueryInterface,
113         BandTrackCF_AddRef,
114         BandTrackCF_Release,
115         BandTrackCF_CreateInstance,
116         BandTrackCF_LockServer
117 };
118
119 static IClassFactoryImpl BandTrack_CF = {&BandTrackCF_Vtbl, 1 };
120
121 /******************************************************************
122  *              DllMain
123  *
124  *
125  */
126 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
127         if (fdwReason == DLL_PROCESS_ATTACH) {
128             DisableThreadLibraryCalls(hinstDLL);
129                 /* FIXME: Initialisation */
130         } else if (fdwReason == DLL_PROCESS_DETACH) {
131                 /* FIXME: Cleanup */
132         }
133
134         return TRUE;
135 }
136
137
138 /******************************************************************
139  *              DllCanUnloadNow (DMBAND.1)
140  *
141  *
142  */
143 HRESULT WINAPI DMBAND_DllCanUnloadNow(void) {
144     FIXME("(void): stub\n");
145     return S_FALSE;
146 }
147
148
149 /******************************************************************
150  *              DllGetClassObject (DMBAND.2)
151  *
152  *
153  */
154 HRESULT WINAPI DMBAND_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
155     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
156
157         if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
158                 *ppv = (LPVOID) &Band_CF;
159                 IClassFactory_AddRef((IClassFactory*)*ppv);
160                 return S_OK;
161         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
162                 *ppv = (LPVOID) &BandTrack_CF;
163                 IClassFactory_AddRef((IClassFactory*)*ppv);
164                 return S_OK;    
165         }
166         
167     WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
168     return CLASS_E_CLASSNOTAVAILABLE;
169 }