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

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

class JobJBridge : public KIO::Job
{
public:
	~JobJBridge() {QtSupport::qtKeyDeleted(this);}
	JobJBridge(bool showProgressInfo) : Job(showProgressInfo) {}
	void protected_addSubjob(Job* job) {
		Job::addSubjob(job);
		return;
	}
	void protected_removeSubjob(Job* job) {
		Job::removeSubjob(job);
		return;
	}
	void protected_emitPercent(unsigned long processedSize, unsigned long totalSize) {
		Job::emitPercent(processedSize, totalSize);
		return;
	}
	void protected_emitSpeed(unsigned long bytes_per_second) {
		Job::emitSpeed(bytes_per_second);
		return;
	}
	void protected_emitResult() {
		Job::emitResult();
		return;
	}
	void protected_slotResult(KIO::Job* job) {
		Job::slotResult(job);
		return;
	}
	void protected_slotSpeed(KIO::Job* arg1, unsigned long bytes_per_second) {
		Job::slotSpeed(arg1, bytes_per_second);
		return;
	}
	void protected_slotInfoMessage(KIO::Job* arg1, const QString& arg2) {
		Job::slotInfoMessage(arg1, arg2);
		return;
	}
	void protected_slotSpeedTimeout() {
		Job::slotSpeedTimeout();
		return;
	}
	void childEvent(QChildEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "childEvent", arg1, "org.kde.qt.QChildEvent")) {
			QObject::childEvent(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_Job_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj) && ((KIO::Job*)QtSupport::getQt(env, obj))->parent() == (QObject *) 0) {
		delete (KIO::Job*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_kill__Z(JNIEnv *env, jobject obj, jboolean quietly)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->kill((bool) quietly);
	return;
}

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

JNIEXPORT jint JNICALL
Java_org_kde_koala_Job_error(JNIEnv *env, jobject obj)
{
	return (jint) ((JobJBridge*) QtSupport::getQt(env, obj))->error();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_Job_progressId(JNIEnv *env, jobject obj)
{
	return (jint) ((JobJBridge*) QtSupport::getQt(env, obj))->progressId();
}

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_showErrorDialog__Lorg_kde_qt_QWidget_2(JNIEnv *env, jobject obj, jobject parent)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->showErrorDialog((QWidget*) QtSupport::getQt(env, parent));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_showErrorDialog__(JNIEnv *env, jobject obj)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->showErrorDialog(0L);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_setWindow(JNIEnv *env, jobject obj, jobject window)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->setWindow((QWidget*) QtSupport::getQt(env, window));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Job_window(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((JobJBridge*) QtSupport::getQt(env, obj))->window(), "org.kde.qt.QWidget");
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_newJob(JNIEnv *env, jobject obj, jboolean showProgressInfo)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new JobJBridge((bool) showProgressInfo));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_addSubjob(JNIEnv *env, jobject obj, jint job)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_addSubjob((KIO::Job*) job);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_removeSubjob(JNIEnv *env, jobject obj, jint job)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_removeSubjob((KIO::Job*) job);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_emitPercent(JNIEnv *env, jobject obj, jlong processedSize, jlong totalSize)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_emitPercent((unsigned long) processedSize, (unsigned long) totalSize);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_emitSpeed(JNIEnv *env, jobject obj, jlong bytes_per_second)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_emitSpeed((unsigned long) bytes_per_second);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_emitResult(JNIEnv *env, jobject obj)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_emitResult();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_slotResult(JNIEnv *env, jobject obj, jobject job)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_slotResult((KIO::Job*) QtSupport::getQt(env, job));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_slotSpeed(JNIEnv *env, jobject obj, jobject arg1, jlong bytes_per_second)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_slotSpeed((KIO::Job*) QtSupport::getQt(env, arg1), (unsigned long) bytes_per_second);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_slotInfoMessage(JNIEnv *env, jobject obj, jobject arg1, jstring arg2)
{
static QString * _qstring_arg2 = 0;
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_slotInfoMessage((KIO::Job*) QtSupport::getQt(env, arg1), (QString&) * (QString *) QtSupport::toQString(env, arg2, &_qstring_arg2));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_slotSpeedTimeout(JNIEnv *env, jobject obj)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_slotSpeedTimeout();
	return;
}

