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

@implementation  SshProcess


- initWithText: (NSString *)host user: (NSString *)user command: (NSString *)command
{
static qt_QCString * _qcstring_command = 0L;
static qt_QCString * _qcstring_user = 0L;
static qt_QCString * _qcstring_host = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_SshProcess((qt_QCString*) [host toQCString: &_qcstring_host], (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_SshProcess(0, 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_SshProcess((kde_SshProcess *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

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

- setStub: (NSString *)stub
{
static qt_QCString * _qcstring_stub = 0L;
	kde_SshProcess_setStub((kde_SshProcess *)[self qt], (qt_QCString*) [stub toQCString: &_qcstring_stub]);
	return self;
}

- (int) checkNeedPassword
{
	return (int) kde_SshProcess_checkNeedPassword((kde_SshProcess *)[self qt]);
}

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

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

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

- (NSString *) prompt
{
static qt_QCString * _qcstring = 0L;
	_qcstring = kde_SshProcess_prompt((kde_SshProcess *)[self qt]);
	return [NSString fromQCString: _qcstring];
}

- (NSString *) error
{
static qt_QCString * _qcstring = 0L;
	_qcstring = kde_SshProcess_error((kde_SshProcess *)[self qt]);
	return [NSString fromQCString: _qcstring];
}

- (NSString *) display
{
static qt_QCString * _qcstring = 0L;
	_qcstring = kde_SshProcess_display((kde_SshProcess *)[self qt]);
	return [NSString fromQCString: _qcstring];
}

- (NSString *) displayAuth
{
static qt_QCString * _qcstring = 0L;
	_qcstring = kde_SshProcess_displayAuth((kde_SshProcess *)[self qt]);
	return [NSString fromQCString: _qcstring];
}

- (NSString *) dcopServer
{
static qt_QCString * _qcstring = 0L;
	_qcstring = kde_SshProcess_dcopServer((kde_SshProcess *)[self qt]);
	return [NSString fromQCString: _qcstring];
}

+ (int) SshNotFound
{
	return (int) SSHPROCESS_SshNotFound;
}

+ (int) SshNeedsPassword
{
	return (int) SSHPROCESS_SshNeedsPassword;
}

+ (int) SshIncorrectPassword
{
	return (int) SSHPROCESS_SshIncorrectPassword;
}

@end
