summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-21 17:43:18 (UTC)
committer zautrix <zautrix>2005-04-21 17:43:18 (UTC)
commitfd38343ef53c9b2a48208f747100579703cc1814 (patch) (side-by-side diff)
tree2aeabdf01986d59d72044615b952a65b4d8ba292 /korganizer
parent0a13a3490ec3bf4735e3435f80f58fa7d50b4448 (diff)
downloadkdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.zip
kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.tar.gz
kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.tar.bz2
backup impl
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp30
1 files changed, 30 insertions, 0 deletions
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 @@
#include "klocale.h"
#include "kconfig.h"
#include "externalapphandler.h"
+#include <kglobalsettings.h>
using namespace KCal;
#ifndef _WIN32_
@@ -1801,6 +1802,35 @@ void MainWindow::save()
return;
mSyncManager->setBlockSave(true);
if ( mView->checkFileVersion( defaultFileName()) ) {
+ if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
+ QDate reference ( 2000,1,1);
+ int daysTo = reference.daysTo ( QDate::currentDate() );
+ if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
+ setCaption(i18n("KO/Pi:Creating backup ... please wait ..." ));
+ qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
+ // we need the file path, the backup dir and the number of bups as param
+ QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
+ if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
+ bupDir = KGlobalSettings::backupDataDir();
+ int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );//55;//call backup
+ if ( retval == 0 ) {
+ qDebug("KO: Backup cancelled. Will try again tomorrow ");
+ // retval == 0 : backup skipped for today, try again tomorrow
+ KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
+ } else if ( retval == 1 ){
+ qDebug("KO: Backup created.");
+ // backup ok
+ KOPrefs::instance()->mLastBackupDate = daysTo;
+
+ } else if ( retval == 2 ){
+ qDebug("KO: Backup globally cancelled.");
+ // backup globally cancelled
+ KPimGlobalPrefs::instance()->mBackupEnabled = false;
+ }
+ // retval == 3: do nothing, try again later
+ }
+ ; // KPimGlobalPrefs::instance()->mLastBackupDate
+ }
QTime neededSaveTime = QDateTime::currentDateTime().time();
setCaption(i18n("KO/Pi:Saving Data to File ..." ));
qDebug("KO: Start saving data to file!");