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

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

class KFilterDevJBridge : public KFilterDev
{
public:
	KFilterDevJBridge(KFilterBase* filter, bool autodeleteFilterBase) : KFilterDev(filter, autodeleteFilterBase) {}
	~KFilterDevJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KFilterDev_newKFilterDev__Lorg_kde_koala_KFilterBase_2Z(JNIEnv *env, jobject obj, jobject filter, jboolean autodeleteFilterBase)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KFilterDevJBridge((KFilterBase*) QtSupport::getQt(env, filter), (bool) autodeleteFilterBase));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KFilterDev_newKFilterDev__Lorg_kde_koala_KFilterBase_2(JNIEnv *env, jobject obj, jobject filter)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KFilterDevJBridge((KFilterBase*) QtSupport::getQt(env, filter), false));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KFilterDev_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KFilterDev_finalize(env, obj);
	return;
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFilterDev_open(JNIEnv *env, jobject obj, jint mode)
{
	return (jboolean) ((KFilterDev*) QtSupport::getQt(env, obj))->open((int) mode);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KFilterDev_close(JNIEnv *env, jobject obj)
{
	((KFilterDev*) QtSupport::getQt(env, obj))->close();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KFilterDev_flush(JNIEnv *env, jobject obj)
{
	((KFilterDev*) QtSupport::getQt(env, obj))->flush();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KFilterDev_setOrigFileName(JNIEnv *env, jobject obj, jstring fileName)
{
static QCString * _qcstring_fileName = 0;
	((KFilterDev*) QtSupport::getQt(env, obj))->setOrigFileName((QCString&) * (QCString *) QtSupport::toQCString(env, fileName, &_qcstring_fileName));
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KFilterDev_size(JNIEnv *env, jobject obj)
{
	return (jint) ((KFilterDev*) QtSupport::getQt(env, obj))->size();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KFilterDev_at__(JNIEnv *env, jobject obj)
{
	return (jint) ((KFilterDev*) QtSupport::getQt(env, obj))->at();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFilterDev_at__I(JNIEnv *env, jobject obj, jint arg1)
{
	return (jboolean) ((KFilterDev*) QtSupport::getQt(env, obj))->at((QIODevice::Offset) arg1);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFilterDev_atEnd(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KFilterDev*) QtSupport::getQt(env, obj))->atEnd();
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_KFilterDev_readBlock(JNIEnv *env, jobject obj, jstring data, jlong maxlen)
{
static QCString * _qstring_data = 0;
	return (jlong) ((KFilterDev*) QtSupport::getQt(env, obj))->readBlock((char*) QtSupport::toCharString(env, data, &_qstring_data), (Q_ULONG) maxlen);
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_KFilterDev_writeBlock(JNIEnv *env, jobject obj, jstring data, jlong len)
{
static QCString * _qstring_data = 0;
	return (jlong) ((KFilterDev*) QtSupport::getQt(env, obj))->writeBlock((char*) QtSupport::toCharString(env, data, &_qstring_data), (Q_ULONG) len);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KFilterDev_getch(JNIEnv *env, jobject obj)
{
	return (jint) ((KFilterDev*) QtSupport::getQt(env, obj))->getch();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KFilterDev_putch(JNIEnv *env, jobject obj, jint arg1)
{
	return (jint) ((KFilterDev*) QtSupport::getQt(env, obj))->putch((int) arg1);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KFilterDev_ungetch(JNIEnv *env, jobject obj, jint arg1)
{
	return (jint) ((KFilterDev*) QtSupport::getQt(env, obj))->ungetch((int) arg1);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFilterDev_createFilterDevice(JNIEnv *env, jclass obj, jobject base, jobject file)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)KFilterDevJBridge::createFilterDevice((KFilterBase*) QtSupport::getQt(env, base), (QFile*) QtSupport::getQt(env, file)), "org.kde.qt.QIODeviceInterface");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFilterDev_deviceForFile__Ljava_lang_String_2Ljava_lang_String_2Z(JNIEnv *env, jclass obj, jstring fileName, jstring mimetype, jboolean forceFilter)
{
static QString * _qstring_mimetype = 0;
static QString * _qstring_fileName = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)KFilterDevJBridge::deviceForFile((QString&) * (QString *) QtSupport::toQString(env, fileName, &_qstring_fileName), (QString&) * (QString *) QtSupport::toQString(env, mimetype, &_qstring_mimetype), (bool) forceFilter), "org.kde.qt.QIODeviceInterface");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFilterDev_deviceForFile__Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring fileName)
{
static QString * _qstring_fileName = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)KFilterDevJBridge::deviceForFile((QString&) * (QString *) QtSupport::toQString(env, fileName, &_qstring_fileName), QString::null, false), "org.kde.qt.QIODeviceInterface");
}

