-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 36b101c..1748e8d 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp @@ -1,22 +1,23 @@ #include "backuprestore.h" #include "errordialog.h" /* OPIE */ #include <opie2/odebug.h> #include <opie2/ostorageinfo.h> using namespace Opie::Core; #include <opie2/ofiledialog.h> +#include <opie2/owait.h> using namespace Opie::Ui; #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> /* QT */ #include <qapplication.h> #include <qmultilineedit.h> #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> @@ -242,25 +243,29 @@ void BackupAndRestore::scanForApplicationSettings() * tar and gzip --best. Report failure or success */ void BackupAndRestore::backup() { QString backupFiles; if(getBackupFiles(backupFiles, NULL) == 0) { QMessageBox::critical(this, "Message", "No items selected.",QString("Ok") ); return; } - setCaption(tr("Backup and Restore... working...")); + OWait *owait = new OWait(); + Global::statusMessage( tr( "Backing up..." ) ); + owait->show(); + qApp->processEvents(); + QString outputFile = backupLocations[storeToLocation->currentText()]; QDateTime datetime = QDateTime::currentDateTime(); QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + QString::number( datetime.date().day() ).rightJustify(2, '0'); outputFile += "/" + dateString; QString t = outputFile; int c = 1; while(QFile::exists(outputFile + EXTENSION)) { @@ -275,24 +280,28 @@ void BackupAndRestore::backup() outputFile += EXTENSION; QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() ) .arg( getExcludeFile() ) .arg( backupFiles ) .arg( outputFile.latin1() ) .arg( tempFileName.latin1() ); odebug << commandLine << oendl; int r = system( commandLine ); + owait->hide(); + delete owait; + + //Error-Handling if(r != 0) { perror("Error: "); QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) { case 1: owarn << "Details pressed !" << oendl; ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); @@ -425,25 +434,29 @@ void BackupAndRestore::rescanFolder(QString directory) * Restore a backup file. * Report errors or success */ void BackupAndRestore::restore() { QListViewItem *restoreItem = restoreList->currentItem(); if(!restoreItem) { QMessageBox::critical(this, tr( "Message" ), tr( "Please select something to restore." ),QString( tr( "Ok") ) ); return; } - setCaption(tr("Backup and Restore... working...")); + + OWait *owait = new OWait(); + Global::statusMessage( tr( "Restore Backup..." ) ); + owait->show(); + qApp->processEvents(); QString restoreFile = backupLocations[restoreSource->currentText()]; restoreFile += "/" + restoreItem->text(0); odebug << restoreFile << oendl; //check if backup file come from opie 1.0.x QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() ); int r = system( commandLine ); @@ -458,24 +471,27 @@ void BackupAndRestore::restore() startDir = QDir::homeDirPath(); } //unpack backup file commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir ) .arg( restoreFile.latin1() ) .arg( tempFileName.latin1() ); odebug << commandLine << oendl; r = system( commandLine ); + owait->hide(); + delete owait; + //error handling if(r != 0) { QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) { case 1: owarn << "Details pressed !" << oendl; ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); QFile errorFile( tempFileName ); if ( errorFile.open(IO_ReadOnly) ) |