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

#include <qtjava/QtSupport.h>
#include <kdejava/DCOPStub.h>

class DCOPStubJBridge : public DCOPStub
{
public:
	DCOPStubJBridge(const QCString& app, const QCString& obj) : DCOPStub(app, obj) {}
	DCOPStubJBridge(DCOPClient* client, const QCString& app, const QCString& obj) : DCOPStub(client, app, obj) {}
	~DCOPStubJBridge() {QtSupport::qtKeyDeleted(this);}
	void protected_setStatus(Status _status) {
		DCOPStub::setStatus(_status);
		return;
	}
	void protected_callFailed() {
		DCOPStub::callFailed();
		return;
	}
	DCOPClient*  protected_dcopClient() {
		return (DCOPClient* ) DCOPStub::dcopClient();
	}
};


JNIEXPORT void JNICALL
Java_org_kde_koala_DCOPStub_newDCOPStub__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring app, jstring _obj)
{
static QCString * _qcstring_obj = 0;
static QCString * _qcstring_app = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new DCOPStubJBridge((QCString&) * (QCString *) QtSupport::toQCString(env, app, &_qcstring_app), (QCString&) * (QCString *) QtSupport::toQCString(env, _obj, &_qcstring_obj)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DCOPStub_newDCOPStub__Lorg_kde_koala_DCOPClient_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject client, jstring app, jstring _obj)
{
static QCString * _qcstring_obj = 0;
static QCString * _qcstring_app = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new DCOPStubJBridge((DCOPClient*) QtSupport::getQt(env, client), (QCString&) * (QCString *) QtSupport::toQCString(env, app, &_qcstring_app), (QCString&) * (QCString *) QtSupport::toQCString(env, _obj, &_qcstring_obj)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

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

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

JNIEXPORT jint JNICALL
Java_org_kde_koala_DCOPStub_status(JNIEnv *env, jobject obj)
{
	return (jint) ((DCOPStubJBridge*) QtSupport::getQt(env, obj))->status();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_DCOPStub_ok(JNIEnv *env, jobject obj)
{
	return (jboolean) ((DCOPStubJBridge*) QtSupport::getQt(env, obj))->ok();
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DCOPStub_setStatus(JNIEnv *env, jobject obj, jint _status)
{
	((DCOPStubJBridge*) QtSupport::getQt(env, obj))->protected_setStatus((DCOPStub::Status) _status);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_DCOPStub_callFailed(JNIEnv *env, jobject obj)
{
	((DCOPStubJBridge*) QtSupport::getQt(env, obj))->protected_callFailed();
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_koala_DCOPStub_dcopClient(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((DCOPStubJBridge*) QtSupport::getQt(env, obj))->protected_dcopClient(), "org.kde.koala.DCOPClient");
}

