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