/***************************************************************************
                            QProcess.cpp -  description
                             -------------------
    begin                : Wed Nov 21 17:05:56 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 17:05:56 2001, 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 <qprocess.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <qtjava/QProcess.h>

class QProcessJBridge : public QProcess
{
public:
	QProcessJBridge(QObject* parent, const char* name) : QProcess(parent, name) {}
	QProcessJBridge(const QString& arg0, QObject* parent, const char* name) : QProcess(arg0, parent, name) {}
	QProcessJBridge(const QStringList& args, QObject* parent, const char* name) : QProcess(args, parent, name) {}
	~QProcessJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_connectNotify(const char* signal) {
		QProcess::connectNotify(signal);
		return;
	}
	void protected_disconnectNotify(const char* signal) {
		QProcess::disconnectNotify(signal);
		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_qt_QProcess_newQProcess__Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject parent, jstring name)
{
static QCString * _qstring_name = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QProcessJBridge((QObject*) QtSupport::getQt(env, parent), (char*) QtSupport::toCharString(env, name, &_qstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_newQProcess__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring arg0, jobject parent, jstring name)
{
static QCString * _qstring_name = 0;
static QString * _qstring_arg0 = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QProcessJBridge((QString&) * (QString *) QtSupport::toQString(env, arg0, &_qstring_arg0), (QObject*) QtSupport::getQt(env, parent), (char*) QtSupport::toCharString(env, name, &_qstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_newQProcess__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring arg0)
{
static QString * _qstring_arg0 = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QProcessJBridge((QString&) * (QString *) QtSupport::toQString(env, arg0, &_qstring_arg0), 0, 0));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_newQProcess___3Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobjectArray args, jobject parent, jstring name)
{
static QCString * _qstring_name = 0;
static QStringList * _qlist_args = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QProcessJBridge((QStringList&) * (QStringList *) QtSupport::toQStringList(env, args, &_qlist_args), (QObject*) QtSupport::getQt(env, parent), (char*) QtSupport::toCharString(env, name, &_qstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_newQProcess___3Ljava_lang_String_2(JNIEnv *env, jobject obj, jobjectArray args)
{
static QStringList * _qlist_args = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QProcessJBridge((QStringList&) * (QStringList *) QtSupport::toQStringList(env, args, &_qlist_args), 0, 0));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj) && ((QProcess*)QtSupport::getQt(env, obj))->parent() == (QObject *) 0) {
		delete (QProcess*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QProcess_arguments(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((QProcessJBridge*) QtSupport::getQt(env, obj))->arguments();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_clearArguments(JNIEnv *env, jobject obj)
{
	((QProcessJBridge*) QtSupport::getQt(env, obj))->clearArguments();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_setArguments(JNIEnv *env, jobject obj, jobjectArray args)
{
static QStringList * _qlist_args = 0;
	((QProcessJBridge*) QtSupport::getQt(env, obj))->setArguments((QStringList&) * (QStringList *) QtSupport::toQStringList(env, args, &_qlist_args));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_addArgument(JNIEnv *env, jobject obj, jstring arg)
{
static QString * _qstring_arg = 0;
	((QProcessJBridge*) QtSupport::getQt(env, obj))->addArgument((QString&) * (QString *) QtSupport::toQString(env, arg, &_qstring_arg));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QProcess_workingDirectory(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QDir (((QProcessJBridge*) QtSupport::getQt(env, obj))->workingDirectory()), "org.kde.qt.QDir", TRUE);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_setWorkingDirectory(JNIEnv *env, jobject obj, jobject dir)
{
	((QProcessJBridge*) QtSupport::getQt(env, obj))->setWorkingDirectory((QDir&) *(QDir *) QtSupport::getQt(env, dir));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_setCommunication(JNIEnv *env, jobject obj, jint c)
{
	((QProcessJBridge*) QtSupport::getQt(env, obj))->setCommunication((int) c);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QProcess_communication(JNIEnv *env, jobject obj)
{
	return (jint) ((QProcessJBridge*) QtSupport::getQt(env, obj))->communication();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_start___3Ljava_lang_String_2(JNIEnv *env, jobject obj, jobjectArray _env)
{
static QStringList * _qlist_env = 0;
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->start((QStringList*) QtSupport::toQStringList(env, _env, &_qlist_env));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_start__(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->start(0);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_launch__Ljava_lang_String_2_3Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring buf, jobjectArray _env)
{
static QStringList * _qlist_env = 0;
static QString * _qstring_buf = 0;
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->launch((QString&) * (QString *) QtSupport::toQString(env, buf, &_qstring_buf), (QStringList*) QtSupport::toQStringList(env, _env, &_qlist_env));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_launch__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring buf)
{
static QString * _qstring_buf = 0;
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->launch((QString&) * (QString *) QtSupport::toQString(env, buf, &_qstring_buf), 0);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_launch___3B_3Ljava_lang_String_2(JNIEnv *env, jobject obj, jbyteArray buf, jobjectArray _env)
{
static QStringList * _qlist_env = 0;
static QByteArray * _qbyteArray_buf = 0;
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->launch((QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, buf, &_qbyteArray_buf), (QStringList*) QtSupport::toQStringList(env, _env, &_qlist_env));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_launch___3B(JNIEnv *env, jobject obj, jbyteArray buf)
{
static QByteArray * _qbyteArray_buf = 0;
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->launch((QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, buf, &_qbyteArray_buf), 0);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_isRunning(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->isRunning();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_normalExit(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->normalExit();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QProcess_exitStatus(JNIEnv *env, jobject obj)
{
	return (jint) ((QProcessJBridge*) QtSupport::getQt(env, obj))->exitStatus();
}

JNIEXPORT jbyteArray JNICALL
Java_org_kde_qt_QProcess_readStdout(JNIEnv *env, jobject obj)
{
	QByteArray  _qbyteArray;
	_qbyteArray = ((QProcessJBridge*) QtSupport::getQt(env, obj))->readStdout();
	return QtSupport::fromQByteArray(env, &_qbyteArray);
}

JNIEXPORT jbyteArray JNICALL
Java_org_kde_qt_QProcess_readStderr(JNIEnv *env, jobject obj)
{
	QByteArray  _qbyteArray;
	_qbyteArray = ((QProcessJBridge*) QtSupport::getQt(env, obj))->readStderr();
	return QtSupport::fromQByteArray(env, &_qbyteArray);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_canReadLineStdout(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->canReadLineStdout();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QProcess_canReadLineStderr(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QProcessJBridge*) QtSupport::getQt(env, obj))->canReadLineStderr();
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QProcess_readLineStdout(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((QProcessJBridge*) QtSupport::getQt(env, obj))->readLineStdout();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QProcess_readLineStderr(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((QProcessJBridge*) QtSupport::getQt(env, obj))->readLineStderr();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jlong JNICALL
Java_org_kde_qt_QProcess_processIdentifier(JNIEnv *env, jobject obj)
{
	return (jlong) ((QProcessJBridge*) QtSupport::getQt(env, obj))->processIdentifier();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_flushStdin(JNIEnv *env, jobject obj)
{
	((QProcessJBridge*) QtSupport::getQt(env, obj))->flushStdin();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_tryTerminate(JNIEnv *env, jobject obj)
{
	((QProcessJBridge*) QtSupport::getQt(env, obj))->tryTerminate();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_kill(JNIEnv *env, jobject obj)
{
	((QProcessJBridge*) QtSupport::getQt(env, obj))->kill();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_writeToStdin___3B(JNIEnv *env, jobject obj, jbyteArray buf)
{
static QByteArray * _qbyteArray_buf = 0;
	((QProcessJBridge*) QtSupport::getQt(env, obj))->writeToStdin((QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, buf, &_qbyteArray_buf));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_writeToStdin__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring buf)
{
static QString * _qstring_buf = 0;
	((QProcessJBridge*) QtSupport::getQt(env, obj))->writeToStdin((QString&) * (QString *) QtSupport::toQString(env, buf, &_qstring_buf));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_closeStdin(JNIEnv *env, jobject obj)
{
	((QProcessJBridge*) QtSupport::getQt(env, obj))->closeStdin();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_connectNotify(JNIEnv *env, jobject obj, jstring signal)
{
static QCString * _qstring_signal = 0;
	((QProcessJBridge*) QtSupport::getQt(env, obj))->protected_connectNotify((char*) QtSupport::toCharString(env, signal, &_qstring_signal));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QProcess_disconnectNotify(JNIEnv *env, jobject obj, jstring signal)
{
static QCString * _qstring_signal = 0;
	((QProcessJBridge*) QtSupport::getQt(env, obj))->protected_disconnectNotify((char*) QtSupport::toCharString(env, signal, &_qstring_signal));
	return;
}

