/***************************************************************************
                            QSqlDriver.cpp -  description
                             -------------------
    begin                : Wed Nov 21 17:05:56 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 17:05:56 2001, 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 <qsqldriver.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <qtjava/QSqlDriver.h>

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlDriver_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj) && ((QSqlDriver*)QtSupport::getQt(env, obj))->parent() == (QObject *) 0) {
		delete (QSqlDriver*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlDriver_isOpen(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QSqlDriver*) QtSupport::getQt(env, obj))->isOpen();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlDriver_isOpenError(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QSqlDriver*) QtSupport::getQt(env, obj))->isOpenError();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlDriver_beginTransaction(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QSqlDriver*) QtSupport::getQt(env, obj))->beginTransaction();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlDriver_commitTransaction(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QSqlDriver*) QtSupport::getQt(env, obj))->commitTransaction();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlDriver_rollbackTransaction(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QSqlDriver*) QtSupport::getQt(env, obj))->rollbackTransaction();
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlDriver_tables(JNIEnv *env, jobject obj, jstring user)
{
	QStringList  _qlist;
static QString * _qstring_user = 0;
	_qlist = ((QSqlDriver*) QtSupport::getQt(env, obj))->tables((QString&) * (QString *) QtSupport::toQString(env, user, &_qstring_user));
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlDriver_primaryIndex(JNIEnv *env, jobject obj, jstring tableName)
{
	QSqlIndex  _qsql;
static QString * _qstring_tableName = 0;
	_qsql = ((QSqlDriver*) QtSupport::getQt(env, obj))->primaryIndex((QString&) * (QString *) QtSupport::toQString(env, tableName, &_qstring_tableName));
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QSqlIndex(_qsql), "org.kde.qt.QSqlIndex", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlDriver_record__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring tableName)
{
	QSqlRecord  _qsql;
static QString * _qstring_tableName = 0;
	_qsql = ((QSqlDriver*) QtSupport::getQt(env, obj))->record((QString&) * (QString *) QtSupport::toQString(env, tableName, &_qstring_tableName));
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QSqlRecord(_qsql), "org.kde.qt.QSqlRecord", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlDriver_record__Lorg_kde_qt_QSqlQueryInterface_2(JNIEnv *env, jobject obj, jobject query)
{
	QSqlRecord  _qsql;
	_qsql = ((QSqlDriver*) QtSupport::getQt(env, obj))->record((QSqlQuery&) *(QSqlQuery *) QtSupport::getQt(env, query));
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QSqlRecord(_qsql), "org.kde.qt.QSqlRecord", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlDriver_recordInfo__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring tablename)
{
static QString * _qstring_tablename = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)new  QSqlRecordInfo (((QSqlDriver*) QtSupport::getQt(env, obj))->recordInfo((QString&) * (QString *) QtSupport::toQString(env, tablename, &_qstring_tablename))), "org.kde.qt.QSqlRecordInfo", TRUE);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlDriver_recordInfo__Lorg_kde_qt_QSqlQueryInterface_2(JNIEnv *env, jobject obj, jobject query)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)new  QSqlRecordInfo (((QSqlDriver*) QtSupport::getQt(env, obj))->recordInfo((QSqlQuery&) *(QSqlQuery *) QtSupport::getQt(env, query))), "org.kde.qt.QSqlRecordInfo", TRUE);
}

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

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QSqlDriver_formatValue(JNIEnv *env, jobject obj, jobject field, jboolean trimStrings)
{
	QString  _qstring;
	_qstring = ((QSqlDriver*) QtSupport::getQt(env, obj))->formatValue((QSqlField*) QtSupport::getQt(env, field), (bool) trimStrings);
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlDriver_lastError(JNIEnv *env, jobject obj)
{
	QSqlError  _qsql;
	_qsql = ((QSqlDriver*) QtSupport::getQt(env, obj))->lastError();
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QSqlError(_qsql), "org.kde.qt.QSqlError", TRUE);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlDriver_hasFeature(JNIEnv *env, jobject obj, jint f)
{
	return (jboolean) ((QSqlDriver*) QtSupport::getQt(env, obj))->hasFeature((QSqlDriver::DriverFeature) f);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlDriver_open__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring db, jstring user, jstring password, jstring host, jint port)
{
static QString * _qstring_host = 0;
static QString * _qstring_password = 0;
static QString * _qstring_user = 0;
static QString * _qstring_db = 0;
	return (jboolean) ((QSqlDriver*) QtSupport::getQt(env, obj))->open((QString&) * (QString *) QtSupport::toQString(env, db, &_qstring_db), (QString&) * (QString *) QtSupport::toQString(env, user, &_qstring_user), (QString&) * (QString *) QtSupport::toQString(env, password, &_qstring_password), (QString&) * (QString *) QtSupport::toQString(env, host, &_qstring_host), (int) port);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QSqlDriver_open__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring db)
{
static QString * _qstring_db = 0;
	return (jboolean) ((QSqlDriver*) QtSupport::getQt(env, obj))->open((QString&) * (QString *) QtSupport::toQString(env, db, &_qstring_db), QString::null, QString::null, QString::null, -1);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlDriver_close(JNIEnv *env, jobject obj)
{
	((QSqlDriver*) QtSupport::getQt(env, obj))->close();
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QSqlDriver_createQuery(JNIEnv *env, jobject obj)
{
	QSqlQuery  _qsql;
	_qsql = ((QSqlDriver*) QtSupport::getQt(env, obj))->createQuery();
	return (jobject) QtSupport::objectForQtKey(env, (void *)new QSqlQuery(_qsql), "org.kde.qt.QSqlQuery", TRUE);
}

