/***************************************************************************
                            FMOut.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/fmout.h>
#include <qstring.h>
#include <qcstring.h>

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

class FMOutJBridge : public FMOut
{
public:
	FMOutJBridge(int d, int total) : FMOut(d, total) {}
	~FMOutJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_newFMOut__II(JNIEnv *env, jobject obj, jint d, jint total)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new FMOutJBridge((int) d, (int) total));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_newFMOut__(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new FMOutJBridge(0, 12));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_FMOut_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_openDev(JNIEnv *env, jobject obj, jint sqfd)
{
	((FMOut*) QtSupport::getQt(env, obj))->openDev((int) sqfd);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_closeDev(JNIEnv *env, jobject obj)
{
	((FMOut*) QtSupport::getQt(env, obj))->closeDev();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_initDev(JNIEnv *env, jobject obj)
{
	((FMOut*) QtSupport::getQt(env, obj))->initDev();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_noteOn(JNIEnv *env, jobject obj, jstring chn, jstring note, jstring vel)
{
static QCString * _qstring_vel = 0;
static QCString * _qstring_note = 0;
static QCString * _qstring_chn = 0;
	((FMOut*) QtSupport::getQt(env, obj))->noteOn((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, note, &_qstring_note), (uchar) QtSupport::toCharString(env, vel, &_qstring_vel));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_noteOff(JNIEnv *env, jobject obj, jstring chn, jstring note, jstring vel)
{
static QCString * _qstring_vel = 0;
static QCString * _qstring_note = 0;
static QCString * _qstring_chn = 0;
	((FMOut*) QtSupport::getQt(env, obj))->noteOff((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, note, &_qstring_note), (uchar) QtSupport::toCharString(env, vel, &_qstring_vel));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_keyPressure(JNIEnv *env, jobject obj, jstring chn, jstring note, jstring vel)
{
static QCString * _qstring_vel = 0;
static QCString * _qstring_note = 0;
static QCString * _qstring_chn = 0;
	((FMOut*) QtSupport::getQt(env, obj))->keyPressure((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, note, &_qstring_note), (uchar) QtSupport::toCharString(env, vel, &_qstring_vel));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_chnPatchChange(JNIEnv *env, jobject obj, jstring chn, jstring patch)
{
static QCString * _qstring_patch = 0;
static QCString * _qstring_chn = 0;
	((FMOut*) QtSupport::getQt(env, obj))->chnPatchChange((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, patch, &_qstring_patch));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_chnPressure(JNIEnv *env, jobject obj, jstring chn, jstring vel)
{
static QCString * _qstring_vel = 0;
static QCString * _qstring_chn = 0;
	((FMOut*) QtSupport::getQt(env, obj))->chnPressure((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, vel, &_qstring_vel));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_chnPitchBender(JNIEnv *env, jobject obj, jstring chn, jstring lsb, jstring msb)
{
static QCString * _qstring_msb = 0;
static QCString * _qstring_lsb = 0;
static QCString * _qstring_chn = 0;
	((FMOut*) QtSupport::getQt(env, obj))->chnPitchBender((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, lsb, &_qstring_lsb), (uchar) QtSupport::toCharString(env, msb, &_qstring_msb));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_chnController(JNIEnv *env, jobject obj, jstring chn, jstring ctl, jstring v)
{
static QCString * _qstring_v = 0;
static QCString * _qstring_ctl = 0;
static QCString * _qstring_chn = 0;
	((FMOut*) QtSupport::getQt(env, obj))->chnController((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, ctl, &_qstring_ctl), (uchar) QtSupport::toCharString(env, v, &_qstring_v));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_sysex(JNIEnv *env, jobject obj, jstring data, jlong size)
{
static QCString * _qstring_data = 0;
	((FMOut*) QtSupport::getQt(env, obj))->sysex((uchar*) QtSupport::toCharString(env, data, &_qstring_data), (ulong) size);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_setVolumePercentage(JNIEnv *env, jobject obj, jint i)
{
	((FMOut*) QtSupport::getQt(env, obj))->setVolumePercentage((int) i);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_FMOut_patch(JNIEnv *env, jobject obj, jint p)
{
	return (jint) ((FMOut*) QtSupport::getQt(env, obj))->patch((int) p);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_FMOut_setFMPatchesDirectory(JNIEnv *env, jclass obj, jstring dir)
{
static QCString * _qstring_dir = 0;
	FMOutJBridge::setFMPatchesDirectory((char*) QtSupport::toCharString(env, dir, &_qstring_dir));
	return;
}

