/***************************************************************************
                            KFileMetaInfo.cpp -  description
                             -------------------
    begin                : Fri Nov 15 11:45:52 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Nov 15 11:45:52 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library 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 <kfilemetainfo.h>
#include <qstring.h>
#include <qcstring.h>

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

class KFileMetaInfoJBridge : public KFileMetaInfo
{
public:
	KFileMetaInfoJBridge(const QString& path, const QString& mimeType, uint what) : KFileMetaInfo(path, mimeType, what) {}
	KFileMetaInfoJBridge() : KFileMetaInfo() {}
	KFileMetaInfoJBridge(const KFileMetaInfo& original) : KFileMetaInfo(original) {}
	~KFileMetaInfoJBridge() {QtSupport::qtKeyDeleted(this);}
	KFileMetaInfoGroup protected_appendGroup(const QString& name) {
		return (KFileMetaInfoGroup) KFileMetaInfo::appendGroup(name);
	}
	KFilePlugin * const protected_plugin() {
		return (KFilePlugin * const) KFileMetaInfo::plugin();
	}
	void protected_ref() {
		KFileMetaInfo::ref();
		return;
	}
	void protected_deref() {
		KFileMetaInfo::deref();
		return;
	}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KFileMetaInfo_newKFileMetaInfo__Ljava_lang_String_2Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring path, jstring mimeType, jint what)
{
static QString * _qstring_mimeType = 0;
static QString * _qstring_path = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KFileMetaInfoJBridge((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path), (QString&) * (QString *) QtSupport::toQString(env, mimeType, &_qstring_mimeType), (uint) what));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KFileMetaInfo_newKFileMetaInfo__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring path)
{
static QString * _qstring_path = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KFileMetaInfoJBridge((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path), QString::null, KFileMetaInfo::Fastest));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

//JNIEXPORT void JNICALL
//Java_org_kde_koala_KFileMetaInfo_newKFileMetaInfo__(JNIEnv *env, jobject obj, j original)
//{
//	if (QtSupport::getQt(env, obj) == 0) {
//		QtSupport::setQt(env, obj, new KFileMetaInfoJBridge((KFileMetaInfo) original));
//		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
//	}
//	return;
//}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KFileMetaInfo_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KFileMetaInfo_finalize(env, obj);
	return;
}

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

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_groups(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((KFileMetaInfo*) QtSupport::getQt(env, obj))->groups();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_supportedGroups(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((KFileMetaInfo*) QtSupport::getQt(env, obj))->supportedGroups();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_preferredGroups(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((KFileMetaInfo*) QtSupport::getQt(env, obj))->preferredGroups();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_preferredKeys(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((KFileMetaInfo*) QtSupport::getQt(env, obj))->preferredKeys();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_supportedKeys(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((KFileMetaInfo*) QtSupport::getQt(env, obj))->supportedKeys();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_editableGroups(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((KFileMetaInfo*) QtSupport::getQt(env, obj))->editableGroups();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KFileMetaInfo_item__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring key)
//{
//static QString * _qstring_key = 0;
//	return () ((KFileMetaInfo*) QtSupport::getQt(env, obj))->item((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key));
//}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KFileMetaInfo_item__(JNIEnv *env, jobject obj, j hint)
//{
//	return () ((KFileMetaInfo*) QtSupport::getQt(env, obj))->item((KFileMetaInfoItem::Hint) hint);
//}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KFileMetaInfo_saveItem__Ljava_lang_String_2Ljava_lang_String_2Z(JNIEnv *env, jobject obj, jstring key, jstring preferredGroup, jboolean createGroup)
//{
//static QString * _qstring_preferredGroup = 0;
//static QString * _qstring_key = 0;
//	return () ((KFileMetaInfo*) QtSupport::getQt(env, obj))->saveItem((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key), (QString&) * (QString *) QtSupport::toQString(env, preferredGroup, &_qstring_preferredGroup), (bool) createGroup);
//}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KFileMetaInfo_saveItem__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring key)
//{
//static QString * _qstring_key = 0;
//	return () ((KFileMetaInfo*) QtSupport::getQt(env, obj))->saveItem((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key), QString::null, true);
//}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KFileMetaInfo_group(JNIEnv *env, jobject obj, jstring key)
//{
//static QString * _qstring_key = 0;
//	return () ((KFileMetaInfo*) QtSupport::getQt(env, obj))->group((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key));
//}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFileMetaInfo_addGroup(JNIEnv *env, jobject obj, jstring name)
{
static QString * _qstring_name = 0;
	return (jboolean) ((KFileMetaInfo*) QtSupport::getQt(env, obj))->addGroup((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFileMetaInfo_removeGroup(JNIEnv *env, jobject obj, jstring name)
{
static QString * _qstring_name = 0;
	return (jboolean) ((KFileMetaInfo*) QtSupport::getQt(env, obj))->removeGroup((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name));
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_removedGroups(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((KFileMetaInfo*) QtSupport::getQt(env, obj))->removedGroups();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFileMetaInfo_applyChanges(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KFileMetaInfo*) QtSupport::getQt(env, obj))->applyChanges();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFileMetaInfo_contains(JNIEnv *env, jobject obj, jstring key)
{
static QString * _qstring_key = 0;
	return (jboolean) ((KFileMetaInfo*) QtSupport::getQt(env, obj))->contains((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFileMetaInfo_containsGroup(JNIEnv *env, jobject obj, jstring key)
{
static QString * _qstring_key = 0;
	return (jboolean) ((KFileMetaInfo*) QtSupport::getQt(env, obj))->containsGroup((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key));
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_value(JNIEnv *env, jobject obj, jstring key)
{
static QString * _qstring_key = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new const QVariant(((KFileMetaInfo*) QtSupport::getQt(env, obj))->value((QString&) * (QString *) QtSupport::toQString(env, key, &_qstring_key))), "org.kde.qt.QVariant", TRUE);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFileMetaInfo_isValid(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KFileMetaInfo*) QtSupport::getQt(env, obj))->isValid();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KFileMetaInfo_isEmpty(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KFileMetaInfo*) QtSupport::getQt(env, obj))->isEmpty();
}

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

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

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KFileMetaInfo_appendGroup(JNIEnv *env, jobject obj, jstring name)
//{
//static QString * _qstring_name = 0;
//	return () ((KFileMetaInfoJBridge*) QtSupport::getQt(env, obj))->protected_appendGroup((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name));
//}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KFileMetaInfo_plugin(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KFileMetaInfoJBridge*) QtSupport::getQt(env, obj))->protected_plugin(), "org.kde.koala.KFilePlugin");
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KFileMetaInfo_ref(JNIEnv *env, jobject obj)
{
	((KFileMetaInfoJBridge*) QtSupport::getQt(env, obj))->protected_ref();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KFileMetaInfo_deref(JNIEnv *env, jobject obj)
{
	((KFileMetaInfoJBridge*) QtSupport::getQt(env, obj))->protected_deref();
	return;
}

