-rw-r--r-- | microkde/kdecore/kcatalogue.cpp | 4 | ||||
-rw-r--r-- | microkde/kdecore/kconfigbase.h | 4 | ||||
-rw-r--r-- | microkde/kdecore/klibloader.cpp | 29 | ||||
-rw-r--r-- | microkde/kdecore/klibloader.h | 10 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 23 | ||||
-rw-r--r-- | microkde/kdecore/klocale.h | 4 | ||||
-rw-r--r-- | microkde/kdecore/kmdcodec.cpp | 139 | ||||
-rw-r--r-- | microkde/kdecore/kmdcodec.h | 38 | ||||
-rw-r--r-- | microkde/kdecore/kprefs.cpp | 16 | ||||
-rw-r--r-- | microkde/kdecore/kprefs.h | 10 | ||||
-rw-r--r-- | microkde/kdecore/kshortcut.h | 8 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 24 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.h | 10 |
13 files changed, 167 insertions, 152 deletions
diff --git a/microkde/kdecore/kcatalogue.cpp b/microkde/kdecore/kcatalogue.cpp index 97ac326..1600b08 100644 --- a/microkde/kdecore/kcatalogue.cpp +++ b/microkde/kdecore/kcatalogue.cpp @@ -1,131 +1,133 @@ /* This file is part of the KDE libraries Copyright (c) 2001 Hans Petter Bieker <bieker@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 as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. */ //US #include <config.h> #include <qfile.h> +//Added by qt3to4: +#include <Q3CString> #include <kdebug.h> #include "kcatalogue.h" char *k_nl_find_msg(struct kde_loaded_l10nfile *domain_file, const char *msgid); void k_nl_unload_domain (struct loaded_domain *domain); #ifndef KDE_USE_FINAL // with --enable-final, we're getting this from libintl.cpp struct kde_loaded_l10nfile { const char *filename; int decided; const void *data; kde_loaded_l10nfile() : filename(0), decided(0), data(0) {} }; #endif class KCataloguePrivate { public: QString name; kde_loaded_l10nfile domain; }; KCatalogue::KCatalogue(const QString & name) : d( new KCataloguePrivate ) { d->name = name; } KCatalogue::KCatalogue(const KCatalogue & rhs) : d( new KCataloguePrivate ) { *this = rhs; } KCatalogue & KCatalogue::operator=(const KCatalogue & rhs) { d->name = rhs.d->name; setFileName( rhs.fileName() ); return *this; } KCatalogue::~KCatalogue() { doUnload(); delete d; } QString KCatalogue::name() const { return d->name; } void KCatalogue::setFileName( const QString & fileName ) { // nothing to do if the file name is already the same if ( this->fileName() == fileName ) return; doUnload(); - QCString newFileName = QFile::encodeName( fileName ); + Q3CString newFileName = QFile::encodeName( fileName ); if ( !fileName.isEmpty() ) { // set file name char *filename = new char[ newFileName.length() + 1 ]; ::qstrcpy( filename, newFileName ); d->domain.filename = filename; } } QString KCatalogue::fileName() const { return QFile::decodeName( d->domain.filename ); } const char * KCatalogue::translate(const char * msgid) const { qDebug("KCatalogue::translate has to be fixed %s",msgid ); //US return ::k_nl_find_msg( &d->domain, msgid ); return msgid; } void KCatalogue::doUnload() { // use gettext's unloader if ( d->domain.data ) { //US ::k_nl_unload_domain( (struct loaded_domain *)d->domain.data ); qDebug("KCatalogue::doUnload has to be fixed" ); } d->domain.data = 0; // free name delete [] const_cast<char *>(d->domain.filename); d->domain.filename = 0; d->domain.decided = 0; } diff --git a/microkde/kdecore/kconfigbase.h b/microkde/kdecore/kconfigbase.h index 7e56d11..1ef6a04 100644 --- a/microkde/kdecore/kconfigbase.h +++ b/microkde/kdecore/kconfigbase.h @@ -1,102 +1,104 @@ /* This file is part of the KDE libraries Copyright (c) 1999 Preston Brown <pbrown@kde.org> Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org> Copyright (c) 2001 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 as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. */ // $Id$ #ifndef _KCONFIGBASE_H #define _KCONFIGBASE_H #include "kconfig.h" +//Added by qt3to4: +#include <Q3CString> /** * Helper class to facilitate working with @ref KConfig / @ref KSimpleConfig * groups. * * Careful programmers always set the group of a * @ref KConfig @ref KSimpleConfig object to the group they want to read from * and set it back to the old one of afterwards. This is usually * written as: * <pre> * * QString oldgroup config->group(); * config->setGroup( "TheGroupThatIWant" ); * ... * config->writeEntry( "Blah", "Blubb" ); * * config->setGroup( oldgroup ); * </pre> * * In order to facilitate this task, you can use * KConfigGroupSaver. Simply construct such an object ON THE STACK * when you want to switch to a new group. Then, when the object goes * out of scope, the group will automatically be restored. If you * want to use several different groups within a function or method, * you can still use KConfigGroupSaver: Simply enclose all work with * one group (including the creation of the KConfigGroupSaver object) * in one block. * * @author Matthias Kalle Dalheimer <kalle@kde.org> * @version $Id$ * @see KConfigBase, KConfig, KSimpleConfig * @short Helper class for easier use of KConfig/KSimpleConfig groups */ //US I converted the class in a way that it can be used with KConfig objects of microkde class KConfigGroupSaver { public: /** * Constructor. You pass a pointer to the KConfigBase-derived * object you want to work with and a string indicating the _new_ * group. * * @param config The KConfigBase-derived object this * KConfigGroupSaver works on. * @param group The new group that the config object should switch to. */ KConfigGroupSaver( KConfig* config, QString group ) /* KDE 4 : make the second parameter const QString & */ : _config(config), _oldgroup(config->group()) { _config->setGroup( group ); } KConfigGroupSaver( KConfig* config, const char *group ) : _config(config), _oldgroup(config->group()) { _config->setGroup( group ); } - KConfigGroupSaver( KConfig* config, const QCString &group ) + KConfigGroupSaver( KConfig* config, const Q3CString &group ) : _config(config), _oldgroup(config->group()) { _config->setGroup( group ); } ~KConfigGroupSaver() { _config->setGroup( _oldgroup ); } KConfig* config() { return _config; }; private: KConfig* _config; QString _oldgroup; KConfigGroupSaver(const KConfigGroupSaver&); KConfigGroupSaver& operator=(const KConfigGroupSaver&); }; #endif diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp index 6d0475a..0b54eb6 100644 --- a/microkde/kdecore/klibloader.cpp +++ b/microkde/kdecore/klibloader.cpp @@ -1,653 +1,656 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Torben Weis <weis@kde.org> Copyright (C) 2000 Michael Matz <matz@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. */ //US #include <config.h> #include <qclipboard.h> #include <qfile.h> #include <qtimer.h> -#include <qobjectdict.h> -#include <qwidgetlist.h> +#include <q3objectdict.h> #include <qwidget.h> +#include <qwidget.h> +//Added by qt3to4: +#include <Q3CString> +#include <Q3PtrList> #include "kapplication.h" #include "klibloader.h" #include "kstandarddirs.h" #include "kdebug.h" #include "klocale.h" /*US #ifndef NDEBUG #include "ltdl.h" #endif */ //US do everything through qlibrary #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #include <qtopia/qlibrary.h> #else #include <qlibrary.h> #endif -template class QAsciiDict<KLibrary>; +template class Q3AsciiDict<KLibrary>; #include <stdlib.h> //getenv /*US #if HAVE_DLFCN_H # include <dlfcn.h> #endif #ifdef RTLD_GLOBAL # define LT_GLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_GLOBAL DL_GLOBAL # endif #endif #ifndef LT_GLOBAL # define LT_GLOBAL 0 #endif */ /*US extern "C" { extern int lt_dlopen_flag; } */ KLibFactory::KLibFactory( QObject* parent, const char* name ) : QObject( parent, name ) { } KLibFactory::~KLibFactory() { // kdDebug(150) << "Deleting KLibFactory " << this << endl; } QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args ) { QObject* obj = createObject( parent, name, classname, args ); if ( obj ) emit objectCreated( obj ); return obj; } QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &) { return 0; } // ----------------------------------------------- //US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle ) KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle ) { /* Make sure, we have a KLibLoader */ (void) KLibLoader::self(); m_libname = libname; m_filename = filename; m_handle = handle; m_factory = 0; m_timer = 0; } KLibrary::~KLibrary() { // kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl; if ( m_timer && m_timer->isActive() ) m_timer->stop(); // If any object is remaining, delete if ( m_objs.count() > 0 ) { - QPtrListIterator<QObject> it( m_objs ); + Q3PtrListIterator<QObject> it( m_objs ); for ( ; it.current() ; ++it ) { kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl; disconnect( it.current(), SIGNAL( destroyed() ), this, SLOT( slotObjectDestroyed() ) ); } m_objs.setAutoDelete(true); m_objs.clear(); } if ( m_factory ) { // kdDebug(150) << " ... deleting the factory " << m_factory << endl; delete m_factory; } } QString KLibrary::name() const { return m_libname; } QString KLibrary::fileName() const { return m_filename; } KLibFactory* KLibrary::factory() { if ( m_factory ) return m_factory; - QCString symname; + Q3CString symname; symname.sprintf("init_%s", name().latin1() ); void* sym = symbol( symname ); if ( !sym ) { qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); #ifndef NDEBUG //US qDebug("KLibrary: errorcode: %s", lt_dlerror()); #endif kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; return 0; } typedef KLibFactory* (*t_func)(); t_func func = (t_func)sym; m_factory = func(); if( !m_factory ) { kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; return 0; } connect( m_factory, SIGNAL( objectCreated( QObject * ) ), this, SLOT( slotObjectCreated( QObject * ) ) ); return m_factory; } void* KLibrary::symbol( const char* symname ) const { //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); void* sym = m_handle->resolve( symname ); if ( !sym ) { //US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; return 0; } return sym; } bool KLibrary::hasSymbol( const char* symname ) const { //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); void* sym = m_handle->resolve( symname ); return (sym != 0L ); } void KLibrary::unload() const { if (KLibLoader::s_self) KLibLoader::s_self->unloadLibrary(QFile::encodeName(name())); } void KLibrary::slotObjectCreated( QObject *obj ) { if ( !obj ) return; if ( m_timer && m_timer->isActive() ) m_timer->stop(); if ( m_objs.containsRef( obj ) ) return; // we know this object already connect( obj, SIGNAL( destroyed() ), this, SLOT( slotObjectDestroyed() ) ); m_objs.append( obj ); } void KLibrary::slotObjectDestroyed() { m_objs.removeRef( sender() ); if ( m_objs.count() == 0 ) { // kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" // << endl; if ( !m_timer ) { m_timer = new QTimer( this, "klibrary_shutdown_timer" ); connect( m_timer, SIGNAL( timeout() ), this, SLOT( slotTimeout() ) ); } // as long as it's not stable make the timeout short, for debugging // pleasure (matz) //m_timer->start( 1000*60, true ); m_timer->start( 1000*10, true ); } } void KLibrary::slotTimeout() { if ( m_objs.count() != 0 ) return; /* Don't go through KLibLoader::unloadLibrary(), because that uses the ref counter, but this timeout means to unconditionally close this library The destroyed() signal will take care to remove us from all lists. */ delete this; } // ------------------------------------------------- /* This helper class is needed, because KLibraries can go away without being unloaded. So we need some info about KLibraries even after its death. */ class KLibWrapPrivate { public: //US KLibWrapPrivate(KLibrary *l, lt_dlhandle h); KLibWrapPrivate(KLibrary *l, QLibrary* h); KLibrary *lib; enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; int ref_count; //US lt_dlhandle handle; QLibrary *handle; QString name; QString filename; }; //US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) { unload_mode = UNKNOWN; /*US if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { // kdDebug(150) << "Will not unload " << name << endl; unload_mode = DONT_UNLOAD; } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { unload_mode = UNLOAD; } */ //US use instead: if (h->resolve("__kde_do_not_unload") != 0) { // kdDebug(150) << "Will not unload " << name << endl; unload_mode = DONT_UNLOAD; } else if (h->resolve("__kde_do_unload") != 0) { unload_mode = UNLOAD; } } class KLibLoaderPrivate { public: - QPtrList<KLibWrapPrivate> loaded_stack; - QPtrList<KLibWrapPrivate> pending_close; + Q3PtrList<KLibWrapPrivate> loaded_stack; + Q3PtrList<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 ); + Q3AsciiDictIterator<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 ); + Q3CString 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) { #ifdef _WIN32_ libname += ".dll"; #else libname += ".so"; #endif } // 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? #ifndef _WIN32_ libname.insert(pos, "lib"); #endif //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); + self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(QString(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); + Q3PtrListIterator<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 ) { qDebug( "KLibLoader::library could not load library: %s", libfile.latin1()); d->errorMessage = QString::null; 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; } void KLibLoader::unloadLibrary( const char *libname ) { KLibWrapPrivate *wrap = m_libs[ libname ]; if (!wrap) return; if (--wrap->ref_count) return; // kdDebug(150) << "closing library " << libname << endl; m_libs.remove( libname ); disconnect( wrap->lib, SIGNAL( destroyed() ), this, SLOT( slotLibraryDestroyed() ) ); close_pending( wrap ); } KLibFactory* KLibLoader::factory( const char* name ) { KLibrary* lib = library( name ); if ( !lib ) return 0; return lib->factory(); } void KLibLoader::slotLibraryDestroyed() { const KLibrary *lib = static_cast<const KLibrary *>( sender() ); - QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); + Q3AsciiDictIterator<KLibWrapPrivate> it( m_libs ); for (; it.current(); ++it ) if ( it.current()->lib == lib ) { KLibWrapPrivate *wrap = it.current(); wrap->lib = 0; /* the KLibrary object is already away */ m_libs.remove( it.currentKey() ); close_pending( wrap ); return; } } void KLibLoader::close_pending(KLibWrapPrivate *wrap) { if (wrap && !d->pending_close.containsRef( wrap )) d->pending_close.append( wrap ); /* First delete all KLibrary objects in pending_close, but _don't_ unload the DSO behind it. */ - QPtrListIterator<KLibWrapPrivate> it(d->pending_close); + Q3PtrListIterator<KLibWrapPrivate> it(d->pending_close); for (; it.current(); ++it) { wrap = it.current(); if (wrap->lib) { disconnect( wrap->lib, SIGNAL( destroyed() ), this, SLOT( slotLibraryDestroyed() ) ); delete wrap->lib; wrap->lib = 0; } } if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return; bool deleted_one = false; while ((wrap = d->loaded_stack.first())) { /* Let's first see, if we want to try to unload this lib. If the env. var KDE_DOUNLOAD is set, we try to unload every lib. If not, we look at the lib itself, and unload it only, if it exports the symbol __kde_do_unload. */ if (d->unload_mode != KLibLoaderPrivate::UNLOAD && wrap->unload_mode != KLibWrapPrivate::UNLOAD) break; /* Now ensure, that the libs are only unloaded in the reverse direction they were loaded. */ if (!d->pending_close.containsRef( wrap )) { if (!deleted_one) /* Only diagnose, if we really haven't deleted anything. */ // kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; break; } // kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; #if 0 #ifndef Q_WS_QWS if ( !deleted_one ) { /* Only do the hack once in this loop. WABA: *HACK* We need to make sure to clear the clipboard before unloading a DSO because the DSO could have defined an object derived from QMimeSource and placed that on the clipboard. */ /*kapp->clipboard()->clear();*/ /* Well.. let's do something more subtle... convert the clipboard context to text. That should be safe as it only uses objects defined by Qt. */ QWidgetList *widgetlist = QApplication::topLevelWidgets(); QWidget *co = widgetlist->first(); while (co) { if (qstrcmp(co->name(), "internal clipboard owner") == 0) { if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId()) kapp->clipboard()->setText(kapp->clipboard()->text()); break; } co = widgetlist->next(); } delete widgetlist; } #else // FIXME(E): Implement in Qt Embedded #endif #endif // 0 deleted_one = true; //US lt_dlclose(wrap->handle); wrap->handle->unload(); d->pending_close.removeRef(wrap); /* loaded_stack is AutoDelete, so wrap is freed */ d->loaded_stack.remove(); } } void KLibLoader::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } void KLibFactory::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } //US #include "klibloader.moc" diff --git a/microkde/kdecore/klibloader.h b/microkde/kdecore/klibloader.h index ed57109..53d146e 100644 --- a/microkde/kdecore/klibloader.h +++ b/microkde/kdecore/klibloader.h @@ -1,405 +1,405 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Torben Weis <weis@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. */ #ifndef KLIBLOADER_H #define KLIBLOADER_H #include <qobject.h> #include <qstring.h> #include <qstringlist.h> -#include <qasciidict.h> -#include <qptrlist.h> +#include <q3asciidict.h> +#include <q3ptrlist.h> #include <kglobal.h> #include <stdlib.h> // For backwards compatibility class KInstance; class QTimer; class KLibrary; class KLibFactory; class KLibFactoryPrivate; class KLibLoaderPrivate; class KLibraryPrivate; class QLibrary; #define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \ extern "C" { void *init_##libname() { return new factory; } } /** * @short Represents a dynamically loaded library. * * KLibrary allows you to look up symbols of the shared library. * Use @ref KLibLoader to create a new instance of KLibrary. * * @see KLibLoader * @author Torben Weis <weis@kde.org> */ class KLibrary : public QObject { friend class KLibLoader; - friend class QAsciiDict<KLibrary>; + friend class Q3AsciiDict<KLibrary>; Q_OBJECT public: /** * @internal * Don't create KLibrary objects on your own. Instead use @ref KLibLoader. */ //US KLibrary( const QString& libname, const QString& filename, void * handle ); KLibrary( const QString& libname, const QString& filename, QLibrary* handle ); /** * Returns the name of the library. * @return The name of the library like "libkspread". */ QString name() const; /** * Returns the file name of the library. * @return The filename of the library, for example "/opt/kde2&/lib/libkspread.la" */ QString fileName() const; /** * Returns the factory of the library. * @return The factory of the library if there is any, otherwise 0 */ KLibFactory* factory(); /** * Looks up a symbol from the library. This is a very low level * function that you usually don't want to use. Usually you should * check using @ref hasSymbol() whether the symbol actually exists, * otherwise a warning will be printed. * @param name the name of the symbol to look up * @return the address of the symbol, or 0 if it does not exist * @see #hasSymbol */ void* symbol( const char* name ) const; /** * Looks up a symbol from the library. This is a very low level * function that you usually don't want to use. * Unlike @ref symbol(), this method doesn't warn if the symbol doesn't exist, * so if the symbol might or might not exist, better use hasSymbol() before symbol(). * @param name the name of the symbol to check * @return true if the symbol exists * @since 3.1 */ bool hasSymbol( const char* name ) const; /** * Unloads the library. * This typically results in the deletion of this object. You should * not reference its pointer after calling this function. */ void unload() const; private slots: void slotObjectCreated( QObject *obj ); void slotObjectDestroyed(); void slotTimeout(); private: /** * @internal * Don't destruct KLibrary objects yourself. Instead use @ref unload() instead. */ ~KLibrary(); QString m_libname; QString m_filename; KLibFactory* m_factory; //US void * m_handle; QLibrary* m_handle; - QPtrList<QObject> m_objs; + Q3PtrList<QObject> m_objs; QTimer *m_timer; KLibraryPrivate *d; }; class KLibWrapPrivate; /** * The KLibLoader allows you to load libraries dynamically at runtime. * Dependent libraries are loaded automatically. * * KLibLoader follows the singleton pattern. You can not create multiple * instances. Use @ref self() to get a pointer to the loader. * * @see KLibrary * @author Torben Weis <weis@kde.org> */ class KLibLoader : public QObject { friend class KLibrary; Q_OBJECT public: /** * You should NEVER destruct an instance of KLibLoader * until you know what you are doing. This will release * the loaded libraries. */ ~KLibLoader(); /** * Loads and initializes a library. Loading a library multiple times is * handled gracefully. * * This is a convenience function that returns the factory immediately * @param libname This is the library name without extension. Usually that is something like * "libkspread". The function will then search for a file named * "libkspread.la" in the KDE library paths. * The *.la files are created by libtool and contain * important information especially about the libraries dependencies * on other shared libs. Loading a "libfoo.so" could not solve the * dependencies problem. * * You can, however, give a library name ending in ".so" * (or whatever is used on your platform), and the library * will be loaded without resolving dependencies. USE WITH CARE :) * @return the @ref KLibFactory, or 0 if the library does not exist or it does * not have a factory * @see #library */ KLibFactory* factory( const char* libname ); /** * Loads and initializes a library. Loading a library multiple times is * handled gracefully. * * @param libname This is the library name without extension. Usually that is something like * "libkspread". The function will then search for a file named * "libkspread.la" in the KDE library paths. * The *.la files are created by libtool and contain * important information especially about the libraries dependencies * on other shared libs. Loading a "libfoo.so" could not solve the * dependencies problem. * * You can, however, give a library name ending in ".so" * (or whatever is used on your platform), and the library * will be loaded without resolving dependencies. USE WITH CARE :) * @return @ref KLibrary is invalid (0) when the library couldn't be dlopened. in such * a case you can retrieve the error message by calling KLibLoader::lastErrorMessage() * * @see #factory */ virtual KLibrary* library( const char* libname ); /** * Loads and initializes a library. Loading a library multiple times is * handled gracefully. The library is loaded such that the symbols are * globally accessible so libraries with dependencies can be loaded * sequentially. * * @param name This is the library name without extension. Usually that is something like * "libkspread". The function will then search for a file named * "libkspread.la" in the KDE library paths. * The *.la files are created by libtool and contain * important information especially about the libraries dependencies * on other shared libs. Loading a "libfoo.so" could not solve the * dependencies problem. * * You can, however, give a library name ending in ".so" * (or whatever is used on your platform), and the library * will be loaded without resolving dependencies. USE WITH CARE :) * @return KLibrariy is invalid (0) when the library couldn't be dlopened. in such * a case you can retrieve the error message by calling KLibLoader::lastErrorMessage() * * @see #factory */ KLibrary* globalLibrary( const char *name ); /* * Returns an error message that can be useful to debug the problem. * Returns QString::null if the last call to @ref #library() was successful. * You can call this function more than once. The error message is only * reset by a new call to library(). * @return the last error message, or QString::null if there was no error */ QString lastErrorMessage() const; /** * Unloads the library with the given name. * @param libname This is the library name without extension. Usually that is something like * "libkspread". The function will then search for a file named * "libkspread.la" in the KDE library paths. * The *.la files are created by libtool and contain * important information especially about the libraries dependencies * on other shared libs. Loading a "libfoo.so" could not solve the * dependencies problem. * * You can, however, give a library name ending in ".so" * (or whatever is used on your platform), and the library * will be loaded without resolving dependencies. USE WITH CARE :) */ virtual void unloadLibrary( const char *libname ); /** * Returns a pointer to the factory. Use this function to get an instance * of KLibLoader. * @return a pointer to the loader. If no loader exists until now * then one is created. */ static KLibLoader* self(); /** * @internal * Internal Method, called by the KApplication destructor. * Do not call it. * This is what makes it possible to rely on ~KLibFactory * being called in all cases, whether the library is unloaded * while the application is running or when exiting. */ static void cleanUp(); /** * Helper method which looks for a library in the standard paths * ("module" and "lib" resources). * Made public for code that doesn't use KLibLoader itself, but still * wants to open modules. * @param name of the library. If it is not a path, the function searches in * the "module" and "lib" resources. If there is no extension, * ".la" will be appended. * @param instance a KInstance used to get the standard paths */ static QString findLibrary( const char * name/*US , const KInstance * instance = KGlobal::instance()*/ ); protected: KLibLoader( QObject* parent = 0, const char* name = 0 ); private slots: void slotLibraryDestroyed(); private: void close_pending( KLibWrapPrivate * ); - QAsciiDict<KLibWrapPrivate> m_libs; + Q3AsciiDict<KLibWrapPrivate> m_libs; static KLibLoader* s_self; protected: virtual void virtual_hook( int id, void* data ); private: KLibLoaderPrivate *d; }; /** * If you develop a library that is to be loaded dynamically at runtime, then * you should return a pointer to your factory. The K_EXPORT_COMPONENT_FACTORY * macro is provided for this purpose: * <pre> * K_EXPORT_COMPONENT_FACTORY( libkspread, KSpreadFactory ) * </pre> * * The first macro argument is the name of your library, the second specifies the name * of your factory. * * In the constructor of your factory you should create an instance of @ref KInstance * like this: * <pre> * s_global = new KInstance( "kspread" ); * </pre> * This @ref KInstance is comparable to @ref KGlobal used by normal applications. * It allows you to find resource files (images, XML, sound etc.) belonging * to the library. * * If you want to load a library, use @ref KLibLoader. You can query @ref KLibLoader * directly for a pointer to the libraries factory by using the @ref KLibLoader::factory() * function. * * The KLibFactory is used to create the components, the library has to offer. * The factory of KSpread for example will create instances of KSpreadDoc, * while the Konqueror factory will create KonqView widgets. * All objects created by the factory must be derived from @ref QObject, since @ref QObject * offers type safe casting. * * KLibFactory is an abstract class. Reimplement the @ref * createObject() method to give it functionality. * * @author Torben Weis <weis@kde.org> */ class KLibFactory : public QObject { Q_OBJECT public: /** * Create a new factory. * @param parent the parent of the QObject, 0 for no parent * @param name the name of the QObject, 0 for no name */ KLibFactory( QObject* parent = 0, const char* name = 0 ); virtual ~KLibFactory(); /** * Creates a new object. The returned object has to be derived from * the requested classname. * * It is valid behavior to create different kinds of objects * depending on the requested @p classname. For example a koffice * library may usually return a pointer to KoDocument. But * if asked for a "QWidget", it could create a wrapper widget, * that encapsulates the Koffice specific features. * * create() automatically emits a signal @ref objectCreated to tell * the library about its newly created object. This is very * important for reference counting, and allows unloading the * library automatically once all its objects have been destroyed. * * @param parent the parent of the QObject, 0 for no parent * @param name the name of the QObject, 0 for no name * @param classname the name of the class * @param args a list of arguments */ QObject* create( QObject* parent = 0, const char* name = 0, const char* classname = "QObject", const QStringList &args = QStringList() ); signals: /** * Emitted in #create * @param obj the new object */ void objectCreated( QObject *obj ); protected: /** * Creates a new object. The returned object has to be derived from * the requested classname. * * It is valid behavior to create different kinds of objects * depending on the requested @p classname. For example a koffice * library may usually return a pointer to KoDocument. But * if asked for a "QWidget", it could create a wrapper widget, * that encapsulates the Koffice specific features. * * This function is called by #create() * @param parent the parent of the QObject, 0 for no parent * @param name the name of the QObject, 0 for no name * @param classname the name of the class * @param args a list of arguments */ virtual QObject* createObject( QObject* parent = 0, const char* name = 0, const char* classname = "QObject", const QStringList &args = QStringList() ) = 0; protected: virtual void virtual_hook( int id, void* data ); private: KLibFactoryPrivate *d; }; #endif diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 1d8ae9f..dd310fa 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp @@ -1,268 +1,269 @@ #include <qregexp.h> #include <qapplication.h> +#include <QDesktopWidget> #include "kdebug.h" #include "kcalendarsystemgregorian.h" #include "klocale.h" #include <qstringlist.h> //#define COLLECT_TRANSLATION -QDict<QString> *mLocaleDict = 0; -void setLocaleDict( QDict<QString> * dict ) +Q3Dict<QString> *mLocaleDict = 0; +void setLocaleDict( Q3Dict<QString> * dict ) { mLocaleDict = dict; } #ifdef COLLECT_TRANSLATION QStringList missingTrans; QStringList existingTrans1; QStringList existingTrans2; void addMissing(const char *text) { QString mis ( text ); if ( !missingTrans.contains( mis ) ) missingTrans.append(mis); } void addExist(const char *text,QString trans ) { //return; QString mis ( text ); if ( !existingTrans1.contains( mis ) ) { existingTrans1.append(mis); existingTrans2.append(trans); } } #include <qfile.h> -#include <qtextstream.h> +#include <q3textstream.h> #include <qtextcodec.h> #endif void dumpMissing() { #ifdef COLLECT_TRANSLATION QString fileName = "/tmp/usernewtrans.txt"; QFile file( fileName ); - if (!file.open( IO_WriteOnly ) ) { + if (!file.open( QIODevice::WriteOnly ) ) { return ; } - QTextStream ts( &file ); + Q3TextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); int i; for ( i = 0; i< missingTrans.count(); ++i ) { QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; } file.close(); { QString fileName = "/tmp/usertrans.txt"; QFile file( fileName ); - if (!file.open( IO_WriteOnly ) ) { + if (!file.open( QIODevice::WriteOnly ) ) { return ; } - QTextStream ts( &file ); + Q3TextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); int i; for ( i = 0; i< existingTrans1.count(); ++i ) { QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; } file.close(); } #endif } QString i18n(const char *text) { if ( ! mLocaleDict ) { #ifdef COLLECT_TRANSLATION addMissing( text ); #endif return QString( text ); } else { QString* ret = mLocaleDict->find(QString(text)) ; if ( ret == 0 ) { #ifdef COLLECT_TRANSLATION addMissing( text ); #endif return QString( text ); } else { if ( (*ret).isEmpty() ) { #ifdef COLLECT_TRANSLATION addMissing( text ); #endif return QString( text ); } else { #ifdef COLLECT_TRANSLATION addExist( text, *ret ); #endif return (*ret); } } } } QString i18n(const char *,const char *text) { return i18n( text ); } QString i18n(const char *text1, const char *textn, int num) { if ( num == 1 ) return i18n( text1 ); else { QString text = i18n( textn ); int pos = text.find( "%n" ); if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); return text; } } inline void put_it_in( QChar *buffer, uint& index, const QString &s ) { for ( uint l = 0; l < s.length(); l++ ) buffer[index++] = s.at( l ); } inline void put_it_in( QChar *buffer, uint& index, int number ) { buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; } static int readInt(const QString &str, uint &pos) { if (!str.at(pos).isDigit()) return -1; int result = 0; for (; str.length() > pos && str.at(pos).isDigit(); pos++) { result *= 10; result += str.at(pos).digitValue(); } return result; } KLocale::KLocale() : mCalendarSystem( 0 ) { m_decimalSymbol = "."; m_positiveSign = ""; m_negativeSign = "-"; m_thousandsSeparator = ","; mWeekStartsMonday = true; mHourF24Format = true; mIntDateFormat = Default; mIntTimeFormat = Default; mLanguage = 0; mDateFormat = "%a %Y %b %d"; mDateFormatShort = "%Y-%m-%d"; mTimeZoneList << ("-11:00 US/Samoa") << ("-10:00 US/Hawaii") << ("-09:00 US/Alaska") << ("-08:00 US/Pacific") << ("-07:00 US/Mountain") << ("-06:00 US/Central") << ("-05:00 US/Eastern") << ("-04:00 Brazil/West") << ("-03:00 Brazil/East") << ("-02:00 Brazil/DeNoronha") << ("-01:00 Atlantic/Azores") << (" 00:00 Europe/London(UTC)") << ("+01:00 Europe/Oslo(CET)") << ("+02:00 Europe/Helsinki") << ("+03:00 Europe/Moscow") << ("+04:00 Indian/Mauritius") << ("+05:00 Indian/Maldives") << ("+06:00 Indian/Chagos") << ("+07:00 Asia/Bangkok") << ("+08:00 Asia/Hongkong") << ("+09:00 Asia/Tokyo") << ("+10:00 Asia/Vladivostok") << ("+11:00 Asia/Magadan") << ("+12:00 Asia/Kamchatka") // << (" xx:xx User defined offset") << i18n (" Local Time"); mSouthDaylight = false; mTimeZoneOffset = 0; daylightEnabled = false; } void KLocale::setDateFormat( QString s ) { mDateFormat = s; } void KLocale::setDateFormatShort( QString s ) { mDateFormatShort = s; } void KLocale::setHore24Format ( bool b ) { mHourF24Format = b; } void KLocale::setWeekStartMonday( bool b ) { mWeekStartsMonday = b; } KLocale::IntDateFormat KLocale::getIntDateFormat( ) { return mIntDateFormat; } void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) { mIntDateFormat = i; } KLocale::IntDateFormat KLocale::getIntTimeFormat( ) { return mIntTimeFormat; } void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) { mIntTimeFormat = i; } void KLocale::setLanguage( int i ) { mLanguage = i; } int KLocale::language( ) { return mLanguage; } QString KLocale::translate( const char *index ) const { return i18n( index ); } QString KLocale::translate( const char *, const char *fallback) const { return i18n( fallback ); @@ -278,652 +279,652 @@ int KLocale::weekNum ( const QDate & date ) int prevThursday = dayofyear - ( daystoprevthursday ); int subweeknum = 0; if ( prevThursday < 1 ) { seda = seda.addDays( - daystoprevthursday ); dayofyear = seda.dayOfYear(); prevThursday = dayofyear; subweeknum = prevThursday / 7; if ( prevThursday % 7 != 0 ) ++subweeknum; } else { if ( dayofyear >= 360 ) { //maybe week 1 seda = seda.addDays( 7 - daystoprevthursday ); dayofyear = seda.dayOfYear(); if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) ) return 1; } } if ( ! weekNum ) { weekNum = prevThursday / 7; if ( prevThursday % 7 != 0 ) ++weekNum; if ( dayofweek < 4 ) ++weekNum; else if ( dayofweek == 7 && !mWeekStartsMonday ) ++weekNum; if ( weekNum > subweeknum ) weekNum -= subweeknum; } return weekNum; } QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const { const QString rst = timeFormat(intIntDateFormat); // only "pm/am" here can grow, the rest shrinks, but // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; uint index = 0; bool escape = false; int number = 0; for ( uint format_index = 0; format_index < rst.length(); format_index++ ) { if ( !escape ) { if ( rst.at( format_index ).unicode() == '%' ) escape = true; else buffer[index++] = rst.at( format_index ); } else { switch ( rst.at( format_index ).unicode() ) { case '%': buffer[index++] = '%'; break; case 'H': put_it_in( buffer, index, pTime.hour() ); break; case 'I': put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); break; case 'M': put_it_in( buffer, index, pTime.minute() ); break; case 'S': if (includeSecs) put_it_in( buffer, index, pTime.second() ); else { // we remove the seperator sign before the seconds and // assume that works everywhere --index; break; } break; case 'k': number = pTime.hour(); case 'l': // to share the code if ( rst.at( format_index ).unicode() == 'l' ) number = (pTime.hour() + 11) % 12 + 1; if ( number / 10 ) buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; break; case 'p': { QString s; if ( pTime.hour() >= 12 ) put_it_in( buffer, index, i18n("pm") ); else put_it_in( buffer, index, i18n("am") ); break; } default: buffer[index++] = rst.at( format_index ); break; } escape = false; } } QString ret( buffer, index ); delete [] buffer; return ret; } QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const { const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; unsigned int index = 0; bool escape = false; int number = 0; for ( uint format_index = 0; format_index < rst.length(); ++format_index ) { if ( !escape ) { if ( rst.at( format_index ).unicode() == '%' ) escape = true; else buffer[index++] = rst.at( format_index ); } else { switch ( rst.at( format_index ).unicode() ) { case '%': buffer[index++] = '%'; break; case 'Y': put_it_in( buffer, index, pDate.year() / 100 ); case 'y': put_it_in( buffer, index, pDate.year() % 100 ); break; case 'n': number = pDate.month(); case 'e': // to share the code if ( rst.at( format_index ).unicode() == 'e' ) number = pDate.day(); if ( number / 10 ) buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; break; case 'm': put_it_in( buffer, index, pDate.month() ); break; case 'b': put_it_in( buffer, index, monthName(pDate.month(), true) ); break; case 'B': put_it_in( buffer, index, monthName(pDate.month(), false) ); break; case 'd': put_it_in( buffer, index, pDate.day() ); break; case 'a': put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); break; case 'A': put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); break; default: buffer[index++] = rst.at( format_index ); break; } escape = false; } } QString ret( buffer, index ); delete [] buffer; return ret; } QString KLocale::formatDateTime(const QDateTime &pDateTime, bool shortFormat, bool includeSeconds, IntDateFormat intIntDateFormat) const { QString format("%1 %2"); if ( intIntDateFormat == Default ) format = "%1 %2"; else if ( intIntDateFormat == Format1 ) format = "%1 %2"; - else if ( intIntDateFormat == ISODate ) + else if ( intIntDateFormat == Qt::ISODate ) format = "%1T%2"; QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); return res; } QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const { return formatDateTime(pDateTime, true, true, intIntDateFormat); } QDate KLocale::readDate(const QString &intstr, bool* ok) const { QDate date; date = readDate(intstr, true, ok); if (date.isValid()) return date; return readDate(intstr, false, ok); } QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const { QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); return readDate( intstr, fmt, ok ); } QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const { //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; QString str = intstr.simplifyWhiteSpace().lower(); int day = -1, month = -1; // allow the year to be omitted if not in the format int year = QDate::currentDate().year(); uint strpos = 0; uint fmtpos = 0; while (fmt.length() > fmtpos || str.length() > strpos) { if ( !(fmt.length() > fmtpos && str.length() > strpos) ) goto error; QChar c = fmt.at(fmtpos++); if (c != '%') { if (c.isSpace()) strpos++; else if (c != str.at(strpos++)) goto error; continue; } // remove space at the begining if (str.length() > strpos && str.at(strpos).isSpace()) strpos++; c = fmt.at(fmtpos++); - switch (c) + switch (c.unicode()) { case 'a': case 'A': // this will just be ignored { // Cristian Tache: porting to Win: Block added because of "j" redefinition for (int j = 1; j < 8; j++) { QString s = weekDayName(j, c == 'a').lower(); int len = s.length(); if (str.mid(strpos, len) == s) strpos += len; } break; } case 'b': case 'B': { // Cristian Tache: porting to Win: Block added because of "j" redefinition for (int j = 1; j < 13; j++) { QString s = monthName(j, c == 'b').lower(); int len = s.length(); if (str.mid(strpos, len) == s) { month = j; strpos += len; } } break; } case 'd': case 'e': day = readInt(str, strpos); if (day < 1 || day > 31) goto error; break; case 'n': case 'm': month = readInt(str, strpos); if (month < 1 || month > 12) goto error; break; case 'Y': case 'y': year = readInt(str, strpos); if (year < 0) goto error; // Qt treats a year in the range 0-100 as 1900-1999. // It is nicer for the user if we treat 0-68 as 2000-2068 if (year < 69) year += 2000; else if (c == 'y') year += 1900; break; } } //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; if ( year != -1 && month != -1 && day != -1 ) { if (ok) *ok = true; return QDate(year, month, day); } error: if (ok) *ok = false; return QDate(); // invalid date } QTime KLocale::readTime(const QString &intstr, bool *ok) const { QTime _time; _time = readTime(intstr, false, ok); if (_time.isValid()) return _time; return readTime(intstr, true, ok); } QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const { QString str = intstr.simplifyWhiteSpace().lower(); QString Format = timeFormat().simplifyWhiteSpace(); if (!seconds) Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds bool g_12h = false; bool pm = false; uint strpos = 0; uint Formatpos = 0; while (Format.length() > Formatpos || str.length() > strpos) { if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; QChar c = Format.at(Formatpos++); if (c != '%') { if (c.isSpace()) strpos++; else if (c != str.at(strpos++)) goto error; continue; } // remove space at the begining if (str.length() > strpos && str.at(strpos).isSpace()) strpos++; c = Format.at(Formatpos++); - switch (c) + switch (c.unicode()) { case 'p': { QString s; s = i18n("pm").lower(); int len = s.length(); if (str.mid(strpos, len) == s) { pm = true; strpos += len; } else { s = i18n("am").lower(); len = s.length(); if (str.mid(strpos, len) == s) { pm = false; strpos += len; } else goto error; } } break; case 'k': case 'H': g_12h = false; hour = readInt(str, strpos); if (hour < 0 || hour > 23) goto error; break; case 'l': case 'I': g_12h = true; hour = readInt(str, strpos); if (hour < 1 || hour > 12) goto error; break; case 'M': minute = readInt(str, strpos); if (minute < 0 || minute > 59) goto error; break; case 'S': second = readInt(str, strpos); if (second < 0 || second > 59) goto error; break; } } if (g_12h) { hour %= 12; if (pm) hour += 12; } if (ok) *ok = true; return QTime(hour, minute, second); error: if (ok) *ok = false; return QTime(-1, -1, -1); // return invalid date if it didn't work // This will be removed in the near future, since it gives a warning on stderr. // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. } QDateTime KLocale::readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const { bool ok1, ok2; // AT the moment we can not read any other format then ISODate if ( intIntDateFormat != ISODate ) { qDebug("KLocale::readDateTime, only ISODate is supported."); return QDateTime(); } int pos = intstr.find("T"); QString date = intstr.left(pos); QString time = intstr.mid(pos+1); QString dformat = dateFormat(intIntDateFormat); QString tformat = timeFormat(intIntDateFormat); QDate m_date = readDate(date, dformat, &ok1); - QTime m_time = readTime(time, tformat, &ok2); + QTime m_time = readTime(time, !tformat.isEmpty(), &ok2); QDateTime m_dt; if (ok) { if ((ok1 == false) || (ok2 == false)) *ok = false; else *ok = true; } //only set values if both operations returned true. if ((ok1 == true) && (ok2 == true)) { m_dt.setDate(m_date); m_dt.setTime(m_time); } //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); return m_dt; } QDate KLocale::readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const { bool ok1; QString dformat = dateFormat(intIntDateFormat); QDate m_date = readDate(intstr, dformat, &ok1); if (ok) *ok = ok1; //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); return m_date; } bool KLocale::use12Clock() const { return !mHourF24Format ;; } bool KLocale::weekStartsMonday() const { return mWeekStartsMonday; } int KLocale::weekStartDay() const { if ( mWeekStartsMonday ) return 1; return 7; } QString KLocale::weekDayName(int i,bool shortName) const { if ( shortName ) switch ( i ) { case 1: return i18n("Monday", "Mon"); case 2: return i18n("Tuesday", "Tue"); case 3: return i18n("Wednesday", "Wed"); case 4: return i18n("Thursday", "Thu"); case 5: return i18n("Friday", "Fri"); case 6: return i18n("Saturday", "Sat"); case 7: return i18n("Sunday", "Sun"); } else switch ( i ) { case 1: return i18n("Monday"); case 2: return i18n("Tuesday"); case 3: return i18n("Wednesday"); case 4: return i18n("Thursday"); case 5: return i18n("Friday"); case 6: return i18n("Saturday"); case 7: return i18n("Sunday"); } return QString::null; } QString KLocale::monthName(int i,bool shortName) const { if ( shortName ) switch ( i ) { case 1: return i18n("January", "Jan"); case 2: return i18n("February", "Feb"); case 3: return i18n("March", "Mar"); case 4: return i18n("April", "Apr"); case 5: return i18n("May short", "May"); case 6: return i18n("June", "Jun"); case 7: return i18n("July", "Jul"); case 8: return i18n("August", "Aug"); case 9: return i18n("September", "Sep"); case 10: return i18n("October", "Oct"); case 11: return i18n("November", "Nov"); case 12: return i18n("December", "Dec"); } else switch (i) { case 1: return i18n("January"); case 2: return i18n("February"); case 3: return i18n("March"); case 4: return i18n("April"); case 5: return i18n("May long", "May"); case 6: return i18n("June"); case 7: return i18n("July"); case 8: return i18n("August"); case 9: return i18n("September"); case 10: return i18n("October"); case 11: return i18n("November"); case 12: return i18n("December"); } return QString::null; } QString KLocale::country() const { return QString::null; } QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const { const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; if ( dformat == ISODate ) return "%Y-%m-%d"; if ( QApplication::desktop()->width() < 480 ) { if ( dformat == Default ) return "%a %d %b %Y"; else if ( dformat == Format1 ) return "%a %b %d %Y"; } else { if ( dformat == Default ) return "%A %d %B %Y"; else if ( dformat == Format1 ) return "%A %B %d %Y"; } return mDateFormat ; } QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const { const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; if ( dformat == Default ) return "%d.%m.%Y"; else if ( dformat == Format1 ) return "%m.%d.%Y"; else if ( dformat == ISODate ) // = Qt::ISODate return "%Y-%m-%d"; return mDateFormatShort ; } QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const { const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; if ( tformat == Default ) if ( mHourF24Format) return "%H:%M:%S"; else return "%I:%M:%S%p"; else if ( tformat == Format1 ) if ( mHourF24Format) return "%H:%M:%S"; else return "%I:%M:%S%p"; else if ( tformat == ISODate ) // = Qt::ISODate if ( mHourF24Format) return "%H:%M:%S"; else return "%I:%M:%S%p"; // to satisfy the compiler return "%H:%M:%S"; } void KLocale::insertCatalogue ( const QString & ) { diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h index 58e0b39..840fc9d 100644 --- a/microkde/kdecore/klocale.h +++ b/microkde/kdecore/klocale.h @@ -1,119 +1,119 @@ #ifndef MINIKDE_KLOCALE_H #define MINIKDE_KLOCALE_H #include <qstring.h> #include <qstringlist.h> #include <qdatetime.h> -#include <qdict.h> +#include <q3dict.h> #ifndef I18N_NOOP #define I18N_NOOP(x) (x) #endif class KCalendarSystem; -void setLocaleDict( QDict<QString> * dict ); +void setLocaleDict( Q3Dict<QString> * dict ); QString i18n(const char *text); QString i18n(const char *hint, const char *text); QString i18n(const char *text1, const char *textn, int num); // Qt3's uic generates i18n( "msg", "comment" ) calls which conflict // with our i18n method. we use uic -tr tr2i18n to redirect // to the right i18n() function inline QString tr2i18n(const char* message, const char* =0) { return i18n( message); } class KLocale { public: KLocale(); QString formatNumber(double num, int precision = -1) const; QString formatNumber(const QString &numStr) const; double readNumber(const QString &numStr, bool * ok = 0) const; QString decimalSymbol() const; QString thousandsSeparator() const; QString positiveSign() const; QString negativeSign() const; QString translate( const char *index ) const; QString translate( const char *index, const char *fallback) const; enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const; QString formatDateTime(const QDateTime &pDateTime, bool shortFormat, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; QDate readDate(const QString &str, bool* ok = 0) const; QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; QTime readTime(const QString &str, bool* ok = 0) const; QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; bool use12Clock() const; bool weekStartsMonday() const; int weekStartDay() const; QString weekDayName(int,bool=false) const; QString monthName(int,bool=false) const; QString country() const; int weekNum ( const QDate & ); QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; void insertCatalogue ( const QString & ); KCalendarSystem *calendar(); void setHore24Format ( bool ); void setWeekStartMonday( bool ); void setIntDateFormat( IntDateFormat ); void setIntTimeFormat( IntDateFormat ); IntDateFormat getIntDateFormat( ); IntDateFormat getIntTimeFormat( ); void setLanguage( int ); int language(); void setDateFormat( QString ); void setDateFormatShort( QString ); QString m_decimalSymbol; QString m_thousandsSeparator; QString m_currencySymbol; QString m_monetaryDecimalSymbol; QString m_monetaryThousandsSeparator; QString m_positiveSign; QString m_negativeSign; int timezoneOffset( QString ); QStringList timeZoneList() const; void setDaylightSaving( bool, int , int ); int localTimeOffset(const QDateTime &); void setTimezone( const QString &timeZone , bool oddTZ); private: QTime readTime(const QString &str, bool seconds, bool *ok) const; QDate readDate(const QString &str, bool shortFormat, bool *ok) const; KCalendarSystem *mCalendarSystem; bool mWeekStartsMonday; bool mHourF24Format; IntDateFormat mIntDateFormat; IntDateFormat mIntTimeFormat; int mLanguage; QString mDateFormat; QString mDateFormatShort; QStringList mTimeZoneList; bool daylightEnabled; int mDaylightTZoffset; int mNondaylightTZoffset; bool mSouthDaylight; int daylightStart, daylightEnd, mTimeZoneOffset; }; #endif diff --git a/microkde/kdecore/kmdcodec.cpp b/microkde/kdecore/kmdcodec.cpp index bc03569..db11e52 100644 --- a/microkde/kdecore/kmdcodec.cpp +++ b/microkde/kdecore/kmdcodec.cpp @@ -1,1127 +1,1126 @@ /* Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) version 2 as published by the Free Software Foundation. This program 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 General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. RSA Data Security, Inc. Created 1991. All rights reserved. The KMD5 class is based on a C++ implementation of "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by Mordechai T. Abzug, Copyright (c) 1995. This implementation passes the test-suite as defined in RFC 1321. The encoding and decoding utilities in KCodecs with the exception of quoted-printable are based on the java implementation in HTTPClient package by Ronald Tschal� Copyright (C) 1996-1999. The quoted-printable codec as described in RFC 2045, section 6.7. is by Rik Hemsley (C) 2001. */ //US #include <config.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <kdebug.h> #include "kmdcodec.h" +//Added by qt3to4: +#include <Q3CString> #define KMD5_S11 7 #define KMD5_S12 12 #define KMD5_S13 17 #define KMD5_S14 22 #define KMD5_S21 5 #define KMD5_S22 9 #define KMD5_S23 14 #define KMD5_S24 20 #define KMD5_S31 4 #define KMD5_S32 11 #define KMD5_S33 16 #define KMD5_S34 23 #define KMD5_S41 6 #define KMD5_S42 10 #define KMD5_S43 15 #define KMD5_S44 21 const char KCodecs::Base64EncMap[64] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F }; const char KCodecs::Base64DecMap[128] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 }; const char KCodecs::UUEncMap[64] = { 0x60, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F }; const char KCodecs::UUDecMap[128] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; const char KCodecs::hexChars[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; const unsigned int KCodecs::maxQPLineLength = 70; /******************************** KCodecs ********************************/ // strchr(3) for broken systems. static int rikFindChar(register const char * _s, const char c) { register const char * s = _s; while (true) { if ((0 == *s) || (c == *s)) break; ++s; if ((0 == *s) || (c == *s)) break; ++s; if ((0 == *s) || (c == *s)) break; ++s; if ((0 == *s) || (c == *s)) break; ++s; } return s - _s; } -QCString KCodecs::quotedPrintableEncode(const QByteArray& in, bool useCRLF) +Q3CString KCodecs::quotedPrintableEncode(const QByteArray& in, bool useCRLF) { QByteArray out; quotedPrintableEncode (in, out, useCRLF); - return QCString (out.data(), out.size()+1); + return Q3CString (out.data(), out.size()+1); } -QCString KCodecs::quotedPrintableEncode(const QCString& str, bool useCRLF) +Q3CString KCodecs::quotedPrintableEncode(const Q3CString& str, bool useCRLF) { if (str.isEmpty()) return ""; QByteArray in (str.length()); memcpy (in.data(), str.data(), str.length()); return quotedPrintableEncode(in, useCRLF); } void KCodecs::quotedPrintableEncode(const QByteArray& in, QByteArray& out, bool useCRLF) { out.resize (0); if (in.isEmpty()) return; char *cursor; const char *data; unsigned int lineLength; unsigned int pos; const unsigned int length = in.size(); const unsigned int end = length - 1; // Reasonable guess for output size when we're encoding // mostly-ASCII data. It doesn't really matter, because // the underlying allocation routines are quite efficient, // but it's nice to have 0 allocations in many cases. out.resize ((length*12)/10); cursor = out.data(); data = in.data(); lineLength = 0; pos = 0; for (unsigned int i = 0; i < length; i++) { unsigned char c (data[i]); // check if we have to enlarge the output buffer, use // a safety margin of 16 byte pos = cursor-out.data(); if (out.size()-pos < 16) { out.resize(out.size()+4096); cursor = out.data()+pos; } // Plain ASCII chars just go straight out. if ((c >= 33) && (c <= 126) && ('=' != c)) { *cursor++ = c; ++lineLength; } // Spaces need some thought. We have to encode them at eol (or eof). else if (' ' == c) { if ( (i >= length) || ((i < end) && ((useCRLF && ('\r' == data[i + 1]) && ('\n' == data[i + 2])) || (!useCRLF && ('\n' == data[i + 1])))) ) { *cursor++ = '='; *cursor++ = '2'; *cursor++ = '0'; lineLength += 3; } else { *cursor++ = ' '; ++lineLength; } } // If we find a line break, just let it through. else if ((useCRLF && ('\r' == c) && (i < end) && ('\n' == data[i + 1])) || (!useCRLF && ('\n' == c))) { lineLength = 0; if (useCRLF) { *cursor++ = '\r'; *cursor++ = '\n'; ++i; } else { *cursor++ = '\n'; } } // Anything else is converted to =XX. else { *cursor++ = '='; *cursor++ = hexChars[c / 16]; *cursor++ = hexChars[c % 16]; lineLength += 3; } // If we're approaching the maximum line length, do a soft line break. if ((lineLength > maxQPLineLength) && (i < end)) { if (useCRLF) { *cursor++ = '='; *cursor++ = '\r'; *cursor++ = '\n'; } else { *cursor++ = '='; *cursor++ = '\n'; } lineLength = 0; } } out.truncate(cursor - out.data()); } -QCString KCodecs::quotedPrintableDecode(const QByteArray & in) +Q3CString KCodecs::quotedPrintableDecode(const QByteArray & in) { QByteArray out; quotedPrintableDecode (in, out); - return QCString (out.data(), out.size()+1); + return Q3CString (out.data(), out.size()+1); } -QCString KCodecs::quotedPrintableDecode(const QCString & str) +Q3CString KCodecs::quotedPrintableDecode(const Q3CString & str) { if (str.isEmpty()) return ""; QByteArray in (str.length()); memcpy (in.data(), str.data(), str.length()); return quotedPrintableDecode (in); } void KCodecs::quotedPrintableDecode(const QByteArray& in, QByteArray& out) { // clear out the output buffer out.resize (0); if (in.isEmpty()) return; char *cursor; const char *data; const unsigned int length = in.size(); data = in.data(); out.resize (length); cursor = out.data(); for (unsigned int i = 0; i < length; i++) { char c(in.at(i)); if ('=' == c) { if (i < length - 2) { char c1 = in.at(i + 1); char c2 = in.at(i + 2); if (('\n' == c1) || ('\r' == c1 && '\n' == c2)) { // Soft line break. No output. if ('\r' == c1) i += 2; // CRLF line breaks else i += 1; } else { // =XX encoded byte. int hexChar0 = rikFindChar(hexChars, c1); int hexChar1 = rikFindChar(hexChars, c2); if (hexChar0 < 16 && hexChar1 < 16) { *cursor++ = char((hexChar0 * 16) | hexChar1); i += 2; } } } } else { *cursor++ = c; } } out.truncate(cursor - out.data()); } -QCString KCodecs::base64Encode( const QCString& str, bool insertLFs ) +Q3CString KCodecs::base64Encode( const Q3CString& str, bool insertLFs ) { if ( str.isEmpty() ) return ""; QByteArray in (str.length()); memcpy( in.data(), str.data(), str.length() ); return base64Encode( in, insertLFs ); } -QCString KCodecs::base64Encode( const QByteArray& in, bool insertLFs ) +Q3CString KCodecs::base64Encode( const QByteArray& in, bool insertLFs ) { QByteArray out; base64Encode( in, out, insertLFs ); - return QCString( out.data(), out.size()+1 ); + return Q3CString( out.data(), out.size()+1 ); } void KCodecs::base64Encode( const QByteArray& in, QByteArray& out, bool insertLFs ) { // clear out the output buffer out.resize (0); if ( in.isEmpty() ) return; unsigned int sidx = 0; unsigned int didx = 0; const char* data = in.data(); const unsigned int len = in.size(); unsigned int out_len = ((len+2)/3)*4; // Deal with the 76 characters or less per // line limit specified in RFC 2045 on a // pre request basis. insertLFs = (insertLFs && out_len > 76); if ( insertLFs ) out_len += ((out_len-1)/76); int count = 0; out.resize( out_len ); // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion if ( len > 1 ) { while (sidx < len-2) { if ( insertLFs ) { if ( count && (count%76) == 0 ) - out.at(didx++) = '\n'; + out[didx++] = '\n'; count += 4; } - out.at(didx++) = Base64EncMap[(data[sidx] >> 2) & 077]; - out.at(didx++) = Base64EncMap[(data[sidx+1] >> 4) & 017 | + out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; + out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | (data[sidx] << 4) & 077]; - out.at(didx++) = Base64EncMap[(data[sidx+2] >> 6) & 003 | + out[didx++] = Base64EncMap[(data[sidx+2] >> 6) & 003 | (data[sidx+1] << 2) & 077]; - out.at(didx++) = Base64EncMap[data[sidx+2] & 077]; + out[didx++] = Base64EncMap[data[sidx+2] & 077]; sidx += 3; } } if (sidx < len) { if ( insertLFs && (count > 0) && (count%76) == 0 ) - out.at(didx++) = '\n'; + out[didx++] = '\n'; - out.at(didx++) = Base64EncMap[(data[sidx] >> 2) & 077]; + out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; if (sidx < len-1) { - out.at(didx++) = Base64EncMap[(data[sidx+1] >> 4) & 017 | + out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | (data[sidx] << 4) & 077]; - out.at(didx++) = Base64EncMap[(data[sidx+1] << 2) & 077]; + out[didx++] = Base64EncMap[(data[sidx+1] << 2) & 077]; } else { - out.at(didx++) = Base64EncMap[(data[sidx] << 4) & 077]; + out[didx++] = Base64EncMap[(data[sidx] << 4) & 077]; } } // Add padding while (didx < out.size()) - { - out.at(didx) = '='; - didx++; - } + out[didx++] = '='; } -QCString KCodecs::base64Decode( const QCString& str ) +Q3CString KCodecs::base64Decode( const Q3CString& str ) { if ( str.isEmpty() ) return ""; QByteArray in( str.length() ); memcpy( in.data(), str.data(), str.length() ); return base64Decode( in ); } -QCString KCodecs::base64Decode( const QByteArray& in ) +Q3CString KCodecs::base64Decode( const QByteArray& in ) { QByteArray out; base64Decode( in, out ); - return QCString( out.data(), out.size()+1 ); + return Q3CString( out.data(), out.size()+1 ); } void KCodecs::base64Decode( const QByteArray& in, QByteArray& out ) { out.resize(0); if ( in.isEmpty() ) return; unsigned int count = 0; unsigned int len = in.size(), tail = len; const char* data = in.data(); // Deal with possible *nix "BEGIN" marker!! while ( count < len && (data[count] == '\n' || data[count] == '\r' || data[count] == '\t' || data[count] == ' ') ) count++; if ( QString(data+count).left(5).lower() == "begin" ) { count += 5; while ( count < len && data[count] != '\n' && data[count] != '\r' ) count++; while ( count < len && (data[count] == '\n' || data[count] == '\r') ) count ++; data += count; tail = (len -= count); } // Find the tail end of the actual encoded data even if // there is/are trailing CR and/or LF. while ( data[tail-1] == '=' || data[tail-1] == '\n' || data[tail-1] == '\r' ) if ( data[--tail] != '=' ) len = tail; unsigned int outIdx = 0; out.resize( (count=len) ); for (unsigned int idx = 0; idx < count; idx++) { // Adhere to RFC 2045 and ignore characters // that are not part of the encoding table. unsigned char ch = data[idx]; if ((ch > 47 && ch < 58) || (ch > 64 && ch < 91) || (ch > 96 && ch < 123) || ch == '+' || ch == '/' || ch == '=') { - out.at(outIdx++) = Base64DecMap[ch]; + out[outIdx++] = Base64DecMap[ch]; } else { len--; tail--; } } // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl; // 4-byte to 3-byte conversion len = (tail>(len/4)) ? tail-(len/4) : 0; unsigned int sidx = 0, didx = 0; if ( len > 1 ) { while (didx < len-2) { - out.at(didx) = (((out.at(sidx) << 2) & 255) | ((out.at(sidx+1) >> 4) & 003)); - out.at(didx+1) = (((out.at(sidx+1) << 4) & 255) | ((out.at(sidx+2) >> 2) & 017)); - out.at(didx+2) = (((out.at(sidx+2) << 6) & 255) | (out.at(sidx+3) & 077)); + out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); + out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); + out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077)); sidx += 4; didx += 3; } } if (didx < len) - out.at(didx) = (((out.at(sidx) << 2) & 255) | ((out.at(sidx+1) >> 4) & 003)); + out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); if (++didx < len ) - out.at(didx) = (((out.at(sidx+1) << 4) & 255) | ((out.at(sidx+2) >> 2) & 017)); + out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); // Resize the output buffer if ( len == 0 || len < out.size() ) out.resize(len); } -QCString KCodecs::uuencode( const QCString& str ) +Q3CString KCodecs::uuencode( const Q3CString& str ) { if ( str.isEmpty() ) return ""; QByteArray in; in.resize( str.length() ); memcpy( in.data(), str.data(), str.length() ); return uuencode( in ); } -QCString KCodecs::uuencode( const QByteArray& in ) +Q3CString KCodecs::uuencode( const QByteArray& in ) { QByteArray out; uuencode( in, out ); - return QCString( out.data(), out.size()+1 ); + return Q3CString( out.data(), out.size()+1 ); } void KCodecs::uuencode( const QByteArray& in, QByteArray& out ) { out.resize( 0 ); if( in.isEmpty() ) return; unsigned int sidx = 0; unsigned int didx = 0; unsigned int line_len = 45; const char nl[] = "\n"; const char* data = in.data(); const unsigned int nl_len = strlen(nl); const unsigned int len = in.size(); out.resize( (len+2)/3*4 + ((len+line_len-1)/line_len)*(nl_len+1) ); // split into lines, adding line-length and line terminator while (sidx+line_len < len) { // line length - out.at(didx++) = UUEncMap[line_len]; + out[didx++] = UUEncMap[line_len]; // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion for (unsigned int end = sidx+line_len; sidx < end; sidx += 3) { - out.at(didx++) = UUEncMap[(data[sidx] >> 2) & 077]; - out.at(didx++) = UUEncMap[(data[sidx+1] >> 4) & 017 | + out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; + out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 | (data[sidx] << 4) & 077]; - out.at(didx++) = UUEncMap[(data[sidx+2] >> 6) & 003 | + out[didx++] = UUEncMap[(data[sidx+2] >> 6) & 003 | (data[sidx+1] << 2) & 077]; - out.at(didx++) = UUEncMap[data[sidx+2] & 077]; + out[didx++] = UUEncMap[data[sidx+2] & 077]; } // line terminator //for (unsigned int idx=0; idx < nl_len; idx++) - //out.at(didx++) = nl[idx]; + //out[didx++] = nl[idx]; memcpy(out.data()+didx, nl, nl_len); didx += nl_len; } // line length - out.at(didx++) = UUEncMap[len-sidx]; + out[didx++] = UUEncMap[len-sidx]; // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion while (sidx+2 < len) { - out.at(didx++) = UUEncMap[(data[sidx] >> 2) & 077]; - out.at(didx++) = UUEncMap[(data[sidx+1] >> 4) & 017 | + out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; + out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 | (data[sidx] << 4) & 077]; - out.at(didx++) = UUEncMap[(data[sidx+2] >> 6) & 003 | + out[didx++] = UUEncMap[(data[sidx+2] >> 6) & 003 | (data[sidx+1] << 2) & 077]; - out.at(didx++) = UUEncMap[data[sidx+2] & 077]; + out[didx++] = UUEncMap[data[sidx+2] & 077]; sidx += 3; } if (sidx < len-1) { - out.at(didx++) = UUEncMap[(data[sidx] >> 2) & 077]; - out.at(didx++) = UUEncMap[(data[sidx+1] >> 4) & 017 | + out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; + out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 | (data[sidx] << 4) & 077]; - out.at(didx++) = UUEncMap[(data[sidx+1] << 2) & 077]; - out.at(didx++) = UUEncMap[0]; + out[didx++] = UUEncMap[(data[sidx+1] << 2) & 077]; + out[didx++] = UUEncMap[0]; } else if (sidx < len) { - out.at(didx++) = UUEncMap[(data[sidx] >> 2) & 077]; - out.at(didx++) = UUEncMap[(data[sidx] << 4) & 077]; - out.at(didx++) = UUEncMap[0]; - out.at(didx++) = UUEncMap[0]; + out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; + out[didx++] = UUEncMap[(data[sidx] << 4) & 077]; + out[didx++] = UUEncMap[0]; + out[didx++] = UUEncMap[0]; } // line terminator memcpy(out.data()+didx, nl, nl_len); didx += nl_len; // sanity check if ( didx != out.size() ) out.resize( 0 ); } -QCString KCodecs::uudecode( const QCString& str ) +Q3CString KCodecs::uudecode( const Q3CString& str ) { if ( str.isEmpty() ) return ""; QByteArray in; in.resize( str.length() ); memcpy( in.data(), str.data(), str.length() ); return uudecode( in ); } -QCString KCodecs::uudecode( const QByteArray& in ) +Q3CString KCodecs::uudecode( const QByteArray& in ) { QByteArray out; uudecode( in, out ); - return QCString( out.data(), out.size()+1 ); + return Q3CString( out.data(), out.size()+1 ); } void KCodecs::uudecode( const QByteArray& in, QByteArray& out ) { out.resize( 0 ); if( in.isEmpty() ) return; unsigned int sidx = 0; unsigned int didx = 0; unsigned int len = in.size(); unsigned int line_len, end; const char* data = in.data(); // Deal with *nix "BEGIN"/"END" separators!! unsigned int count = 0; while ( count < len && (data[count] == '\n' || data[count] == '\r' || data[count] == '\t' || data[count] == ' ') ) count ++; bool hasLF = false; if ( QString( data+count).left(5).lower() == "begin" ) { count += 5; while ( count < len && data[count] != '\n' && data[count] != '\r' ) count ++; while ( count < len && (data[count] == '\n' || data[count] == '\r') ) count ++; data += count; len -= count; hasLF = true; } out.resize( len/4*3 ); while ( sidx < len ) { // get line length (in number of encoded octets) line_len = UUDecMap[ (unsigned char) data[sidx++]]; // ascii printable to 0-63 and 4-byte to 3-byte conversion end = didx+line_len; char A, B, C, D; if (end > 2) { while (didx < end-2) { A = UUDecMap[(unsigned char) data[sidx]]; B = UUDecMap[(unsigned char) data[sidx+1]]; C = UUDecMap[(unsigned char) data[sidx+2]]; D = UUDecMap[(unsigned char) data[sidx+3]]; - out.at(didx++) = ( ((A << 2) & 255) | ((B >> 4) & 003) ); - out.at(didx++) = ( ((B << 4) & 255) | ((C >> 2) & 017) ); - out.at(didx++) = ( ((C << 6) & 255) | (D & 077) ); + out[didx++] = ( ((A << 2) & 255) | ((B >> 4) & 003) ); + out[didx++] = ( ((B << 4) & 255) | ((C >> 2) & 017) ); + out[didx++] = ( ((C << 6) & 255) | (D & 077) ); sidx += 4; } } if (didx < end) { A = UUDecMap[(unsigned char) data[sidx]]; B = UUDecMap[(unsigned char) data[sidx+1]]; - out.at(didx++) = ( ((A << 2) & 255) | ((B >> 4) & 003) ); + out[didx++] = ( ((A << 2) & 255) | ((B >> 4) & 003) ); } if (didx < end) { B = UUDecMap[(unsigned char) data[sidx+1]]; C = UUDecMap[(unsigned char) data[sidx+2]]; - out.at(didx++) = ( ((B << 4) & 255) | ((C >> 2) & 017) ); + out[didx++] = ( ((B << 4) & 255) | ((C >> 2) & 017) ); } // skip padding while (sidx < len && data[sidx] != '\n' && data[sidx] != '\r') sidx++; // skip end of line while (sidx < len && (data[sidx] == '\n' || data[sidx] == '\r')) sidx++; // skip the "END" separator when present. if ( hasLF && QString( data+sidx).left(3).lower() == "end" ) break; } if ( didx < out.size() ) out.resize( didx ); } /******************************** KMD5 ********************************/ KMD5::KMD5() { init(); } KMD5::KMD5(const char *in, int len) { init(); update(in, len); } KMD5::KMD5(const QByteArray& in) { init(); update( in ); } -KMD5::KMD5(const QCString& in) +KMD5::KMD5(const Q3CString& in) { init(); update( in ); } void KMD5::update(const QByteArray& in) { update(in.data(), int(in.size())); } -void KMD5::update(const QCString& in) +void KMD5::update(const Q3CString& in) { update(in.data(), int(in.length())); } void KMD5::update(const unsigned char* in, int len) { if (len < 0) len = qstrlen(reinterpret_cast<const char*>(in)); if (!len) return; if (m_finalized) { kdWarning() << "KMD5::update called after state was finalized!" << endl; return; } Q_UINT32 in_index; Q_UINT32 buffer_index; Q_UINT32 buffer_space; Q_UINT32 in_length = static_cast<Q_UINT32>( len ); buffer_index = static_cast<Q_UINT32>((m_count[0] >> 3) & 0x3F); if ( (m_count[0] += (in_length << 3))<(in_length << 3) ) m_count[1]++; m_count[1] += (in_length >> 29); buffer_space = 64 - buffer_index; if (in_length >= buffer_space) { memcpy (m_buffer + buffer_index, in, buffer_space); transform (m_buffer); for (in_index = buffer_space; in_index + 63 < in_length; in_index += 64) transform (reinterpret_cast<const unsigned char*>(in+in_index)); buffer_index = 0; } else in_index=0; memcpy(m_buffer+buffer_index, in+in_index, in_length-in_index); } bool KMD5::update(QIODevice& file) { char buffer[1024]; int len; while ((len=file.readBlock(reinterpret_cast<char*>(buffer), sizeof(buffer))) > 0) update(buffer, len); return file.atEnd(); } void KMD5::finalize () { if (m_finalized) return; Q_UINT8 bits[8]; Q_UINT32 index, padLen; static unsigned char PADDING[64]= { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; encode (bits, m_count, 8); //memcpy( bits, m_count, 8 ); // Pad out to 56 mod 64. index = static_cast<Q_UINT32>((m_count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); update (reinterpret_cast<const char*>(PADDING), padLen); // Append length (before padding) update (reinterpret_cast<const char*>(bits), 8); // Store state in digest encode (m_digest, m_state, 16); //memcpy( m_digest, m_state, 16 ); // Fill sensitive information with zero's memset ( (void *)m_buffer, 0, sizeof(*m_buffer)); m_finalized = true; } bool KMD5::verify( const KMD5::Digest& digest) { finalize(); return (0 == memcmp(rawDigest(), digest, sizeof(KMD5::Digest))); } -bool KMD5::verify( const QCString& hexdigest) +bool KMD5::verify( const Q3CString& hexdigest) { finalize(); return (0 == strcmp(hexDigest().data(), hexdigest)); } const KMD5::Digest& KMD5::rawDigest() { finalize(); return m_digest; } void KMD5::rawDigest( KMD5::Digest& bin ) { finalize(); memcpy( bin, m_digest, 16 ); } -QCString KMD5::hexDigest() +Q3CString KMD5::hexDigest() { - QCString s(33); + Q3CString s(33); finalize(); sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], m_digest[12], m_digest[13], m_digest[14], m_digest[15]); return s; } -void KMD5::hexDigest(QCString& s) +void KMD5::hexDigest(Q3CString& s) { finalize(); s.resize(33); sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], m_digest[12], m_digest[13], m_digest[14], m_digest[15]); } -QCString KMD5::base64Digest() +Q3CString KMD5::base64Digest() { QByteArray ba(16); finalize(); memcpy(ba.data(), m_digest, 16); return KCodecs::base64Encode(ba); } void KMD5::init() { d = 0; reset(); } void KMD5::reset() { m_finalized = false; m_count[0] = 0; m_count[1] = 0; m_state[0] = 0x67452301; m_state[1] = 0xefcdab89; m_state[2] = 0x98badcfe; m_state[3] = 0x10325476; memset ( m_buffer, 0, sizeof(*m_buffer)); memset ( m_digest, 0, sizeof(*m_digest)); } void KMD5::transform( const unsigned char block[64] ) { Q_UINT32 a = m_state[0], b = m_state[1], c = m_state[2], d = m_state[3], x[16]; decode (x, block, 64); //memcpy( x, block, 64 ); //US Q_ASSERT(!m_finalized); // not just a user error, since the method is private - ASSERT(!m_finalized); // not just a user error, since the method is private + Q_ASSERT(!m_finalized); // not just a user error, since the method is private /* Round 1 */ FF (a, b, c, d, x[ 0], KMD5_S11, 0xd76aa478); /* 1 */ FF (d, a, b, c, x[ 1], KMD5_S12, 0xe8c7b756); /* 2 */ FF (c, d, a, b, x[ 2], KMD5_S13, 0x242070db); /* 3 */ FF (b, c, d, a, x[ 3], KMD5_S14, 0xc1bdceee); /* 4 */ FF (a, b, c, d, x[ 4], KMD5_S11, 0xf57c0faf); /* 5 */ FF (d, a, b, c, x[ 5], KMD5_S12, 0x4787c62a); /* 6 */ FF (c, d, a, b, x[ 6], KMD5_S13, 0xa8304613); /* 7 */ FF (b, c, d, a, x[ 7], KMD5_S14, 0xfd469501); /* 8 */ FF (a, b, c, d, x[ 8], KMD5_S11, 0x698098d8); /* 9 */ FF (d, a, b, c, x[ 9], KMD5_S12, 0x8b44f7af); /* 10 */ FF (c, d, a, b, x[10], KMD5_S13, 0xffff5bb1); /* 11 */ FF (b, c, d, a, x[11], KMD5_S14, 0x895cd7be); /* 12 */ FF (a, b, c, d, x[12], KMD5_S11, 0x6b901122); /* 13 */ FF (d, a, b, c, x[13], KMD5_S12, 0xfd987193); /* 14 */ FF (c, d, a, b, x[14], KMD5_S13, 0xa679438e); /* 15 */ FF (b, c, d, a, x[15], KMD5_S14, 0x49b40821); /* 16 */ /* Round 2 */ GG (a, b, c, d, x[ 1], KMD5_S21, 0xf61e2562); /* 17 */ GG (d, a, b, c, x[ 6], KMD5_S22, 0xc040b340); /* 18 */ GG (c, d, a, b, x[11], KMD5_S23, 0x265e5a51); /* 19 */ GG (b, c, d, a, x[ 0], KMD5_S24, 0xe9b6c7aa); /* 20 */ GG (a, b, c, d, x[ 5], KMD5_S21, 0xd62f105d); /* 21 */ GG (d, a, b, c, x[10], KMD5_S22, 0x2441453); /* 22 */ GG (c, d, a, b, x[15], KMD5_S23, 0xd8a1e681); /* 23 */ GG (b, c, d, a, x[ 4], KMD5_S24, 0xe7d3fbc8); /* 24 */ GG (a, b, c, d, x[ 9], KMD5_S21, 0x21e1cde6); /* 25 */ GG (d, a, b, c, x[14], KMD5_S22, 0xc33707d6); /* 26 */ GG (c, d, a, b, x[ 3], KMD5_S23, 0xf4d50d87); /* 27 */ GG (b, c, d, a, x[ 8], KMD5_S24, 0x455a14ed); /* 28 */ GG (a, b, c, d, x[13], KMD5_S21, 0xa9e3e905); /* 29 */ GG (d, a, b, c, x[ 2], KMD5_S22, 0xfcefa3f8); /* 30 */ GG (c, d, a, b, x[ 7], KMD5_S23, 0x676f02d9); /* 31 */ GG (b, c, d, a, x[12], KMD5_S24, 0x8d2a4c8a); /* 32 */ /* Round 3 */ HH (a, b, c, d, x[ 5], KMD5_S31, 0xfffa3942); /* 33 */ HH (d, a, b, c, x[ 8], KMD5_S32, 0x8771f681); /* 34 */ HH (c, d, a, b, x[11], KMD5_S33, 0x6d9d6122); /* 35 */ HH (b, c, d, a, x[14], KMD5_S34, 0xfde5380c); /* 36 */ HH (a, b, c, d, x[ 1], KMD5_S31, 0xa4beea44); /* 37 */ HH (d, a, b, c, x[ 4], KMD5_S32, 0x4bdecfa9); /* 38 */ HH (c, d, a, b, x[ 7], KMD5_S33, 0xf6bb4b60); /* 39 */ HH (b, c, d, a, x[10], KMD5_S34, 0xbebfbc70); /* 40 */ HH (a, b, c, d, x[13], KMD5_S31, 0x289b7ec6); /* 41 */ HH (d, a, b, c, x[ 0], KMD5_S32, 0xeaa127fa); /* 42 */ HH (c, d, a, b, x[ 3], KMD5_S33, 0xd4ef3085); /* 43 */ HH (b, c, d, a, x[ 6], KMD5_S34, 0x4881d05); /* 44 */ HH (a, b, c, d, x[ 9], KMD5_S31, 0xd9d4d039); /* 45 */ HH (d, a, b, c, x[12], KMD5_S32, 0xe6db99e5); /* 46 */ HH (c, d, a, b, x[15], KMD5_S33, 0x1fa27cf8); /* 47 */ HH (b, c, d, a, x[ 2], KMD5_S34, 0xc4ac5665); /* 48 */ /* Round 4 */ II (a, b, c, d, x[ 0], KMD5_S41, 0xf4292244); /* 49 */ II (d, a, b, c, x[ 7], KMD5_S42, 0x432aff97); /* 50 */ II (c, d, a, b, x[14], KMD5_S43, 0xab9423a7); /* 51 */ II (b, c, d, a, x[ 5], KMD5_S44, 0xfc93a039); /* 52 */ II (a, b, c, d, x[12], KMD5_S41, 0x655b59c3); /* 53 */ II (d, a, b, c, x[ 3], KMD5_S42, 0x8f0ccc92); /* 54 */ II (c, d, a, b, x[10], KMD5_S43, 0xffeff47d); /* 55 */ II (b, c, d, a, x[ 1], KMD5_S44, 0x85845dd1); /* 56 */ II (a, b, c, d, x[ 8], KMD5_S41, 0x6fa87e4f); /* 57 */ II (d, a, b, c, x[15], KMD5_S42, 0xfe2ce6e0); /* 58 */ II (c, d, a, b, x[ 6], KMD5_S43, 0xa3014314); /* 59 */ II (b, c, d, a, x[13], KMD5_S44, 0x4e0811a1); /* 60 */ II (a, b, c, d, x[ 4], KMD5_S41, 0xf7537e82); /* 61 */ II (d, a, b, c, x[11], KMD5_S42, 0xbd3af235); /* 62 */ II (c, d, a, b, x[ 2], KMD5_S43, 0x2ad7d2bb); /* 63 */ II (b, c, d, a, x[ 9], KMD5_S44, 0xeb86d391); /* 64 */ m_state[0] += a; m_state[1] += b; m_state[2] += c; m_state[3] += d; memset ( static_cast<void *>(x), 0, sizeof(x) ); } inline Q_UINT32 KMD5::rotate_left (Q_UINT32 x, Q_UINT32 n) { return (x << n) | (x >> (32-n)) ; } inline Q_UINT32 KMD5::F (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z) { return (x & y) | (~x & z); } inline Q_UINT32 KMD5::G (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z) { return (x & z) | (y & ~z); } inline Q_UINT32 KMD5::H (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z) { return x ^ y ^ z; } inline Q_UINT32 KMD5::I (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z) { return y ^ (x | ~z); } void KMD5::FF ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ) { a += F(b, c, d) + x + ac; a = rotate_left (a, s) +b; } void KMD5::GG ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac) { a += G(b, c, d) + x + ac; a = rotate_left (a, s) +b; } void KMD5::HH ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ) { a += H(b, c, d) + x + ac; a = rotate_left (a, s) +b; } void KMD5::II ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ) { a += I(b, c, d) + x + ac; a = rotate_left (a, s) +b; } void KMD5::encode ( unsigned char* output, Q_UINT32 *in, Q_UINT32 len ) { #if !defined(WORDS_BIGENDIAN) memcpy(output, in, len); #else Q_UINT32 i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[j] = static_cast<Q_UINT8>((in[i] & 0xff)); output[j+1] = static_cast<Q_UINT8>(((in[i] >> 8) & 0xff)); output[j+2] = static_cast<Q_UINT8>(((in[i] >> 16) & 0xff)); output[j+3] = static_cast<Q_UINT8>(((in[i] >> 24) & 0xff)); } #endif } // Decodes in (Q_UINT8) into output (Q_UINT32). Assumes len is a // multiple of 4. void KMD5::decode (Q_UINT32 *output, const unsigned char* in, Q_UINT32 len) { #if !defined(WORDS_BIGENDIAN) memcpy(output, in, len); #else Q_UINT32 i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = static_cast<Q_UINT32>(in[j]) | (static_cast<Q_UINT32>(in[j+1]) << 8) | (static_cast<Q_UINT32>(in[j+2]) << 16) | (static_cast<Q_UINT32>(in[j+3]) << 24); #endif } diff --git a/microkde/kdecore/kmdcodec.h b/microkde/kdecore/kmdcodec.h index 2c4d611..616b683 100644 --- a/microkde/kdecore/kmdcodec.h +++ b/microkde/kdecore/kmdcodec.h @@ -1,572 +1,574 @@ /* Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) version 2 as published by the Free Software Foundation. This program 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 General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. RSA Data Security, Inc. Created 1991. All rights reserved. The KMD5 class is based on a C++ implementation of "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by Mordechai T. Abzug, Copyright (c) 1995. This implementation passes the test-suite as defined in RFC 1321. The encoding and decoding utilities in KCodecs with the exception of quoted-printable are based on the java implementation in HTTPClient package by Ronald Tschalär Copyright (C) 1996-1999. The quoted-printable codec as described in RFC 2045, section 6.7. is by Rik Hemsley (C) 2001. */ #ifndef _KMDBASE_H #define _KMDBASE_H #define KBase64 KCodecs #include <qglobal.h> #include <qstring.h> #include <qiodevice.h> +//Added by qt3to4: +#include <Q3CString> /** * A wrapper class for the most commonly used encoding and * decoding algorithms. Currently there is support for encoding * and decoding input using base64, uu and the quoted-printable * specifications. * * @sect Usage: * * <PRE> * QCString input = "Aladdin:open sesame"; * QCString result = KCodecs::base64Encode(input); * cout << "Result: " << result.data() << endl; * * Output should be * Result: QWxhZGRpbjpvcGVuIHNlc2FtZQ== * </PRE> * * The above example makes use of the convenience functions * (ones that accept/return null-terminated strings) to encode/decode * a string. If what you need is to encode or decode binary data, then * it is highly recommended that you use the functions that take an input * and output QByteArray as arguments. These functions are specifically * tailored for encoding and decoding binary data. * * @short A collection of commonly used encoding and decoding algorithms. * @author Dawit Alemayehu <adawit@kde.org> * @author Rik Hemsley <rik@kde.org> */ class KCodecs { public: /** * Encodes the given data using the quoted-printable algorithm. * * @param in data to be encoded. * @param useCRLF if true the input data is expected to have * CRLF line breaks and the output will have CRLF line * breaks, too. * @return quoted-printable encoded data. */ - static QCString quotedPrintableEncode(const QByteArray & in, + static Q3CString quotedPrintableEncode(const QByteArray & in, bool useCRLF = true); /** * @overload * * Same as above except it accepts a null terminated * string instead an array. * * @param str data to be encoded. * @param useCRLF if true the input data is expected to have * CRLF line breaks and the output will have CRLF line * breaks, too. * @return quoted-printable encoded data. */ - static QCString quotedPrintableEncode(const QCString & str, + static Q3CString quotedPrintableEncode(const Q3CString & str, bool useCRLF = true); /** * Encodes the given data using the quoted-printable algorithm. * * Use this function if you want the result of the encoding * to be placed in another array which cuts down the number * of copy operation that have to be performed in the process. * This is also the preferred method for encoding binary data. * * NOTE: the output array is first reset and then resized * appropriately before use, hence, all data stored in the * output array will be lost. * * @param in data to be encoded. * @param out decoded data. * @param useCRLF if true the input data is expected to have * CRLF line breaks and the output will have CRLF line * breaks, too. * @return quoted-printable encoded data. */ static void quotedPrintableEncode(const QByteArray & in, QByteArray& out, bool useCRLF); /** * Decodes a quoted-printable encoded string. * * Accepts data with CRLF or standard unix line breaks. * * @param in the data to be decoded. * @return decoded data. */ - static QCString quotedPrintableDecode(const QByteArray & in); + static Q3CString quotedPrintableDecode(const QByteArray & in); /** * @overload * * Same as above except it accepts a null terminated * string instead an array. * * @param str the data to be decoded. * @return decoded data. */ - static QCString quotedPrintableDecode(const QCString & str); + static Q3CString quotedPrintableDecode(const Q3CString & str); /** * Decodes a quoted-printable encoded data. * * Accepts data with CRLF or standard unix line breaks. * Use this function if you want the result of the decoding * to be placed in another array which cuts down the number * of copy operation that have to be performed in the process. * This is also the preferred method for decoding an encoded * binary data. * * NOTE: the output array is first reset and then resized * appropriately before use, hence, all data stored in the * output array will be lost. * * @param in data to be encoded. * @param out decoded data. * * @return quoted-printable encoded data. */ static void quotedPrintableDecode(const QByteArray & in, QByteArray& out); /** * Encodes the given data using the uuencode algorithm. * * The output is split into lines starting with the number of * encoded octets in the line and ending with a newline. No * line is longer than 45 octets (60 characters), excluding the * line terminator. * * @param in the data to be uuencoded * @return a uuencoded data. */ - static QCString uuencode( const QByteArray& in ); + static Q3CString uuencode( const QByteArray& in ); /** * @overload * * Same as the above functions except it accepts * a null terminated string instead an array. * * @param str the string to be uuencoded. * @return the encoded string. */ - static QCString uuencode( const QCString& str ); + static Q3CString uuencode( const Q3CString& str ); /** * Encodes the given data using the uuencode algorithm. * * Use this function if you want the result of the encoding * to be placed in another array and cut down the number of * copy operation that have to be performed in the process. * This is the preffered method for encoding binary data. * * NOTE: the output array is first reset and then resized * appropriately before use, hence, all data stored in the * output array will be lost. * * @param in the data to be uuencoded. * @param out the container for the uudecoded data. */ static void uuencode( const QByteArray& in, QByteArray& out ); /** * Decodes the given data using the uuencode algorithm. * * Any 'begin' and 'end' lines like those generated by * the utilities in unix and unix-like OS will be * automatically ignored. * * @param in the data uuencoded data to be decoded. * @return a decoded string. */ - static QCString uudecode( const QByteArray& in ); + static Q3CString uudecode( const QByteArray& in ); /** * @overload * * Same as the above functions except it accepts * a null terminated string instead an array. * * @param str the string to be decoded. * @return a uudecoded string. */ - static QCString uudecode( const QCString& str ); + static Q3CString uudecode( const Q3CString& str ); /** * Decodes the given data using the uudecode algorithm. * * Use this function if you want the result of the decoding * to be placed in another array which cuts down the number * of copy operation that have to be performed in the process. * This is the preferred method for decoding binary data. * * Any 'begin' and 'end' lines like those generated by * the utilities in unix and unix-like OS will be * automatically ignored. * * NOTE: the output array is first reset and then resized * appropriately before use, hence, all data stored in the * output array will be lost. * * @param in the uuencoded-data to be decoded. * @param out the container for the uudecoded data. */ static void uudecode( const QByteArray& in, QByteArray& out ); /** * Encodes the given data using the base64 algorithm. * * The boolean argument determines if the encoded data is * going to be restricted to 76 characters or less per line * as specified by RFC 2045. If @p insertLFs is true, then * there will be 76 characters or less per line. * * @param in the data to be encoded. * @param insertLFs limit the number of characters per line. * * @return a base64 encoded string. */ - static QCString base64Encode( const QByteArray& in, bool insertLFs = false); + static Q3CString base64Encode( const QByteArray& in, bool insertLFs = false); /** * @overload * * Same as the above functions except it accepts * a null terminated string instead an array. * * @param str the string to be encoded. * @param insertLFs limit the number of characters per line. * @return the decoded string. */ - static QCString base64Encode( const QCString& str, bool insertLFs = false ); + static Q3CString base64Encode( const Q3CString& str, bool insertLFs = false ); /** * Encodes the given data using the base64 algorithm. * * Use this function if you want the result of the encoding * to be placed in another array which cuts down the number * of copy operation that have to be performed in the process. * This is also the preferred method for encoding binary data. * * The boolean argument determines if the encoded data is going * to be restricted to 76 characters or less per line as specified * by RFC 2045. If @p insertLFs is true, then there will be 76 * characters or less per line. * * NOTE: the output array is first reset and then resized * appropriately before use, hence, all data stored in the * output array will be lost. * * @param in the data to be encoded using base64. * @param out the container for the encoded data. * @param insertLFs limit the number of characters per line. */ static void base64Encode( const QByteArray& in, QByteArray& out, bool insertLFs = false ); /** * Decodes the given data that was encoded using the * base64 algorithm. * * @param in the base64-encoded data to be decoded. * @return the decoded data. */ - static QCString base64Decode( const QByteArray& in ); + static Q3CString base64Decode( const QByteArray& in ); /** * @overload * * Same as the above functions except it accepts * a null terminated string instead an array. * * @param str the base64-encoded string. * @return the decoded string. */ - static QCString base64Decode( const QCString& str ); + static Q3CString base64Decode( const Q3CString& str ); /** * Decodes the given data that was encoded with the base64 * algorithm. * * Use this function if you want the result of the decoding * to be placed in another array which cuts down the number * of copy operation that have to be performed in the process. * This is also the preferred method for decoding an encoded * binary data. * * NOTE: the output array is first reset and then resized * appropriately before use, hence, all data stored in the * output array will be lost. * * @param in the encoded data to be decoded. * @param out the container for the decoded data. */ static void base64Decode( const QByteArray& in, QByteArray& out ); private: KCodecs(); private: static const char UUEncMap[64]; static const char UUDecMap[128]; static const char Base64EncMap[64]; static const char Base64DecMap[128]; static const char hexChars[16]; static const unsigned int maxQPLineLength; }; class KMD5Private; /** * Provides an easy to use C++ implementation of RSA's * MD5 algorithm. * * The default constructor is designed to provide much the same * functionality as the most commonly used C-implementation, while * the other three constructors are meant to further simplify the * process of obtaining a digest by calculating the result in a * single step. * * KMD5 is state-based, that means you can add new contents with * update() as long as you didn't request the digest value yet. * After the digest value was requested, the object is "finalized" * and you have to call reset() to be able to do another calculation * with it. The reason for this behaviour is that upon requesting * the message digest KMD5 has to pad the received contents up to a * 64 byte boundary to calculate its value. After this operation it * is not possible to resume consuming data. * * @sect Usage: * * A common usage of this class: * * <PRE> * const char* test1; * KMD5::Digest rawResult; * * test1 = "This is a simple test."; * KMD5 context (test1); * cout << "Hex Digest output: " << context.hexDigest().data() << endl; * </PRE> * * To cut down on the unnecessary overhead of creating multiple KMD5 * objects, you can simply invoke @ref reset() to reuse the same object * in making another calculation: * * <PRE> * context.reset (); * context.update ("TWO"); * context.update ("THREE"); * cout << "Hex Digest output: " << context.hexDigest().data() << endl; * </PRE> * * @short An adapted C++ implementation of RSA Data Securities MD5 algorithm. * @author Dirk Mueller <mueller@kde.org>, Dawit Alemayehu <adawit@kde.org> */ class KMD5 { public: typedef unsigned char Digest[16]; KMD5(); /** * Constructor that updates the digest for the given string. * * @param in C string or binary data * @param len if negative, calculates the length by using * strlen on the first parameter, otherwise * it trusts the given length (does not stop on NUL byte). */ KMD5(const char* in, int len = -1); /** * @overload * * Same as above except it accepts a QByteArray as its argument. */ KMD5(const QByteArray& a ); /** * @overload * * Same as above except it accepts a QByteArray as its argument. */ - KMD5(const QCString& a ); + KMD5(const Q3CString& a ); /** * Updates the message to be digested. Be sure to add all data * before you read the digest. After reading the digest, you * can <b>not</b> add more data! * * @param in message to be added to digest * @param len the length of the given message. */ void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); } /** * @overload */ void update(const unsigned char* in, int len = -1); /** * @overload * * @param in message to be added to the digest (QByteArray). */ void update(const QByteArray& in ); /** * @overload * * @param in message to be added to the digest (QByteArray). */ - void update(const QCString& in ); + void update(const Q3CString& in ); /** * @overload * * reads the data from an I/O device, i.e. from a file (QFile). * * NOTE that the file must be open for reading. * * @param file a pointer to FILE as returned by calls like f{d,re}open * * @returns false if an error occured during reading. */ bool update(QIODevice& file); /** * Calling this function will reset the calculated message digest. * Use this method to perform another message digest calculation * without recreating the KMD5 object. */ void reset(); /** * @return the raw representation of the digest */ const Digest& rawDigest (); /** * Fills the given array with the binary representation of the * message digest. * * Use this method if you do not want to worry about making * copy of the digest once you obtain it. * * @param bin an array of 16 characters ( char[16] ) */ void rawDigest( KMD5::Digest& bin ); /** * Returns the value of the calculated message digest in * a hexadecimal representation. */ - QCString hexDigest (); + Q3CString hexDigest (); /** * @overload */ - void hexDigest(QCString&); + void hexDigest(Q3CString&); /** * Returns the value of the calculated message digest in * a base64-encoded representation. */ - QCString base64Digest (); + Q3CString base64Digest (); /** * returns true if the calculated digest for the given * message matches the given one. */ bool verify( const KMD5::Digest& digest); /** * @overload */ - bool verify(const QCString&); + bool verify(const Q3CString&); protected: /** * Performs the real update work. Note * that length is implied to be 64. */ void transform( const unsigned char buffer[64] ); /** * finalizes the digest */ void finalize(); private: KMD5(const KMD5& u); KMD5& operator=(const KMD5& md); void init(); void encode( unsigned char* output, Q_UINT32 *in, Q_UINT32 len ); void decode( Q_UINT32 *output, const unsigned char* in, Q_UINT32 len ); Q_UINT32 rotate_left( Q_UINT32 x, Q_UINT32 n ); Q_UINT32 F( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z ); Q_UINT32 G( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z ); Q_UINT32 H( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z ); Q_UINT32 I( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z ); void FF( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ); void GG( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ); void HH( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ); void II( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ); private: Q_UINT32 m_state[4]; Q_UINT32 m_count[2]; Q_UINT8 m_buffer[64]; Digest m_digest; bool m_finalized; KMD5Private* d; }; #endif diff --git a/microkde/kdecore/kprefs.cpp b/microkde/kdecore/kprefs.cpp index 0220a34..d4010fa 100644 --- a/microkde/kdecore/kprefs.cpp +++ b/microkde/kdecore/kprefs.cpp @@ -1,512 +1,514 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@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 as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. */ // $Id$ #include <qcolor.h> +//Added by qt3to4: +#include <Q3ValueList> #include <kconfig.h> #include <kstandarddirs.h> #include <kglobal.h> #include <kdebug.h> #include "kprefs.h" class KPrefsItemBool : public KPrefsItem { public: KPrefsItemBool(const QString &group,const QString &name,bool *,bool defaultValue=true); virtual ~KPrefsItemBool() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: bool *mReference; bool mDefault; }; class KPrefsItemInt : public KPrefsItem { public: KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); virtual ~KPrefsItemInt() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: int *mReference; int mDefault; }; class KPrefsItemColor : public KPrefsItem { public: KPrefsItemColor(const QString &group,const QString &name,QColor *, const QColor &defaultValue=QColor(128,128,128)); virtual ~KPrefsItemColor() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: QColor *mReference; QColor mDefault; }; class KPrefsItemSize : public KPrefsItem { public: KPrefsItemSize(const QString &group,const QString &name,QSize *, const QSize &defaultValue=QSize()); ~KPrefsItemSize() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: QSize *mReference; QSize mDefault; }; class KPrefsItemFont : public KPrefsItem { public: KPrefsItemFont(const QString &group,const QString &name,QFont *, const QFont &defaultValue=QFont("helvetica",12)); virtual ~KPrefsItemFont() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: QFont *mReference; QFont mDefault; }; class KPrefsItemString : public KPrefsItem { public: KPrefsItemString(const QString &group,const QString &name,QString *, const QString &defaultValue="", bool isPassword=false); virtual ~KPrefsItemString() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: QString *mReference; QString mDefault; bool mPassword; }; class KPrefsItemStringList : public KPrefsItem { public: KPrefsItemStringList(const QString &group,const QString &name,QStringList *, const QStringList &defaultValue=QStringList()); virtual ~KPrefsItemStringList() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: QStringList *mReference; QStringList mDefault; }; class KPrefsItemIntList : public KPrefsItem { public: - KPrefsItemIntList(const QString &group,const QString &name,QValueList<int> *, - const QValueList<int> &defaultValue=QValueList<int>()); + KPrefsItemIntList(const QString &group,const QString &name,Q3ValueList<int> *, + const Q3ValueList<int> &defaultValue=Q3ValueList<int>()); virtual ~KPrefsItemIntList() {} void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); private: - QValueList<int> *mReference; - QValueList<int> mDefault; + Q3ValueList<int> *mReference; + Q3ValueList<int> mDefault; }; KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name, bool *reference,bool defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemBool::setDefault() { *mReference = mDefault; } void KPrefsItemBool::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemBool::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readBoolEntry(mName,mDefault); } KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name, int *reference,int defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemInt::setDefault() { *mReference = mDefault; } void KPrefsItemInt::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemInt::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readNumEntry(mName,mDefault); } KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name, QColor *reference,const QColor &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemColor::setDefault() { *mReference = mDefault; } void KPrefsItemColor::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemColor::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readColorEntry(mName,&mDefault); } KPrefsItemSize::KPrefsItemSize(const QString &group,const QString &name, QSize *reference,const QSize &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemSize::setDefault() { *mReference = mDefault; } void KPrefsItemSize::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemSize::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readSizeEntry(mName,&mDefault); } KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name, QFont *reference,const QFont &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemFont::setDefault() { *mReference = mDefault; } void KPrefsItemFont::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemFont::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readFontEntry(mName,&mDefault); } QString endecryptStr( const QString &aStr ) { QString result; uint i; for ( i = 0; i < aStr.length(); i++) result += (aStr.at(i).unicode() < 0x20) ? aStr.at(i) : QChar(0x1001F - aStr.at(i).unicode()); return result; } KPrefsItemString::KPrefsItemString(const QString &group,const QString &name, QString *reference,const QString &defaultValue, bool isPassword) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; mPassword = isPassword; } void KPrefsItemString::setDefault() { *mReference = mDefault; } void KPrefsItemString::writeConfig(KConfig *config) { config->setGroup(mGroup); if ( mPassword ) config->writeEntry(mName, endecryptStr( *mReference ) ); else config->writeEntry(mName,*mReference); } void KPrefsItemString::readConfig(KConfig *config) { config->setGroup(mGroup); QString value; if ( mPassword ) { value = config->readEntry( mName, endecryptStr( mDefault ) ); *mReference = endecryptStr( value ); } else { *mReference = config->readEntry( mName, mDefault ); } } KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name, QStringList *reference,const QStringList &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemStringList::setDefault() { *mReference = mDefault; } void KPrefsItemStringList::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemStringList::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readListEntry(mName); } KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name, - QValueList<int> *reference,const QValueList<int> &defaultValue) : + Q3ValueList<int> *reference,const Q3ValueList<int> &defaultValue) : KPrefsItem(group,name) { mReference = reference; mDefault = defaultValue; } void KPrefsItemIntList::setDefault() { *mReference = mDefault; } void KPrefsItemIntList::writeConfig(KConfig *config) { config->setGroup(mGroup); config->writeEntry(mName,*mReference); } void KPrefsItemIntList::readConfig(KConfig *config) { config->setGroup(mGroup); *mReference = config->readIntListEntry(mName); } QString *KPrefs::mCurrentGroup = 0; KPrefs::KPrefs(const QString &configname) { if (!configname.isEmpty()) { //qDebug("KPrefs::KPrefs %s",configname.latin1() ); mConfig = new KConfig(locateLocal("config",configname)); } else { qDebug("KPrefs::Global config "); mConfig = KGlobal::config(); } mItems.setAutoDelete(true); // Set default group if (mCurrentGroup == 0) mCurrentGroup = new QString("No Group"); } KPrefs::~KPrefs() { if (mConfig != KGlobal::config()) { delete mConfig; } } void KPrefs::setCurrentGroup(const QString &group) { if (mCurrentGroup) delete mCurrentGroup; mCurrentGroup = new QString(group); } KConfig *KPrefs::config() const { return mConfig; } void KPrefs::setDefaults() { KPrefsItem *item; for(item = mItems.first();item;item = mItems.next()) { item->setDefault(); } usrSetDefaults(); } void KPrefs::readConfig() { KPrefsItem *item; for(item = mItems.first();item;item = mItems.next()) { item->readConfig(mConfig); } usrReadConfig(); //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1()); } void KPrefs::writeConfig() { KPrefsItem *item; for(item = mItems.first();item;item = mItems.next()) { item->writeConfig(mConfig); } usrWriteConfig(); //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1()); mConfig->sync(); } void KPrefs::addItem(KPrefsItem *item) { mItems.append(item); } void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue) { addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue) { addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) { addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) { addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue) { addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue)); } void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) { addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); } void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) { addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); } void KPrefs::addItemStringList(const QString &key,QStringList *reference, const QStringList &defaultValue) { addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); } -void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference, - const QValueList<int> &defaultValue) +void KPrefs::addItemIntList(const QString &key,Q3ValueList<int> *reference, + const Q3ValueList<int> &defaultValue) { addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); } diff --git a/microkde/kdecore/kprefs.h b/microkde/kdecore/kprefs.h index 95d2724..d9d1572 100644 --- a/microkde/kdecore/kprefs.h +++ b/microkde/kdecore/kprefs.h @@ -1,316 +1,318 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@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 as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. */ #ifndef _KPREFS_H #define _KPREFS_H // $Id$ -#include <qptrlist.h> +#include <q3ptrlist.h> #include <qcolor.h> #include <qfont.h> #include <qsize.h> #include <qstringlist.h> +//Added by qt3to4: +#include <Q3ValueList> class KConfig; /** @short Class for storing a preferences setting @author Cornelius Schumacher @see KPref This class represents one preferences setting as used by @ref KPrefs. Subclasses of KPrefsItem implement storage functions for a certain type of setting. Normally you don't have to use this class directly. Use the special addItem() functions of KPrefs instead. If you subclass this class you will have to register instances with the function KPrefs::addItem(). */ class KPrefsItem { public: /** Constructor. @param group Config file group. @param name Config file key. */ KPrefsItem(const QString &group,const QString &name) : mGroup(group),mName(name) {} /** Destructor. */ virtual ~KPrefsItem() {} /** This function is called by @ref KPrefs to set this setting to its default value. */ virtual void setDefault() = 0; /** This function is called by @ref KPrefs to read the value for this setting from a config file. value. */ virtual void readConfig(KConfig *) = 0; /** This function is called by @ref KPrefs to write the value of this setting to a config file. */ virtual void writeConfig(KConfig *) = 0; protected: QString mGroup; QString mName; }; /** @short Class for handling preferences settings for an application. @author Cornelius Schumacher @see KPrefsItem This class provides an interface to preferences settings. Preferences items can be registered by the addItem() function corresponding to the data type of the seetting. KPrefs then handles reading and writing of config files and setting of default values. Normally you will subclass KPrefs, add data members for the preferences settings and register the members in the constructor of the subclass. Example: <pre> class MyPrefs : public KPrefs { public: MyPrefs() { setCurrentGroup("MyGroup"); addItemBool("MySetting1",&mMyBool,false); addItemColor("MySetting2",&mMyColor,QColor(1,2,3)); setCurrentGroup("MyOtherGroup"); addItemFont("MySetting3",&mMyFont,QFont("helvetica",12)); } bool mMyBool; QColor mMyColor; QFont mMyFont; } </pre> It might be convenient in many cases to make this subclass of KPrefs a singleton for global access from all over the application without passing references to the KPrefs object around. You can set all values to default values by calling @ref setDefaults(), write the data to the configuration file by calling @ref writeConfig() and read the data from the configuration file by calling @ref readConfig(). If you have items, which are not covered by the existing addItem() functions you can add customized code for reading, writing and default setting by implementing the functions @ref usrSetDefaults(), @ref usrReadConfig() and @ref usrWriteConfig(). Internally preferences settings are stored in instances of subclasses of @ref KPrefsItem. You can also add KPrefsItem subclasses for your own types and call the generic @ref addItem() to register them. */ class KPrefs { public: /** Constructor. @param configname name of config file. If no name is given, the default config file as returned by kapp()->config() is used. */ KPrefs(const QString &configname=QString::null); /** Destructor */ virtual ~KPrefs(); /** Set preferences to default values. All registered items are set to their default values. */ void setDefaults(); /** Read preferences from config file. All registered items are set to the values read from disk. */ void readConfig(); /** Write preferences to config file. The values of all registered items are written to disk. */ void writeConfig(); /** Set the config file group for subsequent addItem() calls. It is valid until setCurrentGroup() is called with a new argument. Call this before you add any items. The default value is "No Group". */ static void setCurrentGroup(const QString &group); /** Register a custom @ref KPrefsItem. */ void addItem(KPrefsItem *); /** Register an item of type bool. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ void addItemBool(const QString &key,bool *reference, bool defaultValue=false); /** Register an item of type int. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ void addItemInt(const QString &key,int *reference, int defaultValue=0); /** Register an item of type QColor. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ void addItemColor(const QString &key,QColor *reference, const QColor &defaultValue=QColor(128,128,128)); /** Register an item of type QSize. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ void addItemSize(const QString &key,QSize *reference, const QSize &defaultValue=QSize()); /** Register an item of type QFont. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ void addItemFont(const QString &key,QFont *reference, const QFont &defaultValue=QFont("helvetica",12)); /** Register an item of type QString. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ void addItemString(const QString &key,QString *reference, const QString &defaultValue=""); /** Register a password item of type QString. The string value is written encrypted to the config file. Note that the current encryption scheme is very weak. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ void addItemPassword(const QString &key,QString *reference, const QString &defaultValue=""); /** Register an item of type QStringList. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ void addItemStringList(const QString &key,QStringList *reference, const QStringList &defaultValue=QStringList()); /** Register an item of type QValueList<int>. @param key Key used in config file. @param reference Pointer to the variable, which is set by readConfig() and setDefaults() calls and read by writeConfig() calls. @param defaultValue Default value, which is used by setDefaults() and when the config file does not yet contain the key of this item. */ - void addItemIntList(const QString &key,QValueList<int> *reference, - const QValueList<int> &defaultValue=QValueList<int>()); + void addItemIntList(const QString &key,Q3ValueList<int> *reference, + const Q3ValueList<int> &defaultValue=Q3ValueList<int>()); protected: /** Implemented by subclasses that use special defaults. */ virtual void usrSetDefaults() {}; /** Implemented by subclasses that read special config values. */ virtual void usrReadConfig() {}; /** Implemented by subclasses that write special config values. */ virtual void usrWriteConfig() {}; /** Return the @ref KConfig object used for reading and writing the settings. */ KConfig *config() const; private: static QString *mCurrentGroup; KConfig *mConfig; // pointer to KConfig object - QPtrList<KPrefsItem> mItems; + Q3PtrList<KPrefsItem> mItems; }; #endif diff --git a/microkde/kdecore/kshortcut.h b/microkde/kdecore/kshortcut.h index 4813734..244d590 100644 --- a/microkde/kdecore/kshortcut.h +++ b/microkde/kdecore/kshortcut.h @@ -374,473 +374,473 @@ class KKey //US bool init( const KKeyNative& key ); /** * Copies the given key sequence over this key sequence. * @param keySeq the key sequence to copy * @return true if successful, false otherwise */ //US bool init( const KKeySequence& keySeq ); /** * Initializes this key sequence to contain the given key sequence. * The description consists of comma-separated keys as * required by @ref KKey::KKey(const QString&). * @param key the description of the key * @return true if successful, false otherwise * @see KKeyServer::Sym::init() * @see KKey::KKey(const QString&) */ //US bool init( const QString& key ); /** * Copy the given key sequence into this sequence. */ //US KKeySequence& operator =( const KKeySequence& seq ) //US { init( seq ); return *this; } /** * Returns the number of key strokes of this sequence. * @return the number of key strokes * @see MAX_KEYS */ //US uint count() const; /** * Return the @p i'th key of this sequence, or a null key if there * are less then i keys. * @param i the key to retrieve * @return the @p i'th key, or @ref KKey::null() if there are less * than i keys * @see MAX_KEYS */ //US const KKey& key( uint i ) const; /** * @internal */ //US bool isTriggerOnRelease() const; /** * Sets the @p i'th key of the sequence. You can not introduce gaps * in a sequence, so you must use an @p i <= @ref count(). Also note that * the maximum length of a key sequence is @ref MAX_KEYS. * @param i the position of the new key (<= @ref count(), <= @ref MAX_KEYS) * @param key the key to set * @return true if successful, false otherwise */ //US bool setKey( uint i, const KKey& key ); /** * @internal */ //US void setTriggerOnRelease( bool ); /** * Returns true if the key sequence is null (after @ref clear() or empty * constructor). * @return true if the key sequence is null * @see clear() * @see null() */ //US bool isNull() const; /** * Returns true if this key sequence begins with the given sequence. * @param keySeq the key sequence to search * @return true if this key sequence begins with the given sequence */ //US bool startsWith( const KKeySequence& keySeq ) const; /** * Compares this object with the given key sequence. Returns a negative * number if the given KKeySequence is larger, 0 if they are equal and * a positive number this KKeySequence is larger. Key sequences are * compared by comparing the individual keys, starting from the beginning * until an unequal key has been found. If a sequence contains more * keys, it is considered larger. * @param keySeq the key sequence to compare to * @return a negative number if the given KKeySequence is larger, 0 if * they are equal and a positive number this KKeySequence is larger * @see KKey::sequence */ //US int compare( const KKeySequence& keySeq ) const; /** * Compares the keys of both sequences. * @see compare() */ //US bool operator == ( const KKeySequence& seq ) const //US { return compare( seq ) == 0; } /** * Compares the keys of both sequences. * @see compare() */ //US bool operator != ( const KKeySequence& seq ) const //US { return compare( seq ) != 0; } /** * Compares the keys of both sequences. * @see compare() */ //US bool operator < ( const KKeySequence& seq ) const //US { return compare( seq ) < 0; } // TODO: consider adding Qt::SequenceMatch matches(...) methods for QKeySequence equivalence /** * Converts this key sequence to a QKeySequence. * @return the QKeySequence */ //US QKeySequence qt() const; /** * Returns the qt key code of the first key. * @return the qt key code of the first key * @see Qt::Key * @see KKey::keyCodeQt() */ //US int keyCodeQt() const; /** * Returns the key sequence as a number of key presses as * returned by @ref KKey::toString(), seperated by commas. * @return the string represenation of this key sequence * @see KKey::toString() */ //US QString toString() const; /** * @internal */ //US QString toStringInternal() const; /** * Returns a null key sequence. * @return the null key sequence * @see isNull() * @see clear() */ //US static KKeySequence& null(); //US protected: //US uchar m_nKeys; //US uchar m_bTriggerOnRelease; // BCI: m_rgvar should be renamed to m_rgkey for KDE 4.0 //US KKey m_rgvar[MAX_KEYS]; //US private: //US class KKeySequencePrivate* d; //US friend class KKeyNative; //US}; /** * The KShortcut class is used to represent a keyboard shortcut to an action. * A shortcut is normally a single key with modifiers, such as Ctrl+V. * A KShortcut object may also contain an alternate key which will also * activate the action it's associated to, as long as no other actions have * defined that key as their primary key. Ex: Ctrl+V;Shift+Insert. */ class KShortcut { public: /** * The maximum number of key sequences that can be contained in * a KShortcut. */ enum { MAX_SEQUENCES = 2 }; /** * Creates a new null shortcut. * @see null() * @see isNull() * @see clear() */ KShortcut() {} /** * Creates a new shortcut with the given Qt key code * as the only key sequence. * @param keyQt the qt keycode * @see Qt::Key */ - KShortcut( int keyQt ) {} + KShortcut( int /*keyQt */) {} /** * Creates a new shortcut that contains only the given qt key * sequence. * @param keySeq the qt key sequence to add */ //US KShortcut( const QKeySequence& keySeq ) {} /** * Creates a new shortcut that contains only the given key * in its only sequence. * @param key the key to add */ //US KShortcut( const KKey& key ); /** * Creates a new shortcut that contains only the given key * sequence. * @param keySeq the key sequence to add */ //US KShortcut( const KKeySequence& keySeq ); /** * Copies the given shortcut. * @param shortcut the shortcut to add */ //US KShortcut( const KShortcut& shortcut ); /** * Creates a new key sequence that contains the given key sequence. * The description consists of semicolon-separated keys as * used in @ref KKeySequence::KKeySequence(const QString&). * @param shortcut the description of the key * @see KKeySequence::KKeySequence(const QString&) */ - KShortcut( const char* shortcut ) {} + KShortcut( const char* /*shortcut */) {} /** * Creates a new key sequence that contains the given key sequence. * The description consists of semicolon-separated keys as * used in @ref KKeySequence::KKeySequence(const QString&). * @param shortcut the description of the key * @see KKeySequence::KKeySequence(const QString&) */ - KShortcut( const QString& shortcut ) {} + KShortcut( const QString& /*shortcut */) {} ~KShortcut() {} /** * Clears the shortcut. The shortcut is null after calling this * function. * @see isNull() */ //US void clear(); /** * Initializes the shortcut with the given Qt key code * as the only key sequence. * @param keyQt the qt keycode * @see Qt::Key */ //US bool init( int keyQt ); /** * Initializes the shortcut with the given qt key sequence. * @param keySeq the qt key sequence to add */ //US bool init( const QKeySequence& keySeq ); /** * Initializes the shortcut with the given key as its only sequence. * @param key the key to add */ //US bool init( const KKey& key ); /** * Initializes the shortcut with the given qt key sequence. * @param keySeq the qt key sequence to add */ //US bool init( const KKeySequence& keySeq ); /** * Copies the given shortcut. * @param shortcut the shortcut to add */ //US bool init( const KShortcut& shortcut ); /** * Initializes the key sequence with the given key sequence. * The description consists of semicolon-separated keys as * used in @ref KKeySequence::KKeySequence(const QString&). * @param shortcut the description of the key * @see KKeySequence::KKeySequence(const QString&) */ //US bool init( const QString& shortcut ); /** * Copies the given shortcut over this shortcut. */ //US KShortcut& operator =( const KShortcut& cut ) //US { init( cut ); return *this; } /** * Returns the number of sequences that are in this * shortcut. * @return the number of sequences * @ref MAX_SEQUENCES */ //US uint count() const; /** * Returns the @p i'th key sequence of this shortcut. * @param i the number of the key sequence to retrieve * @return the @p i'th sequence or @ref KKeySequence::null() if * there are less than @p i key sequences * @ref MAX_SEQUENCES */ //US const KKeySequence& seq( uint i ) const; /** * Returns the key code of the first key sequence, or * null if there is no first key sequence. * @return the key code of the first sequence's first key * @see Qt::Key * @see KKeySequence::keyCodeQt() */ //US int keyCodeQt() const; /** * Returns true if the shortcut is null (after @ref clear() or empty * constructor). * @return true if the shortcut is null * @see clear() * @see null() */ bool isNull() const { return true; } /** * Compares this object with the given shortcut. Returns a negative * number if the given shortcut is larger, 0 if they are equal and * a positive number this shortcut is larger. Shortcuts are * compared by comparing the individual key sequences, starting from the * beginning until an unequal key sequences has been found. If a shortcut * contains more key sequences, it is considered larger. * @param shortcut the shortcut to compare to * @return a negative number if the given KShortcut is larger, 0 if * they are equal and a positive number this KShortcut is larger * @see KKey::compare() * @see KKeyShortcut::compare() */ //US int compare( const KShortcut& shortcut ) const; /** * Compares the sequences of both shortcuts. * @see compare() */ //US bool operator == ( const KShortcut& cut ) const //US { return compare( cut ) == 0; } /** * Compares the sequences of both shortcuts. * @see compare() */ //US bool operator != ( const KShortcut& cut ) const //US { return compare( cut ) != 0; } /** * Compares the sequences of both shortcuts. * @see compare() */ //US bool operator < ( const KShortcut& cut ) const //US { return compare( cut ) < 0; } /** * Checks whether this shortcut contains a sequence that starts * with the given key. * @param key the key to check * @return true if a key sequence starts with the key */ //US bool contains( const KKey& key ) const; /** * Checks whether this shortcut contains a sequence that starts * with the given key. * @param key the key to check * @return true if a key sequence starts with the key */ //US bool contains( const KKeyNative& key ) const; /** * Checks whether this shortcut contains the given sequence. * @param keySeq the key sequence to check * @return true if the shortcut has the given key sequence */ //US bool contains( const KKeySequence& keySeq ) const; /** * Sets the @p i'th key sequence of the shortcut. You can not introduce * gaps in the list of sequences, so you must use an @i <= @ref count(). * Also note that the maximum number of key sequences is @ref MAX_SEQUENCES. * @param i the position of the new key sequence(<= @ref count(), * <= @ref MAX_SEQUENCES) * @param keySeq the key sequence to set * @return true if successful, false otherwise */ //US bool setSeq( uint i, const KKeySequence& keySeq ); /** * Appends the given key sequence. * @param keySeq the key sequence to add * @return true if successful, false otherwise * @see setSeq() * @see MAX_SEQUENCES */ //US bool append( const KKeySequence& keySeq ); /** * Appends the given key * @param spec the key to add * @return true if successful, false otherwise * @see setSeq() * @see MAX_SEQUENCES * @since 3.2 */ //US bool append( const KKey& spec ); /** * Appends the sequences from the given shortcut. * @param cut the shortcut to append * @return true if successful, false otherwise * @see MAX_SEQUENCES * @since 3.2 */ //US bool append( const KShortcut& cut ); /** * Converts this shortcut to a key sequence. The first key sequence * will be taken. */ //US operator QKeySequence () const; /** * Returns a description of the shortcut as semicolon-separated * ket sequences, as returned by @ref KKeySequence::toString(). * @return the string represenation of this shortcut * @see KKey::toString() * @see KKeySequence::toString() */ //US QString toString() const; /** * @internal */ - QString toStringInternal( const KShortcut* pcutDefault = 0 ) const + QString toStringInternal( const KShortcut* /*pcutDefault*/ = 0 ) const { return "EMPTY IMPL."; } /** * Returns a null shortcut. * @return the null shortcut * @see isNull() * @see clear() */ //US static KShortcut& null(); //US protected: //US uint m_nSeqs; //US KKeySequence m_rgseq[MAX_SEQUENCES]; //US private: //US class KShortcutPrivate* d; //US friend class KKeyNative; //US#ifndef KDE_NO_COMPAT //US public: //US operator int () const { return keyCodeQt(); } //US#endif }; #endif // __KSHORTCUT_H diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index d5bfefd..f10934b 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp @@ -1,677 +1,679 @@ /* 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 <q3asciidict.h> +#include <q3dict.h> #include <qdir.h> #include <qfileinfo.h> #include <qstring.h> #include <qmessagebox.h> #include <qapplication.h> #include <qstringlist.h> +//Added by qt3to4: +#include <Q3CString> #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>; +template class Q3Dict<QStringList>; #if 0 -#include <qtextedit.h> +#include <q3textedit.h> void ddd( QString op ) { - static QTextEdit * dot = 0; + static Q3TextEdit * dot = 0; if ( ! dot ) - dot = new QTextEdit(); + dot = new Q3TextEdit(); dot->show(); dot->append( op ); } #endif class KStandardDirs::KStandardDirsPrivate { public: KStandardDirsPrivate() : restrictionsActive(false), dataRestrictionActive(false) { } bool restrictionsActive; bool dataRestrictionActive; - QAsciiDict<bool> restrictions; + Q3AsciiDict<bool> restrictions; QStringList xdgdata_prefixes; QStringList xdgconf_prefixes; }; static const char* const types[] = {"html", "icon", "apps", "sound", "data", "locale", "services", "mime", "servicetypes", "config", "exe", "tmp", "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); else key = "data_"+relPath; if (d && d->restrictions[key.latin1()]) d->dataRestrictionActive = true; } QStringList KStandardDirs::allTypes() const { QStringList list; for (int i = 0; types[i] != 0; ++i) list.append(QString::fromLatin1(types[i])); return list; } void KStandardDirs::addPrefix( const QString& _dir ) { if (_dir.isNull()) return; QString dir = _dir; if (dir.at(dir.length() - 1) != '/') dir += '/'; if (!prefixes.contains(dir)) { prefixes.append(dir); dircache.clear(); } } void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) { if (_dir.isNull()) return; QString dir = _dir; if (dir.at(dir.length() - 1) != '/') dir += '/'; if (!d->xdgconf_prefixes.contains(dir)) { d->xdgconf_prefixes.append(dir); dircache.clear(); } } void KStandardDirs::addXdgDataPrefix( const QString& _dir ) { if (_dir.isNull()) return; QString dir = _dir; if (dir.at(dir.length() - 1) != '/') dir += '/'; if (!d->xdgdata_prefixes.contains(dir)) { d->xdgdata_prefixes.append(dir); dircache.clear(); } } QString KStandardDirs::kfsstnd_prefixes() { return prefixes.join(":"); } bool KStandardDirs::addResourceType( const char *type, const QString& relativename ) { if (relativename.isNull()) return false; QStringList *rels = relatives.find(type); if (!rels) { rels = new QStringList(); relatives.insert(type, rels); } QString copy = relativename; if (copy.at(copy.length() - 1) != '/') copy += '/'; if (!rels->contains(copy)) { rels->prepend(copy); dircache.remove(type); // clean the cache return true; } return false; } bool KStandardDirs::addResourceDir( const char *type, const QString& absdir) { QStringList *paths = absolutes.find(type); if (!paths) { paths = new QStringList(); absolutes.insert(type, paths); } QString copy = absdir; if (copy.at(copy.length() - 1) != '/') copy += '/'; if (!paths->contains(copy)) { paths->append(copy); dircache.remove(type); // clean the cache return true; } return false; } QString KStandardDirs::findResource( const char *type, const QString& filename ) const { if (filename.at(0) == '/') return filename; // absolute dirs are absolute dirs, right? :-/ #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") 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); + int pos = regexp.exactMatch(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 ) { //US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; continue; // Couldn't stat (e.g. no read permissions) } if ( recursive ) { if ( pathfnInfo.isDir()) { lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); } /*US if (!regexp.exactMatch(fn)) continue; // No match */ //US this should do the same: - pos = regexp.match(fn); + pos = regexp.exactMatch(fn); if (!pos == 0) continue; // No match } //US if ( S_ISREG( buff.st_mode)) if ( pathfnInfo.isFile()) { if (!uniq || !relList.contains(relPart + fn)) { list.append( pathfn ); relList.append( relPart + fn ); } } } //US closedir( dp ); } else { // We look for a single file. QString fn = pattern; QString pathfn = path + fn; //US struct stat buff; QFileInfo pathfnInfo(QFile::encodeName(pathfn)); //US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) if ( pathfnInfo.isReadable() == false ) return; // File not found //US if ( S_ISREG( buff.st_mode)) if ( pathfnInfo.isFile()) { if (!uniq || !relList.contains(relPart + fn)) { list.append( pathfn ); relList.append( relPart + fn ); } } } } static void lookupPrefix(const QString& prefix, const QString& relpath, const QString& relPart, const QRegExp ®exp, QStringList& list, QStringList& relList, bool recursive, bool uniq) { if (relpath.isNull()) { lookupDirectory(prefix, relPart, regexp, list, relList, recursive, uniq); return; } QString path; QString rest; if (relpath.length()) { int slash = relpath.find('/'); if (slash < 0) rest = relpath.left(relpath.length() - 1); else { path = relpath.left(slash); rest = relpath.mid(slash + 1); } } assert(prefix.at(prefix.length() - 1) == '/'); //US struct stat buff; if (path.contains('*') || path.contains('?')) { QRegExp pathExp(path, true, true); //US DIR *dp = opendir( QFile::encodeName(prefix) ); QDir dp(QFile::encodeName(prefix)); //US if (!dp) if (!dp.exists()) { return; } //US struct dirent *ep; 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 encodes the strings it++; if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~') continue; #ifdef DESKTOP_VERSION if (pathExp.search(fn) == -1) continue; // No match #else //US this should do the same: if (pathExp.find(fn, 0) == -1) continue; // No match #endif QString rfn = relPart+fn; fn = prefix + fn; //US if ( stat( QFile::encodeName(fn), &buff ) != 0 ) QFileInfo fnInfo(QFile::encodeName(fn)); if ( fnInfo.isReadable() == false ) { //US kdDebug() << "Error statting " << fn << " : " << perror << endl; continue; // Couldn't stat (e.g. no permissions) } //US if ( S_ISDIR( buff.st_mode )) if ( fnInfo.isDir() ) lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq); } //US closedir( dp ); } else { // Don't stat, if the dir doesn't exist we will find out // when we try to open it. lookupPrefix(prefix + path + '/', rest, relPart + path + '/', regexp, list, relList, recursive, uniq); } } QStringList KStandardDirs::findAllResources( const char *type, const QString& filter, bool recursive, bool uniq, QStringList &relList) const { QStringList list; if (filter.at(0) == '/') // absolute paths we return { list.append( filter); return list; } QString filterPath; QString filterFile; if (filter.length()) { int slash = filter.findRev('/'); if (slash < 0) filterFile = filter; else { filterPath = filter.left(slash + 1); filterFile = filter.mid(slash + 1); } } checkConfig(); if (d && d->restrictionsActive && (strcmp(type, "data")==0)) applyDataRestrictions(filter); QStringList candidates = resourceDirs(type); if (filterFile.isEmpty()) filterFile = "*"; QRegExp regExp(filterFile, true, true); for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) { lookupPrefix(*it, filterPath, "", regExp, list, relList, recursive, uniq); } return list; } QStringList KStandardDirs::findAllResources( const char *type, const QString& filter, bool recursive, bool uniq) const { QStringList relList; return findAllResources(type, filter, recursive, uniq, relList); } QString KStandardDirs::realPath(const QString &dirname) { @@ -919,485 +921,485 @@ int KStandardDirs::findAllExe( QStringList& list, const QString& appname, } 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/"; if (!strcmp(type, "module")) 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/"; if (!strcmp(type, "tmp")) return "tmp/"; 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; } bool KStandardDirs::makeDir(const QString& dir2, int mode) { QString dir = QDir::convertSeparators( dir2 ); #if 0 //LR // we want an absolute path if (dir.at(0) != '/') return false; QString target = dir; uint len = target.length(); // append trailing slash if missing if (dir.at(len - 1) != '/') target += '/'; QString base(""); uint i = 1; while( i < len ) { //US struct stat st; int pos = target.find('/', i); base += target.mid(i - 1, pos - i + 1); - QCString baseEncoded = QFile::encodeName(base); + Q3CString baseEncoded = QFile::encodeName(base); // bail out if we encountered a problem //US if (stat(baseEncoded, &st) != 0) QFileInfo baseEncodedInfo(baseEncoded); if (!baseEncodedInfo.exists()) { // Directory does not exist.... // Or maybe a dangling symlink ? //US if (lstat(baseEncoded, &st) == 0) if (baseEncodedInfo.isSymLink()) { //US (void)unlink(baseEncoded); // try removing QFile(baseEncoded).remove(); } //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) QDir dirObj; if ( dirObj.mkdir(baseEncoded) != true ) { //US perror("trying to create local folder"); return false; // Couldn't create it :-( } } i = pos + 1; } return true; #endif // ******************************************** // new code for WIN32 QDir dirObj; // we want an absolute path #ifndef _WIN32_ 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; } QString readEnvPath(const char *env) { //#ifdef _WIN32_ // return ""; //#else - QCString c_path; + Q3CString c_path; if ( getenv(env) != NULL ) c_path = QString ( 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 QString tmp = readEnvPath("QPEDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); tmp = readEnvPath("QTDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); tmp = readEnvPath("OPIEDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); #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()) { #ifdef _WIN32_ if (localKdeDir.at(localKdeDir.length()-1) != '\\') localKdeDir += '\\'; #else if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; #endif //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); } else { QString confFile; #ifdef DESKTOP_VERSION confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; QFileInfo fi ( confFile ); if ( !fi.exists() ) confFile = QDir::homeDirPath() + "/.microkdehome"; else qDebug("Loading path info from " + confFile ); #else confFile = QDir::homeDirPath() + "/.microkdehome"; #endif KConfig cfg ( confFile ); cfg.setGroup("Global"); localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); #ifdef DESKTOP_VERSION if ( localKdeDir.startsWith( "LOCAL:" ) ) { #ifdef _WIN32_ localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); #else localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); #endif qDebug("Using local conf dir %s ",localKdeDir.latin1() ); // <stdlib.h> #ifdef _WIN32_ QString envSt = "LOCALMICROKDEHOME="+localKdeDir; _putenv( envSt.latin1()); #else setenv( "LOCALMICROKDEHOME", localKdeDir.latin1(), 1 ); #endif } #endif } } 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); for (QStringList::ConstIterator it = xdgdirList.begin(); it != xdgdirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addXdgConfigPrefix(dir); } // end XDG_CONFIG_XXX // begin XDG_DATA_XXX xdgdirs = readEnvPath("XDG_DATA_DIRS"); diff --git a/microkde/kdecore/kstandarddirs.h b/microkde/kdecore/kstandarddirs.h index 901384e..f0e28fc 100644 --- a/microkde/kdecore/kstandarddirs.h +++ b/microkde/kdecore/kstandarddirs.h @@ -1,219 +1,219 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> Stephan Kulow <coolo@kde.org> 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 as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. */ #ifndef SSK_KSTDDIRS_H #define SSK_KSTDDIRS_H #include <qstring.h> -#include <qdict.h> +#include <q3dict.h> #include <qstringlist.h> #include <kglobal.h> class KConfig; class KStandardDirsPrivate; /** * @short Site-independent access to standard KDE directories. * @author Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> * @version $Id$ * * This is one of the most central classes in kdelibs as * it provides a basic service: It knows where the files * reside on the user's hard disk. And it's meant to be the * only one that knows -- to make the real location as * transparent as possible to both the user and the applications. * * To this end it insulates the application from all information * and applications always refer to a file with a resource type * (e.g. icon) and a filename (e.g. khexdit.xpm). In an ideal world * the application would make no assumption where this file is and * leave it up to @ref KStandardDirs::findResource("apps", "Home.desktop") * to apply this knowledge to return /opt/kde/share/applnk/Home.desktop * or ::locate("data", "kgame/background.jpg") to return * /opt/kde/share/apps/kgame/background.jpg * * The main idea behind KStandardDirs is that there are several * toplevel prefixes below which the files lie. One of these prefixes is * the one where the user installed kdelibs, one is where the * application was installed, and one is $HOME/.kde, but there * may be even more. Under these prefixes there are several well * defined suffixes where specific resource types are to be found. * For example, for the resource type "html" the suffixes could be * share/doc/HTML and share/doc/kde/HTML. * So the search algorithm basicly appends to each prefix each registered * suffix and tries to locate the file there. * To make the thing even more complex, it's also possible to register * absolute paths that KStandardDirs looks up after not finding anything * in the former steps. They can be useful if the user wants to provide * specific directories that aren't in his $HOME/.kde directory for, * for example, icons. * * @sect Standard resources that kdelibs allocates are: * * @li apps - Applications menu (.desktop files). * @li cache - Cached information (e.g. favicons, web-pages) * @li cgi - CGIs to run from kdehelp. * @li config - Configuration files. * @li data - Where applications store data. * @li exe - Executables in $prefix/bin. @ref findExe() for a function that takes $PATH into account. * @li html - HTML documentation. * @li icon - Icons, see @ref KIconLoader. * @li lib - Libraries. * @li locale - Translation files for @ref KLocale. * @li mime - Mime types. * @li module - Module (dynamically loaded library). * @li qtplugins - Qt plugins (dynamically loaded objects for Qt) * @li services - Services. * @li servicetypes - Service types. * @li scripts - Application scripting additions. * @li sound - Application sounds. * @li templates - Templates * @li wallpaper - Wallpapers. * @li tmp - Temporary files (specfic for both current host and current user) * @li socket - UNIX Sockets (specific for both current host and current user) * * A type that is added by the class @ref KApplication if you use it, is * appdata. This one makes the use of the type data a bit easier as it * appends the name of the application. * So while you had to ::locate("data", "appname/filename") so you can * also write ::locate("appdata", "filename") if your KApplication instance * is called "appname" (as set via KApplication's constructor or KAboutData, if * you use the global KStandardDirs object @ref KGlobal::dirs()). * Please note though that you cannot use the "appdata" * type if you intend to use it in an applet for Kicker because 'appname' would * be "Kicker" instead of the applet's name. Therefore, for applets, you've got * to work around this by using ::locate("data", "appletname/filename"). * * @sect KStandardDirs supports the following environment variables: * * @li KDEDIRS: This may set an additional number of directory prefixes to * search for resources. The directories should be seperated * by ':'. The directories are searched in the order they are * specified. * @li KDEDIR: Used for backwards compatibility. As KDEDIRS but only a single * directory may be specified. If KDEDIRS is set KDEDIR is * ignored. * @li KDEHOME: The directory where changes are saved to. This directory is * used to search for resources first. If KDEHOME is not * specified it defaults to "$HOME/.kde" * @li KDEROOTHOME: Like KDEHOME, but used for the root user. * If KDEROOTHOME is not set it defaults to the .kde directory in the * home directory of root, usually "/root/.kde". * Note that the setting of $HOME is ignored in this case. * * @see KGlobalSettings */ class KStandardDirs { public: /** * KStandardDirs' constructor. It just initializes the caches. **/ KStandardDirs( ); /** * KStandardDirs' destructor. */ virtual ~KStandardDirs(); /** * Adds another search dir to front of the @p fsstnd list. * * @li When compiling kdelibs, the prefix is added to this. * @li KDEDIRS or KDEDIR is taking into account * @li Additional dirs may be loaded from kdeglobals. * * @param dir The directory to append relative paths to. */ void addPrefix( const QString& dir ); /** * Adds another search dir to front of the XDG_CONFIG_XXX list * of prefixes. * This prefix is only used for resources that start with "xdgconf-" * * @param dir The directory to append relative paths to. */ void addXdgConfigPrefix( const QString& dir ); /** * Adds another search dir to front of the XDG_DATA_XXX list * of prefixes. * This prefix is only used for resources that start with "xdgdata-" * * @param dir The directory to append relative paths to. */ void addXdgDataPrefix( const QString& dir ); /** * Adds suffixes for types. * * You may add as many as you need, but it is advised that there * is exactly one to make writing definite. * All basic types (@ref kde_default) are added by @ref addKDEDefaults(), * but for those you can add more relative paths as well. * * The later a suffix is added, the higher its priority. Note, that the * suffix should end with / but doesn't have to start with one (as prefixes * should end with one). So adding a suffix for app_pics would look * like KGlobal::dirs()->addResourceType("app_pics", "share/app/pics"); * * @param type Specifies a short descriptive string to access * files of this type. * @param relativename Specifies a directory relative to the root * of the KFSSTND. * @return true if successful, false otherwise. */ bool addResourceType( const char *type, const QString& relativename ); /** * Adds absolute path at the end of the search path for * particular types (for example in case of icons where * the user specifies extra paths). * * You shouldn't need this * function in 99% of all cases besides adding user-given * paths. * * @param type Specifies a short descriptive string to access files * of this type. * @param absdir Points to directory where to look for this specific * type. Non-existant directories may be saved but pruned. * @return true if successful, false otherwise. */ bool addResourceDir( const char *type, const QString& absdir); /** * Tries to find a resource in the following order: * @li All PREFIX/\<relativename> paths (most recent first). * @li All absolute paths (most recent first). * * The filename should be a filename relative to the base dir * for resources. So is a way to get the path to libkdecore.la * to findResource("lib", "libkdecore.la"). KStandardDirs will * then look into the subdir lib of all elements of all prefixes * ($KDEDIRS) for a file libkdecore.la and return the path to * the first one it finds (e.g. /opt/kde/lib/libkdecore.la) * @@ -385,301 +385,301 @@ public: * @param list Will be filled with the pathnames of all the * executables found. Will be empty if the executable * was not found. * @param appname The name of the executable for which to * search. * @param pathstr The path list which will be searched. If this * is 0 (default), the $PATH environment variable will * be searched. * @param ignoreExecBit If true, an existing file will be returned * even if its executable bit is not set. * * @return The number of executables found, 0 if none were found. * * @see findExe() */ static int findAllExe( QStringList& list, const QString& appname, const QString& pathstr=QString::null, bool ignoreExecBit=false ); /** * This function adds the defaults that are used by the current * KDE version. * * It's a series of @ref addResourceTypes() * and @ref addPrefix() calls. * You normally wouldn't call this function because it's called * for you from @ref KGlobal. */ void addKDEDefaults(); /** * Reads customized entries out of the given config object and add * them via @ref addResourceDirs(). * * @param config The object the entries are read from. This should * contain global config files * @return true if new config paths have been added * from @p config. **/ bool addCustomized(KConfig *config); /** * This function is used internally by almost all other function as * it serves and fills the directories cache. * * @param type The type of resource * @return The list of possible directories for the specified @p type. * The function updates the cache if possible. If the resource * type specified is unknown, it will return an empty list. * Note, that the directories are assured to exist beside the save * location, which may not exist, but is returned anyway. */ QStringList resourceDirs(const char *type) const; /** * This function will return a list of all the types that KStandardDirs * supports. * * @return All types that KDE supports */ QStringList allTypes() const; /** * Finds a location to save files into for the given type * in the user's home directory. * * @param type The type of location to return. * @param suffix A subdirectory name. * Makes it easier for you to create subdirectories. * You can't pass filenames here, you _have_ to pass * directory names only and add possible filename in * that directory yourself. A directory name always has a * trailing slash ('/'). * @param create If set, saveLocation() will create the directories * needed (including those given by @p suffix). * * @return A path where resources of the specified type should be * saved, or QString::null if the resource type is unknown. */ QString saveLocation(const char *type, const QString& suffix = QString::null, bool create = true) const; /** * Converts an absolute path to a path relative to a certain * resource. * * If "abs = ::locate(resource, rel)" * then "rel = relativeLocation(resource, abs)" and vice versa. * * @param type The type of resource. * * @param absPath An absolute path to make relative. * * @return A relative path relative to resource @p type that * will find @p absPath. If no such relative path exists, absPath * will be returned unchanged. */ QString relativeLocation(const char *type, const QString &absPath); /** * Recursively creates still-missing directories in the given path. * * The resulting permissions will depend on the current umask setting. * permission = mode & ~umask. * * @param dir Absolute path of the directory to be made. * @param mode Directory permissions. * @return true if successful, false otherwise */ static bool makeDir(const QString& dir, int mode = 0755); /** * This returns a default relative path for the standard KDE * resource types. Below is a list of them so you get an idea * of what this is all about. * * @li data - share/apps * @li html - share/doc/HTML * @li icon - share/icon * @li config - share/config * @li pixmap - share/pixmaps * @li apps - share/applnk * @li sound - share/sounds * @li locale - share/locale * @li services - share/services * @li servicetypes - share/servicetypes * @li mime - share/mimelnk * @li wallpaper - share/wallpapers * @li templates - share/templates * @li exe - bin * @li lib - lib * * @returns Static default for the specified resource. You * should probably be using locate() or locateLocal() * instead. * @see locate() * @see locateLocal() */ static QString kde_default(const char *type); /** * @internal (for use by sycoca only) */ QString kfsstnd_prefixes(); /** * Returns the toplevel directory in which KStandardDirs * will store things. Most likely $HOME/.kde * Don't use this function if you can use locateLocal * @return the toplevel directory */ QString localkdedir() const; /** * @return $XDG_DATA_HOME * See also http://www.freedesktop.org/standards/basedir/draft/basedir-spec/basedir-spec.html */ QString localxdgdatadir() const; /** * @return $XDG_CONFIG_HOME * See also http://www.freedesktop.org/standards/basedir/draft/basedir-spec/basedir-spec.html */ QString localxdgconfdir() const; /** * Checks for existence and accessability. * Faster than creating a QFileInfo first. * @param fullPath the path to check * @return true if the directory exists */ static bool exists(const QString &fullPath); /** * Expands all symbolic links and resolves references to * '/./', '/../' and extra '/' characters in @p dirname * and returns the canonicalized absolute pathname. * The resulting path will have no symbolic link, '/./' * or '/../' components. * @since 3.1 */ static QString realPath(const QString &dirname); static void setAppDir( const QString & ); static QString appDir(); private: QStringList prefixes; // Directory dictionaries - QDict<QStringList> absolutes; - QDict<QStringList> relatives; + Q3Dict<QStringList> absolutes; + Q3Dict<QStringList> relatives; - mutable QDict<QStringList> dircache; - mutable QDict<QString> savelocations; + mutable Q3Dict<QStringList> dircache; + mutable Q3Dict<QString> savelocations; // Disallow assignment and copy-construction KStandardDirs( const KStandardDirs& ); KStandardDirs& operator= ( const KStandardDirs& ); bool addedCustoms; class KStandardDirsPrivate; KStandardDirsPrivate *d; //US static QString mAppDir; void checkConfig() const; void applyDataRestrictions(const QString &) const; //US void createSpecialResource(const char*); }; /** * \addtogroup locates Locate Functions * @{ * On The Usage Of 'locate' and 'locateLocal' * * Typical KDE applications use resource files in one out of * three ways: * * 1) A resource file is read but is never written. A system * default is supplied but the user can override this * default in his local .kde directory: * * \code * // Code example * myFile = locate("appdata", "groups.lst"); * myData = myReadGroups(myFile); // myFile may be null * \endcode * * 2) A resource file is read and written. If the user has no * local version of the file the system default is used. * The resource file is always written to the users local * .kde directory. * * \code * // Code example * myFile = locate("appdata", "groups.lst") * myData = myReadGroups(myFile); * ... * doSomething(myData); * ... * myFile = locateLocal("appdata", "groups.lst"); * myWriteGroups(myFile, myData); * \endcode * * 3) A resource file is read and written. No system default * is used if the user has no local version of the file. * The resource file is always written to the users local * .kde directory. * * \code * // Code example * myFile = locateLocal("appdata", "groups.lst"); * myData = myReadGroups(myFile); * ... * doSomething(myData); * ... * myFile = locateLocal("appdata", "groups.lst"); * myWriteGroups(myFile, myData); * \endcode **/ /*! * \relates KStandardDirs * This function is just for convenience. It simply calls *instance->dirs()->\link KStandardDirs::findResource() findResource\endlink(type, filename). **/ QString locate( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance()*/ ); /*! * \relates KStandardDirs * This function is much like locate. However it returns a * filename suitable for writing to. No check is made if the * specified filename actually exists. Missing directories * are created. If filename is only a directory, without a * specific file, filename must have a trailing slash. * **/ QString locateLocal( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance() */ ); /*! * \relates KStandardDirs * This function is much like locate. No check is made if the * specified filename actually exists. Missing directories * are created if @p createDir is true. If filename is only * a directory, without a specific file, * filename must have a trailing slash. * **/ QString locateLocal( const char *type, const QString& filename, bool createDir /*US , const KInstance* instance = KGlobal::instance() */); QString readEnvPath(const char *env); /*! @} */ #endif // SSK_KSTDDIRS_H |