/***************************************************************************
                            KJavaAppletServer.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <kdec/kde_KJavaAppletServer.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KJavaAppletServer.h>
#include <kdeobjc/KJavaAppletContext.h>
#include <kdeobjc/KJavaProcess.h>
#include <qtobjc/QByteArray.h>


@implementation  KJavaAppletServer


- init
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KJavaAppletServer()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parent] == nil) {
			kde_del_KJavaAppletServer((kde_KJavaAppletServer *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- createContext: (int)contextId context: (KJavaAppletContext*)context
{
	kde_KJavaAppletServer_createContext((kde_KJavaAppletServer *)[self qt], (int)contextId, (kde_KJavaAppletContext*) [context qt]);
	return self;
}

- destroyContext: (int)contextId
{
	kde_KJavaAppletServer_destroyContext((kde_KJavaAppletServer *)[self qt], (int)contextId);
	return self;
}

- initApplet: (int)contextId appletId: (int)appletId
{
	kde_KJavaAppletServer_initApplet((kde_KJavaAppletServer *)[self qt], (int)contextId, (int)appletId);
	return self;
}

- destroyApplet: (int)contextId appletId: (int)appletId
{
	kde_KJavaAppletServer_destroyApplet((kde_KJavaAppletServer *)[self qt], (int)contextId, (int)appletId);
	return self;
}

- startApplet: (int)contextId appletId: (int)appletId
{
	kde_KJavaAppletServer_startApplet((kde_KJavaAppletServer *)[self qt], (int)contextId, (int)appletId);
	return self;
}

- stopApplet: (int)contextId appletId: (int)appletId
{
	kde_KJavaAppletServer_stopApplet((kde_KJavaAppletServer *)[self qt], (int)contextId, (int)appletId);
	return self;
}

- sendURLData: (NSString *)loaderID url: (NSString *)url data: (QByteArray*)data
{
static qt_QString * _qstring_url = 0L;
static qt_QString * _qstring_loaderID = 0L;
	kde_KJavaAppletServer_sendURLData((kde_KJavaAppletServer *)[self qt], (qt_QString *) [loaderID toQString: &_qstring_loaderID], (qt_QString *) [url toQString: &_qstring_url], (qt_QByteArray*) [data qt]);
	return self;
}

- quit
{
	kde_KJavaAppletServer_quit((kde_KJavaAppletServer *)[self qt]);
	return self;
}

- (NSString *) appletLabel
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KJavaAppletServer_appletLabel((kde_KJavaAppletServer *)[self qt]);
	return [NSString fromQString: _qstring];
}

+ (KJavaAppletServer*) allocateJavaServer
{
	return (KJavaAppletServer*) [QtSupport objectForQtKey: kde_KJavaAppletServer_allocateJavaServer() withClass: [KJavaAppletServer class] allocatedInObjcWorld: YES];
}

+ freeJavaServer
{
	kde_KJavaAppletServer_freeJavaServer();
	return self;
}

+ (NSString *) getAppletLabel
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KJavaAppletServer_getAppletLabel();
	return [NSString fromQString: _qstring];
}

- setupJava: (KJavaProcess*)p
{
	kde_KJavaAppletServer_setupJava((kde_KJavaAppletServer *)[self qt], (kde_KJavaProcess*) [p qt]);
	return self;
}

- slotJavaRequest: (QByteArray*)qb
{
	kde_KJavaAppletServer_slotJavaRequest((kde_KJavaAppletServer *)[self qt], (qt_QByteArray*) [qb qt]);
	return self;
}

- checkShutdown
{
	kde_KJavaAppletServer_checkShutdown((kde_KJavaAppletServer *)[self qt]);
	return self;
}

@end
