-rw-r--r-- | bin/kdepim/korganizer/germantranslation.txt | 13 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 30 | ||||
-rw-r--r-- | libkdepim/kcmconfigs/kdepimconfigwidget.cpp | 28 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 6 | ||||
-rw-r--r-- | libkdepim/kpimprefs.cpp | 3 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 1 | ||||
-rw-r--r-- | microkde/kapplication.cpp | 120 | ||||
-rw-r--r-- | microkde/kapplication.h | 1 |
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 | |||
@@ -1354,4 +1354,17 @@ | |||
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 | { "","" }, |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 68e5e5a..9ad0694 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -62,4 +62,5 @@ | |||
62 | #include "kconfig.h" | 62 | #include "kconfig.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | #include <kglobalsettings.h> | ||
64 | 65 | ||
65 | using namespace KCal; | 66 | using namespace KCal; |
@@ -1802,4 +1803,33 @@ void MainWindow::save() | |||
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 ..." )); |
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 | |||
@@ -133,5 +133,5 @@ void KDEPIMConfigWidget::setupBackupTab() | |||
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 ); |
@@ -140,5 +140,6 @@ void KDEPIMConfigWidget::setupBackupTab() | |||
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); |
@@ -152,5 +153,13 @@ void KDEPIMConfigWidget::setupBackupTab() | |||
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 | } |
@@ -807,4 +816,11 @@ void KDEPIMConfigWidget::usrReadConfig() | |||
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(",") )); |
@@ -817,7 +833,4 @@ void KDEPIMConfigWidget::usrReadConfig() | |||
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; |
@@ -867,4 +880,7 @@ void KDEPIMConfigWidget::usrWriteConfig() | |||
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") ); |
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index 90321b2..9c28425 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp | |||
@@ -201,4 +201,10 @@ void KPimGlobalPrefs::setGlobalConfig() | |||
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 | } |
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index d68ccb6..714d1b7 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp | |||
@@ -51,4 +51,7 @@ KPimPrefs::KPimPrefs( const QString &name ) : | |||
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 | ||
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index c177bd6..bf80042 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h | |||
@@ -62,4 +62,5 @@ class KPimPrefs : public KPrefs | |||
62 | int mRingSyncAlgoPrefs; | 62 | int mRingSyncAlgoPrefs; |
63 | QString mLastSyncedLocalFile; | 63 | QString mLastSyncedLocalFile; |
64 | int mLastBackupDate; | ||
64 | 65 | ||
65 | 66 | ||
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index 80a83e0..539397b 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp | |||
@@ -125,2 +125,122 @@ void KApplication::showText(QString caption, QString text) | |||
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 | |||
137 | class 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(); } | ||
165 | private: | ||
166 | QRadioButton* vcal, *ical, *ocal, *tcal; | ||
167 | }; | ||
168 | int 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 | |||
@@ -26,4 +26,5 @@ class KApplication | |||
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 | ||