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

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

class KSSLPKCS12JBridge : public KSSLPKCS12
{
public:
	~KSSLPKCS12JBridge() {QtSupport::qtKeyDeleted(this);}
	KSSLPKCS12JBridge() : KSSLPKCS12() {}
	bool  protected_parse(QString pass) {
		return (bool ) KSSLPKCS12::parse(pass);
	}
};


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

JNIEXPORT void JNICALL
Java_org_kde_koala_KSSLPKCS12_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KSSLPKCS12_finalize(env, obj);
	return;
}

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

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

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

//JNIEXPORT void JNICALL
//Java_org_kde_koala_KSSLPKCS12_setCert(JNIEnv *env, jobject obj, j c)
//{
//	((KSSLPKCS12*) QtSupport::getQt(env, obj))->setCert((PKCS12*) c);
//	return;
//}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSLPKCS12_changePassword(JNIEnv *env, jobject obj, jstring pold, jstring pnew)
{
static QString * _qstring_pnew = 0;
static QString * _qstring_pold = 0;
	return (jboolean) ((KSSLPKCS12*) QtSupport::getQt(env, obj))->changePassword((QString) * (QString *) QtSupport::toQString(env, pold, &_qstring_pold), (QString) * (QString *) QtSupport::toQString(env, pnew, &_qstring_pnew));
}

//JNIEXPORT  JNICALL
//Java_org_kde_koala_KSSLPKCS12_getPrivateKey(JNIEnv *env, jobject obj)
//{
//	return () ((KSSLPKCS12*) QtSupport::getQt(env, obj))->getPrivateKey();
//}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KSSLPKCS12_getCertificate(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((KSSLPKCS12*) QtSupport::getQt(env, obj))->getCertificate(), "org.kde.koala.KSSLCertificate");
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSLPKCS12_toFile(JNIEnv *env, jobject obj, jstring filename)
{
static QString * _qstring_filename = 0;
	return (jboolean) ((KSSLPKCS12*) QtSupport::getQt(env, obj))->toFile((QString) * (QString *) QtSupport::toQString(env, filename, &_qstring_filename));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KSSLPKCS12_validate(JNIEnv *env, jobject obj)
{
	return (jint) ((KSSLPKCS12*) QtSupport::getQt(env, obj))->validate();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KSSLPKCS12_revalidate(JNIEnv *env, jobject obj)
{
	return (jint) ((KSSLPKCS12*) QtSupport::getQt(env, obj))->revalidate();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSLPKCS12_isValid(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KSSLPKCS12*) QtSupport::getQt(env, obj))->isValid();
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KSSLPKCS12_fromString__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring base64, jstring password)
{
static QString * _qstring_password = 0;
static QString * _qstring_base64 = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)KSSLPKCS12JBridge::fromString((QString) * (QString *) QtSupport::toQString(env, base64, &_qstring_base64), (QString) * (QString *) QtSupport::toQString(env, password, &_qstring_password)), "org.kde.koala.KSSLPKCS12");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KSSLPKCS12_fromString__Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring base64)
{
static QString * _qstring_base64 = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)KSSLPKCS12JBridge::fromString((QString) * (QString *) QtSupport::toQString(env, base64, &_qstring_base64), ""), "org.kde.koala.KSSLPKCS12");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KSSLPKCS12_loadCertFile__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring filename, jstring password)
{
static QString * _qstring_password = 0;
static QString * _qstring_filename = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)KSSLPKCS12JBridge::loadCertFile((QString) * (QString *) QtSupport::toQString(env, filename, &_qstring_filename), (QString) * (QString *) QtSupport::toQString(env, password, &_qstring_password)), "org.kde.koala.KSSLPKCS12");
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_KSSLPKCS12_loadCertFile__Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring filename)
{
static QString * _qstring_filename = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)KSSLPKCS12JBridge::loadCertFile((QString) * (QString *) QtSupport::toQString(env, filename, &_qstring_filename), ""), "org.kde.koala.KSSLPKCS12");
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KSSLPKCS12_parse(JNIEnv *env, jobject obj, jstring pass)
{
static QString * _qstring_pass = 0;
	return (jboolean) ((KSSLPKCS12JBridge*) QtSupport::getQt(env, obj))->protected_parse((QString) * (QString *) QtSupport::toQString(env, pass, &_qstring_pass));
}

