/***************************************************************************
                            BrowserExtension.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 <kparts/browserextension.h>
#include <qstring.h>
#include <qcstring.h>

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

class BrowserExtensionJBridge : public KParts::BrowserExtension
{
public:
	BrowserExtensionJBridge(KParts::ReadOnlyPart* parent, const char* name) : BrowserExtension(parent, name) {}
	~BrowserExtensionJBridge() {QtSupport::qtKeyDeleted(this);}
	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_BrowserExtension_newBrowserExtension__Lorg_kde_koala_ReadOnlyPart_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject parent, jstring name)
{
static QCString * _qstring_name = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new BrowserExtensionJBridge((KParts::ReadOnlyPart*) QtSupport::getQt(env, parent), (char*) QtSupport::toCharString(env, name, &_qstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_BrowserExtension_newBrowserExtension__Lorg_kde_koala_ReadOnlyPart_2(JNIEnv *env, jobject obj, jobject parent)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new BrowserExtensionJBridge((KParts::ReadOnlyPart*) QtSupport::getQt(env, parent), 0L));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_BrowserExtension_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_BrowserExtension_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_BrowserExtension_setURLArgs(JNIEnv *env, jobject obj, jobject args)
{
	((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->setURLArgs((KParts::URLArgs&) *(KParts::URLArgs *) QtSupport::getQt(env, args));
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_BrowserExtension_urlArgs(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new KParts::URLArgs (((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->urlArgs()), "org.kde.koala.URLArgs", TRUE);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_BrowserExtension_xOffset(JNIEnv *env, jobject obj)
{
	return (jint) ((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->xOffset();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_BrowserExtension_yOffset(JNIEnv *env, jobject obj)
{
	return (jint) ((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->yOffset();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_BrowserExtension_saveState(JNIEnv *env, jobject obj, jobject stream)
{
	((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->saveState((QDataStream&) *(QDataStream *) QtSupport::getQt(env, stream));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_BrowserExtension_restoreState(JNIEnv *env, jobject obj, jobject stream)
{
	((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->restoreState((QDataStream&) *(QDataStream *) QtSupport::getQt(env, stream));
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_BrowserExtension_isURLDropHandlingEnabled(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->isURLDropHandlingEnabled();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_BrowserExtension_setURLDropHandlingEnabled(JNIEnv *env, jobject obj, jboolean enable)
{
	((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->setURLDropHandlingEnabled((bool) enable);
	return;
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_BrowserExtension_setBrowserInterface(JNIEnv *env, jobject obj, jobject impl)
//{
//	((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->setBrowserInterface((BrowserInterface*) QtSupport::getQt(env, impl));
//	return;
//}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_BrowserExtension_browserInterface(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->browserInterface(), "org.kde.koala.BrowserInterface");
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_BrowserExtension_isActionEnabled(JNIEnv *env, jobject obj, jstring name)
{
static QCString * _qstring_name = 0;
	return (jboolean) ((KParts::BrowserExtension*) QtSupport::getQt(env, obj))->isActionEnabled((char*) QtSupport::toCharString(env, name, &_qstring_name));
}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_BrowserExtension_actionSlotMap(JNIEnv *env, jclass obj)
//{
//	return () BrowserExtensionJBridge::actionSlotMap();
//}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_BrowserExtension_actionSlotMapPtr(JNIEnv *env, jclass obj)
//{
//	return () BrowserExtensionJBridge::actionSlotMapPtr();
//}

//JNIEXPORT jobject JNICALL
//Java_org_kde_koala_BrowserExtension_childObject(JNIEnv *env, jclass obj, jobject obj)
//{
//	return (jobject) QtSupport::objectForQtKey(env, (void *)BrowserExtensionJBridge::childObject((QObject*) QtSupport::getQt(env, obj)), "org.kde.koala.BrowserExtension");
//}

