/***************************************************************************
                            DCOPObject.cpp -  description
                             -------------------
    begin                : Sun Aug 26 09:45:02 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Aug 26 09:45:02 2001, using kdoc parser/custom Java conversion backend.
 ***************************************************************************/

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

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

class DCOPObjectJBridge : public DCOPObject
{
public:
	DCOPObjectJBridge() : DCOPObject() {}
	DCOPObjectJBridge(QObject* obj) : DCOPObject(obj) {}
	DCOPObjectJBridge(const QCString& objId) : DCOPObject(objId) {}
	~DCOPObjectJBridge() {QtSupport::qtKeyDeleted(this);}
};


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

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

JNIEXPORT void JNICALL
Java_org_kde_koala_DCOPObject_newDCOPObject__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring objId)
{
static QCString * _qcstring_objId = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new DCOPObjectJBridge((QCString&) * (QCString *) QtSupport::toQCString(env, objId, &_qcstring_objId)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DCOPObject_objId(JNIEnv *env, jobject obj)
{
	QCString  _qcstring;
	_qcstring = ((DCOPObjectJBridge*) QtSupport::getQt(env, obj))->objId();
	return QtSupport::fromQCString(env, &_qcstring);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DCOPObject_process(JNIEnv *env, jobject obj, jstring fun, jbyteArray data, jstring replyType, jbyteArray replyData)
{
static QByteArray * _qbyteArray_replyData = 0;
static QCString * _qcstring_replyType = 0;
static QByteArray * _qbyteArray_data = 0;
static QCString * _qcstring_fun = 0;
	return (jboolean) ((DCOPObjectJBridge*) QtSupport::getQt(env, obj))->process((QCString&) * (QCString *) QtSupport::toQCString(env, fun, &_qcstring_fun), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data), (QCString&) * (QCString *) QtSupport::toQCString(env, replyType, &_qcstring_replyType), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, replyData, &_qbyteArray_replyData));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DCOPObject_processDynamic(JNIEnv *env, jobject obj, jstring fun, jbyteArray data, jstring replyType, jbyteArray replyData)
{
static QByteArray * _qbyteArray_replyData = 0;
static QCString * _qcstring_replyType = 0;
static QByteArray * _qbyteArray_data = 0;
static QCString * _qcstring_fun = 0;
	return (jboolean) ((DCOPObjectJBridge*) QtSupport::getQt(env, obj))->processDynamic((QCString&) * (QCString *) QtSupport::toQCString(env, fun, &_qcstring_fun), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data), (QCString&) * (QCString *) QtSupport::toQCString(env, replyType, &_qcstring_replyType), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, replyData, &_qbyteArray_replyData));
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DCOPObject_interfaces(JNIEnv *env, jobject obj)
{
	QCStringList  _qlist;
	_qlist = ((DCOPObjectJBridge*) QtSupport::getQt(env, obj))->interfaces();
	return (jobject) KDESupport::arrayWithQCStringList(env, (QCStringList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DCOPObject_functions(JNIEnv *env, jobject obj)
{
	QCStringList  _qlist;
	_qlist = ((DCOPObjectJBridge*) QtSupport::getQt(env, obj))->functions();
	return (jobject) KDESupport::arrayWithQCStringList(env, (QCStringList *) &_qlist);
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DCOPObject_emitDCOPSignal(JNIEnv *env, jobject obj, jstring signal, jbyteArray data)
{
static QByteArray * _qbyteArray_data = 0;
static QCString * _qcstring_signal = 0;
	((DCOPObjectJBridge*) QtSupport::getQt(env, obj))->emitDCOPSignal((QCString&) * (QCString *) QtSupport::toQCString(env, signal, &_qcstring_signal), (QByteArray&) * (QByteArray *) QtSupport::toQByteArray(env, data, &_qbyteArray_data));
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DCOPObject_connectDCOPSignal(JNIEnv *env, jobject obj, jstring sender, jstring senderObj, jstring signal, jstring slot, jboolean Volatile)
{
static QCString * _qcstring_slot = 0;
static QCString * _qcstring_signal = 0;
static QCString * _qcstring_senderObj = 0;
static QCString * _qcstring_sender = 0;
	return (jboolean) ((DCOPObjectJBridge*) QtSupport::getQt(env, obj))->connectDCOPSignal((QCString&) * (QCString *) QtSupport::toQCString(env, sender, &_qcstring_sender), (QCString&) * (QCString *) QtSupport::toQCString(env, senderObj, &_qcstring_senderObj), (QCString&) * (QCString *) QtSupport::toQCString(env, signal, &_qcstring_signal), (QCString&) * (QCString *) QtSupport::toQCString(env, slot, &_qcstring_slot), (bool) Volatile);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DCOPObject_disconnectDCOPSignal(JNIEnv *env, jobject obj, jstring sender, jstring senderObj, jstring signal, jstring slot)
{
static QCString * _qcstring_slot = 0;
static QCString * _qcstring_signal = 0;
static QCString * _qcstring_senderObj = 0;
static QCString * _qcstring_sender = 0;
	return (jboolean) ((DCOPObjectJBridge*) QtSupport::getQt(env, obj))->disconnectDCOPSignal((QCString&) * (QCString *) QtSupport::toQCString(env, sender, &_qcstring_sender), (QCString&) * (QCString *) QtSupport::toQCString(env, senderObj, &_qcstring_senderObj), (QCString&) * (QCString *) QtSupport::toQCString(env, signal, &_qcstring_signal), (QCString&) * (QCString *) QtSupport::toQCString(env, slot, &_qcstring_slot));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DCOPObject_hasObject(JNIEnv *env, jclass obj, jstring objId)
{
static QCString * _qcstring_objId = 0;
	return (jboolean) DCOPObjectJBridge::hasObject((QCString&) * (QCString *) QtSupport::toQCString(env, objId, &_qcstring_objId));
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DCOPObject_find(JNIEnv *env, jclass obj, jstring objId)
{
static QCString * _qcstring_objId = 0;
	return (jobject) QtSupport::objectForQtKey(env, (void *)DCOPObjectJBridge::find((QCString&) * (QCString *) QtSupport::toQCString(env, objId, &_qcstring_objId)), "org.kde.koala.DCOPObjectInterface");
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_DCOPObject_objectName(JNIEnv *env, jclass obj, jobject _obj)
{
	QCString  _qcstring;
	_qcstring = DCOPObjectJBridge::objectName((QObject*) QtSupport::getQt(env, _obj));
	return QtSupport::fromQCString(env, &_qcstring);
}

