summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp2
-rw-r--r--kabc/plugins/file/resourcefile.cpp41
-rw-r--r--kabc/plugins/file/resourcefile.h2
-rw-r--r--microkde/kdatetbl.cpp2
-rw-r--r--microkde/kdecore/kstandarddirs.cpp4
-rw-r--r--microkde/kdecore/kstandarddirs.h4
6 files changed, 39 insertions, 16 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index aa96210..9118c3d 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -250,97 +250,97 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
if (! picture.undefined() ) {
picAvailintern = (picture.isIntern() && !picture.data().isNull());
picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
}
if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
if ( picAvailintern ) {
QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
} else {
if ( picAvailUrl ) {
QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
} else {
if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) {
static bool setDefaultImageChildren = false;
if ( !setDefaultImageChildren ) {
QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) );
setDefaultImageChildren = true;
}
picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">";
} else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) {
static bool setDefaultImagepouses = false;
if ( !setDefaultImagepouses ) {
QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) );
setDefaultImagepouses = true;
}
picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">";
} else {
QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
if ( gen == "male" ) {
static bool setDefaultImageMale = false;
if ( !setDefaultImageMale ) {
QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) );
setDefaultImageMale = true;
}
picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">";
} else if ( gen == "female" ) {
static bool setDefaultImageFemale = false;
if ( !setDefaultImageFemale ) {
QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) );
setDefaultImageFemale = true;
}
picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">";
} else {
static bool setDefaultImage = false;
if ( !setDefaultImage ) {
- qDebug("Setting default pixmap ");
+ //qDebug("Setting default pixmap ");
QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) );
setDefaultImage = true;
}
picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">";
}
}
}
}
mText = QString::fromLatin1(
"<html>"
"<body text=\"%1\" bgcolor=\"%2\">" // text and background color
"<table>"
"<tr>"
"<td rowspan=\"3\" align=\"right\" valign=\"top\">"
"%3"
"</td>"
"<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
"</tr>"
"%5" // role
"%6" // organization
"<td colspan=\"2\">&nbsp;</td>"
"%7" // dynamic part
"%8" // notes
"</table>"
"</body>"
"</html>")
//US
.arg( /*KGlobalSettings::textColor().name()*/ "black" )
//US
.arg( /*KGlobalSettings::baseColor().name()*/ "white" )
.arg( picString )
.arg( name )
.arg( aRole )
.arg( aOrga )
.arg( dynamicPart )
.arg( notes );
} else { // no picture!
mText = "<table width=\"100%\">\n";
//mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
#ifdef DESKTOP_VERSION
mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>";
#else
mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>";
mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>";
#endif
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index dc5932f..4ab7f02 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -10,395 +10,412 @@
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.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <sys/types.h>
#include <sys/stat.h>
#ifndef _WIN32_
#include <unistd.h>
#endif
#include <qfile.h>
#include <qfileinfo.h>
#include <qregexp.h>
#include <qtimer.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
#include <klocale.h>
//US #include <ksavefile.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include "formatfactory.h"
#include "resource.h"
#include "resourcefileconfig.h"
#include "stdaddressbook.h"
#define NO_DIRWATCH
#include "resourcefile.h"
//#define ALLOW_LOCKING
-
using namespace KABC;
extern "C"
#ifdef _WIN32_
__declspec(dllexport)
#else
{
#endif
//US void *init_kabc_file()
void *init_microkabc_file()
{
return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>();
}
#ifndef _WIN32_
}
#endif
ResourceFile::ResourceFile( const KConfig *config )
: Resource( config ) , mFormat( 0 )
{
QString fileName, formatName, default_fileName;
default_fileName = StdAddressBook::fileName();
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
fileName = cfg->readEntry( "FileName", default_fileName );
formatName = cfg->readEntry( "FileFormat", "vcard" );
} else {
fileName = default_fileName;
formatName = "vcard";
}
init( fileName, formatName );
}
ResourceFile::ResourceFile( const QString &fileName ,
const QString &formatName )
: Resource( 0 )
{
// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
+
+
+
init( fileName, formatName );
}
void ResourceFile::init( const QString &fileName, const QString &formatName )
{
mFormatName = formatName;
FormatFactory *factory = FormatFactory::self();
mFormat = factory->format( mFormatName );
if ( !mFormat ) {
mFormatName = "vcard";
mFormat = factory->format( mFormatName );
}
#ifndef NO_DIRWATCH
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
#endif
+
+
+ QString localKdeDir;
+ localKdeDir = readEnvPath("LOCALMICROKDEHOME");
+ if ( ! localKdeDir.isEmpty() ) {
+ qDebug("LOCALMICROKDEHOME is set to: %s",localKdeDir.latin1() );
+
+
+
+
+ }
+ qDebug("RESOURCE: %s ", fileName.latin1());
+
+
+
setFileName( fileName );
}
ResourceFile::~ResourceFile()
{
delete mFormat;
mFormat = 0;
}
void ResourceFile::writeConfig( KConfig *config )
{
config->setGroup( "Resource_" + identifier() );
Resource::writeConfig( config );
- config->writeEntry( "FileName", mFileName );
+ config->writeEntry( "FileName", fileName() );
config->writeEntry( "FileFormat", mFormatName );
// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
}
Ticket *ResourceFile::requestSaveTicket()
{
kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl;
if ( !addressBook() ) return 0;
#ifdef ALLOW_LOCKING
if ( !lock( mFileName ) ) {
qDebug("unablt to lock file ");
return 0;
}
#endif
return createTicket( this );
}
bool ResourceFile::doOpen()
{
- QFile file( mFileName );
- qDebug("ResourceFile::openfile %s ", mFileName.latin1());
+ QFile file( fileName() );
+ qDebug("ResourceFile::openfile %s ", fileName().latin1());
if ( !file.exists() ) {
// try to create the file
bool ok = file.open( IO_WriteOnly );
if ( ok )
file.close();
return ok;
} else {
if ( !file.open( IO_ReadWrite ) )
return false;
if ( file.size() == 0 ) {
file.close();
return true;
}
bool ok = mFormat->checkFormat( &file );
file.close();
return ok;
}
}
void ResourceFile::doClose()
{
}
bool ResourceFile::load()
{
- QFile file( mFileName );
+ QFile file( fileName() );
if ( !file.open( IO_ReadOnly ) ) {
- addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) );
+ addressBook()->error( i18n( "Unable to open file '%1'." ).arg( fileName() ) );
return false;
}
// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
return mFormat->loadAll( addressBook(), this, &file );
}
bool ResourceFile::save( Ticket *ticket )
{
// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
// create backup file
QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
/*US we use a simpler method to create a backupfile
(void) KSaveFile::backupFile( mFileName, QString::null
,extension );
KSaveFile saveFile( mFileName );
bool ok = false;
if ( saveFile.status() == 0 && saveFile.file() )
{
mFormat->saveAll( addressBook(), this, saveFile.file() );
ok = saveFile.close();
}
*/
//US ToDo: write backupfile
#ifndef NO_DIRWATCH
mDirWatch.stopScan();
#endif
QFile info;
- info.setName( mFileName );
+ info.setName( fileName() );
bool ok = info.open( IO_WriteOnly );
if ( ok ) {
mFormat->saveAll( addressBook(), this, &info );
info.close();
ok = true;
}
else {
}
if ( !ok )
- addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
+ addressBook()->error( i18n( "Unable to save file '%1'." ).arg( fileName() ) );
#ifndef NO_DIRWATCH
mDirWatch.startScan();
#endif
delete ticket;
#ifdef ALLOW_LOCKING
unlock( mFileName );
#endif
return ok;
}
bool ResourceFile::lock( const QString &fileName )
{
#ifdef ALLOW_LOCKING
QString fn = fileName;
//US change the implementation how the lockfilename is getting created
//US fn.replace( QRegExp("/"), "_" );
//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
if (QFile::exists( lockName )) return false;
QString lockUniqueName;
lockUniqueName = fn + KApplication::randomString( 8 );
url = lockUniqueName;
//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
// Create unique file
QFile file( mLockUniqueName );
file.open( IO_WriteOnly );
file.close();
// Create lock file
int result = 0;
#ifndef _WIN32_
result = ::link( QFile::encodeName( mLockUniqueName ),
QFile::encodeName( lockName ) );
#endif
if ( result == 0 ) {
addressBook()->emitAddressBookLocked();
return true;
}
// TODO: check stat
return false;
#else
return true;
#endif
}
void ResourceFile::unlock( const QString &fileName )
{
#ifdef ALLOW_LOCKING
QString fn = fileName;
//US change the implementation how the lockfilename is getting created
//US fn.replace( QRegExp( "/" ), "_" );
//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
//US QString lockName = fn + ".lock";
KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
QFile::remove( lockName );
QFile::remove( mLockUniqueName );
addressBook()->emitAddressBookUnlocked();
#else
return;
#endif
}
void ResourceFile::setFileName( const QString &fileName )
{
#ifndef NO_DIRWATCH
mDirWatch.stopScan();
mDirWatch.removeFile( mFileName );
mFileName = fileName;
mDirWatch.addFile( mFileName );
mDirWatch.startScan();
#else
- mFileName = fileName;
+ mFileName2 = fileName;
#endif
//US simulate KDirWatch event
//US fileChanged();
}
QString ResourceFile::fileName() const
{
- return mFileName;
+ return mFileName2;
}
void ResourceFile::setFormat( const QString &format )
{
mFormatName = format;
delete mFormat;
FormatFactory *factory = FormatFactory::self();
mFormat = factory->format( mFormatName );
/*US
//qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1());
if (mFormatName == "vcard") {
mFormat = new VCardFormatPlugin2();
// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1());
}
else if (mFormatName == "binary") {
mFormat = new BinaryFormat();
// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1());
}
else
qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1());
*/
}
QString ResourceFile::format() const
{
return mFormatName;
}
void ResourceFile::fileChanged()
{
// There is a small theoretical chance that KDirWatch calls us before
// we are fully constructed
if (!addressBook())
return;
- QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
+ QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
load();
addressBook()->emitAddressBookChanged();
}
}
void ResourceFile::removeAddressee( const Addressee &addr )
{
QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) );
QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) );
QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) );
}
void ResourceFile::cleanUp()
{
- unlock( mFileName );
+ unlock( fileName() );
}
//US #include "resourcefile.moc"
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h
index b4421b2..dd38a9d 100644
--- a/kabc/plugins/file/resourcefile.h
+++ b/kabc/plugins/file/resourcefile.h
@@ -102,62 +102,62 @@ public:
* Returns true if all addressees could be saved otherwise false.
*
* @param ticket The ticket returned by @ref requestSaveTicket()
*/
virtual bool save( Ticket *ticket );
/**
* Set name of file to be used for saving.
*/
void setFileName( const QString & );
/**
* Return name of file used for loading and saving the address book.
*/
QString fileName() const;
/**
Sets a new format by name.
*/
void setFormat( const QString &name );
/**
Returns the format name.
*/
QString format() const;
/**
* Remove a addressee from its source.
* This method is mainly called by KABC::AddressBook.
*/
virtual void removeAddressee( const Addressee& addr );
/**
* This method is called by an error handler if the application
* crashed
*/
virtual void cleanUp();
protected slots:
void fileChanged();
protected:
void init( const QString &fileName, const QString &format );
bool lock( const QString &fileName );
void unlock( const QString &fileName );
private:
- QString mFileName;
+ QString mFileName2;
QString mFormatName;
FormatPlugin *mFormat;
QString mLockUniqueName;
#ifndef NO_DIRWATCH
KDirWatch mDirWatch;
#endif
};
}
#endif
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index d182279..2d97c8c 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -279,97 +279,97 @@ KDateTable::keyPressEvent( QKeyEvent *e )
updateCell(temp/7+1, temp%7); // Update the previously selected cell
updateCell(pos/7+1, pos%7); // Update the selected cell
assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
}
void
KDateTable::viewportResizeEvent(QResizeEvent * e)
{
QGridView::viewportResizeEvent(e);
setCellWidth(viewport()->width()/7);
setCellHeight(viewport()->height()/7);
}
void
KDateTable::setFontSize(int size)
{
int count;
QRect rect;
// ----- store rectangles:
fontsize=size;
QFont _font = font();
_font.setPointSize(fontsize);
setFont( _font );
_font.setBold( true );
QFontMetrics metrics(_font);
// ----- find largest day name:
maxCell.setWidth(0);
maxCell.setHeight(0);
for(count=0; count<7; ++count)
{
rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
}
// ----- compare with a real wide number and add some space:
rect=metrics.boundingRect(QString::fromLatin1("88"));
maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
#ifdef DESKTOP_VERSION
maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
#else
maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
#endif
if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
maxCell.setHeight(maxCell.width() * 1000 / 1900 );
- qDebug("setmax ");
+ //qDebug("setmax ");
}
}
void
KDateTable::contentsMousePressEvent(QMouseEvent *e)
{
if(e->type()!=QEvent::MouseButtonPress)
{ // the KDatePicker only reacts on mouse press events:
return;
}
if(!isEnabled())
{
KNotifyClient::beep();
return;
}
int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
// -----
int row, col, pos, temp;
QPoint mouseCoord;
// -----
mouseCoord = e->pos();
row=rowAt(mouseCoord.y());
col=columnAt(mouseCoord.x());
if(row<0 || col<0)
{ // the user clicked on the frame of the table
return;
}
pos=7*(row-1)+col+1;
#if 0
if(pos+dayoff<=firstday)
{ // this day is in the previous month
KNotifyClient::beep();
return;
}
if(firstday+numdays<pos+dayoff)
{ // this date is in the next month
KNotifyClient::beep();
return;
}
#endif
temp=firstday+date.day()-dayoff-1;
QDate da = QDate(date.year(), date.month(),1);
setDate(da.addDays( pos-firstday+dayoff-1));
updateCell(temp/7+1, temp%7); // Update the previously selected cell
updateCell(row, col); // Update the selected cell
// assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
emit(tableClicked());
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp
index 810c889..4ab1a68 100644
--- a/microkde/kdecore/kstandarddirs.cpp
+++ b/microkde/kdecore/kstandarddirs.cpp
@@ -1158,97 +1158,97 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode)
uint i = 1;
while( i < len )
{
//US struct stat st;
#ifndef _WIN32_
int pos = target.find('/', i);
#else
int pos = target.find('\\', i);
#endif
if ( pos < 0 )
return true;
base += target.mid(i - 1, pos - i + 1);
//QMessageBox::information( 0,"cap111", base, 1 );
/*US
QCString baseEncoded = QFile::encodeName(base);
// bail out if we encountered a problem
if (stat(baseEncoded, &st) != 0)
{
// Directory does not exist....
// Or maybe a dangling symlink ?
if (lstat(baseEncoded, &st) == 0)
(void)unlink(baseEncoded); // try removing
if ( mkdir(baseEncoded, (mode_t) mode) != 0) {
perror("trying to create local folder");
return false; // Couldn't create it :-(
}
}
*/
if (dirObj.exists(base) == false)
{
//qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1());
if (dirObj.mkdir(base) != true)
{
qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1());
return false;
}
}
i = pos + 1;
}
return true;
}
-static QString readEnvPath(const char *env)
+QString readEnvPath(const char *env)
{
//#ifdef _WIN32_
// return "";
//#else
QCString 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);
@@ -1261,96 +1261,98 @@ void KStandardDirs::addKDEDefaults()
#ifdef __KDE_EXECPREFIX
QString execPrefix(__KDE_EXECPREFIX);
if (execPrefix!="NONE")
kdedirList.append(execPrefix);
#endif
QString localKdeDir;
//US if (getuid())
if (true)
{
localKdeDir = readEnvPath("MICROKDEHOME");
if (!localKdeDir.isEmpty())
{
#ifdef _WIN32_
if (localKdeDir.at(localKdeDir.length()-1) != '\\')
localKdeDir += '\\';
#else
if (localKdeDir.at(localKdeDir.length()-1) != '/')
localKdeDir += '/';
#endif
//QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 );
}
else
{
QString confFile;
#ifdef DESKTOP_VERSION
confFile = qApp->applicationDirPath ()+ "/.microkdehome" ;
QFileInfo fi ( confFile );
if ( !fi.exists() )
confFile = QDir::homeDirPath() + "/.microkdehome";
else
qDebug("Loading path info from " + confFile );
#else
confFile = QDir::homeDirPath() + "/.microkdehome";
#endif
KConfig cfg ( confFile );
cfg.setGroup("Global");
localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" );
#ifdef DESKTOP_VERSION
if ( localKdeDir.startsWith( "LOCAL:" ) ) {
#ifdef _WIN32_
localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 );
#else
localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 );
#endif
qDebug("Using local conf dir %s ",localKdeDir.latin1() );
+ // <stdlib.h>
+ setenv( "LOCALMICROKDEHOME", localKdeDir.latin1(), 1 );
}
#endif
}
}
else
{
// We treat root different to prevent root messing up the
// file permissions in the users home directory.
localKdeDir = readEnvPath("MICROKDEROOTHOME");
if (!localKdeDir.isEmpty())
{
if (localKdeDir.at(localKdeDir.length()-1) != '/')
localKdeDir += '/';
}
else
{
//US struct passwd *pw = getpwuid(0);
//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/";
qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed");
}
}
//US localKdeDir = appDir();
//US
// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1());
if (localKdeDir != "-/")
{
localKdeDir = KShell::tildeExpand(localKdeDir);
addPrefix(localKdeDir);
}
for (QStringList::ConstIterator it = kdedirList.begin();
it != kdedirList.end(); it++)
{
QString dir = KShell::tildeExpand(*it);
addPrefix(dir);
}
// end KDEDIRS
// begin XDG_CONFIG_XXX
QStringList xdgdirList;
QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS");
if (!xdgdirs.isEmpty())
{
tokenize(xdgdirList, xdgdirs, ":");
}
diff --git a/microkde/kdecore/kstandarddirs.h b/microkde/kdecore/kstandarddirs.h
index bee864e..901384e 100644
--- a/microkde/kdecore/kstandarddirs.h
+++ b/microkde/kdecore/kstandarddirs.h
@@ -602,80 +602,84 @@ public:
* On The Usage Of 'locate' and 'locateLocal'
*
* Typical KDE applications use resource files in one out of
* three ways:
*
* 1) A resource file is read but is never written. A system
* default is supplied but the user can override this
* default in his local .kde directory:
*
* \code
* // Code example
* myFile = locate("appdata", "groups.lst");
* myData = myReadGroups(myFile); // myFile may be null
* \endcode
*
* 2) A resource file is read and written. If the user has no
* local version of the file the system default is used.
* The resource file is always written to the users local
* .kde directory.
*
* \code
* // Code example
* myFile = locate("appdata", "groups.lst")
* myData = myReadGroups(myFile);
* ...
* doSomething(myData);
* ...
* myFile = locateLocal("appdata", "groups.lst");
* myWriteGroups(myFile, myData);
* \endcode
*
* 3) A resource file is read and written. No system default
* is used if the user has no local version of the file.
* The resource file is always written to the users local
* .kde directory.
*
* \code
* // Code example
* myFile = locateLocal("appdata", "groups.lst");
* myData = myReadGroups(myFile);
* ...
* doSomething(myData);
* ...
* myFile = locateLocal("appdata", "groups.lst");
* myWriteGroups(myFile, myData);
* \endcode
**/
+
/*!
* \relates KStandardDirs
* This function is just for convenience. It simply calls
*instance->dirs()->\link KStandardDirs::findResource() findResource\endlink(type, filename).
**/
QString locate( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance()*/ );
/*!
* \relates KStandardDirs
* This function is much like locate. However it returns a
* filename suitable for writing to. No check is made if the
* specified filename actually exists. Missing directories
* are created. If filename is only a directory, without a
* specific file, filename must have a trailing slash.
*
**/
QString locateLocal( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance() */ );
/*!
* \relates KStandardDirs
* This function is much like locate. No check is made if the
* specified filename actually exists. Missing directories
* are created if @p createDir is true. If filename is only
* a directory, without a specific file,
* filename must have a trailing slash.
*
**/
QString locateLocal( const char *type, const QString& filename, bool createDir /*US , const KInstance* instance = KGlobal::instance() */);
+QString readEnvPath(const char *env);
+
+
/*! @} */
#endif // SSK_KSTDDIRS_H