/***************************************************************************
                            KProcIO.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_KProcIO.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KProcIO.h>
#include <qtobjc/QTextCodec.h>


@implementation  KProcIO


- initWithTextCodec: (QTextCodec*)codec
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KProcIO((qt_QTextCodec*) [codec qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- (BOOL) start: (int)runmode includeStderr: (BOOL)includeStderr
{
	return (BOOL) kde_KProcIO_start((kde_KProcIO *)[self qt], (int)runmode, (int)includeStderr);
}

- (BOOL) start
{
	return (BOOL) kde_KProcIO_start((kde_KProcIO *)[self qt], [KProcIO NotifyOnExit], 0);
}

- (BOOL) writeStdin: (NSString *)line AppendNewLine: (BOOL)AppendNewLine
{
static qt_QString * _qstring_line = 0L;
	return (BOOL) kde_KProcIO_writeStdin((kde_KProcIO *)[self qt], (qt_QString *) [line toQString: &_qstring_line], (int)AppendNewLine);
}

- (BOOL) writeStdin: (NSString *)line 
{
static qt_QString * _qstring_line = 0L;
	return (BOOL) kde_KProcIO_writeStdin((kde_KProcIO *)[self qt], (qt_QString *) [line toQString: &_qstring_line], 1);
}

- (BOOL) fputs: (NSString *)line AppendNewLine: (BOOL)AppendNewLine
{
static qt_QString * _qstring_line = 0L;
	return (BOOL) kde_KProcIO_fputs((kde_KProcIO *)[self qt], (qt_QString *) [line toQString: &_qstring_line], (int)AppendNewLine);
}

- (BOOL) fputs: (NSString *)line 
{
static qt_QString * _qstring_line = 0L;
	return (BOOL) kde_KProcIO_fputs((kde_KProcIO *)[self qt], (qt_QString *) [line toQString: &_qstring_line], 1);
}

- (int) readln: (NSString *)line autoAck: (BOOL)autoAck partial: (int*)partial
{
static qt_QString * _qstring_line = 0L;
	return (int) kde_KProcIO_readln((kde_KProcIO *)[self qt], (qt_QString *) [line toQString: &_qstring_line], (int)autoAck, (int*)partial);
}

- (int) readln: (NSString *)line 
{
static qt_QString * _qstring_line = 0L;
	return (int) kde_KProcIO_readln((kde_KProcIO *)[self qt], (qt_QString *) [line toQString: &_qstring_line], 1, 0);
}

- (int) fgets: (NSString *)line autoAck: (BOOL)autoAck
{
static qt_QString * _qstring_line = 0L;
	return (int) kde_KProcIO_fgets((kde_KProcIO *)[self qt], (qt_QString *) [line toQString: &_qstring_line], (int)autoAck);
}

- (int) fgets: (NSString *)line 
{
static qt_QString * _qstring_line = 0L;
	return (int) kde_KProcIO_fgets((kde_KProcIO *)[self qt], (qt_QString *) [line toQString: &_qstring_line], 0);
}

- resetAll
{
	kde_KProcIO_resetAll((kde_KProcIO *)[self qt]);
	return self;
}

- ackRead
{
	kde_KProcIO_ackRead((kde_KProcIO *)[self qt]);
	return self;
}

- enableReadSignals: (BOOL)enable
{
	kde_KProcIO_enableReadSignals((kde_KProcIO *)[self qt], (int)enable);
	return self;
}

- controlledEmission
{
	kde_KProcIO_controlledEmission((kde_KProcIO *)[self qt]);
	return self;
}

- received: (KProcess*)proc buffer: (NSString *)buffer buflen: (int)buflen
{
	kde_KProcIO_received((kde_KProcIO *)[self qt], (kde_KProcess*) [proc qt], (char*) [buffer cString], (int)buflen);
	return self;
}

- sent: (KProcess*)arg1
{
	kde_KProcIO_sent((kde_KProcIO *)[self qt], (kde_KProcess*) [arg1 qt]);
	return self;
}

@end
