summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt13
-rw-r--r--korganizer/mainwindow.cpp30
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp28
-rw-r--r--libkdepim/kpimglobalprefs.cpp6
-rw-r--r--libkdepim/kpimprefs.cpp3
-rw-r--r--libkdepim/kpimprefs.h1
-rw-r--r--microkde/kapplication.cpp120
-rw-r--r--microkde/kapplication.h1
8 files changed, 196 insertions, 6 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index fa18304..9e9a1a1 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1353,6 +1353,19 @@
1353{ "Alternating background of list views","Abwechselnder Hintergrund für Listen" }, 1353{ "Alternating background of list views","Abwechselnder Hintergrund für Listen" },
1354{ "times","Zeiten" }, 1354{ "times","Zeiten" },
1355{ "The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?","Das Todo\n%1\nhat Untertodos!\nMöchten Sie die Kategorien\nauch für alle Untertodos setzen?" }, 1355{ "The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?","Das Todo\n%1\nhat Untertodos!\nMöchten Sie die Kategorien\nauch für alle Untertodos setzen?" },
1356{ "Backup enabled","Backup angeschaltet" },
1357{ "Use standard backup dir","Standard Backupverzeichnis" },
1358{ "Number of Backups:","Anzahl der Backups" },
1359{ "Make backup every ","Mache ein Backup alle " },
1360{ " days"," Tage" },
1361{ "","" },
1362{ "","" },
1363{ "","" },
1364{ "","" },
1365{ "","" },
1366{ "","" },
1367{ "","" },
1368{ "","" },
1356{ "","" }, 1369{ "","" },
1357{ "","" }, 1370{ "","" },
1358{ "","" }, 1371{ "","" },
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 68e5e5a..9ad0694 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -61,6 +61,7 @@
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64#include <kglobalsettings.h>
64 65
65using namespace KCal; 66using namespace KCal;
66#ifndef _WIN32_ 67#ifndef _WIN32_
@@ -1801,6 +1802,35 @@ void MainWindow::save()
1801 return; 1802 return;
1802 mSyncManager->setBlockSave(true); 1803 mSyncManager->setBlockSave(true);
1803 if ( mView->checkFileVersion( defaultFileName()) ) { 1804 if ( mView->checkFileVersion( defaultFileName()) ) {
1805 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1806 QDate reference ( 2000,1,1);
1807 int daysTo = reference.daysTo ( QDate::currentDate() );
1808 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1809 setCaption(i18n("KO/Pi:Creating backup ... please wait ..." ));
1810 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1811 // we need the file path, the backup dir and the number of bups as param
1812 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1813 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1814 bupDir = KGlobalSettings::backupDataDir();
1815 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );//55;//call backup
1816 if ( retval == 0 ) {
1817 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1818 // retval == 0 : backup skipped for today, try again tomorrow
1819 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1820 } else if ( retval == 1 ){
1821 qDebug("KO: Backup created.");
1822 // backup ok
1823 KOPrefs::instance()->mLastBackupDate = daysTo;
1824
1825 } else if ( retval == 2 ){
1826 qDebug("KO: Backup globally cancelled.");
1827 // backup globally cancelled
1828 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1829 }
1830 // retval == 3: do nothing, try again later
1831 }
1832 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1833 }
1804 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1834 QTime neededSaveTime = QDateTime::currentDateTime().time();
1805 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1835 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1806 qDebug("KO: Start saving data to file!"); 1836 qDebug("KO: Start saving data to file!");
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
index fbfbc45..93538ec 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -132,14 +132,15 @@ void KDEPIMConfigWidget::setupBackupTab()
132 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) ); 132 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) );
133 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame); 133 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame);
134 sb = addWidBool(i18n("Use standard backup dir"), 134 sb = addWidBool(i18n("Use standard backup dir"),
135 &(KPimGlobalPrefs::instance()->mBackupEnabled),bupFrame); 135 &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame);
136 bupLayout->addWidget((QWidget*)sb->checkBox()); 136 bupLayout->addWidget((QWidget*)sb->checkBox());
137 mBackupUrl = new KURLRequester( bupFrame ); 137 mBackupUrl = new KURLRequester( bupFrame );
138 mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); 138 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
139 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) ); 139 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) );
140 bupLayout->addWidget( mBackupUrl ); 140 bupLayout->addWidget( mBackupUrl );
141 141
142 142 mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir );
143 bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled );
143 QHBox *dummy = new QHBox(bupFrame); 144 QHBox *dummy = new QHBox(bupFrame);
144 new QLabel(i18n("Number of Backups:"),dummy); 145 new QLabel(i18n("Number of Backups:"),dummy);
145 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy); 146 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy);
@@ -151,7 +152,15 @@ void KDEPIMConfigWidget::setupBackupTab()
151 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy); 152 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy);
152 new QLabel(i18n(" days"),dummy); 153 new QLabel(i18n(" days"),dummy);
153 new QLabel(i18n(" "),dummy); 154 new QLabel(i18n(" "),dummy);
154 bupLayout->addWidget( dummy ); 155 bupLayout->addWidget( dummy );
156 QString localKdeDir;
157 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
158 if ( ! localKdeDir.isEmpty() ) {
159 sb->checkBox()->setEnabled( false );
160 sb->checkBox()->setChecked( true );
161 mBackupUrl->setEnabled( false );
162 KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true;
163 }
155 164
156} 165}
157void KDEPIMConfigWidget::setupStoreTab() 166void KDEPIMConfigWidget::setupStoreTab()
@@ -806,6 +815,13 @@ void KDEPIMConfigWidget::usrReadConfig()
806 bool blocked = signalsBlocked(); 815 bool blocked = signalsBlocked();
807 blockSignals( true ); 816 blockSignals( true );
808 817
818 if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir )
819 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
820 else
821 mBackupUrl->setURL(prefs->mBackupDatadir);
822 mBackupNumbersSpin->setValue( prefs->mBackupNumbers );
823 mBackupDayCountSpin->setValue( prefs->mBackupDayCount);
824
809 QString dummy = prefs->mUserDateFormatLong; 825 QString dummy = prefs->mUserDateFormatLong;
810 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 826 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
811 dummy = prefs->mUserDateFormatShort; 827 dummy = prefs->mUserDateFormatShort;
@@ -816,9 +832,6 @@ void KDEPIMConfigWidget::usrReadConfig()
816 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); 832 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1));
817 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); 833 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId));
818 834
819
820
821
822 mEmailClient = prefs->mEmailClient; 835 mEmailClient = prefs->mEmailClient;
823 mEmailOtherChannel = prefs->mEmailOtherChannel; 836 mEmailOtherChannel = prefs->mEmailOtherChannel;
824 mEmailOtherMessage = prefs->mEmailOtherMessage; 837 mEmailOtherMessage = prefs->mEmailOtherMessage;
@@ -866,6 +879,9 @@ void KDEPIMConfigWidget::usrWriteConfig()
866 879
867 saveEditFieldSettings(); 880 saveEditFieldSettings();
868 881
882 prefs->mBackupNumbers = mBackupNumbersSpin->value();
883 prefs->mBackupDayCount = mBackupDayCountSpin->value();
884 prefs->mBackupDatadir = mBackupUrl->url();
869 885
870 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 886 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
871 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 887 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index 90321b2..9c28425 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -200,6 +200,12 @@ void KPimGlobalPrefs::setGlobalConfig()
200 mDaylightsavingEnd ); 200 mDaylightsavingEnd );
201 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); 201 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min );
202 KGlobalSettings::setAlternateBackgroundColor(mAlternateColor); 202 KGlobalSettings::setAlternateBackgroundColor(mAlternateColor);
203 QString localKdeDir;
204 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
205 if ( ! localKdeDir.isEmpty() ) {
206 mBackupUseDefaultDir = true;
207 mBackupDatadir = KGlobalSettings::backupDataDir();
208 }
203 209
204} 210}
205KPimGlobalPrefs::~KPimGlobalPrefs() 211KPimGlobalPrefs::~KPimGlobalPrefs()
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index d68ccb6..714d1b7 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -50,6 +50,9 @@ KPimPrefs::KPimPrefs( const QString &name ) :
50 addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false ); 50 addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false );
51 addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false ); 51 addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false );
52 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 52 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
53
54 setCurrentGroup("BackupDate");
55 addItemInt("LastBackupDate",&mLastBackupDate,0);
53} 56}
54 57
55KPimPrefs::~KPimPrefs() 58KPimPrefs::~KPimPrefs()
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index c177bd6..bf80042 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -61,6 +61,7 @@ class KPimPrefs : public KPrefs
61 bool mPassiveSyncAutoStart; 61 bool mPassiveSyncAutoStart;
62 int mRingSyncAlgoPrefs; 62 int mRingSyncAlgoPrefs;
63 QString mLastSyncedLocalFile; 63 QString mLastSyncedLocalFile;
64 int mLastBackupDate;
64 65
65 66
66 protected: 67 protected:
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index 80a83e0..539397b 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -124,3 +124,123 @@ void KApplication::showText(QString caption, QString text)
124 dia.exec(); 124 dia.exec();
125 125
126} 126}
127
128#include <qlabel.h>
129#include <qpushbutton.h>
130#include <qlayout.h>
131#include <qdir.h>
132#include <qradiobutton.h>
133#include <qbuttongroup.h>
134#include "kglobal.h"
135#include "klocale.h"
136
137class KBackupPrefs : public QDialog
138{
139 public:
140 KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) :
141 QDialog( parent, name, true )
142 {
143 setCaption( i18n("Backup Failed!") );
144 QVBoxLayout* lay = new QVBoxLayout( this );
145 lay->setSpacing( 3 );
146 lay->setMargin( 3 );
147 QLabel * lab = new QLabel( message, this );
148 lay->addWidget( lab );
149 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this );
150 lay->addWidget( format );
151 format->setExclusive ( true ) ;
152 vcal = new QRadioButton(i18n("Try again now"), format );
153 tcal = new QRadioButton(i18n("Try again later"), format );
154 ical = new QRadioButton(i18n("Try again tomorrow"), format );
155 ocal = new QRadioButton(i18n("Disable backup"), format );
156 vcal->setChecked( true );
157 QPushButton * ok = new QPushButton( i18n("OK"), this );
158 lay->addWidget(ok );
159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
160 }
161
162 bool again() { return vcal->isChecked(); }
163 bool later() { return tcal->isChecked(); }
164 bool againTomorrow() { return ical->isChecked(); }
165private:
166 QRadioButton* vcal, *ical, *ocal, *tcal;
167};
168int KApplication::createBackup( QString fn, QString dp, int numBup )
169{
170 if ( numBup < 1) return 3;
171 int ret = 3;
172 qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup);
173 QDir bupDir ( dp );
174 bool tryAgain = true;
175 while ( tryAgain ) {
176 if ( !bupDir.exists() ) {
177 KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + dp.right(30));
178 if ( !noDir.exec() ) return 3;
179 if ( noDir.againTomorrow() ) {
180 return 0;
181 } else if ( noDir.later() ) {
182 return 3;
183 } else if ( !noDir.again() ) {
184 return 2;
185 }
186 } else {
187 tryAgain = false;
188 }
189 }
190 // we have a valid dir!
191 QStringList allFileList = bupDir.entryList(QDir::Files);
192 QFileInfo fileInfo ( fn );
193 QString fName = fileInfo.fileName ();
194 QStringList fileList;
195
196 int i;
197 for ( i = 0; i < allFileList.count(); ++i ) {
198 QString fi = allFileList[i];
199 if ( fi. find( fName ) > -1 )
200 fileList.append( fi );
201 }
202 qDebug("%d backup files exist ", fileList.count());
203 int count = fileList.count();
204 fileList.sort();
205 int remCount = 0;
206 while ( count >= numBup ) {
207 QString fnr = dp + "/"+fileList[remCount];
208 QFile::remove( fnr );
209 --count;
210 ++remCount;
211 }
212 QDateTime mRunStart = QDateTime::currentDateTime();
213 QString file = "%1%2%3-%4%5%6-";
214 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
215 file.replace ( QRegExp (" "), "0" );
216 file += fName ;
217 file = dp + "/"+file;
218 QString command;
219 int res = 0;
220#ifdef _WIN32_
221 command = "xcopy "+ fn+ " "+file;
222 command = QDir::convertSeparators( command );
223#else
224 command = "cp "+ fn+ " "+file;
225#endif
226 qDebug("command %s ",command.latin1() );
227 tryAgain = true;
228 while ( tryAgain ) {
229 res = system ( command.latin1() );
230 qDebug("copy result %d ", res);
231 if ( res != 0 ) {
232 KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>"));
233 if ( !noDir.exec() ) return 3;
234 if ( noDir.againTomorrow() ) {
235 return 0;
236 } else if ( noDir.later() ) {
237 return 3;
238 } else if ( !noDir.again() ) {
239 return 2;
240 }
241 } else {
242 tryAgain = false;
243 }
244 }
245 return 1;
246}
diff --git a/microkde/kapplication.h b/microkde/kapplication.h
index f7eb1ef..de5a084 100644
--- a/microkde/kapplication.h
+++ b/microkde/kapplication.h
@@ -25,6 +25,7 @@ class KApplication
25 static void showFile(QString caption, QString file); 25 static void showFile(QString caption, QString file);
26 static void showText(QString caption, QString text); 26 static void showText(QString caption, QString text);
27 static bool convert2latin1(QString file); 27 static bool convert2latin1(QString file);
28 static int createBackup( QString fn, QString dp, int numBup );
28}; 29};
29 30
30 31