/***************************************************************************
                            KTar.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_KTar.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KTar.h>
#include <qtobjc/QIODevice.h>


@implementation  KTar


- initWithText: (NSString *)filename mimetype: (NSString *)mimetype
{
static qt_QString * _qstring_mimetype = 0L;
static qt_QString * _qstring_filename = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KTar((qt_QString *) [filename toQString: &_qstring_filename], (qt_QString *) [mimetype toQString: &_qstring_mimetype])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)filename 
{
static qt_QString * _qstring_filename = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KTar((qt_QString *) [filename toQString: &_qstring_filename], qt_QString_null())];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithIODevice: (QIODevice *)dev
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KTar1((qt_QIODevice *) [dev qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- (NSString *) fileName
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KTar_fileName((kde_KTar *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setOrigFileName: (NSString *)fileName
{
static qt_QCString * _qcstring_fileName = 0L;
	kde_KTar_setOrigFileName((kde_KTar *)[self qt], (qt_QCString*) [fileName toQCString: &_qcstring_fileName]);
	return self;
}

- (BOOL) writeDir: (NSString *)name user: (NSString *)user group: (NSString *)group
{
static qt_QString * _qstring_group = 0L;
static qt_QString * _qstring_user = 0L;
static qt_QString * _qstring_name = 0L;
	return (BOOL) kde_KTar_writeDir((kde_KTar *)[self qt], (qt_QString *) [name toQString: &_qstring_name], (qt_QString *) [user toQString: &_qstring_user], (qt_QString *) [group toQString: &_qstring_group]);
}

- (BOOL) prepareWriting: (NSString *)name user: (NSString *)user group: (NSString *)group size: (unsigned int)size
{
static qt_QString * _qstring_group = 0L;
static qt_QString * _qstring_user = 0L;
static qt_QString * _qstring_name = 0L;
	return (BOOL) kde_KTar_prepareWriting((kde_KTar *)[self qt], (qt_QString *) [name toQString: &_qstring_name], (qt_QString *) [user toQString: &_qstring_user], (qt_QString *) [group toQString: &_qstring_group], (unsigned int)size);
}

- (BOOL) doneWriting: (unsigned int)size
{
	return (BOOL) kde_KTar_doneWriting((kde_KTar *)[self qt], (unsigned int)size);
}

- (BOOL) openArchive: (int)mode
{
	return (BOOL) kde_KTar_openArchive((kde_KTar *)[self qt], (int)mode);
}

- (BOOL) closeArchive
{
	return (BOOL) kde_KTar_closeArchive((kde_KTar *)[self qt]);
}

@end
