/***************************************************************************
                            DeviceManager.cpp -  description
                             -------------------
    begin                : Sun Aug 26 09:45:02 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Aug 26 09:45:02 2001, using kdoc parser/custom Java conversion backend.
 ***************************************************************************/

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

#include <qtjava/QtSupport.h>
#include <kdejava/DeviceManager.h>

class DeviceManagerJBridge : public DeviceManager
{
public:
	DeviceManagerJBridge(int def) : DeviceManager(def) {}
	~DeviceManagerJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_seqbuf_dump() {
		DeviceManager::seqbuf_dump();
		return;
	}
	void protected_seqbuf_clean() {
		DeviceManager::seqbuf_clean();
		return;
	}
	void protected_checkAlsa() {
		DeviceManager::checkAlsa();
		return;
	}
};


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

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

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

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_initManager(JNIEnv *env, jobject obj)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->initManager();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_checkInit(JNIEnv *env, jobject obj)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->checkInit();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DeviceManager_chntodev(JNIEnv *env, jobject obj, jint chn)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->chntodev((int) chn), "org.kde.koala.MidiOut");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DeviceManager_deviceForChannel(JNIEnv *env, jobject obj, jint chn)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->deviceForChannel((int) chn), "org.kde.koala.MidiOut");
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_deviceNumberForChannel(JNIEnv *env, jobject obj, jint chn)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->deviceNumberForChannel((int) chn);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_setDeviceNumberForChannel(JNIEnv *env, jobject obj, jint chn, jint dev)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->setDeviceNumberForChannel((int) chn, (int) dev);
	return;
}

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

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_usingAlsa(JNIEnv *env, jobject obj)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->usingAlsa();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_openDev(JNIEnv *env, jobject obj)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->openDev();
	return;
}

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_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;
	((DeviceManagerJBridge*) 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_DeviceManager_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;
	((DeviceManagerJBridge*) 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_DeviceManager_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;
	((DeviceManagerJBridge*) 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_DeviceManager_chnPatchChange(JNIEnv *env, jobject obj, jstring chn, jstring patch)
{
static QCString * _qstring_patch = 0;
static QCString * _qstring_chn = 0;
	((DeviceManagerJBridge*) 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_DeviceManager_chnPressure(JNIEnv *env, jobject obj, jstring chn, jstring vel)
{
static QCString * _qstring_vel = 0;
static QCString * _qstring_chn = 0;
	((DeviceManagerJBridge*) 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_DeviceManager_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;
	((DeviceManagerJBridge*) 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_DeviceManager_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;
	((DeviceManagerJBridge*) 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_DeviceManager_sysEx(JNIEnv *env, jobject obj, jstring data, jlong size)
{
static QCString * _qstring_data = 0;
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->sysEx((uchar*) QtSupport::toCharString(env, data, &_qstring_data), (ulong) size);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_wait(JNIEnv *env, jobject obj, jdouble ms)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->wait((double) ms);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_tmrSetTempo(JNIEnv *env, jobject obj, jint v)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->tmrSetTempo((int) v);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_tmrStart(JNIEnv *env, jobject obj, jlong tpcn)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->tmrStart((long int) tpcn);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_tmrStop(JNIEnv *env, jobject obj)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->tmrStop();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_tmrContinue(JNIEnv *env, jobject obj)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->tmrContinue();
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_sync__Z(JNIEnv *env, jobject obj, jboolean f)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->sync((bool) f);
	return;
}

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

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

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_defaultDevice(JNIEnv *env, jobject obj)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->defaultDevice();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_setDefaultDevice(JNIEnv *env, jobject obj, jint i)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->setDefaultDevice((int) i);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_setPatchesToUse(JNIEnv *env, jobject obj, jintArray patchesused)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->setPatchesToUse( (int*) QtSupport::toIntPtr(env, patchesused));
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_setMidiMap(JNIEnv *env, jobject obj, jobject map)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->setMidiMap((MidiMapper*) QtSupport::getQt(env, map));
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_rate(JNIEnv *env, jobject obj)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->rate();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_midiPorts(JNIEnv *env, jobject obj)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->midiPorts();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_DeviceManager_synthDevices(JNIEnv *env, jobject obj)
{
	return (jint) ((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->synthDevices();
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DeviceManager_name(JNIEnv *env, jobject obj, jint i)
{
	const char * _qcstring;
	_qcstring = (const char *)((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->name((int) i);
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DeviceManager_type(JNIEnv *env, jobject obj, jint i)
{
	const char * _qcstring;
	_qcstring = (const char *)((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->type((int) i);
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_DeviceManager_checkAlsa(JNIEnv *env, jobject obj)
{
	((DeviceManagerJBridge*) QtSupport::getQt(env, obj))->protected_checkAlsa();
	return;
}

