- implemented loader, loader's stream and loading of objects (now you
[wine] / dlls / dmstyle / style.c
1 /* IDirectMusicStyle8 Implementation
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 "windef.h"
21 #include "winbase.h"
22 #include "winuser.h"
23 #include "wingdi.h"
24 #include "wine/debug.h"
25
26 #include "dmstyle_private.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
29
30 /* IDirectMusicStyle8 IUnknown part: */
31 HRESULT WINAPI IDirectMusicStyle8Impl_QueryInterface (LPDIRECTMUSICSTYLE8 iface, REFIID riid, LPVOID *ppobj)
32 {
33         ICOM_THIS(IDirectMusicStyle8Impl,iface);
34
35         if (IsEqualIID (riid, &IID_IUnknown) || 
36             IsEqualIID (riid, &IID_IDirectMusicStyle) ||
37             IsEqualIID (riid, &IID_IDirectMusicStyle8)) {
38                 IDirectMusicStyle8Impl_AddRef(iface);
39                 *ppobj = This;
40                 return S_OK;
41         }
42
43         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
44         return E_NOINTERFACE;
45 }
46
47 ULONG WINAPI IDirectMusicStyle8Impl_AddRef (LPDIRECTMUSICSTYLE8 iface)
48 {
49         ICOM_THIS(IDirectMusicStyle8Impl,iface);
50         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
51         return ++(This->ref);
52 }
53
54 ULONG WINAPI IDirectMusicStyle8Impl_Release (LPDIRECTMUSICSTYLE8 iface)
55 {
56         ICOM_THIS(IDirectMusicStyle8Impl,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 /* IDirectMusicStyle8 IDirectMusicStyle part: */
66 HRESULT WINAPI IDirectMusicStyle8Impl_GetBand (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicBand** ppBand)
67 {
68         ICOM_THIS(IDirectMusicStyle8Impl,iface);
69
70         FIXME("(%p, %p, %p): stub\n", This, pwszName, ppBand);
71
72         return S_OK;
73 }
74
75 HRESULT WINAPI IDirectMusicStyle8Impl_EnumBand (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName)
76 {
77         ICOM_THIS(IDirectMusicStyle8Impl,iface);
78
79         FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
80
81         return S_OK;
82 }
83
84 HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultBand (LPDIRECTMUSICSTYLE8 iface, IDirectMusicBand** ppBand)
85 {
86         ICOM_THIS(IDirectMusicStyle8Impl,iface);
87
88         FIXME("(%p, %p): stub\n", This, ppBand);
89
90         return S_OK;
91 }
92
93 HRESULT WINAPI IDirectMusicStyle8Impl_EnumMotif (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName)
94 {
95         ICOM_THIS(IDirectMusicStyle8Impl,iface);
96
97         FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
98
99         return S_OK;
100 }
101
102 HRESULT WINAPI IDirectMusicStyle8Impl_GetMotif (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicSegment** ppSegment)
103 {
104         ICOM_THIS(IDirectMusicStyle8Impl,iface);
105
106         FIXME("(%p, %p, %p): stub\n", This, pwszName, ppSegment);
107
108         return S_OK;
109 }
110
111 HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultChordMap (LPDIRECTMUSICSTYLE8 iface, IDirectMusicChordMap** ppChordMap)
112 {
113         ICOM_THIS(IDirectMusicStyle8Impl,iface);
114
115         FIXME("(%p, %p): stub\n", This, ppChordMap);
116
117         return S_OK;
118 }
119
120 HRESULT WINAPI IDirectMusicStyle8Impl_EnumChordMap (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName)
121 {
122         ICOM_THIS(IDirectMusicStyle8Impl,iface);
123
124         FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
125
126         return S_OK;
127 }
128
129 HRESULT WINAPI IDirectMusicStyle8Impl_GetChordMap (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicChordMap** ppChordMap)
130 {
131         ICOM_THIS(IDirectMusicStyle8Impl,iface);
132
133         FIXME("(%p, %p, %p): stub\n", This, pwszName, ppChordMap);
134
135         return S_OK;
136 }
137
138 HRESULT WINAPI IDirectMusicStyle8Impl_GetTimeSignature (LPDIRECTMUSICSTYLE8 iface, DMUS_TIMESIGNATURE* pTimeSig)
139 {
140         ICOM_THIS(IDirectMusicStyle8Impl,iface);
141
142         FIXME("(%p, %p): stub\n", This, pTimeSig);
143
144         return S_OK;
145 }
146
147 HRESULT WINAPI IDirectMusicStyle8Impl_GetEmbellishmentLength (LPDIRECTMUSICSTYLE8 iface, DWORD dwType, DWORD dwLevel, DWORD* pdwMin, DWORD* pdwMax)
148 {
149         ICOM_THIS(IDirectMusicStyle8Impl,iface);
150
151         FIXME("(%p, %ld, %ld, %p, %p): stub\n", This, dwType, dwLevel, pdwMin, pdwMax);
152
153         return S_OK;
154 }
155
156 HRESULT WINAPI IDirectMusicStyle8Impl_GetTempo (LPDIRECTMUSICSTYLE8 iface, double* pTempo)
157 {
158         ICOM_THIS(IDirectMusicStyle8Impl,iface);
159
160         FIXME("(%p, %p): stub\n", This, pTempo);
161
162         return S_OK;
163 }
164
165 /* IDirectMusicStyle8 IDirectMusicStyle8 part: */
166 HRESULT WINAPI IDirectMusicStyle8ImplEnumPattern (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, DWORD dwPatternType, WCHAR* pwszName)
167 {
168         ICOM_THIS(IDirectMusicStyle8Impl,iface);
169
170         FIXME("(%p, %ld, %ld, %p): stub\n", This, dwIndex, dwPatternType, pwszName);
171
172         return S_OK;
173 }
174
175 ICOM_VTABLE(IDirectMusicStyle8) DirectMusicStyle8_Vtbl =
176 {
177     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
178         IDirectMusicStyle8Impl_QueryInterface,
179         IDirectMusicStyle8Impl_AddRef,
180         IDirectMusicStyle8Impl_Release,
181         IDirectMusicStyle8Impl_GetBand,
182         IDirectMusicStyle8Impl_EnumBand,
183         IDirectMusicStyle8Impl_GetDefaultBand,
184         IDirectMusicStyle8Impl_EnumMotif,
185         IDirectMusicStyle8Impl_GetMotif,
186         IDirectMusicStyle8Impl_GetDefaultChordMap,
187         IDirectMusicStyle8Impl_EnumChordMap,
188         IDirectMusicStyle8Impl_GetChordMap,
189         IDirectMusicStyle8Impl_GetTimeSignature,
190         IDirectMusicStyle8Impl_GetEmbellishmentLength,
191         IDirectMusicStyle8Impl_GetTempo,
192         IDirectMusicStyle8ImplEnumPattern
193 };
194
195 /* for ClassFactory */
196 HRESULT WINAPI DMUSIC_CreateDirectMusicStyle (LPCGUID lpcGUID, LPDIRECTMUSICSTYLE8* ppDMStyle, LPUNKNOWN pUnkOuter)
197 {
198         IDirectMusicStyle8Impl* dmstlye;
199         
200         if (IsEqualIID (lpcGUID, &IID_IDirectMusicStyle)
201                 || IsEqualIID (lpcGUID, &IID_IDirectMusicStyle8)) {
202                 dmstlye = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyle8Impl));
203                 if (NULL == dmstlye) {
204                         *ppDMStyle = (LPDIRECTMUSICSTYLE8) NULL;
205                         return E_OUTOFMEMORY;
206                 }
207                 dmstlye->lpVtbl = &DirectMusicStyle8_Vtbl;
208                 dmstlye->ref = 1;
209                 *ppDMStyle = (LPDIRECTMUSICSTYLE8) dmstlye;
210                 return S_OK;
211         }
212         
213         WARN("No interface found\n");
214         return E_NOINTERFACE;
215 }
216
217
218 /*****************************************************************************
219  * IDirectMusicStyleObject implementation
220  */
221 /* IDirectMusicStyleObject IUnknown part: */
222 HRESULT WINAPI IDirectMusicStyleObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
223 {
224         ICOM_THIS(IDirectMusicStyleObject,iface);
225
226         if (IsEqualIID (riid, &IID_IUnknown) 
227                 || IsEqualIID (riid, &IID_IDirectMusicObject)) {
228                 IDirectMusicStyleObject_AddRef(iface);
229                 *ppobj = This;
230                 return S_OK;
231         } else if (IsEqualIID (riid, &IID_IPersistStream)) {
232                 IPersistStream_AddRef ((LPPERSISTSTREAM)This->pStream);
233                 *ppobj = (LPPERSISTSTREAM)This->pStream;
234                 return S_OK;
235         } else if (IsEqualIID (riid, &IID_IDirectMusicStyle)
236                 || IsEqualIID (riid, &IID_IDirectMusicStyle8)) {
237                 IDirectMusicStyle8_AddRef ((LPDIRECTMUSICSTYLE8)This->pStyle);
238                 *ppobj = (LPDIRECTMUSICSTYLE8)This->pStyle;
239                 return S_OK;
240         }
241
242         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
243         return E_NOINTERFACE;
244 }
245
246 ULONG WINAPI IDirectMusicStyleObject_AddRef (LPDIRECTMUSICOBJECT iface)
247 {
248         ICOM_THIS(IDirectMusicStyleObject,iface);
249         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
250         return ++(This->ref);
251 }
252
253 ULONG WINAPI IDirectMusicStyleObject_Release (LPDIRECTMUSICOBJECT iface)
254 {
255         ICOM_THIS(IDirectMusicStyleObject,iface);
256         ULONG ref = --This->ref;
257         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
258         if (ref == 0) {
259                 HeapFree(GetProcessHeap(), 0, This);
260         }
261         return ref;
262 }
263
264 /* IDirectMusicStyleObject IDirectMusicObject part: */
265 HRESULT WINAPI IDirectMusicStyleObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
266 {
267         ICOM_THIS(IDirectMusicStyleObject,iface);
268
269         TRACE("(%p, %p)\n", This, pDesc);
270         pDesc = This->pDesc;
271         
272         return S_OK;
273 }
274
275 HRESULT WINAPI IDirectMusicStyleObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
276 {
277         ICOM_THIS(IDirectMusicStyleObject,iface);
278
279         TRACE("(%p, %p)\n", This, pDesc);
280         This->pDesc = pDesc;
281
282         return S_OK;
283 }
284
285 HRESULT WINAPI IDirectMusicStyleObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
286 {
287         ICOM_THIS(IDirectMusicStyleObject,iface);
288
289         FIXME("(%p, %p, %p): stub\n", This, pStream, pDesc);
290
291         return S_OK;
292 }
293
294 ICOM_VTABLE(IDirectMusicObject) DirectMusicStyleObject_Vtbl =
295 {
296     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
297         IDirectMusicStyleObject_QueryInterface,
298         IDirectMusicStyleObject_AddRef,
299         IDirectMusicStyleObject_Release,
300         IDirectMusicStyleObject_GetDescriptor,
301         IDirectMusicStyleObject_SetDescriptor,
302         IDirectMusicStyleObject_ParseDescriptor
303 };
304
305 /* for ClassFactory */
306 HRESULT WINAPI DMUSIC_CreateDirectMusicStyleObject (LPCGUID lpcGUID, LPDIRECTMUSICOBJECT* ppObject, LPUNKNOWN pUnkOuter)
307 {
308         IDirectMusicStyleObject *obj;
309         
310         TRACE("(%p,%p,%p)\n", lpcGUID, ppObject, pUnkOuter);
311         if (IsEqualIID (lpcGUID, &IID_IDirectMusicObject)) {
312                 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyleObject));
313                 if (NULL == obj) {
314                         *ppObject = (LPDIRECTMUSICOBJECT) NULL;
315                         return E_OUTOFMEMORY;
316                 }
317                 obj->lpVtbl = &DirectMusicStyleObject_Vtbl;
318                 obj->ref = 1;
319                 /* prepare IPersistStream */
320                 obj->pStream = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyleObjectStream));
321                 obj->pStream->lpVtbl = &DirectMusicStyleObjectStream_Vtbl;
322                 obj->pStream->ref = 1;  
323                 obj->pStream->pParentObject = obj;
324                 /* prepare IDirectMusicStyle */
325                 DMUSIC_CreateDirectMusicStyle (&IID_IDirectMusicStyle8, (LPDIRECTMUSICSTYLE8*)&obj->pStyle, NULL);
326                 obj->pStyle->pObject = obj;
327                 *ppObject = (LPDIRECTMUSICOBJECT) obj;
328                 return S_OK;
329         }
330         WARN("No interface found\n");
331         
332         return E_NOINTERFACE;
333 }
334         
335 /*****************************************************************************
336  * IDirectMusicStyleObjectStream implementation
337  */
338 /* IDirectMusicStyleObjectStream IUnknown part: */
339 HRESULT WINAPI IDirectMusicStyleObjectStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj)
340 {
341         ICOM_THIS(IDirectMusicStyleObjectStream,iface);
342
343         if (IsEqualIID (riid, &IID_IUnknown)
344                 || IsEqualIID (riid, &IID_IPersistStream)) {
345                 IDirectMusicStyleObjectStream_AddRef(iface);
346                 *ppobj = This;
347                 return S_OK;
348         }
349
350         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
351         return E_NOINTERFACE;
352 }
353
354 ULONG WINAPI IDirectMusicStyleObjectStream_AddRef (LPPERSISTSTREAM iface)
355 {
356         ICOM_THIS(IDirectMusicStyleObjectStream,iface);
357         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
358         return ++(This->ref);
359 }
360
361 ULONG WINAPI IDirectMusicStyleObjectStream_Release (LPPERSISTSTREAM iface)
362 {
363         ICOM_THIS(IDirectMusicStyleObjectStream,iface);
364         ULONG ref = --This->ref;
365         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
366         if (ref == 0) {
367                 HeapFree(GetProcessHeap(), 0, This);
368         }
369         return ref;
370 }
371
372 /* IDirectMusicStyleObjectStream IPersist part: */
373 HRESULT WINAPI IDirectMusicStyleObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
374 {
375         return E_NOTIMPL;
376 }
377
378 /* IDirectMusicStyleObjectStream IPersistStream part: */
379 HRESULT WINAPI IDirectMusicStyleObjectStream_IsDirty (LPPERSISTSTREAM iface)
380 {
381         return E_NOTIMPL;
382 }
383
384 HRESULT WINAPI IDirectMusicStyleObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
385 {
386         FIXME(": Loading not implemented yet\n");
387         return S_OK;
388 }
389
390 HRESULT WINAPI IDirectMusicStyleObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
391 {
392         return E_NOTIMPL;
393 }
394
395 HRESULT WINAPI IDirectMusicStyleObjectStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
396 {
397         return E_NOTIMPL;
398 }
399
400 ICOM_VTABLE(IPersistStream) DirectMusicStyleObjectStream_Vtbl =
401 {
402     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
403         IDirectMusicStyleObjectStream_QueryInterface,
404         IDirectMusicStyleObjectStream_AddRef,
405         IDirectMusicStyleObjectStream_Release,
406         IDirectMusicStyleObjectStream_GetClassID,
407         IDirectMusicStyleObjectStream_IsDirty,
408         IDirectMusicStyleObjectStream_Load,
409         IDirectMusicStyleObjectStream_Save,
410         IDirectMusicStyleObjectStream_GetSizeMax
411 };