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

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

class KMimeMagicJBridge : public KMimeMagic
{
public:
	KMimeMagicJBridge(const QString& configFile) : KMimeMagic(configFile) {}
	~KMimeMagicJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_initStatic() {
		KMimeMagic::initStatic();
		return;
	}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KMimeMagic_newKMimeMagic(JNIEnv *env, jobject obj, jstring configFile)
{
static QString * _qstring_configFile = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KMimeMagicJBridge((QString&) * (QString *) QtSupport::toQString(env, configFile, &_qstring_configFile)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KMimeMagic_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KMimeMagic_finalize(env, obj);
	return;
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KMimeMagic_mergeConfig(JNIEnv *env, jobject obj, jstring configFile)
{
static QString * _qstring_configFile = 0;
	return (jboolean) ((KMimeMagic*) QtSupport::getQt(env, obj))->mergeConfig((QString&) * (QString *) QtSupport::toQString(env, configFile, &_qstring_configFile));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KMimeMagic_mergeBufConfig(JNIEnv *env, jobject obj, jstring arg1)
{
static QCString * _qstring_arg1 = 0;
	return (jboolean) ((KMimeMagic*) QtSupport::getQt(env, obj))->mergeBufConfig((char*) QtSupport::toCharString(env, arg1, &_qstring_arg1));
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KMimeMagic_setFollowLinks(JNIEnv *env, jobject obj, jboolean _enable)
{
	((KMimeMagic*) QtSupport::getQt(env, obj))->setFollowLinks((bool) _enable);
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KMimeMagic_findFileType(JNIEnv *env, jobject obj, jstring _filename)
{
static QString * _qstring__filename = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KMimeMagic*) QtSupport::getQt(env, obj))->findFileType((QString&) * (QString *) QtSupport::toQString(env, _filename, &_qstring__filename)), "org.kde.koala.KMimeMagicResult");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KMimeMagic_findBufferType(JNIEnv *env, jobject obj, jbyteArray p)
{
static QByteArray * _qbyteArray_p = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KMimeMagic*) QtSupport::getQt(env, obj))->findBufferType((QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, p, &_qbyteArray_p)), "org.kde.koala.KMimeMagicResult");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KMimeMagic_findBufferFileType(JNIEnv *env, jobject obj, jbyteArray arg1, jstring filename)
{
static QString * _qstring_filename = 0;
static QByteArray * _qbyteArray_arg1 = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KMimeMagic*) QtSupport::getQt(env, obj))->findBufferFileType((QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, arg1, &_qbyteArray_arg1), (QString&) * (QString *) QtSupport::toQString(env, filename, &_qstring_filename)), "org.kde.koala.KMimeMagicResult");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KMimeMagic_self(JNIEnv *env, jclass obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)KMimeMagicJBridge::self(), "org.kde.koala.KMimeMagic");
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_KMimeMagic_initStatic(JNIEnv *env, jclass obj)
//{
//	KMimeMagicJBridge::protected_initStatic();
//	return;
//}

