/***************************************************************************
                            QHttp.cpp -  description
                             -------------------
    begin                : Sun Nov  3 10:27:27 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Nov  3 10:27:27 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 <qhttp.h>
#include <qstring.h>
#include <qcstring.h>

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

class QHttpJBridge : public QHttp
{
public:
	QHttpJBridge() : QHttp() {}
	QHttpJBridge(QObject* parent, const char* name) : QHttp(parent, name) {}
	QHttpJBridge(const QString& hostname, Q_UINT16 port, QObject* parent, const char* name) : QHttp(hostname, port, parent, name) {}
	~QHttpJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_operationGet(QNetworkOperation* op) {
		QHttp::operationGet(op);
		return;
	}
	void protected_operationPut(QNetworkOperation* op) {
		QHttp::operationPut(op);
		return;
	}
	void protected_timerEvent(QTimerEvent* arg1) {
		QHttp::timerEvent(arg1);
		return;
	}
	void customEvent(QCustomEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "customEvent", arg1, "org.kde.qt.QCustomEvent")) {
			QObject::customEvent(arg1);
		}
		return;
	}
	void timerEvent(QTimerEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "timerEvent", arg1, "org.kde.qt.QTimerEvent")) {
			QHttp::timerEvent(arg1);
		}
		return;
	}
	void childEvent(QChildEvent* arg1) {
		if (! QtSupport::eventDelegate(this, "childEvent", arg1, "org.kde.qt.QChildEvent")) {
			QObject::childEvent(arg1);
		}
		return;
	}
};


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

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_newQHttp__Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject parent, jstring name)
{
static QCString * _qstring_name = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QHttpJBridge((QObject*) QtSupport::getQt(env, parent), (char*) QtSupport::toCharString(env, name, &_qstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_newQHttp__Lorg_kde_qt_QObject_2(JNIEnv *env, jobject obj, jobject parent)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QHttpJBridge((QObject*) QtSupport::getQt(env, parent), 0));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_newQHttp__Ljava_lang_String_2SLorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring hostname, jshort port, jobject parent, jstring name)
{
static QCString * _qstring_name = 0;
static QString * _qstring_hostname = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QHttpJBridge((QString&) * (QString *) QtSupport::toQString(env, hostname, &_qstring_hostname), (Q_UINT16) port, (QObject*) QtSupport::getQt(env, parent), (char*) QtSupport::toCharString(env, name, &_qstring_name)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_newQHttp__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring hostname)
{
static QString * _qstring_hostname = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QHttpJBridge((QString&) * (QString *) QtSupport::toQString(env, hostname, &_qstring_hostname), 80, 0, 0));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_qt_QHttp_finalize(env, obj);
	return;
}

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

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_supportedOperations(JNIEnv *env, jobject obj)
{
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->supportedOperations();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_setHost__Ljava_lang_String_2S(JNIEnv *env, jobject obj, jstring hostname, jshort port)
{
static QString * _qstring_hostname = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->setHost((QString&) * (QString *) QtSupport::toQString(env, hostname, &_qstring_hostname), (Q_UINT16) port);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_setHost__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring hostname)
{
static QString * _qstring_hostname = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->setHost((QString&) * (QString *) QtSupport::toQString(env, hostname, &_qstring_hostname), 80);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_get__Ljava_lang_String_2Lorg_kde_qt_QIODeviceInterface_2(JNIEnv *env, jobject obj, jstring path, jobject to)
{
static QString * _qstring_path = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->get((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path), (QIODevice*) QtSupport::getQt(env, to));
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_get__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring path)
{
static QString * _qstring_path = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->get((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path), 0);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_post__Ljava_lang_String_2Lorg_kde_qt_QIODeviceInterface_2Lorg_kde_qt_QIODeviceInterface_2(JNIEnv *env, jobject obj, jstring path, jobject data, jobject to)
{
static QString * _qstring_path = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->post((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path), (QIODevice*) QtSupport::getQt(env, data), (QIODevice*) QtSupport::getQt(env, to));
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_post__Ljava_lang_String_2Lorg_kde_qt_QIODeviceInterface_2(JNIEnv *env, jobject obj, jstring path, jobject data)
{
static QString * _qstring_path = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->post((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path), (QIODevice*) QtSupport::getQt(env, data), 0);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_post__Ljava_lang_String_2_3BLorg_kde_qt_QIODeviceInterface_2(JNIEnv *env, jobject obj, jstring path, jbyteArray data, jobject to)
{
static QByteArray * _qbyteArray_data = 0;
static QString * _qstring_path = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->post((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data), (QIODevice*) QtSupport::getQt(env, to));
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_post__Ljava_lang_String_2_3B(JNIEnv *env, jobject obj, jstring path, jbyteArray data)
{
static QByteArray * _qbyteArray_data = 0;
static QString * _qstring_path = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->post((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data), 0);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_head(JNIEnv *env, jobject obj, jstring path)
{
static QString * _qstring_path = 0;
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->head((QString&) * (QString *) QtSupport::toQString(env, path, &_qstring_path));
}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QHttp_request__Lorg_kde_qt_QIODeviceInterface_2Lorg_kde_qt_QIODeviceInterface_2(JNIEnv *env, jobject obj, j header, jobject device, jobject to)
//{
//	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->request((QHttpRequestHeader) header, (QIODevice*) QtSupport::getQt(env, device), (QIODevice*) QtSupport::getQt(env, to));
//}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QHttp_request__(JNIEnv *env, jobject obj, j header)
//{
//	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->request((QHttpRequestHeader) header, 0, 0);
//}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QHttp_request___3BLorg_kde_qt_QIODeviceInterface_2(JNIEnv *env, jobject obj, j header, jbyteArray data, jobject to)
//{
//static QByteArray * _qbyteArray_data = 0;
//	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->request((QHttpRequestHeader) header, (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data), (QIODevice*) QtSupport::getQt(env, to));
//}

//JNIEXPORT jint JNICALL
//Java_org_kde_qt_QHttp_request___3B(JNIEnv *env, jobject obj, j header, jbyteArray data)
//{
//static QByteArray * _qbyteArray_data = 0;
//	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->request((QHttpRequestHeader) header, (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data), 0);
//}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_closeConnection(JNIEnv *env, jobject obj)
{
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->closeConnection();
}

JNIEXPORT jlong JNICALL
Java_org_kde_qt_QHttp_bytesAvailable(JNIEnv *env, jobject obj)
{
	return (jlong) ((QHttp*) QtSupport::getQt(env, obj))->bytesAvailable();
}

JNIEXPORT jlong JNICALL
Java_org_kde_qt_QHttp_readBlock(JNIEnv *env, jobject obj, jstring data, jlong maxlen)
{
static QCString * _qstring_data = 0;
	return (jlong) ((QHttp*) QtSupport::getQt(env, obj))->readBlock((char*) QtSupport::toCharString(env, data, &_qstring_data), (Q_ULONG) maxlen);
}

JNIEXPORT jbyteArray JNICALL
Java_org_kde_qt_QHttp_readAll(JNIEnv *env, jobject obj)
{
	QByteArray  _qbyteArray;
	_qbyteArray = ((QHttp*) QtSupport::getQt(env, obj))->readAll();
	return QtSupport::fromQByteArray(env, &_qbyteArray);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_currentId(JNIEnv *env, jobject obj)
{
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->currentId();
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QHttp_currentSourceDevice(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((QHttp*) QtSupport::getQt(env, obj))->currentSourceDevice(), "org.kde.qt.QIODeviceInterface");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QHttp_currentDestinationDevice(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((QHttp*) QtSupport::getQt(env, obj))->currentDestinationDevice(), "org.kde.qt.QIODeviceInterface");
}

//JNIEXPORT  JNICALL
//Java_org_kde_qt_QHttp_currentRequest(JNIEnv *env, jobject obj)
//{
//	return () ((QHttp*) QtSupport::getQt(env, obj))->currentRequest();
//}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QHttp_hasPendingRequests(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QHttp*) QtSupport::getQt(env, obj))->hasPendingRequests();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_clearPendingRequests(JNIEnv *env, jobject obj)
{
	((QHttp*) QtSupport::getQt(env, obj))->clearPendingRequests();
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_state(JNIEnv *env, jobject obj)
{
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->state();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QHttp_error(JNIEnv *env, jobject obj)
{
	return (jint) ((QHttp*) QtSupport::getQt(env, obj))->error();
}

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

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_abort(JNIEnv *env, jobject obj)
{
	((QHttp*) QtSupport::getQt(env, obj))->abort();
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_operationGet(JNIEnv *env, jobject obj, jobject op)
{
	((QHttpJBridge*) QtSupport::getQt(env, obj))->protected_operationGet((QNetworkOperation*) QtSupport::getQt(env, op));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_operationPut(JNIEnv *env, jobject obj, jobject op)
{
	((QHttpJBridge*) QtSupport::getQt(env, obj))->protected_operationPut((QNetworkOperation*) QtSupport::getQt(env, op));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QHttp_timerEvent(JNIEnv *env, jobject obj, jobject arg1)
{
	((QHttpJBridge*) QtSupport::getQt(env, obj))->protected_timerEvent((QTimerEvent*) QtSupport::getQt(env, arg1));
	return;
}

