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

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

class SlaveJBridge : public KIO::SlaveInterface
{
public:
	SlaveJBridge(KIO::Connection* connection) : SlaveInterface(connection) {}
	~SlaveJBridge() {QtSupport::qtKeyDeleted(this);}
	 bool  protected_dispatch() {
		return ( bool ) SlaveInterface::dispatch();
	}
	 bool  protected_dispatch(int _cmd, const QByteArray& data) {
		return ( bool ) SlaveInterface::dispatch(_cmd, data);
	}
	void protected_openPassDlg(KIO::AuthInfo& info) {
		SlaveInterface::openPassDlg(info);
		return;
	}
	void protected_openPassDlg(const QString& prompt, const QString& user, const QString& caption, const QString& comment, const QString& label, bool readOnly) {
		SlaveInterface::openPassDlg(prompt, user, caption, comment, label, readOnly);
		return;
	}
	void protected_openPassDlg(const QString& prompt, const QString& user, bool readOnly) {
		SlaveInterface::openPassDlg(prompt, user, readOnly);
		return;
	}
	void protected_messageBox(int type, const QString& text, const QString& caption, const QString& buttonYes, const QString& buttonNo) {
		SlaveInterface::messageBox(type, text, caption, buttonYes, buttonNo);
		return;
	}
	void protected_requestNetwork(const QString& arg1, const QString& arg2) {
		SlaveInterface::requestNetwork(arg1, arg2);
		return;
	}
	void protected_dropNetwork(const QString& arg1, const QString& arg2) {
		SlaveInterface::dropNetwork(arg1, arg2);
		return;
	}
	void protected_sigpipe_handler(int arg1) {
		SlaveInterface::sigpipe_handler(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_Slave_newSlave(JNIEnv *env, jobject obj, jobject connection)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new SlaveJBridge((KIO::Connection*) QtSupport::getQt(env, connection)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_Slave_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_setConnection(JNIEnv *env, jobject obj, jobject connection)
{
	((KIO::SlaveInterface*) QtSupport::getQt(env, obj))->setConnection((KIO::Connection*) QtSupport::getQt(env, connection));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_Slave_connection(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KIO::SlaveInterface*) QtSupport::getQt(env, obj))->connection(), "org.kde.koala.Connection");
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_setProgressId(JNIEnv *env, jobject obj, jint identifier)
{
	((KIO::SlaveInterface*) QtSupport::getQt(env, obj))->setProgressId((int) identifier);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_sendResumeAnswer(JNIEnv *env, jobject obj, jboolean resume)
{
	((KIO::SlaveInterface*) QtSupport::getQt(env, obj))->sendResumeAnswer((bool) resume);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Slave_dispatch__(JNIEnv *env, jobject obj)
{
	return (jboolean) ((SlaveJBridge*) QtSupport::getQt(env, obj))->protected_dispatch();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Slave_dispatch__I_3B(JNIEnv *env, jobject obj, jint _cmd, jbyteArray data)
{
static QByteArray * _qbyteArray_data = 0;
	return (jboolean) ((SlaveJBridge*) QtSupport::getQt(env, obj))->protected_dispatch((int) _cmd, (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data));
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_openPassDlg__Lorg_kde_koala_AuthInfo_2(JNIEnv *env, jobject obj, jobject info)
{
	((SlaveJBridge*) QtSupport::getQt(env, obj))->protected_openPassDlg((KIO::AuthInfo&) *(KIO::AuthInfo *) QtSupport::getQt(env, info));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_openPassDlg__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Z(JNIEnv *env, jobject obj, jstring prompt, jstring user, jstring caption, jstring comment, jstring label, jboolean readOnly)
{
static QString * _qstring_label = 0;
static QString * _qstring_comment = 0;
static QString * _qstring_caption = 0;
static QString * _qstring_user = 0;
static QString * _qstring_prompt = 0;
	((SlaveJBridge*) QtSupport::getQt(env, obj))->protected_openPassDlg((QString&) * (QString *) QtSupport::toQString(env, prompt, &_qstring_prompt), (QString&) * (QString *) QtSupport::toQString(env, user, &_qstring_user), (QString&) * (QString *) QtSupport::toQString(env, caption, &_qstring_caption), (QString&) * (QString *) QtSupport::toQString(env, comment, &_qstring_comment), (QString&) * (QString *) QtSupport::toQString(env, label, &_qstring_label), (bool) readOnly);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_openPassDlg__Ljava_lang_String_2Ljava_lang_String_2Z(JNIEnv *env, jobject obj, jstring prompt, jstring user, jboolean readOnly)
{
static QString * _qstring_user = 0;
static QString * _qstring_prompt = 0;
	((SlaveJBridge*) QtSupport::getQt(env, obj))->protected_openPassDlg((QString&) * (QString *) QtSupport::toQString(env, prompt, &_qstring_prompt), (QString&) * (QString *) QtSupport::toQString(env, user, &_qstring_user), (bool) readOnly);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_messageBox(JNIEnv *env, jobject obj, jint type, jstring text, jstring caption, jstring buttonYes, jstring buttonNo)
{
static QString * _qstring_buttonNo = 0;
static QString * _qstring_buttonYes = 0;
static QString * _qstring_caption = 0;
static QString * _qstring_text = 0;
	((SlaveJBridge*) QtSupport::getQt(env, obj))->protected_messageBox((int) type, (QString&) * (QString *) QtSupport::toQString(env, text, &_qstring_text), (QString&) * (QString *) QtSupport::toQString(env, caption, &_qstring_caption), (QString&) * (QString *) QtSupport::toQString(env, buttonYes, &_qstring_buttonYes), (QString&) * (QString *) QtSupport::toQString(env, buttonNo, &_qstring_buttonNo));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_requestNetwork(JNIEnv *env, jobject obj, jstring arg1, jstring arg2)
{
static QString * _qstring_arg2 = 0;
static QString * _qstring_arg1 = 0;
	((SlaveJBridge*) QtSupport::getQt(env, obj))->protected_requestNetwork((QString&) * (QString *) QtSupport::toQString(env, arg1, &_qstring_arg1), (QString&) * (QString *) QtSupport::toQString(env, arg2, &_qstring_arg2));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Slave_dropNetwork(JNIEnv *env, jobject obj, jstring arg1, jstring arg2)
{
static QString * _qstring_arg2 = 0;
static QString * _qstring_arg1 = 0;
	((SlaveJBridge*) QtSupport::getQt(env, obj))->protected_dropNetwork((QString&) * (QString *) QtSupport::toQString(env, arg1, &_qstring_arg1), (QString&) * (QString *) QtSupport::toQString(env, arg2, &_qstring_arg2));
	return;
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_Slave_sigpipe_handler(JNIEnv *env, jclass obj, jint arg1)
//{
//	SlaveJBridge::protected_sigpipe_handler((int) arg1);
//	return;
//}

