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

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

class KTarJBridge : public KTar
{
public:
	KTarJBridge(const QString& filename, const QString& mimetype) : KTar(filename, mimetype) {}
	KTarJBridge(QIODevice* dev) : KTar(dev) {}
	~KTarJBridge() {QtSupport::qtKeyDeleted(this);}
	 bool  protected_openArchive(int mode) {
		return ( bool ) KTar::openArchive(mode);
	}
	 bool  protected_closeArchive() {
		return ( bool ) KTar::closeArchive();
	}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_KTar_newKTar__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring filename, jstring mimetype)
{
static QString * _qstring_mimetype = 0;
static QString * _qstring_filename = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KTarJBridge((QString&) * (QString *) QtSupport::toQString(env, filename, &_qstring_filename), (QString&) * (QString *) QtSupport::toQString(env, mimetype, &_qstring_mimetype)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KTar_newKTar__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring filename)
{
static QString * _qstring_filename = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KTarJBridge((QString&) * (QString *) QtSupport::toQString(env, filename, &_qstring_filename), QString::null));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KTar_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KTar_finalize(env, obj);
	return;
}

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KTar_setOrigFileName(JNIEnv *env, jobject obj, jstring fileName)
{
static QCString * _qcstring_fileName = 0;
	((KTar*) QtSupport::getQt(env, obj))->setOrigFileName((QCString&) * (QCString *) QtSupport::toQCString(env, fileName, &_qcstring_fileName));
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KTar_writeDir(JNIEnv *env, jobject obj, jstring name, jstring user, jstring group)
{
static QString * _qstring_group = 0;
static QString * _qstring_user = 0;
static QString * _qstring_name = 0;
	return (jboolean) ((KTar*) QtSupport::getQt(env, obj))->writeDir((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name), (QString&) * (QString *) QtSupport::toQString(env, user, &_qstring_user), (QString&) * (QString *) QtSupport::toQString(env, group, &_qstring_group));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KTar_prepareWriting(JNIEnv *env, jobject obj, jstring name, jstring user, jstring group, jint size)
{
static QString * _qstring_group = 0;
static QString * _qstring_user = 0;
static QString * _qstring_name = 0;
	return (jboolean) ((KTar*) QtSupport::getQt(env, obj))->prepareWriting((QString&) * (QString *) QtSupport::toQString(env, name, &_qstring_name), (QString&) * (QString *) QtSupport::toQString(env, user, &_qstring_user), (QString&) * (QString *) QtSupport::toQString(env, group, &_qstring_group), (uint) size);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KTar_doneWriting(JNIEnv *env, jobject obj, jint size)
{
	return (jboolean) ((KTar*) QtSupport::getQt(env, obj))->doneWriting((uint) size);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KTar_openArchive(JNIEnv *env, jobject obj, jint mode)
{
	return (jboolean) ((KTarJBridge*) QtSupport::getQt(env, obj))->protected_openArchive((int) mode);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KTar_closeArchive(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KTarJBridge*) QtSupport::getQt(env, obj))->protected_closeArchive();
}

