Add support for some MCIWNDF_ styles, indicate that we do not support
[wine] / dlls / dmloader / container.c
1 /* IDirectMusicContainer
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 <stdarg.h>
21
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "wingdi.h"
26 #include "wine/debug.h"
27
28 #include "dmloader_private.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
31
32 /* IDirectMusicContainer IUnknown parts follow: */
33 HRESULT WINAPI IDirectMusicContainerImpl_QueryInterface (LPDIRECTMUSICCONTAINER iface, REFIID riid, LPVOID *ppobj)
34 {
35         ICOM_THIS(IDirectMusicContainerImpl,iface);
36
37         if (IsEqualIID (riid, &IID_IUnknown) || 
38             IsEqualIID (riid, &IID_IDirectMusicContainer)) {
39                 IDirectMusicContainerImpl_AddRef(iface);
40                 *ppobj = This;
41                 return S_OK;
42         }
43         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
44         return E_NOINTERFACE;
45 }
46
47 ULONG WINAPI IDirectMusicContainerImpl_AddRef (LPDIRECTMUSICCONTAINER iface)
48 {
49         ICOM_THIS(IDirectMusicContainerImpl,iface);
50         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
51         return ++(This->ref);
52 }
53
54 ULONG WINAPI IDirectMusicContainerImpl_Release (LPDIRECTMUSICCONTAINER iface)
55 {
56         ICOM_THIS(IDirectMusicContainerImpl,iface);
57         ULONG ref = --This->ref;
58         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
59         if (ref == 0) {
60                 HeapFree(GetProcessHeap(), 0, This);
61         }
62         return ref;
63 }
64
65 /* IDirectMusicContainer Interface follow: */
66 HRESULT WINAPI IDirectMusicContainerImpl_EnumObject (LPDIRECTMUSICCONTAINER iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc, WCHAR* pwszAlias)
67 {
68         ICOM_THIS(IDirectMusicContainerImpl,iface);
69
70         FIXME("(%p, %s, %ld, %p, %p): stub\n", This, debugstr_guid(rguidClass), dwIndex, pDesc, pwszAlias);
71
72         return S_OK;
73 }
74
75 ICOM_VTABLE(IDirectMusicContainer) DirectMusicContainer_Vtbl =
76 {
77     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
78         IDirectMusicContainerImpl_QueryInterface,
79         IDirectMusicContainerImpl_AddRef,
80         IDirectMusicContainerImpl_Release,
81         IDirectMusicContainerImpl_EnumObject
82 };
83
84 /* for ClassFactory */
85 HRESULT WINAPI DMUSIC_CreateDirectMusicContainer (LPCGUID lpcGUID, LPDIRECTMUSICCONTAINER *ppDMCon, LPUNKNOWN pUnkOuter)
86 {
87         IDirectMusicContainerImpl* dmcon;
88         
89         if (IsEqualIID (lpcGUID, &IID_IDirectMusicContainer)) {
90                 dmcon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerImpl));
91                 if (NULL == dmcon) {
92                         *ppDMCon = (LPDIRECTMUSICCONTAINER) NULL;
93                         return E_OUTOFMEMORY;
94                 }
95                 dmcon->lpVtbl = &DirectMusicContainer_Vtbl;
96                 dmcon->ref = 1;
97                 *ppDMCon = (LPDIRECTMUSICCONTAINER) dmcon;
98                 return S_OK;
99         }
100         WARN("No interface found\n");
101         
102         return E_NOINTERFACE;   
103 }
104
105 /*****************************************************************************
106  * IDirectMusicContainerObject implementation
107  */
108 /* IDirectMusicContainerObject IUnknown part: */
109 HRESULT WINAPI IDirectMusicContainerObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
110 {
111         ICOM_THIS(IDirectMusicContainerObject,iface);
112
113         if (IsEqualIID (riid, &IID_IUnknown) 
114                 || IsEqualIID (riid, &IID_IDirectMusicObject)) {
115                 IDirectMusicContainerObject_AddRef(iface);
116                 *ppobj = This;
117                 return S_OK;
118         } else if (IsEqualIID (riid, &IID_IPersistStream)) {
119                 IPersistStream_AddRef ((LPPERSISTSTREAM)This->pStream);
120                 *ppobj = (LPPERSISTSTREAM)This->pStream;
121                 return S_OK;
122         } else if (IsEqualIID (riid, &IID_IDirectMusicContainer)) {
123                 IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER)This->pContainer);
124                 *ppobj = (LPDIRECTMUSICCONTAINER)This->pContainer;
125                 return S_OK;
126         }
127         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
128         return E_NOINTERFACE;
129 }
130
131 ULONG WINAPI IDirectMusicContainerObject_AddRef (LPDIRECTMUSICOBJECT iface)
132 {
133         ICOM_THIS(IDirectMusicContainerObject,iface);
134         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
135         return ++(This->ref);
136 }
137
138 ULONG WINAPI IDirectMusicContainerObject_Release (LPDIRECTMUSICOBJECT iface)
139 {
140         ICOM_THIS(IDirectMusicContainerObject,iface);
141         ULONG ref = --This->ref;
142         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
143         if (ref == 0) {
144                 HeapFree(GetProcessHeap(), 0, This);
145         }
146         return ref;
147 }
148
149 /* IDirectMusicContainerObject IDirectMusicObject part: */
150 HRESULT WINAPI IDirectMusicContainerObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
151 {
152         ICOM_THIS(IDirectMusicContainerObject,iface);
153
154         TRACE("(%p, %p)\n", This, pDesc);
155         pDesc = This->pDesc;
156         
157         return S_OK;
158 }
159
160 HRESULT WINAPI IDirectMusicContainerObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
161 {
162         ICOM_THIS(IDirectMusicContainerObject,iface);
163
164         TRACE("(%p, %p)\n", This, pDesc);
165         This->pDesc = pDesc;
166
167         return S_OK;
168 }
169
170 HRESULT WINAPI IDirectMusicContainerObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
171 {
172         ICOM_THIS(IDirectMusicContainerObject,iface);
173
174         FIXME("(%p, %p, %p): stub\n", This, pStream, pDesc);
175
176         return S_OK;
177 }
178
179 ICOM_VTABLE(IDirectMusicObject) DirectMusicContainerObject_Vtbl =
180 {
181     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
182         IDirectMusicContainerObject_QueryInterface,
183         IDirectMusicContainerObject_AddRef,
184         IDirectMusicContainerObject_Release,
185         IDirectMusicContainerObject_GetDescriptor,
186         IDirectMusicContainerObject_SetDescriptor,
187         IDirectMusicContainerObject_ParseDescriptor
188 };
189
190 /* for ClassFactory */
191 HRESULT WINAPI DMUSIC_CreateDirectMusicContainerObject (LPCGUID lpcGUID, LPDIRECTMUSICOBJECT* ppObject, LPUNKNOWN pUnkOuter)
192 {
193         IDirectMusicContainerObject *obj;
194         
195         TRACE("(%p,%p,%p)\n", lpcGUID, ppObject, pUnkOuter);
196         if (IsEqualIID (lpcGUID, &IID_IDirectMusicObject)) {
197                 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerObject));
198                 if (NULL == obj) {
199                         *ppObject = (LPDIRECTMUSICOBJECT) NULL;
200                         return E_OUTOFMEMORY;
201                 }
202                 obj->lpVtbl = &DirectMusicContainerObject_Vtbl;
203                 obj->ref = 1;
204                 /* prepare IPersistStream */
205                 obj->pStream = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerObjectStream));
206                 obj->pStream->lpVtbl = &DirectMusicContainerObjectStream_Vtbl;
207                 obj->pStream->ref = 1;  
208                 obj->pStream->pParentObject = obj;
209                 /* prepare IDirectMusicContainer */
210                 DMUSIC_CreateDirectMusicContainer (&IID_IDirectMusicContainer, (LPDIRECTMUSICCONTAINER*)&obj->pContainer, NULL);
211                 obj->pContainer->pObject = obj;
212                 *ppObject = (LPDIRECTMUSICOBJECT) obj;
213                 return S_OK;
214         }
215         WARN("No interface found\n");
216         
217         return E_NOINTERFACE;
218 }
219         
220 /*****************************************************************************
221  * IDirectMusicContainerObjectStream implementation
222  */
223 /* IDirectMusicContainerObjectStream IUnknown part: */
224 HRESULT WINAPI IDirectMusicContainerObjectStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj)
225 {
226         ICOM_THIS(IDirectMusicContainerObjectStream,iface);
227
228         if (IsEqualIID (riid, &IID_IUnknown)
229                 || IsEqualIID (riid, &IID_IPersistStream)) {
230                 IDirectMusicContainerObjectStream_AddRef(iface);
231                 *ppobj = This;
232                 return S_OK;
233         }
234         
235         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
236         return E_NOINTERFACE;
237 }
238
239 ULONG WINAPI IDirectMusicContainerObjectStream_AddRef (LPPERSISTSTREAM iface)
240 {
241         ICOM_THIS(IDirectMusicContainerObjectStream,iface);
242         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
243         return ++(This->ref);
244 }
245
246 ULONG WINAPI IDirectMusicContainerObjectStream_Release (LPPERSISTSTREAM iface)
247 {
248         ICOM_THIS(IDirectMusicContainerObjectStream,iface);
249         ULONG ref = --This->ref;
250         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
251         if (ref == 0) {
252                 HeapFree(GetProcessHeap(), 0, This);
253         }
254         return ref;
255 }
256
257 /* IDirectMusicContainerObjectStream IPersist part: */
258 HRESULT WINAPI IDirectMusicContainerObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
259 {
260         return E_NOTIMPL;
261 }
262
263 /* IDirectMusicContainerObjectStream IPersistStream part: */
264 HRESULT WINAPI IDirectMusicContainerObjectStream_IsDirty (LPPERSISTSTREAM iface)
265 {
266         return E_NOTIMPL;
267 }
268
269 HRESULT WINAPI IDirectMusicContainerObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
270 {
271         FIXME(": Loading not implemented yet\n");
272         return S_OK;
273 }
274
275 HRESULT WINAPI IDirectMusicContainerObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
276 {
277         return E_NOTIMPL;
278 }
279
280 HRESULT WINAPI IDirectMusicContainerObjectStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
281 {
282         return E_NOTIMPL;
283 }
284
285 ICOM_VTABLE(IPersistStream) DirectMusicContainerObjectStream_Vtbl =
286 {
287     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
288         IDirectMusicContainerObjectStream_QueryInterface,
289         IDirectMusicContainerObjectStream_AddRef,
290         IDirectMusicContainerObjectStream_Release,
291         IDirectMusicContainerObjectStream_GetClassID,
292         IDirectMusicContainerObjectStream_IsDirty,
293         IDirectMusicContainerObjectStream_Load,
294         IDirectMusicContainerObjectStream_Save,
295         IDirectMusicContainerObjectStream_GetSizeMax
296 };