author | zautrix <zautrix> | 2005-04-21 22:07:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-21 22:07:10 (UTC) |
commit | 6284b1d7d597463347b471ed8ec2770f4e2d449b (patch) (unidiff) | |
tree | 5444a13ed788191733fec406791ddf03ec246b59 /pwmanager | |
parent | fd38343ef53c9b2a48208f747100579703cc1814 (diff) | |
download | kdepimpi-6284b1d7d597463347b471ed8ec2770f4e2d449b.zip kdepimpi-6284b1d7d597463347b471ed8ec2770f4e2d449b.tar.gz kdepimpi-6284b1d7d597463347b471ed8ec2770f4e2d449b.tar.bz2 |
fixes
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 61f2616..36b0df5 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -35,6 +35,8 @@ | |||
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
38 | #include <kconfig.h> | ||
39 | #include <kglobalsettings.h> | ||
38 | #include <libkcal/syncdefines.h> | 40 | #include <libkcal/syncdefines.h> |
39 | 41 | ||
40 | 42 | ||
@@ -427,6 +429,49 @@ PwMerror PwMDoc::saveDoc(char compress, const QString *file) | |||
427 | if (!backupFile(filename)) | 429 | if (!backupFile(filename)) |
428 | return e_fileBackup; | 430 | return e_fileBackup; |
429 | } | 431 | } |
432 | int mLastBackupDate = 0; | ||
433 | KConfig configGlobal (locateLocal("config","pwmanagerbuprc")); | ||
434 | QFileInfo fileInfo ( filename ); | ||
435 | mLastBackupDate = configGlobal.readNumEntry( "LastBackupDate-"+ fileInfo.fileName (), 0 ); | ||
436 | KConfig config (locateLocal("config","microkdeglobalrc")); | ||
437 | config.setGroup( "BackupSettings" ); | ||
438 | bool b_enabled = config.readBoolEntry( "BackupEnabled" ); | ||
439 | if ( b_enabled ) { | ||
440 | int num = config.readNumEntry( "BackupNumbers" ); | ||
441 | int d_count = config.readNumEntry( "BackupDayCount" ); | ||
442 | bool stdDir = config.readBoolEntry( "BackupUseDefaultDir" ); | ||
443 | QString bupDir = config.readEntry( "BackupDatadir" ); | ||
444 | QDate reference ( 2000,1,1 ); | ||
445 | int daysTo = reference.daysTo ( QDate::currentDate() ); | ||
446 | bool saveDate = false; | ||
447 | if ( daysTo - d_count >= mLastBackupDate ) { | ||
448 | qDebug("KA: Last backup was %d days ago ", daysTo - mLastBackupDate ); | ||
449 | if ( stdDir ) | ||
450 | bupDir = KGlobalSettings::backupDataDir(); | ||
451 | int retval = KApplication::createBackup( filename, bupDir, num ); | ||
452 | if ( retval == 0 ) { | ||
453 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | ||
454 | // retval == 0 : backup skipped for today, try again tomorrow | ||
455 | mLastBackupDate = daysTo - d_count+1; | ||
456 | saveDate = true; | ||
457 | } else if ( retval == 1 ){ | ||
458 | qDebug("KO: Backup created."); | ||
459 | // backup ok | ||
460 | mLastBackupDate = daysTo; | ||
461 | saveDate = true; | ||
462 | } else if ( retval == 2 ){ | ||
463 | qDebug("KO: Backup globally cancelled."); | ||
464 | // backup globally cancelled | ||
465 | b_enabled = false; | ||
466 | } | ||
467 | if ( !b_enabled ) { | ||
468 | config.writeEntry( "mBackupEnabled", false ); | ||
469 | } | ||
470 | if ( saveDate ) { | ||
471 | configGlobal.writeEntry( "LastBackupDate-"+ fileInfo.fileName (), mLastBackupDate ); | ||
472 | } | ||
473 | } | ||
474 | } | ||
430 | if (QFile::exists(filename)) { | 475 | if (QFile::exists(filename)) { |
431 | /* Move the existing file to some tmp file. | 476 | /* Move the existing file to some tmp file. |
432 | * When saving file succeeds, delete tmp file. Otherwise | 477 | * When saving file succeeds, delete tmp file. Otherwise |