/***************************************************************************
                            Scheduler.cpp -  description
                             -------------------
    begin                : Wed Jan 30 16:02:13 2002
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Jan 30 16:02:13 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_

#define private protected
#include <kio/scheduler.h>
#undef private

#include <qstring.h>
#include <qcstring.h>

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

class SchedulerJBridge : public KIO::Scheduler
{
public:
	~SchedulerJBridge() {QtSupport::qtKeyDeleted(this);}
	bool  protected_startJobScheduled(ProtocolInfo* protInfo) {
		return (bool ) Scheduler::startJobScheduled(protInfo);
	}
	bool  protected_startJobDirect() {
		return (bool ) Scheduler::startJobDirect();
	}
	static Scheduler * protected_self() {
		return Scheduler::self();
	}
	SchedulerJBridge() : Scheduler() {}
	void protected_startStep() {
		Scheduler::startStep();
		return;
	}
	void protected_slotCleanIdleSlaves() {
		Scheduler::slotCleanIdleSlaves();
		return;
	}
	void protected_slotSlaveConnected() {
		Scheduler::slotSlaveConnected();
		return;
	}
	void protected_slotSlaveError(int error, const QString& errorMsg) {
		Scheduler::slotSlaveError(error, errorMsg);
		return;
	}
	void protected_slotScheduleCoSlave() {
		Scheduler::slotScheduleCoSlave();
		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_Scheduler_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj) && ((KIO::Scheduler*)QtSupport::getQt(env, obj))->parent() == (QObject *) 0) {
		delete (KIO::Scheduler*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_Scheduler_finalize(env, obj);
	return;
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject sender, jstring signal, jstring member)
{
	return QtSupport::connect(env, sender, signal, obj, member);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_debug_1info(JNIEnv *env, jobject obj)
{
	((KIO::Scheduler*) QtSupport::getQt(env, obj))->debug_info();
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_process(JNIEnv *env, jobject obj, jstring fun, jbyteArray data, jstring replyType, jbyteArray replyData)
{
static QByteArray * _qbyteArray_replyData = 0;
static QCString * _qcstring_replyType = 0;
static QByteArray * _qbyteArray_data = 0;
static QCString * _qcstring_fun = 0;
	return (jboolean) ((KIO::Scheduler*) QtSupport::getQt(env, obj))->process((QCString&) * (QCString *) QtSupport::toQCString(env, fun, &_qcstring_fun), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data), (QCString&) * (QCString *) QtSupport::toQCString(env, replyType, &_qcstring_replyType), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, replyData, &_qbyteArray_replyData));
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Scheduler_functions(JNIEnv *env, jobject obj)
{
	QCStringList  _qlist;
	_qlist = ((KIO::Scheduler*) QtSupport::getQt(env, obj))->functions();
	return (jobject) KDESupport::arrayWithQCStringList(env, (QCStringList *) &_qlist);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_slotSlaveDied(JNIEnv *env, jobject obj, jobject slave)
{
	((KIO::Scheduler*) QtSupport::getQt(env, obj))->slotSlaveDied((KIO::Slave*) QtSupport::getQt(env, slave));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_slotSlaveStatus(JNIEnv *env, jobject obj, jlong pid, jstring protocol, jstring host, jboolean connected)
{
static QString * _qstring_host = 0;
static QCString * _qcstring_protocol = 0;
	((KIO::Scheduler*) QtSupport::getQt(env, obj))->slotSlaveStatus((pid_t) pid, (QCString&) * (QCString *) QtSupport::toQCString(env, protocol, &_qcstring_protocol), (QString&) * (QString *) QtSupport::toQString(env, host, &_qstring_host), (bool) connected);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_doJob(JNIEnv *env, jclass obj, jobject job)
{
	SchedulerJBridge::doJob((KIO::SimpleJob*) QtSupport::getQt(env, job));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_scheduleJob(JNIEnv *env, jclass obj, jobject job)
{
	SchedulerJBridge::scheduleJob((KIO::SimpleJob*) QtSupport::getQt(env, job));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_cancelJob(JNIEnv *env, jclass obj, jobject job)
{
	SchedulerJBridge::cancelJob((KIO::SimpleJob*) QtSupport::getQt(env, job));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_jobFinished(JNIEnv *env, jclass obj, jobject job, jobject slave)
{
	SchedulerJBridge::jobFinished((KIO::SimpleJob*) QtSupport::getQt(env, job), (KIO::Slave*) QtSupport::getQt(env, slave));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_putSlaveOnHold(JNIEnv *env, jclass obj, jobject job, jobject url)
{
	SchedulerJBridge::putSlaveOnHold((KIO::SimpleJob*) QtSupport::getQt(env, job), (KURL&) *(KURL *) QtSupport::getQt(env, url));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_removeSlaveOnHold(JNIEnv *env, jclass obj)
{
	SchedulerJBridge::removeSlaveOnHold();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_publishSlaveOnHold(JNIEnv *env, jclass obj)
{
	SchedulerJBridge::publishSlaveOnHold();
	return;
}

//JNIEXPORT jobject JNICALL
//Java_org_kde_koala_Scheduler_getConnectedSlave(JNIEnv *env, jclass obj, jobject url, jobject config)
//{
//	return (jobject) QtSupport::objectForQtKey(env, (void *)SchedulerJBridge::getConnectedSlave((KURL&) *(KURL *) QtSupport::getQt(env, url), (KIO::MetaData&) *(KIO::MetaData *) QtSupport::getQt(env, config)), "org.kde.koala.Slave");
//}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Scheduler_getConnectedSlave(JNIEnv *env, jclass obj, jobject url)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)SchedulerJBridge::getConnectedSlave((KURL&) *(KURL *) QtSupport::getQt(env, url), KIO::MetaData()), "org.kde.koala.Slave");
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_assignJobToSlave(JNIEnv *env, jclass obj, jobject slave, jobject job)
{
	return (jboolean) SchedulerJBridge::assignJobToSlave((KIO::Slave*) QtSupport::getQt(env, slave), (KIO::SimpleJob*) QtSupport::getQt(env, job));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_disconnectSlave(JNIEnv *env, jclass obj, jobject slave)
{
	return (jboolean) SchedulerJBridge::disconnectSlave((KIO::Slave*) QtSupport::getQt(env, slave));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_connect__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring signal, jobject receiver, jstring member)
{
	return QtSupport::connect(env, QtSupport::objectForQtKey(env, SchedulerJBridge::protected_self(), "org.kde.koala.Scheduler"), signal, receiver, member);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jclass obj, jobject sender, jstring signal, jobject receiver, jstring member)
{
	return QtSupport::connect(env, sender, signal, receiver, member);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_disconnect(JNIEnv *env, jclass obj, jobject sender, jstring signal, jobject receiver, jstring member)
{
	return QtSupport::disconnect(env, sender, signal, receiver, member);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_checkSlaveOnHold(JNIEnv *env, jclass obj, jboolean b)
{
	SchedulerJBridge::checkSlaveOnHold((bool) b);
	return;
}

//JNIEXPORT jboolean JNICALL
//Java_org_kde_koala_Scheduler_startJobScheduled(JNIEnv *env, jobject obj, jobject protInfo)
//{
//	return (jboolean) ((SchedulerJBridge*) QtSupport::getQt(env, obj))->protected_startJobScheduled((ProtocolInfo*) QtSupport::getQt(env, protInfo));
//}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_startJobDirect(JNIEnv *env, jobject obj)
{
	return (jboolean) ((SchedulerJBridge*) QtSupport::getQt(env, obj))->protected_startJobDirect();
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_startStep(JNIEnv *env, jobject obj)
{
	((SchedulerJBridge*) QtSupport::getQt(env, obj))->protected_startStep();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_slotCleanIdleSlaves(JNIEnv *env, jobject obj)
{
	((SchedulerJBridge*) QtSupport::getQt(env, obj))->protected_slotCleanIdleSlaves();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_slotSlaveConnected(JNIEnv *env, jobject obj)
{
	((SchedulerJBridge*) QtSupport::getQt(env, obj))->protected_slotSlaveConnected();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_slotSlaveError(JNIEnv *env, jobject obj, jint error, jstring errorMsg)
{
static QString * _qstring_errorMsg = 0;
	((SchedulerJBridge*) QtSupport::getQt(env, obj))->protected_slotSlaveError((int) error, (QString&) * (QString *) QtSupport::toQString(env, errorMsg, &_qstring_errorMsg));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Scheduler_slotScheduleCoSlave(JNIEnv *env, jobject obj)
{
	((SchedulerJBridge*) QtSupport::getQt(env, obj))->protected_slotScheduleCoSlave();
	return;
}

