/***************************************************************************
                            VoiceManager.cpp -  description
                             -------------------
    begin                : Sun Jan 27 16:22:17 2002
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Jan 27 16:22:17 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
***************************************************************************/

#define _BOOL_H_
#include <libkmid/voiceman.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <kdejava/KDESupport.h>
#include <kdejava/VoiceManager.h>

class VoiceManagerJBridge : public VoiceManager
{
public:
	VoiceManagerJBridge(int totalvoices) : VoiceManager(totalvoices) {}
	~VoiceManagerJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_VoiceManager_newVoiceManager(JNIEnv *env, jobject obj, jint totalvoices)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new VoiceManagerJBridge((int) totalvoices));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_VoiceManager_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj)) {
		delete (VoiceManager*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_VoiceManager_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_VoiceManager_finalize(env, obj);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_VoiceManager_isDisposed(JNIEnv *env, jobject obj)
{
	return (QtSupport::getQt(env, obj) == 0);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_VoiceManager_allocateVoice(JNIEnv *env, jobject obj, jint chn, jint key)
{
	return (jint) ((VoiceManager*) QtSupport::getQt(env, obj))->allocateVoice((int) chn, (int) key);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_VoiceManager_deallocateVoice(JNIEnv *env, jobject obj, jint identifier)
{
	((VoiceManager*) QtSupport::getQt(env, obj))->deallocateVoice((int) identifier);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_VoiceManager_initSearch(JNIEnv *env, jobject obj)
{
	((VoiceManager*) QtSupport::getQt(env, obj))->initSearch();
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_VoiceManager_search__I(JNIEnv *env, jobject obj, jint chn)
{
	return (jint) ((VoiceManager*) QtSupport::getQt(env, obj))->search((int) chn);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_VoiceManager_search__II(JNIEnv *env, jobject obj, jint chn, jint note)
{
	return (jint) ((VoiceManager*) QtSupport::getQt(env, obj))->search((int) chn, (int) note);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_VoiceManager_channel(JNIEnv *env, jobject obj, jint v)
{
	return (jint) ((VoiceManager*) QtSupport::getQt(env, obj))->channel((int) v);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_VoiceManager_note(JNIEnv *env, jobject obj, jint v)
{
	return (jint) ((VoiceManager*) QtSupport::getQt(env, obj))->note((int) v);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_VoiceManager_used(JNIEnv *env, jobject obj, jint v)
{
	return (jint) ((VoiceManager*) QtSupport::getQt(env, obj))->used((int) v);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_VoiceManager_clearLists(JNIEnv *env, jobject obj)
{
	((VoiceManager*) QtSupport::getQt(env, obj))->clearLists();
	return;
}

