summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore
Side-by-side diff
Diffstat (limited to 'microkde/kdecore') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdecore/kcatalogue.cpp4
-rw-r--r--microkde/kdecore/kconfigbase.h4
-rw-r--r--microkde/kdecore/klibloader.cpp29
-rw-r--r--microkde/kdecore/klibloader.h10
-rw-r--r--microkde/kdecore/klocale.cpp23
-rw-r--r--microkde/kdecore/klocale.h4
-rw-r--r--microkde/kdecore/kmdcodec.cpp139
-rw-r--r--microkde/kdecore/kmdcodec.h38
-rw-r--r--microkde/kdecore/kprefs.cpp16
-rw-r--r--microkde/kdecore/kprefs.h10
-rw-r--r--microkde/kdecore/kshortcut.h8
-rw-r--r--microkde/kdecore/kstandarddirs.cpp24
-rw-r--r--microkde/kdecore/kstandarddirs.h10
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,203 +1,206 @@
/* 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 );
}
@@ -260,361 +263,361 @@ void KLibrary::slotTimeout()
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();
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,178 +1,178 @@
/* 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
@@ -242,97 +242,97 @@ public:
* 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:
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,124 +1,125 @@
#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);
}
}
}
}
@@ -422,157 +423,157 @@ QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat
// 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.
@@ -593,193 +594,193 @@ QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) con
}
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;
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,62 +1,62 @@
#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;
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,89 +1,91 @@
/*
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
@@ -102,104 +104,104 @@ const char KCodecs::UUEncMap[64] =
};
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.
@@ -235,589 +237,586 @@ void KCodecs::quotedPrintableEncode(const QByteArray& in, QByteArray& out, bool
}
}
// 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)
@@ -828,180 +827,180 @@ bool KMD5::update(QIODevice& file)
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 */
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,370 +1,372 @@
/*
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
@@ -386,187 +388,187 @@ class KMD5Private;
* 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,71 +1,73 @@
/*
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:
@@ -95,107 +97,107 @@ class KPrefsItemFont : public KPrefsItem {
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);
}
@@ -319,97 +321,97 @@ 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;
}
}
@@ -460,53 +462,53 @@ void KPrefs::writeConfig()
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,76 +1,78 @@
/*
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;
@@ -238,79 +240,79 @@ class KPrefs {
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
@@ -518,142 +518,142 @@ class KKey
* @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&)
*/
@@ -771,76 +771,76 @@ class KShortcut
//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,136 +1,138 @@
/* 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;
}
@@ -400,134 +402,134 @@ bool KStandardDirs::exists(const QString &fullPath)
static void lookupDirectory(const QString& path, const QString &relPart,
const QRegExp &regexp,
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 &regexp,
QStringList& list,
QStringList& relList,
bool recursive, bool uniq)
{
@@ -1063,97 +1065,97 @@ QString KStandardDirs::saveLocation(const char *type,
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;
@@ -1163,97 +1165,97 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode)
#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
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,75 +1,75 @@
/*
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.
@@ -529,101 +529,101 @@ public:
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");