Tests for recent variant changes.
[wine] / dlls / dmcompos / chordmap.c
1 /* IDirectMusicChordMap 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 "dmcompos_private.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
31
32 /* IDirectMusicChordMap IUnknown parts follow: */
33 HRESULT WINAPI IDirectMusicChordMapImpl_QueryInterface (LPDIRECTMUSICCHORDMAP iface, REFIID riid, LPVOID *ppobj)
34 {
35         ICOM_THIS(IDirectMusicChordMapImpl,iface);
36
37         if (IsEqualIID (riid, &IID_IUnknown) || 
38             IsEqualIID (riid, &IID_IDirectMusicChordMap)) {
39                 IDirectMusicChordMapImpl_AddRef(iface);
40                 *ppobj = This;
41                 return S_OK;
42         }
43         
44         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
45         return E_NOINTERFACE;
46 }
47
48 ULONG WINAPI IDirectMusicChordMapImpl_AddRef (LPDIRECTMUSICCHORDMAP iface)
49 {
50         ICOM_THIS(IDirectMusicChordMapImpl,iface);
51         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
52         return ++(This->ref);
53 }
54
55 ULONG WINAPI IDirectMusicChordMapImpl_Release (LPDIRECTMUSICCHORDMAP iface)
56 {
57         ICOM_THIS(IDirectMusicChordMapImpl,iface);
58         ULONG ref = --This->ref;
59         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
60         if (ref == 0) {
61                 HeapFree(GetProcessHeap(), 0, This);
62         }
63         return ref;
64 }
65
66 /* IDirectMusicChordMap Interface follow: */
67 HRESULT WINAPI IDirectMusicChordMapImpl_GetScale (LPDIRECTMUSICCHORDMAP iface, DWORD* pdwScale)
68 {
69         ICOM_THIS(IDirectMusicChordMapImpl,iface);
70
71         TRACE("(%p, %p)\n", This, pdwScale);
72         *pdwScale = This->dwScale;
73
74         return S_OK;
75 }
76
77 ICOM_VTABLE(IDirectMusicChordMap) DirectMusicChordMap_Vtbl =
78 {
79     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
80         IDirectMusicChordMapImpl_QueryInterface,
81         IDirectMusicChordMapImpl_AddRef,
82         IDirectMusicChordMapImpl_Release,
83         IDirectMusicChordMapImpl_GetScale
84 };
85
86 /* for ClassFactory */
87 HRESULT WINAPI DMUSIC_CreateDirectMusicChordMap (LPCGUID lpcGUID, LPDIRECTMUSICCHORDMAP* ppDMCM, LPUNKNOWN pUnkOuter)
88 {
89         IDirectMusicChordMapImpl* dmchordmap;
90         
91         if (IsEqualIID (lpcGUID, &IID_IDirectMusicChordMap)) {
92                 dmchordmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicChordMapImpl));
93                 if (NULL == dmchordmap) {
94                         *ppDMCM = (LPDIRECTMUSICCHORDMAP) NULL;
95                         return E_OUTOFMEMORY;
96                 }
97                 dmchordmap->lpVtbl = &DirectMusicChordMap_Vtbl;
98                 dmchordmap->ref = 1;
99                 *ppDMCM = (LPDIRECTMUSICCHORDMAP) dmchordmap;
100                 return S_OK;
101         }
102         WARN("No interface found\n");
103         
104         return E_NOINTERFACE;   
105 }
106
107 /*****************************************************************************
108  * IDirectMusicChordMapObject implementation
109  */
110 /* IDirectMusicChordMapObject IUnknown part: */
111 HRESULT WINAPI IDirectMusicChordMapObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
112 {
113         ICOM_THIS(IDirectMusicChordMapObject,iface);
114
115         if (IsEqualIID (riid, &IID_IUnknown) 
116                 || IsEqualIID (riid, &IID_IDirectMusicObject)) {
117                 IDirectMusicChordMapObject_AddRef(iface);
118                 *ppobj = This;
119                 return S_OK;
120         } else if (IsEqualIID (riid, &IID_IPersistStream)) {
121                 IPersistStream_AddRef ((LPPERSISTSTREAM)This->pStream);
122                 *ppobj = (LPPERSISTSTREAM)This->pStream;
123                 return S_OK;
124         } else if (IsEqualIID (riid, &IID_IDirectMusicChordMap)) {
125                 IDirectMusicChordMap_AddRef ((LPDIRECTMUSICCHORDMAP)This->pChordMap);
126                 *ppobj = (LPDIRECTMUSICCHORDMAP)This->pChordMap;
127                 return S_OK;
128         }
129         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
130         return E_NOINTERFACE;
131 }
132
133 ULONG WINAPI IDirectMusicChordMapObject_AddRef (LPDIRECTMUSICOBJECT iface)
134 {
135         ICOM_THIS(IDirectMusicChordMapObject,iface);
136         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
137         return ++(This->ref);
138 }
139
140 ULONG WINAPI IDirectMusicChordMapObject_Release (LPDIRECTMUSICOBJECT iface)
141 {
142         ICOM_THIS(IDirectMusicChordMapObject,iface);
143         ULONG ref = --This->ref;
144         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
145         if (ref == 0) {
146                 HeapFree(GetProcessHeap(), 0, This);
147         }
148         return ref;
149 }
150
151 /* IDirectMusicChordMapObject IDirectMusicObject part: */
152 HRESULT WINAPI IDirectMusicChordMapObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
153 {
154         ICOM_THIS(IDirectMusicChordMapObject,iface);
155
156         TRACE("(%p, %p)\n", This, pDesc);
157         pDesc = This->pDesc;
158         
159         return S_OK;
160 }
161
162 HRESULT WINAPI IDirectMusicChordMapObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
163 {
164         ICOM_THIS(IDirectMusicChordMapObject,iface);
165
166         TRACE("(%p, %p)\n", This, pDesc);
167         This->pDesc = pDesc;
168
169         return S_OK;
170 }
171
172 HRESULT WINAPI IDirectMusicChordMapObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
173 {
174         ICOM_THIS(IDirectMusicChordMapObject,iface);
175
176         FIXME("(%p, %p, %p): stub\n", This, pStream, pDesc);
177
178         return S_OK;
179 }
180
181 ICOM_VTABLE(IDirectMusicObject) DirectMusicChordMapObject_Vtbl =
182 {
183     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
184         IDirectMusicChordMapObject_QueryInterface,
185         IDirectMusicChordMapObject_AddRef,
186         IDirectMusicChordMapObject_Release,
187         IDirectMusicChordMapObject_GetDescriptor,
188         IDirectMusicChordMapObject_SetDescriptor,
189         IDirectMusicChordMapObject_ParseDescriptor
190 };
191
192 /* for ClassFactory */
193 HRESULT WINAPI DMUSIC_CreateDirectMusicChordMapObject (LPCGUID lpcGUID, LPDIRECTMUSICOBJECT* ppObject, LPUNKNOWN pUnkOuter)
194 {
195         IDirectMusicChordMapObject *obj;
196         
197         TRACE("(%p,%p,%p)\n", lpcGUID, ppObject, pUnkOuter);
198         if (IsEqualIID (lpcGUID, &IID_IDirectMusicObject)) {
199                 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicChordMapObject));
200                 if (NULL == obj) {
201                         *ppObject = (LPDIRECTMUSICOBJECT) NULL;
202                         return E_OUTOFMEMORY;
203                 }
204                 obj->lpVtbl = &DirectMusicChordMapObject_Vtbl;
205                 obj->ref = 1;
206                 /* prepare IPersistStream */
207                 obj->pStream = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicChordMapObjectStream));
208                 obj->pStream->lpVtbl = &DirectMusicChordMapObjectStream_Vtbl;
209                 obj->pStream->ref = 1;  
210                 obj->pStream->pParentObject = obj;
211                 /* prepare IDirectMusiChordMap */
212                 DMUSIC_CreateDirectMusicChordMap (&IID_IDirectMusicChordMap, (LPDIRECTMUSICCHORDMAP*)&obj->pChordMap, NULL);
213                 obj->pChordMap->pObject = obj;
214                 *ppObject = (LPDIRECTMUSICOBJECT) obj;
215                 return S_OK;
216         }
217         WARN("No interface found\n");
218         
219         return E_NOINTERFACE;
220 }
221         
222 /*****************************************************************************
223  * IDirectMusicChordMapObjectStream implementation
224  */
225 /* IDirectMusicChordMapObjectStream IUnknown part: */
226 HRESULT WINAPI IDirectMusicChordMapObjectStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj)
227 {
228         ICOM_THIS(IDirectMusicChordMapObjectStream,iface);
229
230         if (IsEqualIID (riid, &IID_IUnknown)
231                 || IsEqualIID (riid, &IID_IPersistStream)) {
232                 IDirectMusicChordMapObjectStream_AddRef(iface);
233                 *ppobj = This;
234                 return S_OK;
235         }
236         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
237         return E_NOINTERFACE;
238 }
239
240 ULONG WINAPI IDirectMusicChordMapObjectStream_AddRef (LPPERSISTSTREAM iface)
241 {
242         ICOM_THIS(IDirectMusicChordMapObjectStream,iface);
243         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
244         return ++(This->ref);
245 }
246
247 ULONG WINAPI IDirectMusicChordMapObjectStream_Release (LPPERSISTSTREAM iface)
248 {
249         ICOM_THIS(IDirectMusicChordMapObjectStream,iface);
250         ULONG ref = --This->ref;
251         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
252         if (ref == 0) {
253                 HeapFree(GetProcessHeap(), 0, This);
254         }
255         return ref;
256 }
257
258 /* IDirectMusicChordMapObjectStream IPersist part: */
259 HRESULT WINAPI IDirectMusicChordMapObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
260 {
261         return E_NOTIMPL;
262 }
263
264 /* IDirectMusicChordMapObjectStream IPersistStream part: */
265 HRESULT WINAPI IDirectMusicChordMapObjectStream_IsDirty (LPPERSISTSTREAM iface)
266 {
267         return E_NOTIMPL;
268 }
269
270 HRESULT WINAPI IDirectMusicChordMapObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
271 {
272         FIXME(": Loading not implemented yet\n");
273         return S_OK;
274 }
275
276 HRESULT WINAPI IDirectMusicChordMapObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
277 {
278         return E_NOTIMPL;
279 }
280
281 HRESULT WINAPI IDirectMusicChordMapObjectStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
282 {
283         return E_NOTIMPL;
284 }
285
286 ICOM_VTABLE(IPersistStream) DirectMusicChordMapObjectStream_Vtbl =
287 {
288     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
289         IDirectMusicChordMapObjectStream_QueryInterface,
290         IDirectMusicChordMapObjectStream_AddRef,
291         IDirectMusicChordMapObjectStream_Release,
292         IDirectMusicChordMapObjectStream_GetClassID,
293         IDirectMusicChordMapObjectStream_IsDirty,
294         IDirectMusicChordMapObjectStream_Load,
295         IDirectMusicChordMapObjectStream_Save,
296         IDirectMusicChordMapObjectStream_GetSizeMax
297 };