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

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

class MidiOutJBridge : public MidiOut
{
public:
	MidiOutJBridge(int d) : MidiOut(d) {}
	~MidiOutJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_seqbuf_dump() {
		MidiOut::seqbuf_dump();
		return;
	}
	void protected_seqbuf_clean() {
		MidiOut::seqbuf_clean();
		return;
	}
};


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

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_MidiOut_finalize(env, obj);
	return;
}

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

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

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

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

JNIEXPORT jint JNICALL
Java_org_kde_koala_MidiOut_deviceType(JNIEnv *env, jobject obj)
{
	return (jint) ((MidiOut*) QtSupport::getQt(env, obj))->deviceType();
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_MidiOut_deviceName(JNIEnv *env, jobject obj)
{
	const char *  _qcstring;
	_qcstring = (const char *)((MidiOut*) QtSupport::getQt(env, obj))->deviceName();
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_setMidiMapper(JNIEnv *env, jobject obj, jobject map)
{
	((MidiOut*) QtSupport::getQt(env, obj))->setMidiMapper((MidiMapper*) QtSupport::getQt(env, map));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_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;
	((MidiOut*) 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_MidiOut_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;
	((MidiOut*) 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_MidiOut_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;
	((MidiOut*) 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_MidiOut_chnPatchChange(JNIEnv *env, jobject obj, jstring chn, jstring patch)
{
static QCString * _qstring_patch = 0;
static QCString * _qstring_chn = 0;
	((MidiOut*) 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_MidiOut_chnPressure(JNIEnv *env, jobject obj, jstring chn, jstring vel)
{
static QCString * _qstring_vel = 0;
static QCString * _qstring_chn = 0;
	((MidiOut*) 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_MidiOut_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;
	((MidiOut*) 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_MidiOut_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;
	((MidiOut*) 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_MidiOut_sysex(JNIEnv *env, jobject obj, jstring data, jlong size)
{
static QCString * _qstring_data = 0;
	((MidiOut*) QtSupport::getQt(env, obj))->sysex((uchar*) QtSupport::toCharString(env, data, &_qstring_data), (ulong) size);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_allNotesOff(JNIEnv *env, jobject obj)
{
	((MidiOut*) QtSupport::getQt(env, obj))->allNotesOff();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_channelSilence(JNIEnv *env, jobject obj, jstring chn)
{
static QCString * _qstring_chn = 0;
	((MidiOut*) QtSupport::getQt(env, obj))->channelSilence((uchar) QtSupport::toCharString(env, chn, &_qstring_chn));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_channelMute(JNIEnv *env, jobject obj, jstring chn, jint a)
{
static QCString * _qstring_chn = 0;
	((MidiOut*) QtSupport::getQt(env, obj))->channelMute((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (int) a);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_setVolumePercentage(JNIEnv *env, jobject obj, jint volper)
{
	((MidiOut*) QtSupport::getQt(env, obj))->setVolumePercentage((int) volper);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_MidiOut_ok(JNIEnv *env, jobject obj)
{
	return (jint) ((MidiOut*) QtSupport::getQt(env, obj))->ok();
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_MidiOut_midiMapFilename(JNIEnv *env, jobject obj)
{
	const char * _qcstring;
	_qcstring = (const char *)((MidiOut*) QtSupport::getQt(env, obj))->midiMapFilename();
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_sync__I(JNIEnv *env, jobject obj, jint i)
{
	((MidiOut*) QtSupport::getQt(env, obj))->sync((int) i);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_sync__(JNIEnv *env, jobject obj)
{
	((MidiOut*) QtSupport::getQt(env, obj))->sync(0);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_seqbuf_1dump(JNIEnv *env, jobject obj)
{
	((MidiOutJBridge*) QtSupport::getQt(env, obj))->protected_seqbuf_dump();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiOut_seqbuf_1clean(JNIEnv *env, jobject obj)
{
	((MidiOutJBridge*) QtSupport::getQt(env, obj))->protected_seqbuf_clean();
	return;
}

