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

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

class KRunJBridge : public KRun
{
public:
	KRunJBridge(const KURL& url, mode_t mode, bool isLocalFile, bool showProgressInfo) : KRun(url, mode, isLocalFile, showProgressInfo) {}
	~KRunJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_init() {
		KRun::init();
		return;
	}
	void protected_scanFile() {
		KRun::scanFile();
		return;
	}
	void protected_foundMimeType(const QString& _type) {
		KRun::foundMimeType(_type);
		return;
	}
	void protected_killJob() {
		KRun::killJob();
		return;
	}
	void protected_slotTimeout() {
		KRun::slotTimeout();
		return;
	}
	void protected_slotScanFinished(KIO::Job* arg1) {
		KRun::slotScanFinished(arg1);
		return;
	}
	void protected_slotScanMimeType(KIO::Job* arg1, const QString& type) {
		KRun::slotScanMimeType(arg1, type);
		return;
	}
	void protected_slotStatResult(KIO::Job* arg1) {
		KRun::slotStatResult(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_KRun_newKRun__Lorg_kde_koala_KURL_2JZZ(JNIEnv *env, jobject obj, jobject url, jlong mode, jboolean isLocalFile, jboolean showProgressInfo)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KRunJBridge((KURL&) *(KURL *) QtSupport::getQt(env, url), (mode_t) mode, (bool) isLocalFile, (bool) showProgressInfo));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_newKRun__Lorg_kde_koala_KURL_2(JNIEnv *env, jobject obj, jobject url)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KRunJBridge((KURL&) *(KURL *) QtSupport::getQt(env, url), 0, false, true));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KRun_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_abort(JNIEnv *env, jobject obj)
{
	((KRun*) QtSupport::getQt(env, obj))->abort();
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KRun_hasError(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KRun*) QtSupport::getQt(env, obj))->hasError();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KRun_hasFinished(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KRun*) QtSupport::getQt(env, obj))->hasFinished();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KRun_autoDelete(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KRun*) QtSupport::getQt(env, obj))->autoDelete();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_setAutoDelete(JNIEnv *env, jobject obj, jboolean b)
{
	((KRun*) QtSupport::getQt(env, obj))->setAutoDelete((bool) b);
	return;
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_KRun_run__Lorg_kde_koala_KService_2Ljava_util_ArrayList_2(JNIEnv *env, jclass obj, jobject _service, jobjectArray _urls)
{
static KURL::List * _qlist__urls = 0;
	return (jlong) KRunJBridge::run((KService&) *(KService *) QtSupport::getQt(env, _service), (KURL::List&) * (KURL::List *) KDESupport::toKURLList(env, _urls, &_qlist__urls));
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_KRun_run__Ljava_lang_String_2Ljava_util_ArrayList_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring _exec, jobjectArray _urls, jstring _name, jstring _icon, jstring _obsolete1, jstring _obsolete2)
{
static QString * _qstring__obsolete2 = 0;
static QString * _qstring__obsolete1 = 0;
static QString * _qstring__icon = 0;
static QString * _qstring__name = 0;
static KURL::List * _qlist__urls = 0;
static QString * _qstring__exec = 0;
	return (jlong) KRunJBridge::run((QString&) * (QString *) QtSupport::toQString(env, _exec, &_qstring__exec), (KURL::List&) * (KURL::List *) KDESupport::toKURLList(env, _urls, &_qlist__urls), (QString&) * (QString *) QtSupport::toQString(env, _name, &_qstring__name), (QString&) * (QString *) QtSupport::toQString(env, _icon, &_qstring__icon), (QString&) * (QString *) QtSupport::toQString(env, _obsolete1, &_qstring__obsolete1), (QString&) * (QString *) QtSupport::toQString(env, _obsolete2, &_qstring__obsolete2));
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_KRun_run__Ljava_lang_String_2Ljava_util_ArrayList_2(JNIEnv *env, jclass obj, jstring _exec, jobjectArray _urls)
{
static KURL::List * _qlist__urls = 0;
static QString * _qstring__exec = 0;
	return (jlong) KRunJBridge::run((QString&) * (QString *) QtSupport::toQString(env, _exec, &_qstring__exec), (KURL::List&) * (KURL::List *) KDESupport::toKURLList(env, _urls, &_qlist__urls), QString::null, QString::null, QString::null, QString::null);
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_KRun_runURL(JNIEnv *env, jclass obj, jobject _url, jstring _mimetype)
{
static QString * _qstring__mimetype = 0;
	return (jlong) KRunJBridge::runURL((KURL&) *(KURL *) QtSupport::getQt(env, _url), (QString&) * (QString *) QtSupport::toQString(env, _mimetype, &_qstring__mimetype));
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_KRun_runCommand__Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring cmd)
{
static QString * _qstring_cmd = 0;
	return (jlong) KRunJBridge::runCommand((QString) * (QString *) QtSupport::toQString(env, cmd, &_qstring_cmd));
}

JNIEXPORT jlong JNICALL
Java_org_kde_koala_KRun_runCommand__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring cmd, jstring execName, jstring icon)
{
static QString * _qstring_icon = 0;
static QString * _qstring_execName = 0;
static QString * _qstring_cmd = 0;
	return (jlong) KRunJBridge::runCommand((QString&) * (QString *) QtSupport::toQString(env, cmd, &_qstring_cmd), (QString&) * (QString *) QtSupport::toQString(env, execName, &_qstring_execName), (QString&) * (QString *) QtSupport::toQString(env, icon, &_qstring_icon));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KRun_displayOpenWithDialog(JNIEnv *env, jclass obj, jobjectArray lst)
{
static KURL::List * _qlist_lst = 0;
	return (jboolean) KRunJBridge::displayOpenWithDialog((KURL::List&) * (KURL::List *) KDESupport::toKURLList(env, lst, &_qlist_lst));
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_shellQuote(JNIEnv *env, jclass obj, jstring _str)
{
static QString * _qstring__str = 0;
	KRunJBridge::shellQuote((QString&) * (QString *) QtSupport::toQString(env, _str, &_qstring__str));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KRun_processDesktopExec(JNIEnv *env, jclass obj, jobject _service, jobjectArray _urls, jboolean has_shell)
{
	QStringList  _qlist;
static KURL::List * _qlist__urls = 0;
	_qlist = KRunJBridge::processDesktopExec((KService&) *(KService *) QtSupport::getQt(env, _service), (KURL::List&) * (KURL::List *) KDESupport::toKURLList(env, _urls, &_qlist__urls), (bool) has_shell);
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_init(JNIEnv *env, jobject obj)
{
	((KRunJBridge*) QtSupport::getQt(env, obj))->protected_init();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_scanFile(JNIEnv *env, jobject obj)
{
	((KRunJBridge*) QtSupport::getQt(env, obj))->protected_scanFile();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_foundMimeType(JNIEnv *env, jobject obj, jstring _type)
{
static QString * _qstring__type = 0;
	((KRunJBridge*) QtSupport::getQt(env, obj))->protected_foundMimeType((QString&) * (QString *) QtSupport::toQString(env, _type, &_qstring__type));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_killJob(JNIEnv *env, jobject obj)
{
	((KRunJBridge*) QtSupport::getQt(env, obj))->protected_killJob();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_slotTimeout(JNIEnv *env, jobject obj)
{
	((KRunJBridge*) QtSupport::getQt(env, obj))->protected_slotTimeout();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_slotScanFinished(JNIEnv *env, jobject obj, jobject arg1)
{
	((KRunJBridge*) QtSupport::getQt(env, obj))->protected_slotScanFinished((KIO::Job*) QtSupport::getQt(env, arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_slotScanMimeType(JNIEnv *env, jobject obj, jobject arg1, jstring type)
{
static QString * _qstring_type = 0;
	((KRunJBridge*) QtSupport::getQt(env, obj))->protected_slotScanMimeType((KIO::Job*) QtSupport::getQt(env, arg1), (QString&) * (QString *) QtSupport::toQString(env, type, &_qstring_type));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRun_slotStatResult(JNIEnv *env, jobject obj, jobject arg1)
{
	((KRunJBridge*) QtSupport::getQt(env, obj))->protected_slotStatResult((KIO::Job*) QtSupport::getQt(env, arg1));
	return;
}

