If using the default values, also set dwType to REG_SZ as our default
[wine] / dlls / dmband / dmband_main.c
1 /* DirectMusicBand Main
2  *
3  * Copyright (C) 2003 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 {
26     /* IUnknown fields */
27     ICOM_VFIELD(IClassFactory);
28     DWORD                       ref;
29 } IClassFactoryImpl;
30
31 /******************************************************************
32  *              DirectMusicBand ClassFactory
33  */
34  
35 static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
36 {
37         ICOM_THIS(IClassFactoryImpl,iface);
38
39         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
40         return E_NOINTERFACE;
41 }
42
43 static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface)
44 {
45         ICOM_THIS(IClassFactoryImpl,iface);
46         return ++(This->ref);
47 }
48
49 static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface)
50 {
51         ICOM_THIS(IClassFactoryImpl,iface);
52         /* static class, won't be  freed */
53         return --(This->ref);
54 }
55
56 static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
57 {
58         ICOM_THIS(IClassFactoryImpl,iface);
59
60         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
61         if (IsEqualIID (riid, &IID_IDirectMusicBand)) {
62                 return DMUSIC_CreateDirectMusicBand (riid, (LPDIRECTMUSICBAND*) ppobj, pOuter);
63         } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
64                 return DMUSIC_CreateDirectMusicBandObject (riid, (LPDIRECTMUSICOBJECT*) ppobj, pOuter);
65         }
66         
67         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
68         return E_NOINTERFACE;
69 }
70
71 static HRESULT WINAPI BandCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
72 {
73         ICOM_THIS(IClassFactoryImpl,iface);
74         FIXME("(%p)->(%d),stub!\n", This, dolock);
75         return S_OK;
76 }
77
78 static ICOM_VTABLE(IClassFactory) BandCF_Vtbl = {
79         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
80         BandCF_QueryInterface,
81         BandCF_AddRef,
82         BandCF_Release,
83         BandCF_CreateInstance,
84         BandCF_LockServer
85 };
86
87 static IClassFactoryImpl Band_CF = {&BandCF_Vtbl, 1 };
88
89
90 /******************************************************************
91  *              DirectMusicBandTrack ClassFactory
92  */
93  
94 static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
95 {
96         ICOM_THIS(IClassFactoryImpl,iface);
97
98         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
99         return E_NOINTERFACE;
100 }
101
102 static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface)
103 {
104         ICOM_THIS(IClassFactoryImpl,iface);
105         return ++(This->ref);
106 }
107
108 static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface)
109 {
110         ICOM_THIS(IClassFactoryImpl,iface);
111         /* static class, won't be  freed */
112         return --(This->ref);
113 }
114
115 static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
116 {
117         ICOM_THIS(IClassFactoryImpl,iface);
118
119         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
120         if (IsEqualIID (riid, &IID_IDirectMusicTrack) 
121                 || IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
122                 return DMUSIC_CreateDirectMusicBandTrack (riid, (LPDIRECTMUSICTRACK8*) ppobj, pOuter);
123         }
124         
125         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
126         return E_NOINTERFACE;
127 }
128
129 static HRESULT WINAPI BandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
130 {
131         ICOM_THIS(IClassFactoryImpl,iface);
132         FIXME("(%p)->(%d),stub!\n", This, dolock);
133         return S_OK;
134 }
135
136 static ICOM_VTABLE(IClassFactory) BandTrackCF_Vtbl = {
137         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
138         BandTrackCF_QueryInterface,
139         BandTrackCF_AddRef,
140         BandTrackCF_Release,
141         BandTrackCF_CreateInstance,
142         BandTrackCF_LockServer
143 };
144
145 static IClassFactoryImpl BandTrack_CF = {&BandTrackCF_Vtbl, 1 };
146
147 /******************************************************************
148  *              DllMain
149  *
150  *
151  */
152 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
153 {
154         if (fdwReason == DLL_PROCESS_ATTACH)
155         {
156             DisableThreadLibraryCalls(hinstDLL);
157                 /* FIXME: Initialisation */
158         }
159         else if (fdwReason == DLL_PROCESS_DETACH)
160         {
161                 /* FIXME: Cleanup */
162         }
163
164         return TRUE;
165 }
166
167
168 /******************************************************************
169  *              DllCanUnloadNow (DMBAND.1)
170  *
171  *
172  */
173 HRESULT WINAPI DMBAND_DllCanUnloadNow(void)
174 {
175     FIXME("(void): stub\n");
176
177     return S_FALSE;
178 }
179
180
181 /******************************************************************
182  *              DllGetClassObject (DMBAND.2)
183  *
184  *
185  */
186 HRESULT WINAPI DMBAND_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
187 {
188     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
189
190         if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
191                 *ppv = (LPVOID) &Band_CF;
192                 IClassFactory_AddRef((IClassFactory*)*ppv);
193                 return S_OK;
194         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
195                 *ppv = (LPVOID) &BandTrack_CF;
196                 IClassFactory_AddRef((IClassFactory*)*ppv);
197                 return S_OK;    
198         }
199         
200     WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
201     return CLASS_E_CLASSNOTAVAILABLE;
202 }