/***************************************************************************
                            KScriptManager.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_KScriptManager.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KScriptManager.h>
#include <qtobjc/QVariant.h>


@implementation  KScriptManager


- initWithObject: (QObject *)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KScriptManager((qt_QObject *) [parent qt], (char*) [name cString])];
		[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_KScriptManager((kde_KScriptManager *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (BOOL) addScript: (NSString *)scriptDesktopFile
{
static qt_QString * _qstring_scriptDesktopFile = 0L;
	return (BOOL) kde_KScriptManager_addScript((kde_KScriptManager *)[self qt], (qt_QString *) [scriptDesktopFile toQString: &_qstring_scriptDesktopFile]);
}

- (BOOL) removeScript: (NSString *)scriptName
{
static qt_QString * _qstring_scriptName = 0L;
	return (BOOL) kde_KScriptManager_removeScript((kde_KScriptManager *)[self qt], (qt_QString *) [scriptName toQString: &_qstring_scriptName]);
}

- (NSArray *) scripts
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KScriptManager_scripts((kde_KScriptManager *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- clear
{
	kde_KScriptManager_clear((kde_KScriptManager *)[self qt]);
	return self;
}

- error: (NSString *)msg
{
static qt_QString * _qstring_msg = 0L;
	kde_KScriptManager_error((kde_KScriptManager *)[self qt], (qt_QString *) [msg toQString: &_qstring_msg]);
	return self;
}

- warning: (NSString *)msg
{
static qt_QString * _qstring_msg = 0L;
	kde_KScriptManager_warning((kde_KScriptManager *)[self qt], (qt_QString *) [msg toQString: &_qstring_msg]);
	return self;
}

- output: (NSString *)msg
{
static qt_QString * _qstring_msg = 0L;
	kde_KScriptManager_output((kde_KScriptManager *)[self qt], (qt_QString *) [msg toQString: &_qstring_msg]);
	return self;
}

- progress: (int)percent
{
	kde_KScriptManager_progress((kde_KScriptManager *)[self qt], (int)percent);
	return self;
}

- done: (int)result returned: (QVariant *)returned
{
	kde_KScriptManager_done((kde_KScriptManager *)[self qt], (int)result, (qt_QVariant *) [returned qt]);
	return self;
}

- runScript: (NSString *)scriptName context: (QObject *)context arg: (QVariant *)arg
{
static qt_QString * _qstring_scriptName = 0L;
	kde_KScriptManager_runScript((kde_KScriptManager *)[self qt], (qt_QString *) [scriptName toQString: &_qstring_scriptName], (qt_QObject *) [context qt], (qt_QVariant *) [arg qt]);
	return self;
}

- runScript: (NSString *)scriptName 
{
static qt_QString * _qstring_scriptName = 0L;
	kde_KScriptManager_runScript((kde_KScriptManager *)[self qt], (qt_QString *) [scriptName toQString: &_qstring_scriptName], 0, 0);
	return self;
}

@end
