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

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

class KSSLJBridge : public KSSL
{
public:
	KSSLJBridge(bool init) : KSSL(init) {}
	~KSSLJBridge() {QtSupport::qtKeyDeleted(this);}
};


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

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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KSSL_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KSSL_finalize(env, obj);
	return;
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSL_initialize(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KSSL*) QtSupport::getQt(env, obj))->initialize();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSL_TLSInit(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KSSL*) QtSupport::getQt(env, obj))->TLSInit();
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSL_reInitialize(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KSSL*) QtSupport::getQt(env, obj))->reInitialize();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSL_reconfig(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KSSL*) QtSupport::getQt(env, obj))->reconfig();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KSSL_setAutoReconfig(JNIEnv *env, jobject obj, jboolean ar)
{
	((KSSL*) QtSupport::getQt(env, obj))->setAutoReconfig((bool) ar);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KSSL_seedWithEGD(JNIEnv *env, jobject obj)
{
	return (jint) ((KSSL*) QtSupport::getQt(env, obj))->seedWithEGD();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSL_setSettings(JNIEnv *env, jobject obj, jobject settings)
{
	return (jboolean) ((KSSL*) QtSupport::getQt(env, obj))->setSettings((KSSLSettings*) QtSupport::getQt(env, settings));
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KSSL_settings(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KSSL*) QtSupport::getQt(env, obj))->settings(), "org.kde.koala.KSSLSettings");
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSL_setClientCertificate(JNIEnv *env, jobject obj, jobject pkcs)
{
	return (jboolean) ((KSSL*) QtSupport::getQt(env, obj))->setClientCertificate((KSSLPKCS12*) QtSupport::getQt(env, pkcs));
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KSSL_setProxyUse__ZLjava_lang_String_2ILjava_lang_String_2(JNIEnv *env, jobject obj, jboolean active, jstring realIP, jint realPort, jstring proxy)
{
static QString * _qstring_proxy = 0;
static QString * _qstring_realIP = 0;
	((KSSL*) QtSupport::getQt(env, obj))->setProxyUse((bool) active, (QString) * (QString *) QtSupport::toQString(env, realIP, &_qstring_realIP), (int) realPort, (QString) * (QString *) QtSupport::toQString(env, proxy, &_qstring_proxy));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KSSL_setProxyUse__Z(JNIEnv *env, jobject obj, jboolean active)
{
	((KSSL*) QtSupport::getQt(env, obj))->setProxyUse((bool) active, QString::null, 0, QString::null);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KSSL_setPeerHost__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring realHost)
{
static QString * _qstring_realHost = 0;
	((KSSL*) QtSupport::getQt(env, obj))->setPeerHost((QString) * (QString *) QtSupport::toQString(env, realHost, &_qstring_realHost));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KSSL_setPeerHost__(JNIEnv *env, jobject obj)
{
	((KSSL*) QtSupport::getQt(env, obj))->setPeerHost(QString::null);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KSSL_connect(JNIEnv *env, jobject obj, jint sock)
{
	return (jint) ((KSSL*) QtSupport::getQt(env, obj))->connect((int) sock);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KSSL_read(JNIEnv *env, jobject obj, jint buf, jint len)
{
	return (jint) ((KSSL*) QtSupport::getQt(env, obj))->read((void*) buf, (int) len);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KSSL_peek(JNIEnv *env, jobject obj, jint buf, jint len)
{
	return (jint) ((KSSL*) QtSupport::getQt(env, obj))->peek((void*) buf, (int) len);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KSSL_write(JNIEnv *env, jobject obj, jint buf, jint len)
{
	return (jint) ((KSSL*) QtSupport::getQt(env, obj))->write((void*) buf, (int) len);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KSSL_pending(JNIEnv *env, jobject obj)
{
	return (jint) ((KSSL*) QtSupport::getQt(env, obj))->pending();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KSSL_connectionInfo(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)(KSSLConnectionInfo *) &((KSSL*) QtSupport::getQt(env, obj))->connectionInfo(), "org.kde.koala.KSSLConnectionInfo");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KSSL_peerInfo(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)(KSSLPeerInfo *) &((KSSL*) QtSupport::getQt(env, obj))->peerInfo(), "org.kde.koala.KSSLPeerInfo");
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSL_doesSSLWork(JNIEnv *env, jclass obj)
{
	return (jboolean) KSSLJBridge::doesSSLWork();
}

