/***************************************************************************
                            KDEsuClient.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_KDEsuClient.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KDEsuClient.h>

@implementation  KDEsuClient

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


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

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			kde_del_KDEsuClient((kde_KDEsuClient *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

//- (int) exec: (NSString *)command user: (NSString *)user options: (NSString *)options env: (QCStringList*)env
//{
//static qt_QCString * _qcstring_options = 0L;
//static qt_QCString * _qcstring_user = 0L;
//static qt_QCString * _qcstring_command = 0L;
//	return (int) kde_KDEsuClient_exec((kde_KDEsuClient *)[self qt], (qt_QCString*) [command toQCString: &_qcstring_command], (qt_QCString*) [user toQCString: &_qcstring_user], (qt_QCString*) [options toQCString: &_qcstring_options], (QCStringList) env);
//}

//- (int) exec: (NSString *)command user: (NSString *)user
//{
//static qt_QCString * _qcstring_user = 0L;
//static qt_QCString * _qcstring_command = 0L;
//	return (int) kde_KDEsuClient_exec((kde_KDEsuClient *)[self qt], (qt_QCString*) [command toQCString: &_qcstring_command], (qt_QCString*) [user toQCString: &_qcstring_user], 0, qt_new_QCStringList());
//}

- (int) setPass: (NSString *)pass timeout: (int)timeout
{
	return (int) kde_KDEsuClient_setPass((kde_KDEsuClient *)[self qt], (char*) [pass cString], (int)timeout);
}

- (int) setHost: (NSString *)host
{
static qt_QCString * _qcstring_host = 0L;
	return (int) kde_KDEsuClient_setHost((kde_KDEsuClient *)[self qt], (qt_QCString*) [host toQCString: &_qcstring_host]);
}

- (int) setPriority: (int)priority
{
	return (int) kde_KDEsuClient_setPriority((kde_KDEsuClient *)[self qt], (int)priority);
}

- (int) setScheduler: (int)scheduler
{
	return (int) kde_KDEsuClient_setScheduler((kde_KDEsuClient *)[self qt], (int)scheduler);
}

- (int) delCommand: (NSString *)command user: (NSString *)user
{
static qt_QCString * _qcstring_user = 0L;
static qt_QCString * _qcstring_command = 0L;
	return (int) kde_KDEsuClient_delCommand((kde_KDEsuClient *)[self qt], (qt_QCString*) [command toQCString: &_qcstring_command], (qt_QCString*) [user toQCString: &_qcstring_user]);
}

- (int) setVar: (NSString *)key value: (NSString *)value timeout: (int)timeout group: (NSString *)group
{
static qt_QCString * _qcstring_group = 0L;
static qt_QCString * _qcstring_value = 0L;
static qt_QCString * _qcstring_key = 0L;
	return (int) kde_KDEsuClient_setVar((kde_KDEsuClient *)[self qt], (qt_QCString*) [key toQCString: &_qcstring_key], (qt_QCString*) [value toQCString: &_qcstring_value], (int)timeout, (qt_QCString*) [group toQCString: &_qcstring_group]);
}

- (int) setVar: (NSString *)key value: (NSString *)value 
{
static qt_QCString * _qcstring_value = 0L;
static qt_QCString * _qcstring_key = 0L;
	return (int) kde_KDEsuClient_setVar((kde_KDEsuClient *)[self qt], (qt_QCString*) [key toQCString: &_qcstring_key], (qt_QCString*) [value toQCString: &_qcstring_value], 0, 0);
}

- (NSString *) getVar: (NSString *)key
{
static qt_QCString * _qcstring = 0L;
static qt_QCString * _qcstring_key = 0L;
	_qcstring = kde_KDEsuClient_getVar((kde_KDEsuClient *)[self qt], (qt_QCString*) [key toQCString: &_qcstring_key]);
	return [NSString fromQCString: _qcstring];
}

- (BOOL) findGroup: (NSString *)group
{
static qt_QCString * _qcstring_group = 0L;
	return (BOOL) kde_KDEsuClient_findGroup((kde_KDEsuClient *)[self qt], (qt_QCString*) [group toQCString: &_qcstring_group]);
}

- (int) delVar: (NSString *)key
{
static qt_QCString * _qcstring_key = 0L;
	return (int) kde_KDEsuClient_delVar((kde_KDEsuClient *)[self qt], (qt_QCString*) [key toQCString: &_qcstring_key]);
}

- (int) delVars: (NSString *)special_key
{
static qt_QCString * _qcstring_special_key = 0L;
	return (int) kde_KDEsuClient_delVars((kde_KDEsuClient *)[self qt], (qt_QCString*) [special_key toQCString: &_qcstring_special_key]);
}

- (int) delGroup: (NSString *)group
{
static qt_QCString * _qcstring_group = 0L;
	return (int) kde_KDEsuClient_delGroup((kde_KDEsuClient *)[self qt], (qt_QCString*) [group toQCString: &_qcstring_group]);
}

- (int) ping
{
	return (int) kde_KDEsuClient_ping((kde_KDEsuClient *)[self qt]);
}

- (int) stopServer
{
	return (int) kde_KDEsuClient_stopServer((kde_KDEsuClient *)[self qt]);
}

- (int) startServer
{
	return (int) kde_KDEsuClient_startServer((kde_KDEsuClient *)[self qt]);
}

- (BOOL) isServerSGID
{
	return (BOOL) kde_KDEsuClient_isServerSGID((kde_KDEsuClient *)[self qt]);
}

@end
