author | zautrix <zautrix> | 2005-04-21 17:43:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-21 17:43:18 (UTC) |
commit | fd38343ef53c9b2a48208f747100579703cc1814 (patch) (unidiff) | |
tree | 2aeabdf01986d59d72044615b952a65b4d8ba292 /korganizer/mainwindow.cpp | |
parent | 0a13a3490ec3bf4735e3435f80f58fa7d50b4448 (diff) | |
download | kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.zip kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.tar.gz kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.tar.bz2 |
backup impl
-rw-r--r-- | korganizer/mainwindow.cpp | 30 |
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 @@ | |||
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 | ||
65 | using namespace KCal; | 66 | using 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!"); |