-rw-r--r-- | korganizer/mainwindow.cpp | 10 | ||||
-rw-r--r-- | libkdepim/libkdepim.pro | 2 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 21 |
3 files changed, 24 insertions, 9 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index f4ac0d6..7bf33d3 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -744,263 +744,263 @@ void MainWindow::initActions() SLOT( licence() ) ); //menuBar->insertSeparator(); // ****************************************************** // menubar icons iconToolBar->setHorizontalStretchable (true ); //menuBar->insertItem( iconToolBar ); //xdays_action if (p-> mShowIconNewEvent) ne_action->addTo( iconToolBar ); if (p->mShowIconNewTodo ) nt_action->addTo( iconToolBar ); if (p-> mShowIconSearch) search_action->addTo( iconToolBar ); if (p-> mShowIconNext) whatsnext_action->addTo( iconToolBar ); if (p-> mShowIconNextDays) xdays_action->addTo( iconToolBar ); if (p-> mShowIconList) showlist_action->addTo( iconToolBar ); if (p-> mShowIconDay1) day1_action->addTo( iconToolBar ); if (p-> mShowIconDay5) day5_action->addTo( iconToolBar ); if (p-> mShowIconDay7) day7_action->addTo( iconToolBar ); if (p-> mShowIconMonth) month_action->addTo( iconToolBar ); if (p-> mShowIconTodoview) todoview_action->addTo( iconToolBar ); if (p-> mShowIconJournal) viewjournal_action->addTo( iconToolBar ); icon = loadPixmap( pathString + "2leftarrowB" ); configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); if (p-> mShowIconBackFast) { action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); connect( action, SIGNAL( activated() ), mView, SLOT( goPreviousMonth() ) ); action->addTo( iconToolBar ); } icon = loadPixmap( pathString + "1leftarrowB" ); configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); if (p-> mShowIconBack) { action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); connect( action, SIGNAL( activated() ), mView, SLOT( goPrevious() ) ); action->addTo( iconToolBar ); } if (p-> mShowIconToday) today_action->addTo( iconToolBar ); icon = loadPixmap( pathString + "1rightarrowB" ); configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); if (p-> mShowIconForward) { action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); connect( action, SIGNAL( activated() ), mView, SLOT( goNext() ) ); action->addTo( iconToolBar ); } icon = loadPixmap( pathString + "2rightarrowB" ); configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); if (p-> mShowIconForwardFast) { action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); connect( action, SIGNAL( activated() ), mView, SLOT( goNextMonth() ) ); action->addTo( iconToolBar ); } configureToolBarMenu->insertItem(i18n("What's This?"), 300); if (p-> mShowIconNewEvent) configureToolBarMenu->setItemChecked( 10, true ); if (p->mShowIconNewTodo ) configureToolBarMenu->setItemChecked( 20, true ); if (p-> mShowIconSearch) configureToolBarMenu->setItemChecked( 120, true ); if (p-> mShowIconList) configureToolBarMenu->setItemChecked( 30, true ); if (p-> mShowIconDay1) configureToolBarMenu->setItemChecked( 40, true ); if (p-> mShowIconDay5) configureToolBarMenu->setItemChecked( 50, true ); if (p-> mShowIconDay7) configureToolBarMenu->setItemChecked( 60, true ); if (p-> mShowIconMonth) configureToolBarMenu->setItemChecked( 70, true ); if (p-> mShowIconTodoview) configureToolBarMenu->setItemChecked( 80, true ); if (p-> mShowIconBackFast) configureToolBarMenu->setItemChecked( 200, true ); if (p-> mShowIconBack) configureToolBarMenu->setItemChecked( 210, true ); if (p-> mShowIconToday) configureToolBarMenu->setItemChecked( 130, true ); if (p-> mShowIconForward) configureToolBarMenu->setItemChecked( 220, true ); if (p-> mShowIconForwardFast) configureToolBarMenu->setItemChecked( 230, true ); if (p-> mShowIconNextDays) configureToolBarMenu->setItemChecked( 100, true ); if (p-> mShowIconNext) configureToolBarMenu->setItemChecked( 110, true ); if (p-> mShowIconJournal) configureToolBarMenu->setItemChecked( 90, true ); if (p-> mShowIconWhatsThis) configureToolBarMenu->setItemChecked( 300, true ); QLabel* dummy = new QLabel( iconToolBar ); dummy->setBackgroundColor( iconToolBar->backgroundColor() ); if (!p-> mShowIconStretch) iconToolBar->setStretchableWidget ( dummy ) ; else configureToolBarMenu->setItemChecked( 5, true ); if (p-> mShowIconWhatsThis) QWhatsThis::whatsThisButton ( iconToolBar ); connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); configureAgenda( p->mHourSize ); connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); } void MainWindow::fillSyncMenu() { if ( syncMenu->count() ) syncMenu->clear(); syncMenu->insertItem( i18n("Configure..."), 0 ); syncMenu->insertSeparator(); if ( mServerSocket == 0 ) { - syncMenu->insertItem( i18n("Enable Easy-Pi-Sync"), 2 ); + syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); } else { - syncMenu->insertItem( i18n("Disable Easy-Pi-Sync"), 3 ); + syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); } syncMenu->insertSeparator(); - syncMenu->insertItem( i18n("New Easy-Pi-Sync!"), 4 ); - syncMenu->insertItem( i18n("Quick Easy-Pi-Sync!"), 5 ); + syncMenu->insertItem( i18n("New Pi-Sync!"), 4 ); + syncMenu->insertItem( i18n("Quick Pi-Sync!"), 5 ); syncMenu->insertSeparator(); syncMenu->insertItem( i18n("Multiple sync"), 1 ); syncMenu->insertSeparator(); KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); config.setGroup("General"); QStringList prof = config.readListEntry("SyncProfileNames"); KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); if ( prof.count() < 3 ) { prof.clear(); prof << i18n("Sharp_DTM"); prof << i18n("Local_file"); prof << i18n("Last_file"); KSyncProfile* temp = new KSyncProfile (); temp->setName( prof[0] ); temp->writeConfig(&config); temp->setName( prof[1] ); temp->writeConfig(&config); temp->setName( prof[2] ); temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); config.writeEntry("ExternSyncProfiles","Sharp_DTM"); config.sync(); delete temp; } KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); KOPrefs::instance()->mSyncProfileNames = prof; int i; for ( i = 0; i < prof.count(); ++i ) { syncMenu->insertItem( prof[i], 1000+i ); if ( i == 2 ) syncMenu->insertSeparator(); } QDir app_dir; if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { syncMenu->setItemEnabled( false , 1000 ); } mView->setupExternSyncProfiles(); } int MainWindow::ringSync() { int syncedProfiles = 0; int i; QTime timer; KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; KSyncProfile* temp = new KSyncProfile (); KOPrefs::instance()->mAskForPreferences = false; for ( i = 0; i < syncProfileNames.count(); ++i ) { mCurrentSyncProfile = i; temp->setName(syncProfileNames[mCurrentSyncProfile]); temp->readConfig(&config); if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); ++syncedProfiles; // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); KOPrefs::instance()->mWriteBackInFuture = 0; if ( temp->getWriteBackFuture() ) KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); KOPrefs::instance()->mShowSyncSummary = false; mView->setSyncDevice(syncProfileNames[i] ); mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); if ( i == 0 ) { syncSharp(); } else { if ( temp->getIsLocalFileSync() ) { if ( syncWithFile( temp->getRemoteFileName( ), true ) ) KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); } else { if ( temp->getIsPhoneSync() ) { KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); syncPhone(); } else syncRemote( temp, false ); } } timer.start(); setCaption(i18n("Multiple sync in progress ... please wait!") ); while ( timer.elapsed () < 2000 ) { qApp->processEvents(); #ifndef _WIN32_ sleep (1); #endif } } } delete temp; return syncedProfiles; } void MainWindow::multiSync( bool askforPrefs ) { if (mBlockSaveFlag) return; mBlockSaveFlag = true; QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); if ( QMessageBox::information( this, i18n("KO/Pi Sync"), question, i18n("Yes"), i18n("No"), 0, 0 ) != 0 ) { mBlockSaveFlag = false; setCaption(i18n("Aborted! Nothing synced!")); return; } mView->setSyncDevice(i18n("Multiple profiles") ); KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; if ( askforPrefs ) { mView->edit_sync_options(); KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; } setCaption(i18n("Multiple sync started.") ); qApp->processEvents(); int num = ringSync() ; if ( num > 1 ) ringSync(); mBlockSaveFlag = false; if ( num ) save(); if ( num ) @@ -1882,257 +1882,259 @@ QString MainWindow::getPassword( ) if ( res ) retfile = lab.text(); dia.hide(); qApp->processEvents(); return retfile; } void MainWindow::enableQuick() { QString retfile = ""; QDialog dia ( this, "input-dialog", true ); QLineEdit lab ( &dia ); QVBoxLayout lay( &dia ); lab.setText( KOPrefs::instance()->mPassiveSyncPort ); lay.setMargin(7); lay.setSpacing(7); QLabel label ( i18n("Port number (Default: 9197)"), &dia ); lay.addWidget( &label); lay.addWidget( &lab); dia.setFixedSize( 230,80 ); dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.show(); int res = dia.exec(); if ( res ) retfile = lab.text(); else return; dia.hide(); qApp->processEvents(); KOPrefs::instance()->mPassiveSyncPort = retfile; bool ok; Q_UINT16 port = retfile.toUInt(&ok); if ( ! ok ) { qDebug("no valid port "); return; } qDebug("port %d ", port); mServerSocket = new KServerSocket ( port ,1 ); qDebug("connected "); if ( !mServerSocket->ok() ) { qWarning("Failed to bind to port %d", port); delete mServerSocket; mServerSocket = 0; return; } connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); } void MainWindow::sendFile(QSocket* socket) { setCaption( i18n("Received request for file") ); qDebug("MainWindow::sendFile(QSocket* s) "); if ( mSyncActionDialog ) delete mSyncActionDialog; mSyncActionDialog = new QDialog ( this, "input-dialog", true ); mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); lay->addWidget( label); lay->setMargin(7); lay->setSpacing(7); mSyncActionDialog->setFixedSize( 200,100 ); mSyncActionDialog->show(); qApp->processEvents(); qDebug("saving ... "); save(); QString fileName = defaultFileName(); QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { setCaption( i18n("Error open file") ); delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("error open cal file "); return ; } setCaption( i18n("Sending file...") ); QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); QTextStream os( socket ); os.setCodec( QTextCodec::codecForName("utf8") ); //os.setEncoding( QTextStream::UnicodeUTF8 ); while ( ! ts.atEnd() ) { os << ts.readLine() << "\n"; } //os << ts.read(); socket->close(); file.close(); setCaption( i18n("File sent. Waiting to get back synced file") ); qDebug("file sent "); } void MainWindow::getFile(QSocket* socket) { setCaption( i18n("Receiving synced file...") ); QString fileName = defaultFileName(); QFile file( fileName ); if (!file.open( IO_WriteOnly ) ) { setCaption( i18n("Error open file") ); delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("error open cal file "); return ; } mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); bool first = true; while ( socket->canReadLine () || first ) { first = false; while ( socket->canReadLine () ) { qDebug("avail %d ", socket->bytesAvailable () ); ts << socket->readLine (); } QTime ti; ti.start(); while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); //qApp->processEvents(); qDebug("waiting1b %d ",ti.elapsed () ); if ( !socket->canReadLine () ) { qDebug("waiting1c %d ",ti.elapsed () ); +#ifndef _WIN32_ usleep( 100000); +#endif } //socket->waitForMore ( 100 ); } ts << socket->readLine (); #if 0 #ifdef DESKTOP_VERSION socket->waitForMore ( 5000 ); #else // socket->waitForMore ( 5000 ); // seems to be broken in qt2 bool stop = false; QTime ti; ti.start(); while ( ti.elapsed < 5000 && !stop ) { qApp->processEvents(); if ( socket->canReadLine () ) stop = true ; else { usleep( 100000 ); } } #endif #endif } setCaption( i18n("File received - reloading calendar...") ); socket->close(); file.close(); mView->watchSavedFile(); mView->openCalendar( defaultFileName() ); setCaption( i18n("Easy-Pi-Sync successful!") ); delete mSyncActionDialog; mSyncActionDialog = 0; } void MainWindow::endConnect() { setCaption( i18n("No file received - syncing successful") ); delete mSyncActionDialog; mSyncActionDialog = 0; } void MainWindow::performQuick() { setCaption( i18n("Please input connection settings") ); QString retfile = ""; QDialog dia ( this, "input-dialog", true ); QLineEdit lab ( &dia ); QVBoxLayout lay( &dia ); QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); lay.addWidget( &label); lab.setText( KOPrefs::instance()->mActiveSyncIP ); lay.setMargin(7); lay.setSpacing(7); lay.addWidget( &lab); QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); lay.addWidget( &label2); QLineEdit lab2 ( &dia ); lab2.setText( KOPrefs::instance()->mActiveSyncPort ); lay.addWidget( &lab2); dia.setFixedSize( 230,200 ); dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.show(); int res = dia.exec(); if ( !res ) { setCaption( i18n("Syncing cancelled!") ); return; } dia.hide(); KOPrefs::instance()->mActiveSyncPort = lab2.text(); KOPrefs::instance()->mActiveSyncIP = lab.text(); qApp->processEvents(); performQuickQuick(); } void MainWindow::performQuickQuick() { // setCaption( i18n("") ); bool ok; Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); if ( ! ok ) { setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); return; } if ( !mCommandSocket ) { mCommandSocket = new QSocket( this ); // delete mCommandSocket; //mCommandSocket = new QSocket( this ); connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); } QString host = KOPrefs::instance()->mActiveSyncIP; mCommandSocket->connectToHost( host, port ); QTextStream os( mCommandSocket ); os.setEncoding( QTextStream::UnicodeUTF8 ); os << "GET\r\n"; setCaption( i18n("Sending request for remote file ...") ); } void MainWindow::readFileFromSocket() { setCaption( i18n("Receiving remote file ...") ); qDebug("MainWindow::readFileFromSocket() "); QString fileName; #ifdef _WIN32_ fileName = defaultFileName() +"sync"; #else fileName = "/tmp/kopitempfile.ics"; #endif QFile file( fileName ); if (!file.open( IO_WriteOnly ) ) { setCaption( i18n("Error: Cannot open temp file for write.") ); qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); return ; } //QTextStream os2( mCommandSocket ); //os2.setEncoding( QTextStream::UnicodeUTF8 ); QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); bool first = true; while ( mCommandSocket->canReadLine () || first) { first = false; while ( mCommandSocket->canReadLine () ) { diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro index 7231842..eac19ea 100644 --- a/libkdepim/libkdepim.pro +++ b/libkdepim/libkdepim.pro @@ -1,57 +1,59 @@ TEMPLATE = lib CONFIG = qt warn_on DEFINES +=KORG_NOKABC TARGET = microkdepim INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. DESTDIR=../bin DEFINES += DESKTOP_VERSION include( ../variables.pri ) unix : { OBJECTS_DIR = obj/unix MOC_DIR = moc/unix } win32: { DEFINES += _WIN32_ OBJECTS_DIR = obj/win MOC_DIR = moc/win } INTERFACES = \ HEADERS = \ categoryeditdialog.h \ categoryeditdialog_base.h \ categoryselectdialog.h \ categoryselectdialog_base.h \ externalapphandler.h \ kdateedit.h \ kdatepicker.h \ kinputdialog.h \ kpimprefs.h \ kpimglobalprefs.h \ kprefsdialog.h \ kprefswidget.h \ + ksyncmanager.h \ ksyncprofile.h \ ksyncprefsdialog.h \ kcmconfigs/kcmkdepimconfig.h \ kcmconfigs/kdepimconfigwidget.h SOURCES = \ categoryeditdialog.cpp \ categoryeditdialog_base.cpp \ categoryselectdialog.cpp \ categoryselectdialog_base.cpp \ externalapphandler.cpp \ kdateedit.cpp \ kdatepicker.cpp \ kinputdialog.cpp \ kpimprefs.cpp \ kpimglobalprefs.cpp \ kprefsdialog.cpp \ kprefswidget.cpp \ + ksyncmanager.cpp \ ksyncprofile.cpp \ ksyncprefsdialog.cpp \ kcmconfigs/kcmkdepimconfig.cpp \ kcmconfigs/kdepimconfigwidget.cpp diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 7f2a326..1c3e0ae 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp @@ -1,172 +1,173 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> Copyright (C) 1999 Stephan Kulow <coolo@kde.org> Copyright (C) 1999 Waldo Bastian <bastian@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> * Version: $Id$ * Generated: Thu Mar 5 16:05:28 EST 1998 */ //US #include "config.h" #include <stdlib.h> #include <assert.h> //US#include <errno.h> //US #ifdef HAVE_SYS_STAT_H //US #include <sys/stat.h> //US #endif //US#include <sys/types.h> //US#include <dirent.h> //US#include <pwd.h> #include <qregexp.h> #include <qasciidict.h> #include <qdict.h> #include <qdir.h> #include <qfileinfo.h> #include <qstring.h> +#include <qmessagebox.h> #include <qapplication.h> #include <qstringlist.h> #include "kstandarddirs.h" #include "kconfig.h" #include "kdebug.h" //US #include "kinstance.h" #include "kshell.h" //US#include <sys/param.h> //US#include <unistd.h> //US QString KStandardDirs::mAppDir = QString::null; template class QDict<QStringList>; #if 0 #include <qtextedit.h> void ddd( QString op ) { static QTextEdit * dot = 0; if ( ! dot ) dot = new QTextEdit(); dot->show(); dot->append( op ); } #endif class KStandardDirs::KStandardDirsPrivate { public: KStandardDirsPrivate() : restrictionsActive(false), dataRestrictionActive(false) { } bool restrictionsActive; bool dataRestrictionActive; QAsciiDict<bool> restrictions; QStringList xdgdata_prefixes; QStringList xdgconf_prefixes; }; static const char* const types[] = {"html", "icon", "apps", "sound", "data", "locale", "services", "mime", "servicetypes", "config", "exe", "tmp", "wallpaper", "lib", "pixmap", "templates", "module", "qtplugins", "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; static int tokenize( QStringList& token, const QString& str, const QString& delim ); KStandardDirs::KStandardDirs( ) : addedCustoms(false) { d = new KStandardDirsPrivate; dircache.setAutoDelete(true); relatives.setAutoDelete(true); absolutes.setAutoDelete(true); savelocations.setAutoDelete(true); addKDEDefaults(); } KStandardDirs::~KStandardDirs() { delete d; } bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const { if (!d || !d->restrictionsActive) return false; if (d->restrictions[type]) return true; if (strcmp(type, "data")==0) { applyDataRestrictions(relPath); if (d->dataRestrictionActive) { d->dataRestrictionActive = false; return true; } } return false; } void KStandardDirs::applyDataRestrictions(const QString &relPath) const { QString key; int i = relPath.find('/'); if (i != -1) key = "data_"+relPath.left(i); else key = "data_"+relPath; if (d && d->restrictions[key.latin1()]) d->dataRestrictionActive = true; } QStringList KStandardDirs::allTypes() const { QStringList list; for (int i = 0; types[i] != 0; ++i) list.append(QString::fromLatin1(types[i])); return list; } void KStandardDirs::addPrefix( const QString& _dir ) { if (_dir.isNull()) return; QString dir = _dir; if (dir.at(dir.length() - 1) != '/') dir += '/'; if (!prefixes.contains(dir)) { prefixes.append(dir); dircache.clear(); } } @@ -1079,321 +1080,331 @@ QString KStandardDirs::relativeLocation(const char *type, const QString &absPath } 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); // bail out if we encountered a problem //US if (stat(baseEncoded, &st) != 0) QFileInfo baseEncodedInfo(baseEncoded); if (!baseEncodedInfo.exists()) { // Directory does not exist.... // Or maybe a dangling symlink ? //US if (lstat(baseEncoded, &st) == 0) if (baseEncodedInfo.isSymLink()) { //US (void)unlink(baseEncoded); // try removing QFile(baseEncoded).remove(); } //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) QDir dirObj; if ( dirObj.mkdir(baseEncoded) != true ) { //US perror("trying to create local folder"); return false; // Couldn't create it :-( } } i = pos + 1; } return true; #endif // ******************************************** // new code for WIN32 QDir dirObj; // we want an absolute path #ifndef _WIN32_ if (dir.at(0) != '/') return false; #endif QString target = dir; uint len = target.length(); #ifndef _WIN32_ // append trailing slash if missing if (dir.at(len - 1) != '/') target += '/'; #endif QString base(""); uint i = 1; while( i < len ) { //US struct stat st; #ifndef _WIN32_ int pos = target.find('/', i); #else int pos = target.find('\\', i); #endif if ( pos < 0 ) return true; base += target.mid(i - 1, pos - i + 1); //QMessageBox::information( 0,"cap111", base, 1 ); /*US QCString baseEncoded = QFile::encodeName(base); // bail out if we encountered a problem if (stat(baseEncoded, &st) != 0) { // Directory does not exist.... // Or maybe a dangling symlink ? if (lstat(baseEncoded, &st) == 0) (void)unlink(baseEncoded); // try removing if ( mkdir(baseEncoded, (mode_t) mode) != 0) { perror("trying to create local folder"); return false; // Couldn't create it :-( } } */ if (dirObj.exists(base) == false) { //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); if (dirObj.mkdir(base) != true) { qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); return false; } } i = pos + 1; } return true; } static QString readEnvPath(const char *env) { -#ifdef _WIN32_ - return ""; -#else - QCString c_path = getenv(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 + //#endif + } void KStandardDirs::addKDEDefaults() { + //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); //return; QStringList kdedirList; // begin KDEDIRS QString kdedirs = readEnvPath("MICROKDEDIRS"); if (!kdedirs.isEmpty()) { tokenize(kdedirList, kdedirs, ":"); } else { QString kdedir = readEnvPath("MICROKDEDIR"); if (!kdedir.isEmpty()) { kdedir = KShell::tildeExpand(kdedir); kdedirList.append(kdedir); } } //US kdedirList.append(KDEDIR); //US for embedded, add qtopia dir as kdedir #ifndef DESKTOP_VERSION QString tmp = readEnvPath("QPEDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); tmp = readEnvPath("QTDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); tmp = readEnvPath("OPIEDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); #endif #ifdef __KDE_EXECPREFIX QString execPrefix(__KDE_EXECPREFIX); if (execPrefix!="NONE") kdedirList.append(execPrefix); #endif QString localKdeDir; //US if (getuid()) if (true) { localKdeDir = readEnvPath("MICROKDEHOME"); if (!localKdeDir.isEmpty()) { +#ifdef _WIN32_ + if (localKdeDir.at(localKdeDir.length()-1) != '\\') + localKdeDir += '\\'; +#else if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; +#endif + //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); } else { localKdeDir = QDir::homeDirPath() + "/kdepim/"; } } else { // We treat root different to prevent root messing up the // file permissions in the users home directory. localKdeDir = readEnvPath("MICROKDEROOTHOME"); if (!localKdeDir.isEmpty()) { if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; } else { //US struct passwd *pw = getpwuid(0); //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); } } //US localKdeDir = appDir(); //US // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); if (localKdeDir != "-/") { localKdeDir = KShell::tildeExpand(localKdeDir); addPrefix(localKdeDir); } for (QStringList::ConstIterator it = kdedirList.begin(); it != kdedirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addPrefix(dir); } // end KDEDIRS // begin XDG_CONFIG_XXX QStringList xdgdirList; QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); if (!xdgdirs.isEmpty()) { tokenize(xdgdirList, xdgdirs, ":"); } else { xdgdirList.clear(); xdgdirList.append("/etc/xdg"); } QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); if (!localXdgDir.isEmpty()) { if (localXdgDir.at(localXdgDir.length()-1) != '/') localXdgDir += '/'; } else { //US if (getuid()) if (true) { localXdgDir = QDir::homeDirPath() + "/.config/"; } else { //US struct passwd *pw = getpwuid(0); //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); } } localXdgDir = KShell::tildeExpand(localXdgDir); addXdgConfigPrefix(localXdgDir); for (QStringList::ConstIterator it = xdgdirList.begin(); it != xdgdirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addXdgConfigPrefix(dir); } // end XDG_CONFIG_XXX // begin XDG_DATA_XXX xdgdirs = readEnvPath("XDG_DATA_DIRS"); if (!xdgdirs.isEmpty()) { tokenize(xdgdirList, xdgdirs, ":"); } else { xdgdirList.clear(); for (QStringList::ConstIterator it = kdedirList.begin(); it != kdedirList.end(); it++) { QString dir = *it; if (dir.at(dir.length()-1) != '/') dir += '/'; xdgdirList.append(dir+"share/"); } xdgdirList.append("/usr/local/share/"); xdgdirList.append("/usr/share/"); } localXdgDir = readEnvPath("XDG_DATA_HOME"); if (!localXdgDir.isEmpty()) { if (localXdgDir.at(localXdgDir.length()-1) != '/') localXdgDir += '/'; } else { //US if (getuid()) if (true) { localXdgDir = QDir::homeDirPath() + "/.local/share/"; } else { //US struct passwd *pw = getpwuid(0); //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); |