dmstyle_main.c 13.7 KB
Newer Older
1 2
/* DirectMusicStyle Main
 *
3
 * Copyright (C) 2003-2004 Rok Mandeljc
4
 *
5 6 7 8
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
9 10 11
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
14
 *
15 16 17
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 19 20 21
 */

#include "dmstyle_private.h"

22
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
23

24 25
LONG DMSTYLE_refCount = 0;

26
typedef struct {
27
    const IClassFactoryVtbl *lpVtbl;
28 29
} IClassFactoryImpl;

30 31 32
/******************************************************************
 *		DirectMusicSection ClassFactory
 */
33
static HRESULT WINAPI SectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
34 35 36 37
	FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));

	if (ppobj == NULL) return E_POINTER;
	
38 39 40
	return E_NOINTERFACE;
}

41
static ULONG WINAPI SectionCF_AddRef(LPCLASSFACTORY iface) {
42 43 44
	DMSTYLE_LockModule();

	return 2; /* non-heap based object */
45 46
}

47
static ULONG WINAPI SectionCF_Release(LPCLASSFACTORY iface) {
48 49 50
	DMSTYLE_UnlockModule();

	return 1; /* non-heap based object */
51 52
}

53
static HRESULT WINAPI SectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
54 55
	TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);

56
	/* nothing here yet */
57 58
	WARN("(%s, %p): not found\n", debugstr_dmguid(riid), ppobj);
	
59 60 61
	return E_NOINTERFACE;
}

62
static HRESULT WINAPI SectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
63 64 65 66 67 68 69
	TRACE("(%d)\n", dolock);

	if (dolock)
		DMSTYLE_LockModule();
	else
		DMSTYLE_UnlockModule();

70 71 72
	return S_OK;
}

73
static const IClassFactoryVtbl SectionCF_Vtbl = {
74 75 76 77 78 79 80
	SectionCF_QueryInterface,
	SectionCF_AddRef,
	SectionCF_Release,
	SectionCF_CreateInstance,
	SectionCF_LockServer
};

81
static IClassFactoryImpl Section_CF = {&SectionCF_Vtbl};
82 83 84 85

/******************************************************************
 *		DirectMusicStyle ClassFactory
 */
86
static HRESULT WINAPI StyleCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
87 88 89 90
	FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));

	if (ppobj == NULL) return E_POINTER;
	
91 92 93
	return E_NOINTERFACE;
}

94
static ULONG WINAPI StyleCF_AddRef(LPCLASSFACTORY iface) {
95 96 97
	DMSTYLE_LockModule();

	return 2; /* non-heap based object */
98 99
}

100
static ULONG WINAPI StyleCF_Release(LPCLASSFACTORY iface) {
101 102 103
	DMSTYLE_UnlockModule();

	return 1; /* non-heap based object */
104 105
}

106
static HRESULT WINAPI StyleCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
107 108
	TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
	
109
	return DMUSIC_CreateDirectMusicStyleImpl (riid, ppobj, pOuter);
110 111
}

112
static HRESULT WINAPI StyleCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
113 114 115 116 117 118 119
	TRACE("(%d)\n", dolock);

	if (dolock)
		DMSTYLE_LockModule();
	else
		DMSTYLE_UnlockModule();

120 121 122
	return S_OK;
}

123
static const IClassFactoryVtbl StyleCF_Vtbl = {
124 125 126 127 128 129 130
	StyleCF_QueryInterface,
	StyleCF_AddRef,
	StyleCF_Release,
	StyleCF_CreateInstance,
	StyleCF_LockServer
};

131
static IClassFactoryImpl Style_CF = {&StyleCF_Vtbl};
132 133 134 135

/******************************************************************
 *		DirectMusicChordTrack ClassFactory
 */
136
static HRESULT WINAPI ChordTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
137 138 139 140
	FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));

	if (ppobj == NULL) return E_POINTER;
	
141 142 143
	return E_NOINTERFACE;
}

144
static ULONG WINAPI ChordTrackCF_AddRef(LPCLASSFACTORY iface) {
145 146 147
	DMSTYLE_LockModule();

	return 2; /* non-heap based object */
148 149
}

150
static ULONG WINAPI ChordTrackCF_Release(LPCLASSFACTORY iface) {
151 152 153
	DMSTYLE_UnlockModule();

	return 1; /* non-heap based object */
154 155
}

156
static HRESULT WINAPI ChordTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
157 158
	TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);

159
	return DMUSIC_CreateDirectMusicChordTrack (riid, ppobj, pOuter);
160 161
}

162
static HRESULT WINAPI ChordTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
163 164 165 166 167 168 169
	TRACE("(%d)\n", dolock);

	if (dolock)
		DMSTYLE_LockModule();
	else
		DMSTYLE_UnlockModule();
	
170 171 172
	return S_OK;
}

173
static const IClassFactoryVtbl ChordTrackCF_Vtbl = {
174 175 176 177 178 179 180
	ChordTrackCF_QueryInterface,
	ChordTrackCF_AddRef,
	ChordTrackCF_Release,
	ChordTrackCF_CreateInstance,
	ChordTrackCF_LockServer
};

181
static IClassFactoryImpl ChordTrack_CF = {&ChordTrackCF_Vtbl};
182 183 184 185

/******************************************************************
 *		DirectMusicCommandTrack ClassFactory
 */
186
static HRESULT WINAPI CommandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
187 188 189 190
	FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));

	if (ppobj == NULL) return E_POINTER;
	
191 192 193
	return E_NOINTERFACE;
}

194
static ULONG WINAPI CommandTrackCF_AddRef(LPCLASSFACTORY iface) {
195 196 197
	DMSTYLE_LockModule();

	return 2; /* non-heap based object */
198 199
}

200
static ULONG WINAPI CommandTrackCF_Release(LPCLASSFACTORY iface) {
201 202 203
	DMSTYLE_UnlockModule();

	return 1; /* non-heap based object */
204 205
}

206
static HRESULT WINAPI CommandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
207 208
	TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);

209
	return DMUSIC_CreateDirectMusicCommandTrack (riid, ppobj, pOuter);
210 211
}

212
static HRESULT WINAPI CommandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
213 214 215 216 217 218 219
	TRACE("(%d)\n", dolock);

	if (dolock)
		DMSTYLE_LockModule();
	else
		DMSTYLE_UnlockModule();
	
220 221 222
	return S_OK;
}

223
static const IClassFactoryVtbl CommandTrackCF_Vtbl = {
224 225 226 227 228 229 230
	CommandTrackCF_QueryInterface,
	CommandTrackCF_AddRef,
	CommandTrackCF_Release,
	CommandTrackCF_CreateInstance,
	CommandTrackCF_LockServer
};

231
static IClassFactoryImpl CommandTrack_CF = {&CommandTrackCF_Vtbl};
232 233 234 235

/******************************************************************
 *		DirectMusicStyleTrack ClassFactory
 */
236
static HRESULT WINAPI StyleTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
237 238 239 240
	FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));

	if (ppobj == NULL) return E_POINTER;
	
241 242 243
	return E_NOINTERFACE;
}

244
static ULONG WINAPI StyleTrackCF_AddRef(LPCLASSFACTORY iface) {
245 246 247
	DMSTYLE_LockModule();

	return 2; /* non-heap based object */
248 249
}

250
static ULONG WINAPI StyleTrackCF_Release(LPCLASSFACTORY iface) {
251 252 253
	DMSTYLE_UnlockModule();

	return 1; /* non-heap based object */
254 255
}

256
static HRESULT WINAPI StyleTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
257 258
	TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
	
259
	return DMUSIC_CreateDirectMusicStyleTrack (riid, ppobj, pOuter);
260 261
}

262
static HRESULT WINAPI StyleTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
263 264 265 266 267 268 269
	TRACE("(%d)\n", dolock);

	if (dolock)
		DMSTYLE_LockModule();
	else
		DMSTYLE_UnlockModule();
	
270 271 272
	return S_OK;
}

273
static const IClassFactoryVtbl StyleTrackCF_Vtbl = {
274 275 276 277 278
	StyleTrackCF_QueryInterface,
	StyleTrackCF_AddRef,
	StyleTrackCF_Release,
	StyleTrackCF_CreateInstance,
	StyleTrackCF_LockServer
279 280
};

281
static IClassFactoryImpl StyleTrack_CF = {&StyleTrackCF_Vtbl};
282 283 284 285

/******************************************************************
 *		DirectMusicMotifTrack ClassFactory
 */
286
static HRESULT WINAPI MotifTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
287 288 289 290
	FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));

	if (ppobj == NULL) return E_POINTER;
	
291 292 293
	return E_NOINTERFACE;
}

294
static ULONG WINAPI MotifTrackCF_AddRef(LPCLASSFACTORY iface) {
295 296 297
	DMSTYLE_LockModule();

	return 2; /* non-heap based object */
298 299
}

300
static ULONG WINAPI MotifTrackCF_Release(LPCLASSFACTORY iface) {
301 302 303
	DMSTYLE_UnlockModule();

	return 1; /* non-heap based object */
304 305
}

306
static HRESULT WINAPI MotifTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
307 308
	TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
	
309
	return DMUSIC_CreateDirectMusicMotifTrack (riid, ppobj, pOuter);
310 311
}

312
static HRESULT WINAPI MotifTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
313 314 315 316 317 318 319
	TRACE("(%d)\n", dolock);

	if (dolock)
		DMSTYLE_LockModule();
	else
		DMSTYLE_UnlockModule();
	
320 321 322
	return S_OK;
}

323
static const IClassFactoryVtbl MotifTrackCF_Vtbl = {
324 325 326 327 328 329 330
	MotifTrackCF_QueryInterface,
	MotifTrackCF_AddRef,
	MotifTrackCF_Release,
	MotifTrackCF_CreateInstance,
	MotifTrackCF_LockServer
};

331
static IClassFactoryImpl MotifTrack_CF = {&MotifTrackCF_Vtbl};
332 333 334 335

/******************************************************************
 *		DirectMusicAuditionTrack ClassFactory
 */
336
static HRESULT WINAPI AuditionTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
337 338 339 340
	FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));

	if (ppobj == NULL) return E_POINTER;
	
341 342 343
	return E_NOINTERFACE;
}

344
static ULONG WINAPI AuditionTrackCF_AddRef(LPCLASSFACTORY iface) {
345 346 347
	DMSTYLE_LockModule();

	return 2; /* non-heap based object */
348 349
}

350
static ULONG WINAPI AuditionTrackCF_Release(LPCLASSFACTORY iface) {
351 352 353
	DMSTYLE_UnlockModule();

	return 1; /* non-heap based object */
354 355
}

356
static HRESULT WINAPI AuditionTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
357 358
	TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
	
359
	return DMUSIC_CreateDirectMusicAuditionTrack (riid, ppobj, pOuter);
360 361
}

362
static HRESULT WINAPI AuditionTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
363 364 365 366 367 368 369
	TRACE("(%d)\n", dolock);

	if (dolock)
		DMSTYLE_LockModule();
	else
		DMSTYLE_UnlockModule();

370 371 372
	return S_OK;
}

373
static const IClassFactoryVtbl AuditionTrackCF_Vtbl = {
374 375 376 377 378 379 380
	AuditionTrackCF_QueryInterface,
	AuditionTrackCF_AddRef,
	AuditionTrackCF_Release,
	AuditionTrackCF_CreateInstance,
	AuditionTrackCF_LockServer
};

381
static IClassFactoryImpl AuditionTrack_CF = {&AuditionTrackCF_Vtbl};
382 383 384 385

/******************************************************************
 *		DirectMusicMuteTrack ClassFactory
 */
386
static HRESULT WINAPI MuteTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
387 388 389 390
	FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));

	if (ppobj == NULL) return E_POINTER;
	
391 392 393
	return E_NOINTERFACE;
}

394
static ULONG WINAPI MuteTrackCF_AddRef(LPCLASSFACTORY iface) {
395 396 397
	DMSTYLE_LockModule();

	return 2; /* non-heap based object */
398 399
}

400
static ULONG WINAPI MuteTrackCF_Release(LPCLASSFACTORY iface) {
401 402 403
	DMSTYLE_UnlockModule();

	return 1; /* non-heap based object */
404 405
}

406
static HRESULT WINAPI MuteTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
407 408
	TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);

409
	return DMUSIC_CreateDirectMusicMuteTrack (riid, ppobj, pOuter);
410 411
}

412
static HRESULT WINAPI MuteTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
413 414 415 416 417 418 419
	TRACE("(%d)\n", dolock);

	if (dolock)
		DMSTYLE_LockModule();
	else
		DMSTYLE_UnlockModule();
	
420 421 422
	return S_OK;
}

423
static const IClassFactoryVtbl MuteTrackCF_Vtbl = {
424 425 426 427 428 429 430
	MuteTrackCF_QueryInterface,
	MuteTrackCF_AddRef,
	MuteTrackCF_Release,
	MuteTrackCF_CreateInstance,
	MuteTrackCF_LockServer
};

431
static IClassFactoryImpl MuteTrack_CF = {&MuteTrackCF_Vtbl};
432

433 434 435 436 437
/******************************************************************
 *		DllMain
 *
 *
 */
438 439
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
	if (fdwReason == DLL_PROCESS_ATTACH) {
440 441
            DisableThreadLibraryCalls(hinstDLL);
		/* FIXME: Initialisation */
442
	} else if (fdwReason == DLL_PROCESS_DETACH) {
443 444 445 446 447 448 449 450 451 452 453 454
		/* FIXME: Cleanup */
	}

	return TRUE;
}


/******************************************************************
 *		DllCanUnloadNow (DMSTYLE.1)
 *
 *
 */
455
HRESULT WINAPI DllCanUnloadNow(void) {
456
	return DMSTYLE_refCount != 0 ? S_FALSE : S_OK;
457 458 459 460
}


/******************************************************************
461
 *		DllGetClassObject (DMSTYLE.@)
462 463 464
 *
 *
 */
465
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
466
    TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
    
	if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSection) && IsEqualIID (riid, &IID_IClassFactory)) {
		*ppv = (LPVOID) &Section_CF;
		IClassFactory_AddRef((IClassFactory*)*ppv);
		return S_OK;
	} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyle) && IsEqualIID (riid, &IID_IClassFactory)) {
		*ppv = (LPVOID) &Style_CF;
		IClassFactory_AddRef((IClassFactory*)*ppv);
		return S_OK;		
	} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
		*ppv = (LPVOID) &ChordTrack_CF;
		IClassFactory_AddRef((IClassFactory*)*ppv);
		return S_OK;	
	} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCommandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
		*ppv = (LPVOID) &CommandTrack_CF;
		IClassFactory_AddRef((IClassFactory*)*ppv);
		return S_OK;		
	} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyleTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
		*ppv = (LPVOID) &StyleTrack_CF;
		IClassFactory_AddRef((IClassFactory*)*ppv);
		return S_OK;		
	} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMotifTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
		*ppv = (LPVOID) &MotifTrack_CF;
		IClassFactory_AddRef((IClassFactory*)*ppv);
		return S_OK;		
	} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAuditionTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
		*ppv = (LPVOID) &AuditionTrack_CF;
		IClassFactory_AddRef((IClassFactory*)*ppv);
		return S_OK;		
	} else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMuteTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
		*ppv = (LPVOID) &MuteTrack_CF;
		IClassFactory_AddRef((IClassFactory*)*ppv);
		return S_OK;		
500
	}
501

502
    WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
503 504
    return CLASS_E_CLASSNOTAVAILABLE;
}