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

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

class KJavaAppletServerJBridge : public KJavaAppletServer
{
public:
	KJavaAppletServerJBridge() : KJavaAppletServer() {}
	~KJavaAppletServerJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_setupJava(KJavaProcess* p) {
		KJavaAppletServer::setupJava(p);
		return;
	}
	void protected_slotJavaRequest(const QByteArray& qb) {
		KJavaAppletServer::slotJavaRequest(qb);
		return;
	}
	void protected_checkShutdown() {
		KJavaAppletServer::checkShutdown();
		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_KJavaAppletServer_newKJavaAppletServer(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KJavaAppletServerJBridge());
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KJavaAppletServer_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_createContext(JNIEnv *env, jobject obj, jint contextId, jobject context)
{
	((KJavaAppletServer*) QtSupport::getQt(env, obj))->createContext((int) contextId, (KJavaAppletContext*) QtSupport::getQt(env, context));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_destroyContext(JNIEnv *env, jobject obj, jint contextId)
{
	((KJavaAppletServer*) QtSupport::getQt(env, obj))->destroyContext((int) contextId);
	return;
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_KJavaAppletServer_createApplet(JNIEnv *env, jobject obj, jint contextId, jint appletId, jstring name, jstring clazzName, jstring baseURL, jstring codeBase, jstring jarFile, jobject size, jstring arg1, jstring params, jstring windowTitle)
//{
//static QString * _qstring_windowTitle = 0;
//static QString * _qstring_jarFile = 0;
//static QString * _qstring_codeBase = 0;
//static QString * _qstring_baseURL = 0;
//static QString * _qstring_clazzName = 0;
//static QString * _qstring_name = 0;
//	((KJavaAppletServer*) QtSupport::getQt(env, obj))->createApplet((int) contextId, (int) appletId, (QString) * (QString *) QtSupport::toQString(env, name, &_qstring_name), (QString) * (QString *) QtSupport::toQString(env, clazzName, &_qstring_clazzName), (QString) * (QString *) QtSupport::toQString(env, baseURL, &_qstring_baseURL), (QString) * (QString *) QtSupport::toQString(env, codeBase, &_qstring_codeBase), (QString) * (QString *) QtSupport::toQString(env, jarFile, &_qstring_jarFile), (QSize) *(QSize *) QtSupport::getQt(env, size), (QMap<QString) arg1, (QString>) params, (QString) * (QString *) QtSupport::toQString(env, windowTitle, &_qstring_windowTitle));
//	return;
//}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_initApplet(JNIEnv *env, jobject obj, jint contextId, jint appletId)
{
	((KJavaAppletServer*) QtSupport::getQt(env, obj))->initApplet((int) contextId, (int) appletId);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_destroyApplet(JNIEnv *env, jobject obj, jint contextId, jint appletId)
{
	((KJavaAppletServer*) QtSupport::getQt(env, obj))->destroyApplet((int) contextId, (int) appletId);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_startApplet(JNIEnv *env, jobject obj, jint contextId, jint appletId)
{
	((KJavaAppletServer*) QtSupport::getQt(env, obj))->startApplet((int) contextId, (int) appletId);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_stopApplet(JNIEnv *env, jobject obj, jint contextId, jint appletId)
{
	((KJavaAppletServer*) QtSupport::getQt(env, obj))->stopApplet((int) contextId, (int) appletId);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_sendURLData(JNIEnv *env, jobject obj, jstring loaderID, jstring url, jbyteArray data)
{
static QByteArray * _qbyteArray_data = 0;
static QString * _qstring_url = 0;
static QString * _qstring_loaderID = 0;
	((KJavaAppletServer*) QtSupport::getQt(env, obj))->sendURLData((QString&) * (QString *) QtSupport::toQString(env, loaderID, &_qstring_loaderID), (QString&) * (QString *) QtSupport::toQString(env, url, &_qstring_url), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_quit(JNIEnv *env, jobject obj)
{
	((KJavaAppletServer*) QtSupport::getQt(env, obj))->quit();
	return;
}

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

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KJavaAppletServer_allocateJavaServer(JNIEnv *env, jclass obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)KJavaAppletServerJBridge::allocateJavaServer(), "org.kde.koala.KJavaAppletServer");
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_freeJavaServer(JNIEnv *env, jclass obj)
{
	KJavaAppletServerJBridge::freeJavaServer();
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KJavaAppletServer_getAppletLabel(JNIEnv *env, jclass obj)
{
	QString  _qstring;
	_qstring = KJavaAppletServerJBridge::getAppletLabel();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_setupJava(JNIEnv *env, jobject obj, jobject p)
{
	((KJavaAppletServerJBridge*) QtSupport::getQt(env, obj))->protected_setupJava((KJavaProcess*) QtSupport::getQt(env, p));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_slotJavaRequest(JNIEnv *env, jobject obj, jbyteArray qb)
{
static QByteArray * _qbyteArray_qb = 0;
	((KJavaAppletServerJBridge*) QtSupport::getQt(env, obj))->protected_slotJavaRequest((QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, qb, &_qbyteArray_qb));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KJavaAppletServer_checkShutdown(JNIEnv *env, jobject obj)
{
	((KJavaAppletServerJBridge*) QtSupport::getQt(env, obj))->protected_checkShutdown();
	return;
}

