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

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

class KProcIOJBridge : public KProcIO
{
public:
	KProcIOJBridge(QTextCodec* codec) : KProcIO(codec) {}
	void protected_controlledEmission() {
		KProcIO::controlledEmission();
		return;
	}
	void protected_received(KProcess* proc, char* buffer, int buflen) {
		KProcIO::received(proc, buffer, buflen);
		return;
	}
	void protected_sent(KProcess* arg1) {
		KProcIO::sent(arg1);
		return;
	}
	void childEvent(QChildEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "childEvent", arg1, "org.kde.qt.QChildEvent")) {
			QObject::childEvent(arg1);
		}
		return;
	}
	void customEvent(QCustomEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "customEvent", arg1, "org.kde.qt.QCustomEvent")) {
			QObject::customEvent(arg1);
		}
		return;
	}
	void timerEvent(QTimerEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "timerEvent", arg1, "org.kde.qt.QTimerEvent")) {
			QObject::timerEvent(arg1);
		}
		return;
	}
};


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

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KProcIO_start__IZ(JNIEnv *env, jobject obj, jint runmode, jboolean includeStderr)
{
	return (jboolean) ((KProcIO*) QtSupport::getQt(env, obj))->start((KProcIO::RunMode) runmode, (bool) includeStderr);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KProcIO_start__(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KProcIO*) QtSupport::getQt(env, obj))->start(KProcIO::NotifyOnExit, false);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KProcIO_writeStdin__Ljava_lang_String_2Z(JNIEnv *env, jobject obj, jstring line, jboolean AppendNewLine)
{
static QString * _qstring_line = 0;
	return (jboolean) ((KProcIO*) QtSupport::getQt(env, obj))->writeStdin((QString&) * (QString *) QtSupport::toQString(env, line, &_qstring_line), (bool) AppendNewLine);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KProcIO_writeStdin__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring line)
{
static QString * _qstring_line = 0;
	return (jboolean) ((KProcIO*) QtSupport::getQt(env, obj))->writeStdin((QString&) * (QString *) QtSupport::toQString(env, line, &_qstring_line), TRUE);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KProcIO_fputs__Ljava_lang_String_2Z(JNIEnv *env, jobject obj, jstring line, jboolean AppendNewLine)
{
static QString * _qstring_line = 0;
	return (jboolean) ((KProcIO*) QtSupport::getQt(env, obj))->fputs((QString&) * (QString *) QtSupport::toQString(env, line, &_qstring_line), (bool) AppendNewLine);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KProcIO_fputs__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring line)
{
static QString * _qstring_line = 0;
	return (jboolean) ((KProcIO*) QtSupport::getQt(env, obj))->fputs((QString&) * (QString *) QtSupport::toQString(env, line, &_qstring_line), TRUE);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KProcIO_readln__Ljava_lang_String_2Z_3I(JNIEnv *env, jobject obj, jstring line, jboolean autoAck, jintArray partial)
{
static QString * _qstring_line = 0;
	return (jint) ((KProcIO*) QtSupport::getQt(env, obj))->readln((QString&) * (QString *) QtSupport::toQString(env, line, &_qstring_line), (bool) autoAck,  (bool*) QtSupport::toIntPtr(env, partial));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KProcIO_readln__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring line)
{
static QString * _qstring_line = 0;
	return (jint) ((KProcIO*) QtSupport::getQt(env, obj))->readln((QString&) * (QString *) QtSupport::toQString(env, line, &_qstring_line), true, 0);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KProcIO_fgets__Ljava_lang_String_2Z(JNIEnv *env, jobject obj, jstring line, jboolean autoAck)
{
static QString * _qstring_line = 0;
	return (jint) ((KProcIO*) QtSupport::getQt(env, obj))->fgets((QString&) * (QString *) QtSupport::toQString(env, line, &_qstring_line), (bool) autoAck);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KProcIO_fgets__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring line)
{
static QString * _qstring_line = 0;
	return (jint) ((KProcIO*) QtSupport::getQt(env, obj))->fgets((QString&) * (QString *) QtSupport::toQString(env, line, &_qstring_line), false);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KProcIO_resetAll(JNIEnv *env, jobject obj)
{
	((KProcIO*) QtSupport::getQt(env, obj))->resetAll();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KProcIO_ackRead(JNIEnv *env, jobject obj)
{
	((KProcIO*) QtSupport::getQt(env, obj))->ackRead();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KProcIO_enableReadSignals(JNIEnv *env, jobject obj, jboolean enable)
{
	((KProcIO*) QtSupport::getQt(env, obj))->enableReadSignals((bool) enable);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KProcIO_controlledEmission(JNIEnv *env, jobject obj)
{
	((KProcIOJBridge*) QtSupport::getQt(env, obj))->protected_controlledEmission();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KProcIO_received(JNIEnv *env, jobject obj, jobject proc, jstring buffer, jint buflen)
{
static QCString * _qstring_buffer = 0;
	((KProcIOJBridge*) QtSupport::getQt(env, obj))->protected_received((KProcess*) QtSupport::getQt(env, proc), (char*) QtSupport::toCharString(env, buffer, &_qstring_buffer), (int) buflen);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KProcIO_sent(JNIEnv *env, jobject obj, jobject arg1)
{
	((KProcIOJBridge*) QtSupport::getQt(env, obj))->protected_sent((KProcess*) QtSupport::getQt(env, arg1));
	return;
}

