/***************************************************************************
                            Connection.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 <qcstring.h>
#include <qobject.h>
#include <kio/connection.h>
#include <qstring.h>
#include <qcstring.h>

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

class ConnectionJBridge : public KIO::Connection
{
public:
	ConnectionJBridge() : Connection() {}
	~ConnectionJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_dequeue() {
		Connection::dequeue();
		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_Connection_newConnection(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new ConnectionJBridge());
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_Connection_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_init__Lorg_kde_koala_KSocket_2(JNIEnv *env, jobject obj, jobject sock)
{
	((KIO::Connection*) QtSupport::getQt(env, obj))->init((KSocket*) QtSupport::getQt(env, sock));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_init__II(JNIEnv *env, jobject obj, jint fd_in, jint fd_out)
{
	((KIO::Connection*) QtSupport::getQt(env, obj))->init((int) fd_in, (int) fd_out);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject receiver, jstring member)
{
static QCString * _qstring_member = 0;
	((KIO::Connection*) QtSupport::getQt(env, obj))->connect((QObject*) QtSupport::slotForReceiver(env, receiver, member), "1invoke()");
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_connect__(JNIEnv *env, jobject obj)
{
	((KIO::Connection*) QtSupport::getQt(env, obj))->connect(0, 0);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_close(JNIEnv *env, jobject obj)
{
	((KIO::Connection*) QtSupport::getQt(env, obj))->close();
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_Connection_fd_1from(JNIEnv *env, jobject obj)
{
	return (jint) ((KIO::Connection*) QtSupport::getQt(env, obj))->fd_from();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_Connection_fd_1to(JNIEnv *env, jobject obj)
{
	return (jint) ((KIO::Connection*) QtSupport::getQt(env, obj))->fd_to();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Connection_inited(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KIO::Connection*) QtSupport::getQt(env, obj))->inited();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_send__I_3B(JNIEnv *env, jobject obj, jint cmd, jbyteArray arr)
{
static QByteArray * _qbyteArray_arr = 0;
	((KIO::Connection*) QtSupport::getQt(env, obj))->send((int) cmd, (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, arr, &_qbyteArray_arr));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_send__I(JNIEnv *env, jobject obj, jint cmd)
{
	((KIO::Connection*) QtSupport::getQt(env, obj))->send((int) cmd, QByteArray());
	return;
}

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

JNIEXPORT jint JNICALL
Java_org_kde_koala_Connection_read(JNIEnv *env, jobject obj, jintArray _cmd, jbyteArray arg1)
{
static QByteArray * _qbyteArray_arg1 = 0;
	return (jint) ((KIO::Connection*) QtSupport::getQt(env, obj))->read( (int*) QtSupport::toIntPtr(env, _cmd), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, arg1, &_qbyteArray_arg1));
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_suspend(JNIEnv *env, jobject obj)
{
	((KIO::Connection*) QtSupport::getQt(env, obj))->suspend();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_resume(JNIEnv *env, jobject obj)
{
	((KIO::Connection*) QtSupport::getQt(env, obj))->resume();
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Connection_suspended(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KIO::Connection*) QtSupport::getQt(env, obj))->suspended();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_Connection_dequeue(JNIEnv *env, jobject obj)
{
	((ConnectionJBridge*) QtSupport::getQt(env, obj))->protected_dequeue();
	return;
}

