/***************************************************************************
                            KMimeType.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_KMimeType.h>
#include <kdec/kde_KIcon.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KMimeType.h>
#include <qtobjc/QByteArray.h>

#include <kdeobjc/KDesktopFile.h>
#include <kdeobjc/KURL.h>
#include <qtobjc/QDataStream.h>


@implementation  KMimeType


- initWithText: (NSString *)_fullpath _type: (NSString *)_type _icon: (NSString *)_icon _comment: (NSString *)_comment _patterns: (NSArray *)_patterns
{
static qt_QStringList * _qlist__patterns = 0L;
static qt_QString * _qstring__comment = 0L;
static qt_QString * _qstring__icon = 0L;
static qt_QString * _qstring__type = 0L;
static qt_QString * _qstring__fullpath = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KMimeType((qt_QString *) [_fullpath toQString: &_qstring__fullpath], (qt_QString *) [_type toQString: &_qstring__type], (qt_QString *) [_icon toQString: &_qstring__icon], (qt_QString *) [_comment toQString: &_qstring__comment], (qt_QStringList*) [_patterns toQStringList: (void *)&_qlist__patterns])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)_fullpath
{
static qt_QString * _qstring__fullpath = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KMimeType1((qt_QString *) [_fullpath toQString: &_qstring__fullpath])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDesktopFile: (KDesktopFile*)config
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KMimeType2((kde_KDesktopFile*) [config qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDataStream: (QDataStream *)_str offset: (int)offset
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KMimeType3((qt_QDataStream *) [_str qt], (int)offset)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- (NSString *) icon: (NSString *)arg1 bool: (BOOL)arg2
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qstring = kde_KMimeType_icon((kde_KMimeType *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (int)arg2);
	return [NSString fromQString: _qstring];
}

- (NSString *) iconForURL: (KURL*)arg1 bool: (BOOL)arg2
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KMimeType_icon1((kde_KMimeType *)[self qt], (kde_KURL*) [arg1 qt], (int)arg2);
	return [NSString fromQString: _qstring];
}

- (QPixmap*) pixmap: (int)_group _force_size: (int)_force_size _state: (int)_state _path: (NSString *)_path
{
static qt_QString * _qstring__path = 0L;
	return (QPixmap*) [QtSupport objectForQtKey: kde_KMimeType_pixmap((kde_KMimeType *)[self qt], (int)_group, (int)_force_size, (int)_state, (qt_QString*) [_path toQString: &_qstring__path]) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

- (QPixmap*) pixmap: (int)_group 
{
	return (QPixmap*) [QtSupport objectForQtKey: kde_KMimeType_pixmap((kde_KMimeType *)[self qt], (int)_group, 0, 0, 0L) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

- (QPixmap*) pixmap: (KURL*)_url _group: (int)_group _force_size: (int)_force_size _state: (int)_state _path: (NSString *)_path
{
static qt_QString * _qstring__path = 0L;
	return (QPixmap*) [QtSupport objectForQtKey: kde_KMimeType_pixmap1((kde_KMimeType *)[self qt], (kde_KURL*) [_url qt], (int)_group, (int)_force_size, (int)_state, (qt_QString*) [_path toQString: &_qstring__path]) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

- (QPixmap*) pixmap: (KURL*)_url _group: (int)_group 
{
	return (QPixmap*) [QtSupport objectForQtKey: kde_KMimeType_pixmap1((kde_KMimeType *)[self qt], (kde_KURL*) [_url qt], (int)_group, 0, 0, 0L) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

- (NSString *) comment
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KMimeType_comment((kde_KMimeType *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) comment: (NSString *)arg1 bool: (BOOL)arg2
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_arg1 = 0L;
	_qstring = kde_KMimeType_comment1((kde_KMimeType *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1], (int)arg2);
	return [NSString fromQString: _qstring];
}

- (NSString *) commentForURL: (KURL*)arg1 bool: (BOOL)arg2
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KMimeType_comment2((kde_KMimeType *)[self qt], (kde_KURL*) [arg1 qt], (int)arg2);
	return [NSString fromQString: _qstring];
}

- (NSArray *) patterns
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KMimeType_patterns((kde_KMimeType *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- load: (QDataStream *)arg1
{
	kde_KMimeType_load((kde_KMimeType *)[self qt], (qt_QDataStream *) [arg1 qt]);
	return self;
}

- save: (QDataStream *)arg1
{
	kde_KMimeType_save((kde_KMimeType *)[self qt], (qt_QDataStream *) [arg1 qt]);
	return self;
}

- (QVariant*) property: (NSString *)_name
{
static qt_QString * _qstring__name = 0L;
	return (QVariant*) [QtSupport objectForQtKey: kde_KMimeType_property((kde_KMimeType *)[self qt], (qt_QString *) [_name toQString: &_qstring__name]) withClass: [QVariant class] allocatedInObjcWorld: YES];
}

- (NSArray *) propertyNames
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KMimeType_propertyNames((kde_KMimeType *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ (QPixmap*) pixmapForURL: (KURL*)_url _mode: (long)_mode _group: (int)_group _force_size: (int)_force_size _state: (int)_state _path: (NSString *)_path
{
static qt_QString * _qstring__path = 0L;
	return (QPixmap*) [QtSupport objectForQtKey: kde_KMimeType_pixmapForURL((kde_KURL*) [_url qt], (long)_mode, (int)_group, (int)_force_size, (int)_state, (qt_QString*) [_path toQString: &_qstring__path]) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

+ (QPixmap*) pixmapForURL: (KURL*)_url 
{
	return (QPixmap*) [QtSupport objectForQtKey: kde_KMimeType_pixmapForURL((kde_KURL*) [_url qt], 0, KICON_Desktop, 0, 0, 0L) withClass: [QPixmap class] allocatedInObjcWorld: YES];
}

+ (NSString *) iconForURL: (KURL*)_url _mode: (long)_mode
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KMimeType_iconForURL((kde_KURL*) [_url qt], (long)_mode);
	return [NSString fromQString: _qstring];
}

+ (NSString *) favIconForURL: (KURL*)url
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KMimeType_favIconForURL((kde_KURL*) [url qt]);
	return [NSString fromQString: _qstring];
}

+ (void*) mimeType: (NSString *)_name
{
static qt_QString * _qstring__name = 0L;
	return (void*) kde_KMimeType_mimeType((qt_QString *) [_name toQString: &_qstring__name]);
}

+ (void*) findByURL: (KURL*)_url _mode: (long)_mode _is_local_file: (BOOL)_is_local_file _fast_mode: (BOOL)_fast_mode
{
	return (void*) kde_KMimeType_findByURL((kde_KURL*) [_url qt], (long)_mode, (int)_is_local_file, (int)_fast_mode);
}

+ (void*) findByURL: (KURL*)_url 
{
	return (void*) kde_KMimeType_findByURL((kde_KURL*) [_url qt], 0, 0, 0);
}

+ (void*) findByPath: (NSString *)path mode: (long)mode fast_mode: (BOOL)fast_mode
{
static qt_QString * _qstring_path = 0L;
	return (void*) kde_KMimeType_findByPath((qt_QString *) [path toQString: &_qstring_path], (long)mode, (int)fast_mode);
}

+ (void*) findByPath: (NSString *)path 
{
static qt_QString * _qstring_path = 0L;
	return (void*) kde_KMimeType_findByPath((qt_QString *) [path toQString: &_qstring_path], 0, 0);
}

+ (void*) findByContent: (QByteArray*)data accuracy: (int*)accuracy
{
	return (void*) kde_KMimeType_findByContent((qt_QByteArray*) [data qt], (int*)accuracy);
}

+ (void*) findByContent: (QByteArray*)data 
{
	return (void*) kde_KMimeType_findByContent((qt_QByteArray*) [data qt], 0);
}

+ (void*) findByFileContent: (NSString *)fileName accuracy: (int*)accuracy
{
static qt_QString * _qstring_fileName = 0L;
	return (void*) kde_KMimeType_findByFileContent((qt_QString *) [fileName toQString: &_qstring_fileName], (int*)accuracy);
}

+ (void*) findByFileContent: (NSString *)fileName 
{
static qt_QString * _qstring_fileName = 0L;
	return (void*) kde_KMimeType_findByFileContent((qt_QString *) [fileName toQString: &_qstring_fileName], 0);
}

//+ (List) allMimeTypes
//{
//	return (List) [QtSupport objectForQtKey: kde_KMimeType_allMimeTypes() withClass: [ class] allocatedInObjcWorld: YES];
//}

+ (NSString *) defaultMimeType
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KMimeType_defaultMimeType();
	return [NSString fromQString: _qstring];
}

- loadInternal: (QDataStream *)arg1
{
	kde_KMimeType_loadInternal((kde_KMimeType *)[self qt], (qt_QDataStream *) [arg1 qt]);
	return self;
}

- init: (KDesktopFile*)arg1
{
	kde_KMimeType_init((kde_KMimeType *)[self qt], (kde_KDesktopFile*) [arg1 qt]);
	return self;
}

//+ errorMissingMimeType: (NSString *)_type
//{
//static qt_QString * _qstring__type = 0L;
//	kde_KMimeType_errorMissingMimeType((qt_QString *) [_type toQString: &_qstring__type]);
//	return self;
//}

//+ buildDefaultType
//{
//	kde_KMimeType_buildDefaultType();
//	return self;
//}

//+ checkEssentialMimeTypes
//{
//	kde_KMimeType_checkEssentialMimeTypes();
//	return self;
//}

@end
