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

#include <qtjava/QtSupport.h>
#include <kdejava/KDESupport.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, bool inheritMetaData) {
		Job::addSubjob(job, inheritMetaData);
		return;
	}
	void protected_removeSubjob(Job* job) {
		Job::removeSubjob(job);
		return;
	}
	void protected_emitPercent(KIO::filesize_t processedSize, KIO::filesize_t 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 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_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_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_Job_finalize(env, obj);
	return;
}

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

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

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

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

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

JNIEXPORT jstring JNICALL
Java_org_kde_koala_Job_errorText(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((KIO::Job*) 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 = ((KIO::Job*) QtSupport::getQt(env, obj))->errorString();
	return QtSupport::fromQString(env, &_qstring);
}

//JNIEXPORT jstring JNICALL
//Java_org_kde_koala_Job_htmlErrorString(JNIEnv *env, jobject obj)
//{
//	QString  _qstring;
//	_qstring = ((KIO::Job*) QtSupport::getQt(env, obj))->htmlErrorString();
//	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)
{
	((KIO::Job*) QtSupport::getQt(env, obj))->showErrorDialog((QWidget*) QtSupport::getQt(env, parent));
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_setAutoErrorHandlingEnabled__ZLorg_kde_qt_QWidget_2(JNIEnv *env, jobject obj, jboolean enable, jobject parentWidget)
{
	((KIO::Job*) QtSupport::getQt(env, obj))->setAutoErrorHandlingEnabled((bool) enable, (QWidget*) QtSupport::getQt(env, parentWidget));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_setAutoErrorHandlingEnabled__Z(JNIEnv *env, jobject obj, jboolean enable)
{
	((KIO::Job*) QtSupport::getQt(env, obj))->setAutoErrorHandlingEnabled((bool) enable, 0);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Job_isAutoErrorHandlingEnabled(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KIO::Job*) QtSupport::getQt(env, obj))->isAutoErrorHandlingEnabled();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_setWindow(JNIEnv *env, jobject obj, jobject window)
{
	((KIO::Job*) 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 *)((KIO::Job*) QtSupport::getQt(env, obj))->window(), "org.kde.qt.QWidget");
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_setMetaData(JNIEnv *env, jobject obj, jobject arg1)
{
	((KIO::Job*) QtSupport::getQt(env, obj))->setMetaData((KIO::MetaData&) *(KIO::MetaData *) QtSupport::getQt(env, arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_addMetaData__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring key, jstring value)
{
static QString * _qstring_value = 0;
static QString * _qstring_key = 0;
	((KIO::Job*) QtSupport::getQt(env, obj))->addMetaData((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key), (QString&) * (QString *) QtSupport::toQString(env, value, &_qstring_value));
	return;
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_Job_addMetaData__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring arg1, jstring values)
//{
//	((KIO::Job*) QtSupport::getQt(env, obj))->addMetaData((QMap<QString) arg1, (QString>) values);
//	return;
//}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_Job_mergeMetaData(JNIEnv *env, jobject obj, jstring arg1, jstring values)
//{
//	((KIO::Job*) QtSupport::getQt(env, obj))->mergeMetaData((QMap<QString) arg1, (QString>) values);
//	return;
//}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Job_outgoingMetaData(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new KIO::MetaData (((KIO::Job*) QtSupport::getQt(env, obj))->outgoingMetaData()), "org.kde.koala.MetaData", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Job_metaData(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new KIO::MetaData (((KIO::Job*) QtSupport::getQt(env, obj))->metaData()), "org.kde.koala.MetaData", TRUE);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_Job_queryMetaData(JNIEnv *env, jobject obj, jstring key)
{
	QString  _qstring;
static QString * _qstring_key = 0;
	_qstring = ((KIO::Job*) QtSupport::getQt(env, obj))->queryMetaData((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key));
	return QtSupport::fromQString(env, &_qstring);
}

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__IZ(JNIEnv *env, jobject obj, jint job, jboolean inheritMetaData)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_addSubjob((KIO::Job*) job, (bool) inheritMetaData);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Job_addSubjob__I(JNIEnv *env, jobject obj, jint job)
{
	((JobJBridge*) QtSupport::getQt(env, obj))->protected_addSubjob((KIO::Job*) job, true);
	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, j processedSize, j totalSize)
//{
//	((JobJBridge*) QtSupport::getQt(env, obj))->protected_emitPercent((KIO::filesize_t) processedSize, (KIO::filesize_t) 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;
}

