/***************************************************************************
                            QUrlInfo.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 12:08:37 2001, 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 <qtc/qt_QDateTime.h>
#include <qtc/qt_QUrlInfo.h>

#include <qtobjc/QUrlInfo.h>
#include <qtobjc/QUrl.h>
#include <qtobjc/QUrlOperator.h>


@implementation  QUrlInfo

- (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: qt_new_QUrlInfo()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithUrlOperator: (QUrlOperator*)path file: (NSString *)file
{
static qt_QString * _qstring_file = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QUrlInfo1((qt_QUrlOperator*) [path qt], (qt_QString *) [file toQString: &_qstring_file])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- copyWithZone: (NSZone *) zone
{
	QUrlInfo * aCopy;
	aCopy = [[(QUrlInfo *)[[self class] allocWithZone: zone] setQt: qt_new_QUrlInfo2([self qt])] init];
	[aCopy setAllocatedInObjcWorld: YES];
	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
	return aCopy;
}

- initWithText: (NSString *)name permissions: (int)permissions owner: (NSString *)owner group: (NSString *)group size: (unsigned int)size lastModified: (NSDate *)lastModified lastRead: (NSDate *)lastRead isDir: (BOOL)isDir isFile: (BOOL)isFile isSymLink: (BOOL)isSymLink isWritable: (BOOL)isWritable isReadable: (BOOL)isReadable isExecutable: (BOOL)isExecutable
{
static qt_QDateTime * _qdate_lastRead = 0L;
static qt_QDateTime * _qdate_lastModified = 0L;
static qt_QString * _qstring_group = 0L;
static qt_QString * _qstring_owner = 0L;
static qt_QString * _qstring_name = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QUrlInfo3((qt_QString *) [name toQString: &_qstring_name], (int)permissions, (qt_QString *) [owner toQString: &_qstring_owner], (qt_QString *) [group toQString: &_qstring_group], (unsigned int)size, (qt_QDateTime *) [lastModified toQDateTime: (qt_QDateTime **)&_qdate_lastModified], (qt_QDateTime *) [lastRead toQDateTime: (qt_QDateTime **)&_qdate_lastRead], (int)isDir, (int)isFile, (int)isSymLink, (int)isWritable, (int)isReadable, (int)isExecutable)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithUrl: (QUrl*)url permissions: (int)permissions owner: (NSString *)owner group: (NSString *)group size: (unsigned int)size lastModified: (NSDate *)lastModified lastRead: (NSDate *)lastRead isDir: (BOOL)isDir isFile: (BOOL)isFile isSymLink: (BOOL)isSymLink isWritable: (BOOL)isWritable isReadable: (BOOL)isReadable isExecutable: (BOOL)isExecutable
{
static qt_QDateTime * _qdate_lastRead = 0L;
static qt_QDateTime * _qdate_lastModified = 0L;
static qt_QString * _qstring_group = 0L;
static qt_QString * _qstring_owner = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QUrlInfo4((qt_QUrl*) [url qt], (int)permissions, (qt_QString *) [owner toQString: &_qstring_owner], (qt_QString *) [group toQString: &_qstring_group], (unsigned int)size, (qt_QDateTime *) [lastModified toQDateTime: (qt_QDateTime **)&_qdate_lastModified], (qt_QDateTime *) [lastRead toQDateTime: (qt_QDateTime **)&_qdate_lastRead], (int)isDir, (int)isFile, (int)isSymLink, (int)isWritable, (int)isReadable, (int)isExecutable)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- setName: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	qt_QUrlInfo_setName((qt_QUrlInfo *)[self qt], (qt_QString *) [name toQString: &_qstring_name]);
	return self;
}

- setDir: (BOOL)b
{
	qt_QUrlInfo_setDir((qt_QUrlInfo *)[self qt], (int)b);
	return self;
}

- setFile: (BOOL)b
{
	qt_QUrlInfo_setFile((qt_QUrlInfo *)[self qt], (int)b);
	return self;
}

- setSymLink: (BOOL)b
{
	qt_QUrlInfo_setSymLink((qt_QUrlInfo *)[self qt], (int)b);
	return self;
}

- setOwner: (NSString *)s
{
static qt_QString * _qstring_s = 0L;
	qt_QUrlInfo_setOwner((qt_QUrlInfo *)[self qt], (qt_QString *) [s toQString: &_qstring_s]);
	return self;
}

- setGroup: (NSString *)s
{
static qt_QString * _qstring_s = 0L;
	qt_QUrlInfo_setGroup((qt_QUrlInfo *)[self qt], (qt_QString *) [s toQString: &_qstring_s]);
	return self;
}

- setSize: (unsigned int)s
{
	qt_QUrlInfo_setSize((qt_QUrlInfo *)[self qt], (unsigned int)s);
	return self;
}

- setWritable: (BOOL)b
{
	qt_QUrlInfo_setWritable((qt_QUrlInfo *)[self qt], (int)b);
	return self;
}

- setReadable: (BOOL)b
{
	qt_QUrlInfo_setReadable((qt_QUrlInfo *)[self qt], (int)b);
	return self;
}

- setPermissions: (int)p
{
	qt_QUrlInfo_setPermissions((qt_QUrlInfo *)[self qt], (int)p);
	return self;
}

- setLastModified: (NSDate *)dt
{
static qt_QDateTime * _qdate_dt = 0L;
	qt_QUrlInfo_setLastModified((qt_QUrlInfo *)[self qt], (qt_QDateTime *) [dt toQDateTime: (qt_QDateTime **)&_qdate_dt]);
	return self;
}

- (BOOL) isValid
{
	return (BOOL) qt_QUrlInfo_isValid((qt_QUrlInfo *)[self qt]);
}

- (NSString *) name
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QUrlInfo_name((qt_QUrlInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (int) permissions
{
	return (int) qt_QUrlInfo_permissions((qt_QUrlInfo *)[self qt]);
}

- (NSString *) owner
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QUrlInfo_owner((qt_QUrlInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) group
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QUrlInfo_group((qt_QUrlInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (unsigned int) size
{
	return (unsigned int) qt_QUrlInfo_size((qt_QUrlInfo *)[self qt]);
}

- (NSDate *) lastModified
{
static qt_QDateTime * _qdate = 0L;
	_qdate = qt_QUrlInfo_lastModified((qt_QUrlInfo *)[self qt]);
	return (NSDate *) [(NSDate *) [NSDate alloc] initWithQDateTime: _qdate];
}

- (NSDate *) lastRead
{
static qt_QDateTime * _qdate = 0L;
	_qdate = qt_QUrlInfo_lastRead((qt_QUrlInfo *)[self qt]);
	return (NSDate *) [(NSDate *) [NSDate alloc] initWithQDateTime: _qdate];
}

- (BOOL) isDir
{
	return (BOOL) qt_QUrlInfo_isDir((qt_QUrlInfo *)[self qt]);
}

- (BOOL) isFile
{
	return (BOOL) qt_QUrlInfo_isFile((qt_QUrlInfo *)[self qt]);
}

- (BOOL) isSymLink
{
	return (BOOL) qt_QUrlInfo_isSymLink((qt_QUrlInfo *)[self qt]);
}

- (BOOL) isWritable
{
	return (BOOL) qt_QUrlInfo_isWritable((qt_QUrlInfo *)[self qt]);
}

- (BOOL) isReadable
{
	return (BOOL) qt_QUrlInfo_isReadable((qt_QUrlInfo *)[self qt]);
}

- (BOOL) isExecutable
{
	return (BOOL) qt_QUrlInfo_isExecutable((qt_QUrlInfo *)[self qt]);
}

+ (BOOL) greaterThan: (QUrlInfo*)i1 i2: (QUrlInfo*)i2 sortBy: (int)sortBy
{
	return (BOOL) qt_QUrlInfo_greaterThan((qt_QUrlInfo*) [i1 qt], (qt_QUrlInfo*) [i2 qt], (int)sortBy);
}

+ (BOOL) lessThan: (QUrlInfo*)i1 i2: (QUrlInfo*)i2 sortBy: (int)sortBy
{
	return (BOOL) qt_QUrlInfo_lessThan((qt_QUrlInfo*) [i1 qt], (qt_QUrlInfo*) [i2 qt], (int)sortBy);
}

+ (BOOL) equal: (QUrlInfo*)i1 i2: (QUrlInfo*)i2 sortBy: (int)sortBy
{
	return (BOOL) qt_QUrlInfo_equal((qt_QUrlInfo*) [i1 qt], (qt_QUrlInfo*) [i2 qt], (int)sortBy);
}

@end
