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

@implementation  SuProcess


- initWithText: (NSString *)user command: (NSString *)command
{
static qt_QCString * _qcstring_command = 0L;
static qt_QCString * _qcstring_user = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_SuProcess((qt_QCString*) [user toQCString: &_qcstring_user], (qt_QCString*) [command toQCString: &_qcstring_command])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

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

- (int) exec: (NSString *)password check: (int)check
{
	return (int) kde_SuProcess_exec((kde_SuProcess *)[self qt], (char*) [password cString], (int)check);
}

- (int) exec: (NSString *)password 
{
	return (int) kde_SuProcess_exec((kde_SuProcess *)[self qt], (char*) [password cString], 0);
}

- (int) checkInstall: (NSString *)password
{
	return (int) kde_SuProcess_checkInstall((kde_SuProcess *)[self qt], (char*) [password cString]);
}

- (int) checkNeedPassword
{
	return (int) kde_SuProcess_checkNeedPassword((kde_SuProcess *)[self qt]);
}

+ (int) SuNotFound
{
	return (int) SUPROCESS_SuNotFound;
}

+ (int) SuNotAllowed
{
	return (int) SUPROCESS_SuNotAllowed;
}

+ (int) SuIncorrectPassword
{
	return (int) SUPROCESS_SuIncorrectPassword;
}

@end
