author | zautrix <zautrix> | 2004-07-07 13:35:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-07 13:35:48 (UTC) |
commit | 5030b0bd32b1e526f28ce0339d4b4854492393ae (patch) (side-by-side diff) | |
tree | 0a4bfd70d51f0d9d791511ca536c463d68df8af9 | |
parent | 56721aac86c9ae5253abac8962474c8d1a7e648a (diff) | |
download | kdepimpi-5030b0bd32b1e526f28ce0339d4b4854492393ae.zip kdepimpi-5030b0bd32b1e526f28ce0339d4b4854492393ae.tar.gz kdepimpi-5030b0bd32b1e526f28ce0339d4b4854492393ae.tar.bz2 |
made plugins finding on desktop
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | microkde/kdecore/klibloader.cpp | 6 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 21 |
3 files changed, 24 insertions, 5 deletions
@@ -1,99 +1,99 @@ ############################################################################# # Makefile for building: kopi-desktop -# Generated by qmake (1.07a) (Qt 3.3.2) on: Wed Jul 7 13:43:59 2004 +# Generated by qmake (1.07a) (Qt 3.3.2) on: Wed Jul 7 14:00:48 2004 # Project: kopi-desktop.pro # Template: subdirs # Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro ############################################################################# MAKEFILE = Makefile QMAKE = qmake DEL_FILE = rm -f CHK_DIR_EXISTS= test -d MKDIR = mkdir -p INSTALL_FILE= INSTALL_DIR = SUBTARGETS = \ sub-libical \ sub-libkcal \ sub-microkde \ sub-libkdepim \ sub-kabc \ sub-korganizer \ sub-kaddressbook \ sub-kabc-plugins-file \ sub-kabc-plugins-dir first: all all: Makefile $(SUBTARGETS) libical/$(MAKEFILE): @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-libical: libical/$(MAKEFILE) FORCE cd libical && $(MAKE) -f $(MAKEFILE) libkcal/$(MAKEFILE): @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-libkcal: libkcal/$(MAKEFILE) FORCE cd libkcal && $(MAKE) -f $(MAKEFILE) microkde/$(MAKEFILE): @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" cd microkde && $(QMAKE) microkde.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-microkde: microkde/$(MAKEFILE) FORCE cd microkde && $(MAKE) -f $(MAKEFILE) libkdepim/$(MAKEFILE): @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" cd libkdepim && $(QMAKE) libkdepim.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-libkdepim: libkdepim/$(MAKEFILE) FORCE cd libkdepim && $(MAKE) -f $(MAKEFILE) kabc/$(MAKEFILE): @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" cd kabc && $(QMAKE) kabc.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-kabc: kabc/$(MAKEFILE) FORCE cd kabc && $(MAKE) -f $(MAKEFILE) korganizer/$(MAKEFILE): @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" cd korganizer && $(QMAKE) korganizer.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-korganizer: korganizer/$(MAKEFILE) FORCE cd korganizer && $(MAKE) -f $(MAKEFILE) kaddressbook/$(MAKEFILE): @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" cd kaddressbook && $(QMAKE) kaddressbook.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE cd kaddressbook && $(MAKE) -f $(MAKEFILE) kabc/plugins/file/$(MAKEFILE): @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" cd kabc/plugins/file && $(QMAKE) file.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) kabc/plugins/dir/$(MAKEFILE): @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" cd kabc/plugins/dir && $(QMAKE) dir.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) Makefile: kopi-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro qmake: qmake_all @$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro all: $(SUBTARGETS) qmake_all: libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp index c091e05..9eee912 100644 --- a/microkde/kdecore/klibloader.cpp +++ b/microkde/kdecore/klibloader.cpp @@ -303,215 +303,221 @@ KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) } class KLibLoaderPrivate { public: QPtrList<KLibWrapPrivate> loaded_stack; QPtrList<KLibWrapPrivate> pending_close; enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; QString errorMessage; }; KLibLoader* KLibLoader::s_self = 0; KLibLoader* KLibLoader::self() { if ( !s_self ) s_self = new KLibLoader; return s_self; } void KLibLoader::cleanUp() { if ( !s_self ) return; delete s_self; s_self = 0; } KLibLoader::KLibLoader( QObject* parent, const char* name ) : QObject( parent, name ) { s_self = this; d = new KLibLoaderPrivate; //US lt_dlinit(); d->unload_mode = KLibLoaderPrivate::UNKNOWN; if (getenv("KDE_NOUNLOAD") != 0) d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; else if (getenv("KDE_DOUNLOAD") != 0) d->unload_mode = KLibLoaderPrivate::UNLOAD; d->loaded_stack.setAutoDelete( true ); } KLibLoader::~KLibLoader() { // kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); for (; it.current(); ++it ) { kdDebug(150) << "The KLibLoader contains the library " << it.current()->name << " (" << it.current()->lib << ")" << endl; d->pending_close.append(it.current()); } close_pending(0); delete d; } //static QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) { QCString libname( name ); // only append ".la" if there is no extension // this allows to load non-libtool libraries as well // (mhk, 20000228) int pos = libname.findRev('/'); if (pos < 0) pos = 0; /*US if (libname.find('.', pos) < 0) { libname += ".la"; } */ //US in the microedition we work only with shared libraries. if (libname.find('.', pos) < 0) { libname += ".so"; } // only look up the file if it is not an absolute filename // (mhk, 20000228) QString libfile; if (libname[0] == '/') libfile = libname; else { //US at this point the libname must exist as real filesname. No expansions will be made later // in findResources. Because of that we prepend the lib prefix here to the name //US I add also the "lib" prefix. I do not how could this could have worked before without it? libname.insert(pos, "lib"); //US libfile = instance->dirs()->findResource( "module", libname ); + //qDebug("libname = %s ",libname.data() ); libfile = KGlobal::dirs()->findResource( "module", libname ); + //qDebug("libfile = %s ",libfile.latin1() ); + if ( libfile.isEmpty() ) { //US libfile = instance->dirs()->findResource( "lib", libname ); libfile = KGlobal::dirs()->findResource( "lib", libname ); + //qDebug("libfile2 = %s ",libfile.latin1() ); #ifndef NDEBUG if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; #endif } if ( libfile.isEmpty() ) { #ifndef NDEBUG kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); qDebug("KLibLoader::library could not find library: %s", libname.data()); #endif } else self()->d->errorMessage = QString::null; } + + //qDebug("return libfile = %s ",libfile.latin1() ); return libfile; } KLibrary* KLibLoader::globalLibrary( const char *name ) { KLibrary *tmp; /*US int olt_dlopen_flag = lt_dlopen_flag; lt_dlopen_flag |= LT_GLOBAL; kdDebug(150) << "Loading the next library global with flag " << lt_dlopen_flag << "." << endl; */ tmp = library(name); /*US lt_dlopen_flag = olt_dlopen_flag; */ return tmp; } KLibrary* KLibLoader::library( const char *name ) { if (!name) return 0; KLibWrapPrivate* wrap = m_libs[name]; if (wrap) { /* Nothing to do to load the library. */ wrap->ref_count++; return wrap->lib; } /* Test if this library was loaded at some time, but got unloaded meanwhile, whithout being dlclose()'ed. */ QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); for (; it.current(); ++it) { if (it.current()->name == name) wrap = it.current(); } if (wrap) { d->pending_close.removeRef(wrap); if (!wrap->lib) { /* This lib only was in loaded_stack, but not in m_libs. */ wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); } wrap->ref_count++; } else { QString libfile = findLibrary( name ); if ( libfile.isEmpty() ) return 0; #ifdef DESKTOP_VERSION QLibrary *qlib = new QLibrary( libfile.latin1() ); #else QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); #endif //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); //US if ( !handle ) if ( !qlib ) { //US const char* errmsg = lt_dlerror(); char* errmsg; sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); qDebug(errmsg); if(errmsg) d->errorMessage = QString::fromLatin1(errmsg); else d->errorMessage = QString::null; kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl; return 0; } else d->errorMessage = QString::null; KLibrary *lib = new KLibrary( name, libfile, qlib ); wrap = new KLibWrapPrivate(lib, qlib); d->loaded_stack.prepend(wrap); } m_libs.insert( name, wrap ); connect( wrap->lib, SIGNAL( destroyed() ), this, SLOT( slotLibraryDestroyed() ) ); return wrap->lib; } QString KLibLoader::lastErrorMessage() const { return d->errorMessage; } diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 7f51d78..e1c78f6 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp @@ -1,140 +1,142 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> Copyright (C) 1999 Stephan Kulow <coolo@kde.org> Copyright (C) 1999 Waldo Bastian <bastian@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> * Version: $Id$ * Generated: Thu Mar 5 16:05:28 EST 1998 */ //US #include "config.h" #include <stdlib.h> #include <assert.h> //US#include <errno.h> //US #ifdef HAVE_SYS_STAT_H //US #include <sys/stat.h> //US #endif //US#include <sys/types.h> //US#include <dirent.h> //US#include <pwd.h> #include <qregexp.h> #include <qasciidict.h> #include <qdict.h> #include <qdir.h> #include <qfileinfo.h> #include <qstring.h> +#include <qapplication.h> + #include <qstringlist.h> #include "kstandarddirs.h" #include "kconfig.h" #include "kdebug.h" //US #include "kinstance.h" #include "kshell.h" //US#include <sys/param.h> //US#include <unistd.h> //US QString KStandardDirs::mAppDir = QString::null; template class QDict<QStringList>; #if 0 #include <qtextedit.h> void ddd( QString op ) { static QTextEdit * dot = 0; if ( ! dot ) dot = new QTextEdit(); dot->show(); dot->append( op ); } #endif class KStandardDirs::KStandardDirsPrivate { public: KStandardDirsPrivate() : restrictionsActive(false), dataRestrictionActive(false) { } bool restrictionsActive; bool dataRestrictionActive; QAsciiDict<bool> restrictions; QStringList xdgdata_prefixes; QStringList xdgconf_prefixes; }; static const char* const types[] = {"html", "icon", "apps", "sound", "data", "locale", "services", "mime", "servicetypes", "config", "exe", "wallpaper", "lib", "pixmap", "templates", "module", "qtplugins", "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; static int tokenize( QStringList& token, const QString& str, const QString& delim ); KStandardDirs::KStandardDirs( ) : addedCustoms(false) { d = new KStandardDirsPrivate; dircache.setAutoDelete(true); relatives.setAutoDelete(true); absolutes.setAutoDelete(true); savelocations.setAutoDelete(true); addKDEDefaults(); } KStandardDirs::~KStandardDirs() { delete d; } bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const { if (!d || !d->restrictionsActive) return false; if (d->restrictions[type]) return true; if (strcmp(type, "data")==0) { applyDataRestrictions(relPath); if (d->dataRestrictionActive) { d->dataRestrictionActive = false; return true; } } return false; } void KStandardDirs::applyDataRestrictions(const QString &relPath) const { QString key; int i = relPath.find('/'); if (i != -1) key = "data_"+relPath.left(i); @@ -256,202 +258,210 @@ QString KStandardDirs::findResource( const char *type, #if 0 kdDebug() << "Find resource: " << type << endl; for (QStringList::ConstIterator pit = prefixes.begin(); pit != prefixes.end(); pit++) { kdDebug() << "Prefix: " << *pit << endl; } #endif QString dir = findResourceDir(type, filename); if (dir.isNull()) return dir; else return dir + filename; } /*US static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) { QCString cFile = QFile::encodeName(file); //US struct stat buff; //US if ((access(cFile, R_OK) == 0) && //US (stat( cFile, &buff ) == 0) && //US (S_ISREG( buff.st_mode ))) QFileInfo pathfnInfo(cFile); if (( pathfnInfo.isReadable() == true ) && ( pathfnInfo.isFile()) ) { //US hash = hash + (Q_UINT32) buff.st_ctime; hash = hash + (Q_UINT32) pathfnInfo.lastModified(); } return hash; } */ /*US Q_UINT32 KStandardDirs::calcResourceHash( const char *type, const QString& filename, bool deep) const { Q_UINT32 hash = 0; if (filename.at(0) == '/') { // absolute dirs are absolute dirs, right? :-/ return updateHash(filename, hash); } if (d && d->restrictionsActive && (strcmp(type, "data")==0)) applyDataRestrictions(filename); QStringList candidates = resourceDirs(type); QString fullPath; for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) { hash = updateHash(*it + filename, hash); if (!deep && hash) return hash; } return hash; } */ QStringList KStandardDirs::findDirs( const char *type, const QString& reldir ) const { QStringList list; checkConfig(); if (d && d->restrictionsActive && (strcmp(type, "data")==0)) applyDataRestrictions(reldir); QStringList candidates = resourceDirs(type); QDir testdir; for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) { testdir.setPath(*it + reldir); if (testdir.exists()) list.append(testdir.absPath() + '/'); } return list; } QString KStandardDirs::findResourceDir( const char *type, const QString& filename) const { #ifndef NDEBUG if (filename.isEmpty()) { kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; return QString::null; } #endif if (d && d->restrictionsActive && (strcmp(type, "data")==0)) applyDataRestrictions(filename); QStringList candidates = resourceDirs(type); QString fullPath; - +#ifdef DESKTOP_VERSION +#ifdef _WIN32_ + candidates.prepend( qApp->applicationDirPath () +"\\"); +#else + candidates.prepend( qApp->applicationDirPath () +"/"); +#endif +#endif for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) { + //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1()); if (exists(*it + filename)) return *it; } #ifndef NDEBUG if(false && type != "locale") - kdDebug() << "KStdDirs::findResDir(): can't find \"" << filename << "\" in type \"" << type << "\"." << endl; + qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1()); + #endif return QString::null; } bool KStandardDirs::exists(const QString &fullPath) { //US struct stat buff; QFileInfo fullPathInfo(QFile::encodeName(fullPath)); //US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) if (fullPathInfo.isReadable()) { if (fullPath.at(fullPath.length() - 1) != '/') { //US if (S_ISREG( buff.st_mode )) if (fullPathInfo.isFile()) return true; } else { //US if (S_ISDIR( buff.st_mode )) if (fullPathInfo.isDir()) return true; } } return false; } static void lookupDirectory(const QString& path, const QString &relPart, const QRegExp ®exp, QStringList& list, QStringList& relList, bool recursive, bool uniq) { QString pattern = regexp.pattern(); if (recursive || pattern.contains('?') || pattern.contains('*')) { // We look for a set of files. //US DIR *dp = opendir( QFile::encodeName(path)); QDir dp(QFile::encodeName(path)); if (!dp.exists()) return; static int iii = 0; ++iii; if ( iii == 5 ) abort(); assert(path.at(path.length() - 1) == '/'); //US struct dirent *ep; //US struct stat buff; QString _dot("."); QString _dotdot(".."); //US while( ( ep = readdir( dp ) ) != 0L ) QStringList direntries = dp.entryList(); QStringList::Iterator it = direntries.begin(); while ( it != list.end() ) // for each file... { //US QString fn( QFile::decodeName(ep->d_name)); QString fn = (*it); // dp.entryList already decodes it++; if ( fn.isNull() ) break; if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) continue; /*US if (!recursive && !regexp.exactMatch(fn)) continue; // No match */ //US this should do the same: int pos = regexp.match(fn); if (!recursive && !pos == 0) continue; // No match QString pathfn = path + fn; /*US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; continue; // Couldn't stat (e.g. no read permissions) } if ( recursive ) { if ( S_ISDIR( buff.st_mode )) { lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); } */ //US replacement: QFileInfo pathfnInfo(QFile::encodeName(pathfn)); if ( pathfnInfo.isReadable() == false ) { @@ -876,195 +886,195 @@ QString KStandardDirs::findExe( const QString& appname, // If we reach here, the executable wasn't found. // So return empty string. return QString::null; } int KStandardDirs::findAllExe( QStringList& list, const QString& appname, const QString& pstr, bool ignore ) { QString p = pstr; QFileInfo info; QStringList tokens; if( p.isNull() ) { p = getenv( "PATH" ); } list.clear(); tokenize( tokens, p, ":\b" ); for ( unsigned i = 0; i < tokens.count(); i++ ) { p = tokens[ i ]; p += "/"; p += appname; info.setFile( p ); if( info.exists() && (ignore || info.isExecutable()) && info.isFile() ) { list.append( p ); } } return list.count(); } */ static int tokenize( QStringList& tokens, const QString& str, const QString& delim ) { int len = str.length(); QString token = ""; for( int index = 0; index < len; index++) { if ( delim.find( str[ index ] ) >= 0 ) { tokens.append( token ); token = ""; } else { token += str[ index ]; } } if ( token.length() > 0 ) { tokens.append( token ); } return tokens.count(); } QString KStandardDirs::kde_default(const char *type) { if (!strcmp(type, "data")) return "apps/"; if (!strcmp(type, "html")) return "share/doc/HTML/"; if (!strcmp(type, "icon")) return "share/icons/"; if (!strcmp(type, "config")) return "config/"; if (!strcmp(type, "pixmap")) return "share/pixmaps/"; if (!strcmp(type, "apps")) return "share/applnk/"; if (!strcmp(type, "sound")) return "share/sounds/"; if (!strcmp(type, "locale")) return "share/locale/"; if (!strcmp(type, "services")) return "share/services/"; if (!strcmp(type, "servicetypes")) return "share/servicetypes/"; if (!strcmp(type, "mime")) return "share/mimelnk/"; if (!strcmp(type, "cgi")) return "cgi-bin/"; if (!strcmp(type, "wallpaper")) return "share/wallpapers/"; if (!strcmp(type, "templates")) return "share/templates/"; if (!strcmp(type, "exe")) return "bin/"; if (!strcmp(type, "lib")) - return "lib/"; + return "lib/"; if (!strcmp(type, "module")) - return "lib/kde3/"; + return "lib/kde3/"; if (!strcmp(type, "qtplugins")) return "lib/kde3/plugins"; if (!strcmp(type, "xdgdata-apps")) return "applications/"; if (!strcmp(type, "xdgdata-dirs")) return "desktop-directories/"; if (!strcmp(type, "xdgconf-menu")) return "menus/"; qFatal("unknown resource type %s", type); return QString::null; } QString KStandardDirs::saveLocation(const char *type, const QString& suffix, bool create) const { //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); //return ""; checkConfig(); QString *pPath = savelocations.find(type); if (!pPath) { QStringList *dirs = relatives.find(type); if (!dirs && ( (strcmp(type, "socket") == 0) || (strcmp(type, "tmp") == 0) || (strcmp(type, "cache") == 0) )) { (void) resourceDirs(type); // Generate socket|tmp|cache resource. dirs = relatives.find(type); // Search again. } if (dirs) { // Check for existance of typed directory + suffix if (strncmp(type, "xdgdata-", 8) == 0) pPath = new QString(realPath(localxdgdatadir() + dirs->last())); else if (strncmp(type, "xdgconf-", 8) == 0) pPath = new QString(realPath(localxdgconfdir() + dirs->last())); else pPath = new QString(realPath(localkdedir() + dirs->last())); } else { dirs = absolutes.find(type); if (!dirs) qFatal("KStandardDirs: The resource type %s is not registered", type); pPath = new QString(realPath(dirs->last())); } savelocations.insert(type, pPath); } QString fullPath = *pPath + suffix; //US struct stat st; //US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) QFileInfo fullPathInfo(QFile::encodeName(fullPath)); if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) { if(!create) { #ifndef NDEBUG qDebug("save location %s doesn't exist", fullPath.latin1()); #endif return fullPath; } if(!makeDir(fullPath, 0700)) { qWarning("failed to create %s", fullPath.latin1()); return fullPath; } dircache.remove(type); } return fullPath; } QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) { QString fullPath = absPath; int i = absPath.findRev('/'); if (i != -1) { fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize } QStringList candidates = resourceDirs(type); for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) if (fullPath.startsWith(*it)) { return fullPath.mid((*it).length()); } return absPath; } @@ -1131,193 +1141,196 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) if (dir.at(0) != '/') return false; #endif QString target = dir; uint len = target.length(); #ifndef _WIN32_ // append trailing slash if missing if (dir.at(len - 1) != '/') target += '/'; #endif QString base(""); uint i = 1; while( i < len ) { //US struct stat st; #ifndef _WIN32_ int pos = target.find('/', i); #else int pos = target.find('\\', i); #endif if ( pos < 0 ) return true; base += target.mid(i - 1, pos - i + 1); //QMessageBox::information( 0,"cap111", base, 1 ); /*US QCString baseEncoded = QFile::encodeName(base); // bail out if we encountered a problem if (stat(baseEncoded, &st) != 0) { // Directory does not exist.... // Or maybe a dangling symlink ? if (lstat(baseEncoded, &st) == 0) (void)unlink(baseEncoded); // try removing if ( mkdir(baseEncoded, (mode_t) mode) != 0) { perror("trying to create local folder"); return false; // Couldn't create it :-( } } */ if (dirObj.exists(base) == false) { //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); if (dirObj.mkdir(base) != true) { qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); return false; } } i = pos + 1; } return true; } static QString readEnvPath(const char *env) { #ifdef _WIN32_ return ""; #else QCString c_path = getenv(env); if (c_path.isEmpty()) return QString::null; return QFile::decodeName(c_path); #endif } void KStandardDirs::addKDEDefaults() { //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); //return; QStringList kdedirList; // begin KDEDIRS QString kdedirs = readEnvPath("MICROKDEDIRS"); if (!kdedirs.isEmpty()) { tokenize(kdedirList, kdedirs, ":"); } else { QString kdedir = readEnvPath("MICROKDEDIR"); if (!kdedir.isEmpty()) { kdedir = KShell::tildeExpand(kdedir); kdedirList.append(kdedir); } } //US kdedirList.append(KDEDIR); //US for embedded, add qtopia dir as kdedir + +#ifndef DESKTOP_VERSION kdedirList.append(readEnvPath("QPEDIR" )); +#endif #ifdef __KDE_EXECPREFIX QString execPrefix(__KDE_EXECPREFIX); if (execPrefix!="NONE") kdedirList.append(execPrefix); #endif QString localKdeDir; //US if (getuid()) if (true) { localKdeDir = readEnvPath("MICROKDEHOME"); if (!localKdeDir.isEmpty()) { if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; } else { localKdeDir = QDir::homeDirPath() + "/kdepim/"; } } else { // We treat root different to prevent root messing up the // file permissions in the users home directory. localKdeDir = readEnvPath("MICROKDEROOTHOME"); if (!localKdeDir.isEmpty()) { if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; } else { //US struct passwd *pw = getpwuid(0); //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); } } //US localKdeDir = appDir(); //US // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); if (localKdeDir != "-/") { localKdeDir = KShell::tildeExpand(localKdeDir); addPrefix(localKdeDir); } for (QStringList::ConstIterator it = kdedirList.begin(); it != kdedirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addPrefix(dir); } // end KDEDIRS // begin XDG_CONFIG_XXX QStringList xdgdirList; QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); if (!xdgdirs.isEmpty()) { tokenize(xdgdirList, xdgdirs, ":"); } else { xdgdirList.clear(); xdgdirList.append("/etc/xdg"); } QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); if (!localXdgDir.isEmpty()) { if (localXdgDir.at(localXdgDir.length()-1) != '/') localXdgDir += '/'; } else { //US if (getuid()) if (true) { localXdgDir = QDir::homeDirPath() + "/.config/"; } else { //US struct passwd *pw = getpwuid(0); //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); } } localXdgDir = KShell::tildeExpand(localXdgDir); addXdgConfigPrefix(localXdgDir); |