author | zautrix <zautrix> | 2004-10-03 18:03:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-03 18:03:18 (UTC) |
commit | dd8f6efd23350b101065ddb64f35920f24010185 (patch) (side-by-side diff) | |
tree | 76475452c6c8854178a84e5fff863a21a8e117d3 | |
parent | 2a7b61c2b45a0a0344ae65633b2578b4cde1753f (diff) | |
download | kdepimpi-dd8f6efd23350b101065ddb64f35920f24010185.zip kdepimpi-dd8f6efd23350b101065ddb64f35920f24010185.tar.gz kdepimpi-dd8f6efd23350b101065ddb64f35920f24010185.tar.bz2 |
Fixes for desktop. Fixed kdehomedir on wintendo
-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 @@ -616,519 +616,519 @@ void MainWindow::initActions() action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); action = new QAction( "import_quick", i18n("Import last file"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); importMenu->insertSeparator(); action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); #ifndef DESKTOP_VERSION importMenu->insertSeparator(); action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); #else #ifdef _WIN32_ importMenu->insertSeparator(); action = new QAction( "import_ol", i18n("Import from OL"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); #endif #endif importMenu->insertSeparator(); action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); importMenu->insertSeparator(); action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); importMenu->insertSeparator(); action = new QAction( "manage cat", i18n("Manage new categories..."), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); #ifndef DESKTOP_VERSION importMenu->insertSeparator(); action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); #else importMenu->insertSeparator(); icon = loadPixmap( pathString + "print" ); action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), this, SLOT( printCal() ) ); icon = loadPixmap( pathString + "print" ); action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), this, SLOT( printSel() ) ); #endif importMenu->insertSeparator(); action = new QAction( "beam all", i18n("Save"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); action = new QAction( "beam all", i18n("Exit (+save)"), 0, this ); action->addTo( importMenu ); connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); //menuBar->insertItem( "Configure",configureMenu ); //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); icon = loadPixmap( "korganizer/korganizer" ); action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( keyBindings() ) ); action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( features() ) ); action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( aboutAutoSaving() ) ); action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( aboutKnownBugs() ) ); action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( usertrans() ) ); action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( synchowto() ) ); action = new QAction( "Whats New", i18n("What's new?"), 0,this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( whatsNew() ) ); action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( faq() ) ); action = new QAction( "about", i18n("About..."), 0, this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), SLOT( about() ) ); action = new QAction( "licence", i18n("Licence..."), 0, this ); action->addTo( helpMenu ); connect( action, SIGNAL( activated() ), 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 ) setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); else setCaption(i18n("Nothing synced! No profiles defined for multisync!")); return; } void MainWindow::slotSyncMenu( int action ) { qDebug("syncaction %d ", action); if ( action == 0 ) { // seems to be a Qt2 event handling bug // syncmenu.clear causes a segfault at first time // when we call it after the main event loop, it is ok // same behaviour when calling OM/Pi via QCOP for the first time QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); //confSync(); return; } if ( action == 1 ) { multiSync( true ); return; } if ( action == 2 ) { enableQuick(); QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); return; } if ( action == 3 ) { delete mServerSocket; mServerSocket = 0; QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); return; } if ( action == 4 ) { performQuick(); return; } if ( action == 5 ) { performQuickQuick(); return; } if (mBlockSaveFlag) return; mBlockSaveFlag = true; mCurrentSyncProfile = action - 1000 ; mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); KSyncProfile* temp = new KSyncProfile (); temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); temp->readConfig(&config); KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 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 = temp->getShowSummaryAfterSync(); if ( action == 1000 ) { syncSharp(); } else if ( action == 1001 ) { syncLocalFile(); } else if ( action == 1002 ) { quickSyncLocalFile(); } else if ( action >= 1003 ) { if ( temp->getIsLocalFileSync() ) { if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 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 ); } } delete temp; mBlockSaveFlag = false; } void MainWindow::setDefaultPreferences() { KOPrefs *p = KOPrefs::instance(); p->mCompactDialogs = true; p->mConfirm = true; // p->mEnableQuickTodo = false; } QString MainWindow::resourcePath() { return KGlobal::iconLoader()->iconPath(); } void MainWindow::displayText( QString text ,QString cap ) { QDialog dia( this, "name", true ); ; dia.setCaption( cap ); QVBoxLayout* lay = new QVBoxLayout( &dia ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QTextBrowser tb ( &dia ); lay->addWidget( &tb ); tb.setText( text ); #ifdef DESKTOP_VERSION dia.resize( 640, 480); #else dia.showMaximized(); #endif dia.exec(); } void MainWindow::displayFile( QString fn, QString cap ) { QString fileName = resourcePath() + fn; QString text; QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { return ; } @@ -1754,513 +1754,515 @@ void MainWindow::loadCalendar() QString fn = KOPrefs::instance()->mLastLoadFile; fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( info. exists() ) { mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); int result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, i18n("Load!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { loadbup = false; } } else { QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 0, 1 ); return; } if ( loadbup ) { mView->openCalendar( fn ); KOPrefs::instance()->mLastLoadFile = fn; mess = i18n("KO/Pi:Loaded %1").arg(fn) ; setCaption(mess); } } void MainWindow::quickImportIcal() { importFile( KOPrefs::instance()->mLastImportFile, false ); } void MainWindow::importFile( QString fn, bool quick ) { QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( !info. exists() ) { mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess ); return; } int result = 0; if ( !quick ) { mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, "Import", "Cancel", 0, 0, 1 ); } if ( result == 0 ) { if ( mView->openCalendar( fn, true )) { KOPrefs::instance()->mLastImportFile = fn; setCaption(i18n("Imported file successfully")); } else { setCaption(i18n("Error importing file")); } } } void MainWindow::importIcal() { QString fn =KOPrefs::instance()->mLastImportFile; fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); if ( fn == "" ) return; importFile( fn, true ); } void MainWindow::exportVCalendar() { QString fn = KOPrefs::instance()->mLastVcalFile; fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { if ( mView->exportVCalendar( fn ) ) { KOPrefs::instance()->mLastVcalFile = fn; if ( fn.length() > 20 ) mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; else mes = i18n("KO/Pi:Exported to %1").arg(fn ); setCaption(mes); } } } QString MainWindow::getPassword( ) { QString retfile = ""; QDialog dia ( this, "input-dialog", true ); QLineEdit lab ( &dia ); lab.setEchoMode( QLineEdit::Password ); QVBoxLayout lay( &dia ); lay.setMargin(7); lay.setSpacing(7); lay.addWidget( &lab); dia.setFixedSize( 230,50 ); dia.setCaption( i18n("Enter password") ); 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(); 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 () ) { ts << mCommandSocket->readLine (); } QTime ti; ti.start(); while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { qApp->processEvents(); qDebug("waiting2 %d ",ti.elapsed () ); if ( !mCommandSocket->canReadLine () ) mCommandSocket->waitForMore ( 100 ); } //mCommandSocket->waitForMore ( 5000 ); } file.close(); mCommandSocket->close(); // pending: deleting after signal SIGNAL(delayedCloseFinished()) //delete mCommandSocket; setCaption( i18n("Remote file saved to temp file.") ); //mCommandSocket = 0; mCurrentSyncProfile = 2 ; // last file mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); KSyncProfile* temp = new KSyncProfile (); temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); temp->readConfig(&config); KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 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 = temp->getShowSummaryAfterSync(); setCaption( i18n("Remote file saved to temp file.") ); if ( ! syncWithFile( fileName , true ) ) { setCaption( i18n("Syncing failed.") ); qDebug("Syncing failed "); return; } if ( !mCommandSocketFinish ) { mCommandSocketFinish = new QSocket( this ); } mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); // pending connect signals connected () and error to new slots QString host = KOPrefs::instance()->mActiveSyncIP; QFile file2( fileName ); if (!file2.open( IO_ReadOnly ) ) { setCaption( i18n("Error: Cannot open temp file for read.") ); qDebug("error open cal file "); return ; } setCaption( i18n("Sending back synced file...") ); QTextStream ts2( &file2 ); ts2.setCodec( QTextCodec::codecForName("utf8") ); QTextStream os2( mCommandSocketFinish ); os2.setCodec( QTextCodec::codecForName("utf8") ); //os.setEncoding( QTextStream::UnicodeUTF8 ); if ( KOPrefs::instance()->mWriteBackFile ) { os2 << "PUT\r\n"; while ( ! ts2.atEnd() ) { os2 << ts2.readLine() << "\n"; } } else { os2 << "STOP\r\n"; } mCommandSocketFinish->close(); file.close(); // pending: deleting after signal SIGNAL(delayedCloseFinished()) //delete ( mCommandSocket); //mCommandSocket = 0; qDebug("Syncing succesful! "); setCaption( i18n("Easy-Pi-Sync succesful!") ); } void MainWindow::syncLocalFile() { QString fn =KOPrefs::instance()->mLastSyncedLocalFile; fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); if ( fn == "" ) return; //mView->setSyncDevice("local-file" ); if ( syncWithFile( fn, false ) ) { // Event* e = mView->getLastSyncEvent(); // e->setReadOnly( false ); // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); // e->setReadOnly( true ); } } bool MainWindow::syncWithFile( QString fn , bool quick ) { bool ret = false; QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( !info. exists() ) { mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess ); return ret; } int result = 0; if ( !quick ) { mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess, i18n("Sync"), i18n("Cancel"), 0, 0, 1 ); if ( result ) return false; } if ( KOPrefs::instance()->mAskForPreferences ) mView->edit_sync_options(); if ( result == 0 ) { //qDebug("Now sycing ... "); if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) setCaption( i18n("Synchronization successful") ); else 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,300 +1,301 @@ /* 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(); } } void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) { if (_dir.isNull()) return; QString dir = _dir; if (dir.at(dir.length() - 1) != '/') dir += '/'; if (!d->xdgconf_prefixes.contains(dir)) { d->xdgconf_prefixes.append(dir); dircache.clear(); } } void KStandardDirs::addXdgDataPrefix( const QString& _dir ) { if (_dir.isNull()) return; QString dir = _dir; if (dir.at(dir.length() - 1) != '/') dir += '/'; if (!d->xdgdata_prefixes.contains(dir)) { d->xdgdata_prefixes.append(dir); dircache.clear(); } } QString KStandardDirs::kfsstnd_prefixes() { return prefixes.join(":"); } bool KStandardDirs::addResourceType( const char *type, const QString& relativename ) { if (relativename.isNull()) return false; QStringList *rels = relatives.find(type); if (!rels) { rels = new QStringList(); relatives.insert(type, rels); } QString copy = relativename; if (copy.at(copy.length() - 1) != '/') copy += '/'; if (!rels->contains(copy)) { rels->prepend(copy); dircache.remove(type); // clean the cache return true; } return false; } bool KStandardDirs::addResourceDir( const char *type, const QString& absdir) { QStringList *paths = absolutes.find(type); if (!paths) { paths = new QStringList(); absolutes.insert(type, paths); } QString copy = absdir; if (copy.at(copy.length() - 1) != '/') copy += '/'; if (!paths->contains(copy)) { paths->append(copy); dircache.remove(type); // clean the cache return true; } return false; } QString KStandardDirs::findResource( const char *type, const QString& filename ) const { if (filename.at(0) == '/') return filename; // absolute dirs are absolute dirs, right? :-/ #if 0 kdDebug() << "Find resource: " << type << endl; for (QStringList::ConstIterator pit = prefixes.begin(); pit != prefixes.end(); pit++) { kdDebug() << "Prefix: " << *pit << endl; } #endif QString dir = findResourceDir(type, filename); if (dir.isNull()) return dir; else return dir + filename; } /*US static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) { QCString cFile = QFile::encodeName(file); //US struct stat buff; //US if ((access(cFile, R_OK) == 0) && //US (stat( cFile, &buff ) == 0) && //US (S_ISREG( buff.st_mode ))) QFileInfo pathfnInfo(cFile); if (( pathfnInfo.isReadable() == true ) && ( pathfnInfo.isFile()) ) { //US hash = hash + (Q_UINT32) buff.st_ctime; hash = hash + (Q_UINT32) pathfnInfo.lastModified(); } return hash; } */ /*US Q_UINT32 KStandardDirs::calcResourceHash( const char *type, const QString& filename, bool deep) const { Q_UINT32 hash = 0; if (filename.at(0) == '/') { // absolute dirs are absolute dirs, right? :-/ return updateHash(filename, hash); @@ -951,577 +952,587 @@ QString KStandardDirs::kde_default(const char *type) { if (!strcmp(type, "data")) return "apps/"; if (!strcmp(type, "html")) return "share/doc/HTML/"; if (!strcmp(type, "icon")) return "share/icons/"; if (!strcmp(type, "config")) return "config/"; if (!strcmp(type, "pixmap")) return "share/pixmaps/"; if (!strcmp(type, "apps")) return "share/applnk/"; if (!strcmp(type, "sound")) return "share/sounds/"; if (!strcmp(type, "locale")) return "share/locale/"; if (!strcmp(type, "services")) return "share/services/"; if (!strcmp(type, "servicetypes")) return "share/servicetypes/"; if (!strcmp(type, "mime")) return "share/mimelnk/"; if (!strcmp(type, "cgi")) return "cgi-bin/"; if (!strcmp(type, "wallpaper")) return "share/wallpapers/"; if (!strcmp(type, "templates")) return "share/templates/"; if (!strcmp(type, "exe")) return "bin/"; if (!strcmp(type, "lib")) return "lib/"; if (!strcmp(type, "module")) return "lib/kde3/"; if (!strcmp(type, "qtplugins")) return "lib/kde3/plugins"; if (!strcmp(type, "xdgdata-apps")) return "applications/"; if (!strcmp(type, "xdgdata-dirs")) return "desktop-directories/"; if (!strcmp(type, "xdgconf-menu")) return "menus/"; if (!strcmp(type, "tmp")) return "tmp/"; qFatal("unknown resource type %s", type); return QString::null; } QString KStandardDirs::saveLocation(const char *type, const QString& suffix, bool create) const { //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); //return ""; checkConfig(); QString *pPath = savelocations.find(type); if (!pPath) { QStringList *dirs = relatives.find(type); if (!dirs && ( (strcmp(type, "socket") == 0) || (strcmp(type, "tmp") == 0) || (strcmp(type, "cache") == 0) )) { (void) resourceDirs(type); // Generate socket|tmp|cache resource. dirs = relatives.find(type); // Search again. } if (dirs) { // Check for existance of typed directory + suffix if (strncmp(type, "xdgdata-", 8) == 0) pPath = new QString(realPath(localxdgdatadir() + dirs->last())); else if (strncmp(type, "xdgconf-", 8) == 0) pPath = new QString(realPath(localxdgconfdir() + dirs->last())); else pPath = new QString(realPath(localkdedir() + dirs->last())); } else { dirs = absolutes.find(type); if (!dirs) qFatal("KStandardDirs: The resource type %s is not registered", type); pPath = new QString(realPath(dirs->last())); } savelocations.insert(type, pPath); } QString fullPath = *pPath + suffix; //US struct stat st; //US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) QFileInfo fullPathInfo(QFile::encodeName(fullPath)); if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) { if(!create) { #ifndef NDEBUG qDebug("save location %s doesn't exist", fullPath.latin1()); #endif return fullPath; } if(!makeDir(fullPath, 0700)) { qWarning("failed to create %s", fullPath.latin1()); return fullPath; } dircache.remove(type); } return fullPath; } QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) { QString fullPath = absPath; int i = absPath.findRev('/'); if (i != -1) { fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize } QStringList candidates = resourceDirs(type); for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) if (fullPath.startsWith(*it)) { return fullPath.mid((*it).length()); } return absPath; } bool KStandardDirs::makeDir(const QString& dir2, int mode) { QString dir = QDir::convertSeparators( dir2 ); #if 0 //LR // we want an absolute path if (dir.at(0) != '/') return false; QString target = dir; uint len = target.length(); // append trailing slash if missing if (dir.at(len - 1) != '/') target += '/'; QString base(""); uint i = 1; while( i < len ) { //US struct stat st; int pos = target.find('/', i); base += target.mid(i - 1, pos - i + 1); QCString baseEncoded = QFile::encodeName(base); // 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"); } } localXdgDir = KShell::tildeExpand(localXdgDir); addXdgDataPrefix(localXdgDir); for (QStringList::ConstIterator it = xdgdirList.begin(); it != xdgdirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addXdgDataPrefix(dir); } // end XDG_DATA_XXX uint index = 0; while (types[index] != 0) { addResourceType(types[index], kde_default(types[index])); index++; } addResourceDir("home", QDir::homeDirPath()); } void KStandardDirs::checkConfig() const { /*US if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); */ if (!addedCustoms && KGlobal::config()) const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); } bool KStandardDirs::addCustomized(KConfig *config) { if (addedCustoms) // there are already customized entries return false; // we just quite and hope they are the right ones // save the numbers of config directories. If this changes, // we will return true to give KConfig a chance to reparse uint configdirs = resourceDirs("config").count(); // reading the prefixes in QString oldGroup = config->group(); config->setGroup("Directories"); QStringList list; QStringList::ConstIterator it; list = config->readListEntry("prefixes"); for (it = list.begin(); it != list.end(); it++) addPrefix(*it); // iterating over all entries in the group Directories // to find entries that start with dir_$type /*US QMap<QString, QString> entries = config->entryMap("Directories"); QMap<QString, QString>::ConstIterator it2; for (it2 = entries.begin(); it2 != entries.end(); it2++) { QString key = it2.key(); if (key.left(4) == "dir_") { // generate directory list, there may be more than 1. QStringList dirs = QStringList::split(',', *it2); QStringList::Iterator sIt(dirs.begin()); QString resType = key.mid(4, key.length()); for (; sIt != dirs.end(); ++sIt) { addResourceDir(resType.latin1(), *sIt); } } } // Process KIOSK restrictions. config->setGroup("KDE Resource Restrictions"); entries = config->entryMap("KDE Resource Restrictions"); for (it2 = entries.begin(); it2 != entries.end(); it2++) { QString key = it2.key(); if (!config->readBoolEntry(key, true)) { d->restrictionsActive = true; d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do dircache.remove(key.latin1()); } } */ // save it for future calls - that will return addedCustoms = true; config->setGroup(oldGroup); // return true if the number of config dirs changed return (resourceDirs("config").count() != configdirs); } QString KStandardDirs::localkdedir() const { // Return the prefix to use for saving return prefixes.first(); } QString KStandardDirs::localxdgdatadir() const { // Return the prefix to use for saving return d->xdgdata_prefixes.first(); } QString KStandardDirs::localxdgconfdir() const { // Return the prefix to use for saving return d->xdgconf_prefixes.first(); } void KStandardDirs::setAppDir( const QString &appDir ) { mAppDir = appDir; if ( mAppDir.right( 1 ) != "/" ) mAppDir += "/"; } QString KStandardDirs::appDir() { return mAppDir; } // just to make code more readable without macros |