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

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

class MidiMapperJBridge : public MidiMapper
{
public:
	MidiMapperJBridge(const char* name) : MidiMapper(name) {}
	~MidiMapperJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_MidiMapper_newMidiMapper(JNIEnv *env, jobject obj, jstring name)
{
static QCString * _qstring_name = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new MidiMapperJBridge((char*) QtSupport::toCharString(env, name, &_qstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiMapper_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_MidiMapper_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_MidiMapper_loadFile(JNIEnv *env, jobject obj, jstring name)
{
static QCString * _qstring_name = 0;
	((MidiMapper*) QtSupport::getQt(env, obj))->loadFile((char*) QtSupport::toCharString(env, name, &_qstring_name));
	return;
}

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

//JNIEXPORT jstring JNICALL
//Java_org_kde_koala_MidiMapper_channel(JNIEnv *env, jobject obj, jstring chn)
//{
//	uchar  _qcstring;
//static QCString * _qstring_chn = 0;
//	_qcstring = (const char *)((MidiMapper*) QtSupport::getQt(env, obj))->channel((uchar) QtSupport::toCharString(env, chn, &_qstring_chn));
//	return QtSupport::fromCharString(env, (char *) _qcstring);
//}

//JNIEXPORT jstring JNICALL
//Java_org_kde_koala_MidiMapper_patch(JNIEnv *env, jobject obj, jstring chn, jstring pgm)
//{
//	uchar  _qcstring;
//static QCString * _qstring_pgm = 0;
//static QCString * _qstring_chn = 0;
//	_qcstring = (const char *)((MidiMapper*) QtSupport::getQt(env, obj))->patch((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, pgm, &_qstring_pgm));
//	return QtSupport::fromCharString(env, (char *) _qcstring);
//}

//JNIEXPORT jstring JNICALL
//Java_org_kde_koala_MidiMapper_key(JNIEnv *env, jobject obj, jstring chn, jstring pgm, jstring note)
//{
//	uchar  _qcstring;
//static QCString * _qstring_note = 0;
//static QCString * _qstring_pgm = 0;
//static QCString * _qstring_chn = 0;
//	_qcstring = (const char *)((MidiMapper*) QtSupport::getQt(env, obj))->key((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar) QtSupport::toCharString(env, pgm, &_qstring_pgm), (uchar) QtSupport::toCharString(env, note, &_qstring_note));
//	return QtSupport::fromCharString(env, (char *) _qcstring);
//}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_MidiMapper_pitchBender(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;
//	((MidiMapper*) QtSupport::getQt(env, obj))->pitchBender((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_MidiMapper_controller(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;
//	((MidiMapper*) QtSupport::getQt(env, obj))->controller((uchar) QtSupport::toCharString(env, chn, &_qstring_chn), (uchar&) QtSupport::toCharString(env, ctl, &_qstring_ctl), (uchar&) QtSupport::toCharString(env, v, &_qstring_v));
//	return;
//}

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

