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

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

class KInstanceJBridge : public KInstance
{
public:
	KInstanceJBridge(const QCString& instanceName) : KInstance(instanceName) {}
	KInstanceJBridge(const KAboutData* aboutData) : KInstance(aboutData) {}
	KInstanceJBridge(KInstance* src) : KInstance(src) {}
	~KInstanceJBridge() {QtSupport::qtKeyDeleted(this);}
//	KInstanceJBridge(const KInstance& arg1) : KInstance(arg1) {}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KInstance_newKInstance__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring instanceName)
{
static QCString * _qcstring_instanceName = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KInstanceJBridge((QCString&) * (QCString *) QtSupport::toQCString(env, instanceName, &_qcstring_instanceName)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KInstance_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj)) {
		delete (KInstance*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KInstance_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KInstance_finalize(env, obj);
	return;
}

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

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KInstance_dirs(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KInstance*) QtSupport::getQt(env, obj))->dirs(), "org.kde.koala.KStandardDirs");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KInstance_config(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KInstance*) QtSupport::getQt(env, obj))->config(), "org.kde.koala.KConfig");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KInstance_iconLoader(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KInstance*) QtSupport::getQt(env, obj))->iconLoader(), "org.kde.koala.KIconLoader");
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KInstance_newIconLoader(JNIEnv *env, jobject obj)
{
	((KInstance*) QtSupport::getQt(env, obj))->newIconLoader();
	return;
}

//JNIEXPORT jobject JNICALL
//Java_org_kde_koala_KInstance_charsets(JNIEnv *env, jobject obj)
//{
//	return (jobject) QtSupport::objectForQtKey(env, (void *)((KInstance*) QtSupport::getQt(env, obj))->charsets(), "org.kde.koala.KCharsets");
//}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KInstance_aboutData(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KInstance*) QtSupport::getQt(env, obj))->aboutData(), "org.kde.koala.KAboutData");
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KInstance_instanceName(JNIEnv *env, jobject obj)
{
	QCString  _qcstring;
	_qcstring = ((KInstance*) QtSupport::getQt(env, obj))->instanceName();
	return QtSupport::fromQCString(env, &_qcstring);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KInstance_mimeSourceFactory(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KInstance*) QtSupport::getQt(env, obj))->mimeSourceFactory(), "org.kde.koala.KMimeSourceFactory");
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_KInstance_newKInstance__Lorg_kde_koala_KInstanceInterface_2(JNIEnv *env, jobject obj, jobject arg1)
//{
//	if (QtSupport::getQt(env, obj) == 0) {
//		QtSupport::setQt(env, obj, new KInstanceJBridge((KInstanceJBridge&) *(KInstanceJBridge *) QtSupport::getQt(env, arg1)));
//		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
//	}
//	return;
//}

