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

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

class KTempFileJBridge : public KTempFile
{
public:
	KTempFileJBridge(QString filePrefix, QString fileExtension, int mode) : KTempFile(filePrefix, fileExtension, mode) {}
	~KTempFileJBridge() {QtSupport::qtKeyDeleted(this);}
	KTempFileJBridge(bool arg1) : KTempFile(arg1) {}
	bool  protected_create(const QString& filePrefix, const QString& fileExtension, int mode) {
		return (bool ) KTempFile::create(filePrefix, fileExtension, mode);
	}
	void protected_setError(int error) {
		KTempFile::setError(error);
		return;
	}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KTempFile_newKTempFile__Ljava_lang_String_2Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring filePrefix, jstring fileExtension, jint mode)
{
static QString * _qstring_fileExtension = 0;
static QString * _qstring_filePrefix = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KTempFileJBridge((QString) * (QString *) QtSupport::toQString(env, filePrefix, &_qstring_filePrefix), (QString) * (QString *) QtSupport::toQString(env, fileExtension, &_qstring_fileExtension), (int) mode));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KTempFile_newKTempFile__(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KTempFileJBridge(QString::null, QString::null, 0600));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KTempFile_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KTempFile_finalize(env, obj);
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KTempFile_setAutoDelete(JNIEnv *env, jobject obj, jboolean autoDelete)
{
	((KTempFile*) QtSupport::getQt(env, obj))->setAutoDelete((bool) autoDelete);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KTempFile_status(JNIEnv *env, jobject obj)
{
	return (jint) ((KTempFile*) QtSupport::getQt(env, obj))->status();
}

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

JNIEXPORT jint JNICALL
Java_org_kde_koala_KTempFile_handle(JNIEnv *env, jobject obj)
{
	return (jint) ((KTempFile*) QtSupport::getQt(env, obj))->handle();
}

//JNIEXPORT jFILE* JNICALL
//Java_org_kde_koala_KTempFile_fstream(JNIEnv *env, jobject obj)
//{
//	return (jFILE*) ((KTempFile*) QtSupport::getQt(env, obj))->fstream();
//}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KTempFile_textStream(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KTempFile*) QtSupport::getQt(env, obj))->textStream(), "org.kde.qt.QTextStream");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KTempFile_dataStream(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KTempFile*) QtSupport::getQt(env, obj))->dataStream(), "org.kde.qt.QDataStream");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KTempFile_file(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KTempFile*) QtSupport::getQt(env, obj))->file(), "org.kde.qt.QFile");
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KTempFile_unlink(JNIEnv *env, jobject obj)
{
	((KTempFile*) QtSupport::getQt(env, obj))->unlink();
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KTempFile_close(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KTempFile*) QtSupport::getQt(env, obj))->close();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KTempFile_newKTempFile__Z(JNIEnv *env, jobject obj, jboolean arg1)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KTempFileJBridge((bool) arg1));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KTempFile_create(JNIEnv *env, jobject obj, jstring filePrefix, jstring fileExtension, jint mode)
{
static QString * _qstring_fileExtension = 0;
static QString * _qstring_filePrefix = 0;
	return (jboolean) ((KTempFileJBridge*) QtSupport::getQt(env, obj))->protected_create((QString&) * (QString *) QtSupport::toQString(env, filePrefix, &_qstring_filePrefix), (QString&) * (QString *) QtSupport::toQString(env, fileExtension, &_qstring_fileExtension), (int) mode);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KTempFile_setError(JNIEnv *env, jobject obj, jint error)
{
	((KTempFileJBridge*) QtSupport::getQt(env, obj))->protected_setError((int) error);
	return;
}

