summaryrefslogtreecommitdiff
authorar <ar>2004-10-20 22:13:02 (UTC)
committer ar <ar>2004-10-20 22:13:02 (UTC)
commit24b27cb83dfc2a23c26e6edcda84fe26a9e9d685 (patch) (side-by-side diff)
tree74a0f718dc4199051c4e485d2d6c214a98ac6af6
parentc0ea353593cd6beed183ee0f9b58a16a869a0308 (diff)
downloadopie-24b27cb83dfc2a23c26e6edcda84fe26a9e9d685.zip
opie-24b27cb83dfc2a23c26e6edcda84fe26a9e9d685.tar.gz
opie-24b27cb83dfc2a23c26e6edcda84fe26a9e9d685.tar.bz2
- use busy indicator when backing up and restore
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp20
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,34 +1,35 @@
#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>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qheader.h>
#include <qmessagebox.h>
#include <qcombobox.h>
#include <qlist.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <qlineedit.h>
#include <qstringlist.h>
@@ -230,81 +231,89 @@ void BackupAndRestore::scanForApplicationSettings()
{
QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName());
selectItem(newItem);
}
++it;
}
}
/**
* The "Backup" button has been pressed. Get a list of all of the files that
* should be backed up. If there are no files, emit and error and exit.
* Determine the file name to store the backup in. Backup the file(s) using
* 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))
{
outputFile = t + QString("%1").arg(c);
c++;
}
// We execute tar and compressing its output with gzip..
// The error output will be written into a temp-file which could be provided
// for debugging..
odebug << "Storing file: " << outputFile.latin1() << "" << oendl;
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 );
QFile errorFile( tempFileName );
if ( errorFile.open(IO_ReadOnly) )
{
QTextStream t( &errorFile );
QString s;
while ( !t.eof() )
{ // until end of file...
s += t.readLine(); // line of text excluding '\n'
}
errorFile.close();
pErrDialog->m_textarea->setText( s );
@@ -413,81 +422,88 @@ void BackupAndRestore::rescanFolder(QString directory)
}
else
{
// If it is a backup file add to list.
if(file->fileName().contains(EXTENSION))
(void)new QListViewItem(restoreList, file->fileName());
}
++it;
}
}
/**
* 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 );
QString startDir;
if( r != 0 ) //Applications/backup/exclude not found - old backup file
{
startDir = QString( "/" );
} else
{
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) )
{
QTextStream t( &errorFile );
QString s;
while ( !t.eof() )
{ // until end of file...
s += t.readLine(); // line of text excluding '\n'
}
errorFile.close();
pErrDialog->m_textarea->setText( s );
}
else