/***************************************************************************
                            KStandardDirs.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_KStandardDirs.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KStandardDirs.h>
#include <kdeobjc/KConfig.h>


@implementation  KStandardDirs

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

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

- addPrefix: (NSString *)dir
{
static qt_QString * _qstring_dir = 0L;
	kde_KStandardDirs_addPrefix((kde_KStandardDirs *)[self qt], (qt_QString *) [dir toQString: &_qstring_dir]);
	return self;
}

- (BOOL) addResourceType: (NSString *)type relativename: (NSString *)relativename
{
static qt_QString * _qstring_relativename = 0L;
	return (BOOL) kde_KStandardDirs_addResourceType((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [relativename toQString: &_qstring_relativename]);
}

- (BOOL) addResourceDir: (NSString *)type absdir: (NSString *)absdir
{
static qt_QString * _qstring_absdir = 0L;
	return (BOOL) kde_KStandardDirs_addResourceDir((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [absdir toQString: &_qstring_absdir]);
}

- (NSString *) findResource: (NSString *)type filename: (NSString *)filename
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_filename = 0L;
	_qstring = kde_KStandardDirs_findResource((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [filename toQString: &_qstring_filename]);
	return [NSString fromQString: _qstring];
}

- (unsigned int) calcResourceHash: (NSString *)type filename: (NSString *)filename deep: (BOOL)deep
{
static qt_QString * _qstring_filename = 0L;
	return (unsigned int) kde_KStandardDirs_calcResourceHash((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [filename toQString: &_qstring_filename], (int)deep);
}

- (NSArray *) findDirs: (NSString *)type reldir: (NSString *)reldir
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_reldir = 0L;
	_qlist = kde_KStandardDirs_findDirs((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [reldir toQString: &_qstring_reldir]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSString *) findResourceDir: (NSString *)type filename: (NSString *)filename
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_filename = 0L;
	_qstring = kde_KStandardDirs_findResourceDir((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [filename toQString: &_qstring_filename]);
	return [NSString fromQString: _qstring];
}

- (NSArray *) findAllResources: (NSString *)type filter: (NSString *)filter recursive: (BOOL)recursive uniq: (BOOL)uniq
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_filter = 0L;
	_qlist = kde_KStandardDirs_findAllResources((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [filter toQString: &_qstring_filter], (int)recursive, (int)uniq);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSArray *) findAllResources: (NSString *)type filter: (NSString *)filter recursive: (BOOL)recursive uniq: (BOOL)uniq relPaths: (NSArray *)relPaths
{
static qt_QStringList * _qlist = 0L;
static qt_QStringList * _qlist_relPaths = 0L;
static qt_QString * _qstring_filter = 0L;
	_qlist = kde_KStandardDirs_findAllResources1((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [filter toQString: &_qstring_filter], (int)recursive, (int)uniq, (qt_QStringList*) [relPaths toQStringList: (void *)&_qlist_relPaths]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- addKDEDefaults
{
	kde_KStandardDirs_addKDEDefaults((kde_KStandardDirs *)[self qt]);
	return self;
}

- (BOOL) addCustomized: (KConfig*)config
{
	return (BOOL) kde_KStandardDirs_addCustomized((kde_KStandardDirs *)[self qt], (kde_KConfig*) [config qt]);
}

- (NSArray *) resourceDirs: (NSString *)type
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KStandardDirs_resourceDirs((kde_KStandardDirs *)[self qt], (char*) [type cString]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSArray *) allTypes
{
static qt_QStringList * _qlist = 0L;
	_qlist = kde_KStandardDirs_allTypes((kde_KStandardDirs *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

- (NSString *) saveLocation: (NSString *)type suffix: (NSString *)suffix create: (BOOL)create
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_suffix = 0L;
	_qstring = kde_KStandardDirs_saveLocation((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [suffix toQString: &_qstring_suffix], (int)create);
	return [NSString fromQString: _qstring];
}

- (NSString *) relativeLocation: (NSString *)type absPath: (NSString *)absPath
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_absPath = 0L;
	_qstring = kde_KStandardDirs_relativeLocation((kde_KStandardDirs *)[self qt], (char*) [type cString], (qt_QString *) [absPath toQString: &_qstring_absPath]);
	return [NSString fromQString: _qstring];
}

- (NSString *) kfsstnd_prefixes
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KStandardDirs_kfsstnd_prefixes((kde_KStandardDirs *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) localkdedir
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KStandardDirs_localkdedir((kde_KStandardDirs *)[self qt]);
	return [NSString fromQString: _qstring];
}

+ (NSString *) findExe: (NSString *)appname pathstr: (NSString *)pathstr ignoreExecBit: (BOOL)ignoreExecBit
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_pathstr = 0L;
static qt_QString * _qstring_appname = 0L;
	_qstring = kde_KStandardDirs_findExe((qt_QString *) [appname toQString: &_qstring_appname], (qt_QString *) [pathstr toQString: &_qstring_pathstr], (int)ignoreExecBit);
	return [NSString fromQString: _qstring];
}

+ (int) findAllExe: (NSArray *)list appname: (NSString *)appname pathstr: (NSString *)pathstr ignoreExecBit: (BOOL)ignoreExecBit
{
static qt_QString * _qstring_pathstr = 0L;
static qt_QString * _qstring_appname = 0L;
static qt_QStringList * _qlist_list = 0L;
	return (int) kde_KStandardDirs_findAllExe((qt_QStringList*) [list toQStringList: (void *)&_qlist_list], (qt_QString *) [appname toQString: &_qstring_appname], (qt_QString *) [pathstr toQString: &_qstring_pathstr], (int)ignoreExecBit);
}

+ (int) findAllExe: (NSArray *)list appname: (NSString *)appname 
{
static qt_QString * _qstring_appname = 0L;
static qt_QStringList * _qlist_list = 0L;
	return (int) kde_KStandardDirs_findAllExe((qt_QStringList*) [list toQStringList: (void *)&_qlist_list], (qt_QString *) [appname toQString: &_qstring_appname], qt_QString_null(), 0);
}

+ (BOOL) makeDir: (NSString *)dir mode: (int)mode
{
static qt_QString * _qstring_dir = 0L;
	return (BOOL) kde_KStandardDirs_makeDir((qt_QString *) [dir toQString: &_qstring_dir], (int)mode);
}

+ (BOOL) makeDir: (NSString *)dir 
{
static qt_QString * _qstring_dir = 0L;
	return (BOOL) kde_KStandardDirs_makeDir((qt_QString *) [dir toQString: &_qstring_dir], 0755);
}

+ (NSString *) kde_default: (NSString *)type
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KStandardDirs_kde_default((char*) [type cString]);
	return [NSString fromQString: _qstring];
}

+ (BOOL) exists: (NSString *)fullPath
{
static qt_QString * _qstring_fullPath = 0L;
	return (BOOL) kde_KStandardDirs_exists((qt_QString *) [fullPath toQString: &_qstring_fullPath]);
}

@end
