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

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

class KConfigINIBackEndJBridge : public KConfigINIBackEnd
{
public:
	KConfigINIBackEndJBridge(KConfigBase* _config, const QString& _fileName, const char* _resType, bool _useKDEGlobals) : KConfigINIBackEnd(_config, _fileName, _resType, _useKDEGlobals) {}
	~KConfigINIBackEndJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_parseSingleConfigFile(QFile& rFile, KEntryMap* pWriteBackMap, bool bGlobal, bool bDefault) {
		KConfigINIBackEnd::parseSingleConfigFile(rFile, pWriteBackMap, bGlobal, bDefault);
		return;
	}
	bool  protected_writeConfigFile(QString filename, bool bGlobal, bool bMerge) {
		return (bool ) KConfigINIBackEnd::writeConfigFile(filename, bGlobal, bMerge);
	}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KConfigINIBackEnd_newKConfigINIBackEnd__Lorg_kde_koala_KConfigBase_2Ljava_lang_String_2Ljava_lang_String_2Z(JNIEnv *env, jobject obj, jobject _config, jstring _fileName, jstring _resType, jboolean _useKDEGlobals)
{
static QCString * _qstring__resType = 0;
static QString * _qstring__fileName = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KConfigINIBackEndJBridge((KConfigBase*) QtSupport::getQt(env, _config), (QString&) * (QString *) QtSupport::toQString(env, _fileName, &_qstring__fileName), (char*) QtSupport::toCharString(env, _resType, &_qstring__resType), (bool) _useKDEGlobals));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KConfigINIBackEnd_newKConfigINIBackEnd__Lorg_kde_koala_KConfigBase_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject _config, jstring _fileName, jstring _resType)
{
static QCString * _qstring__resType = 0;
static QString * _qstring__fileName = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KConfigINIBackEndJBridge((KConfigBase*) QtSupport::getQt(env, _config), (QString&) * (QString *) QtSupport::toQString(env, _fileName, &_qstring__fileName), (char*) QtSupport::toCharString(env, _resType, &_qstring__resType), true));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KConfigINIBackEnd_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KConfigINIBackEnd_finalize(env, obj);
	return;
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KConfigINIBackEnd_parseConfigFiles(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KConfigINIBackEnd*) QtSupport::getQt(env, obj))->parseConfigFiles();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KConfigINIBackEnd_sync__Z(JNIEnv *env, jobject obj, jboolean bMerge)
{
	((KConfigINIBackEnd*) QtSupport::getQt(env, obj))->sync((bool) bMerge);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KConfigINIBackEnd_sync__(JNIEnv *env, jobject obj)
{
	((KConfigINIBackEnd*) QtSupport::getQt(env, obj))->sync(true);
	return;
}

//JNIEXPORT void JNICALL
//Java_org_kde_koala_KConfigINIBackEnd_parseSingleConfigFile__Lorg_kde_qt_QFile_2Lorg_kde_koala_KEntryMap_2ZZ(JNIEnv *env, jobject obj, jobject rFile, jobject pWriteBackMap, jboolean bGlobal, jboolean bDefault)
//{
//	((KConfigINIBackEndJBridge*) QtSupport::getQt(env, obj))->protected_parseSingleConfigFile((QFile&) *(QFile *) QtSupport::getQt(env, rFile), (KEntryMap*) QtSupport::getQt(env, pWriteBackMap), (bool) bGlobal, (bool) bDefault);
//	return;
//}

JNIEXPORT void JNICALL
Java_org_kde_koala_KConfigINIBackEnd_parseSingleConfigFile(JNIEnv *env, jobject obj, jobject rFile)
{
	((KConfigINIBackEndJBridge*) QtSupport::getQt(env, obj))->protected_parseSingleConfigFile((QFile&) *(QFile *) QtSupport::getQt(env, rFile), 0L, false, false);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KConfigINIBackEnd_writeConfigFile__Ljava_lang_String_2ZZ(JNIEnv *env, jobject obj, jstring filename, jboolean bGlobal, jboolean bMerge)
{
static QString * _qstring_filename = 0;
	return (jboolean) ((KConfigINIBackEndJBridge*) QtSupport::getQt(env, obj))->protected_writeConfigFile((QString) * (QString *) QtSupport::toQString(env, filename, &_qstring_filename), (bool) bGlobal, (bool) bMerge);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KConfigINIBackEnd_writeConfigFile__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring filename)
{
static QString * _qstring_filename = 0;
	return (jboolean) ((KConfigINIBackEndJBridge*) QtSupport::getQt(env, obj))->protected_writeConfigFile((QString) * (QString *) QtSupport::toQString(env, filename, &_qstring_filename), false, true);
}

