/***************************************************************************
                            KDEsuClient.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 <kdesu/client.h>
#include <qstring.h>
#include <qcstring.h>

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

class KDEsuClientJBridge : public KDEsuClient
{
public:
	KDEsuClientJBridge() : KDEsuClient() {}
	~KDEsuClientJBridge() {QtSupport::qtKeyDeleted(this);}
};


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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KDEsuClient_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KDEsuClient_finalize(env, obj);
	return;
}

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

//JNIEXPORT jint JNICALL
//Java_org_kde_koala_KDEsuClient_exec__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring command, jstring user, jstring options, jstring _env)
//{
//static QCString * _qcstring_options = 0;
//static QCString * _qcstring_user = 0;
//static QCString * _qcstring_command = 0;
//	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->exec((QCString&) * (QCString *) QtSupport::toQCString(env, command, &_qcstring_command), (QCString&) * (QCString *) QtSupport::toQCString(env, user, &_qcstring_user), (QCString&) * (QCString *) QtSupport::toQCString(env, options, &_qcstring_options), (QCStringList) _env);
//}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_exec__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring command, jstring user)
{
static QCString * _qcstring_user = 0;
static QCString * _qcstring_command = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->exec((QCString&) * (QCString *) QtSupport::toQCString(env, command, &_qcstring_command), (QCString&) * (QCString *) QtSupport::toQCString(env, user, &_qcstring_user), 0, QCStringList());
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_setPass(JNIEnv *env, jobject obj, jstring pass, jint timeout)
{
static QCString * _qstring_pass = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->setPass((char*) QtSupport::toCharString(env, pass, &_qstring_pass), (int) timeout);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_setHost(JNIEnv *env, jobject obj, jstring host)
{
static QCString * _qcstring_host = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->setHost((QCString&) * (QCString *) QtSupport::toQCString(env, host, &_qcstring_host));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_setPriority(JNIEnv *env, jobject obj, jint priority)
{
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->setPriority((int) priority);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_setScheduler(JNIEnv *env, jobject obj, jint scheduler)
{
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->setScheduler((int) scheduler);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_delCommand(JNIEnv *env, jobject obj, jstring command, jstring user)
{
static QCString * _qcstring_user = 0;
static QCString * _qcstring_command = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->delCommand((QCString&) * (QCString *) QtSupport::toQCString(env, command, &_qcstring_command), (QCString&) * (QCString *) QtSupport::toQCString(env, user, &_qcstring_user));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_setVar__Ljava_lang_String_2Ljava_lang_String_2ILjava_lang_String_2(JNIEnv *env, jobject obj, jstring key, jstring value, jint timeout, jstring group)
{
static QCString * _qcstring_group = 0;
static QCString * _qcstring_value = 0;
static QCString * _qcstring_key = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->setVar((QCString&) * (QCString *) QtSupport::toQCString(env, key, &_qcstring_key), (QCString&) * (QCString *) QtSupport::toQCString(env, value, &_qcstring_value), (int) timeout, (QCString&) * (QCString *) QtSupport::toQCString(env, group, &_qcstring_group));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_setVar__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring key, jstring value)
{
static QCString * _qcstring_value = 0;
static QCString * _qcstring_key = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->setVar((QCString&) * (QCString *) QtSupport::toQCString(env, key, &_qcstring_key), (QCString&) * (QCString *) QtSupport::toQCString(env, value, &_qcstring_value), 0, 0);
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KDEsuClient_getVar(JNIEnv *env, jobject obj, jstring key)
{
	QCString  _qcstring;
static QCString * _qcstring_key = 0;
	_qcstring = ((KDEsuClient*) QtSupport::getQt(env, obj))->getVar((QCString&) * (QCString *) QtSupport::toQCString(env, key, &_qcstring_key));
	return QtSupport::fromQCString(env, &_qcstring);
}

//JNIEXPORT jstring JNICALL
//Java_org_kde_koala_KDEsuClient_getKeys(JNIEnv *env, jobject obj, jstring group)
//{
//	QCString  _qcstring;
//static QCString * _qcstring_group = 0;
//	_qcstring = (const char *)((KDEsuClient*) QtSupport::getQt(env, obj))->getKeys((QCString&) * (QCString *) QtSupport::toQCString(env, group, &_qcstring_group));
//	return QtSupport::fromCharString(env, (char *) _qcstring);
//}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KDEsuClient_findGroup(JNIEnv *env, jobject obj, jstring group)
{
static QCString * _qcstring_group = 0;
	return (jboolean) ((KDEsuClient*) QtSupport::getQt(env, obj))->findGroup((QCString&) * (QCString *) QtSupport::toQCString(env, group, &_qcstring_group));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_delVar(JNIEnv *env, jobject obj, jstring key)
{
static QCString * _qcstring_key = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->delVar((QCString&) * (QCString *) QtSupport::toQCString(env, key, &_qcstring_key));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_delVars(JNIEnv *env, jobject obj, jstring special_key)
{
static QCString * _qcstring_special_key = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->delVars((QCString&) * (QCString *) QtSupport::toQCString(env, special_key, &_qcstring_special_key));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_delGroup(JNIEnv *env, jobject obj, jstring group)
{
static QCString * _qcstring_group = 0;
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->delGroup((QCString&) * (QCString *) QtSupport::toQCString(env, group, &_qcstring_group));
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_ping(JNIEnv *env, jobject obj)
{
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->ping();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_stopServer(JNIEnv *env, jobject obj)
{
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->stopServer();
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KDEsuClient_startServer(JNIEnv *env, jobject obj)
{
	return (jint) ((KDEsuClient*) QtSupport::getQt(env, obj))->startServer();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KDEsuClient_isServerSGID(JNIEnv *env, jobject obj)
{
	return (jboolean) ((KDEsuClient*) QtSupport::getQt(env, obj))->isServerSGID();
}

