summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-14 13:33:20 (UTC)
committer llornkcor <llornkcor>2002-11-14 13:33:20 (UTC)
commitb65957131fd1e12079aafe78abff9ad31356da72 (patch) (side-by-side diff)
treeb02895370efa055d9a830229a2adb557beb633a5
parentd7d53215cef9420872a4e0f42b547b4148ca33a9 (diff)
downloadopie-b65957131fd1e12079aafe78abff9ad31356da72.zip
opie-b65957131fd1e12079aafe78abff9ad31356da72.tar.gz
opie-b65957131fd1e12079aafe78abff9ad31356da72.tar.bz2
caption
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 02998f0..618ce24 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -1,39 +1,51 @@
+
#include "backuprestore.h"
+#include "output.h"
+
+#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 <qpe/resource.h>
#include <qpe/config.h>
#include <qmessagebox.h>
#include <qcombobox.h>
#include <qlist.h>
#include <stdlib.h>
#include <qregexp.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <dirent.h>
+
#define HEADER_NAME 0
#define HEADER_BACKUP 1
#define BACKUP_LOCATION 2
#define EXTENSION ".bck"
BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name)
: BackupAndRestoreBase(parent, name){
this->showMaximized();
backupList->header()->hide();
restoreList->header()->hide();
connect(backupButton, SIGNAL(clicked()),
this, SLOT(backupPressed()));
connect(restoreButton, SIGNAL(clicked()),
this, SLOT(restore()));
connect(backupList, SIGNAL(clicked( QListViewItem * )),
this, SLOT(selectItem(QListViewItem*)));
connect(restoreSource, SIGNAL(activated( int )),
this, SLOT(sourceDirChanged(int)));
systemSettings = new QListViewItem(backupList, "System Settings", "",
"/etc");
// selectItem(systemSettings);
applicationSettings = new QListViewItem(backupList, "Application Settings", "",
@@ -144,70 +156,81 @@ void BackupAndRestore::scanForApplicationSettings(){
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
//qDebug((d.path()+fi->fileName()).latin1());
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::backupPressed(){
QString backupFiles;
if(getBackupFiles(backupFiles, NULL) == 0){
QMessageBox::critical(this, "Message",
"No items selected.",QString("Ok") );
return;
}
+ setCaption(tr("Backup and Restore... working..."));
QString outputFile = backupLocations[storeToLocation->currentText()];
QDateTime time = QDateTime::currentDateTime();
QString dateString = time.date().toString().replace(QRegExp(" "), "");
outputFile += "/" + dateString;
QString t = outputFile;
int c = 1;
while(QFile::exists(outputFile + EXTENSION)){
outputFile = t + QString("%1").arg(c);
c++;
}
+
+ qDebug(QString("system(\"tar -c %1 | gzip > %2\")").arg(backupFiles).arg(outputFile).latin1());
outputFile += EXTENSION;
- qDebug("system(\"tar -c %1 | gzip > %2\").arg(backupFiles).arg(outputFile).latin1())");
- int r = system(QString("tar -c %1 | gzip > %2").arg(backupFiles).arg(outputFile).latin1() );
- if(r != 0){
- QMessageBox::critical(this, "Message", "Backup Failed.",QString("Ok") );
- return;
- }
- else{
- QMessageBox::critical(this, "Message", "Backup Successfull.",QString("Ok") );
- }
+
+ int r = system( QString("tar -c %1 | gzip > %2").arg(backupFiles).arg(outputFile).latin1() );
+
+
+
+ if(r != 0){
+ perror("Error: ");
+ QString errorMsg="Error\n"+(QString)strerror(errno);
+
+ QMessageBox::critical(this, "Message", "Backup Failed.\n"+errorMsg, QString("Ok") );
+ return;
+ }
+ else{
+ QMessageBox::critical(this, "Message", "Backup Successfull.",QString("Ok") );
+
+ }
+ setCaption(tr("Backup and Restore"));
}
/***
* Get a list of all of the files to backup.
*/
int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){
QListViewItem * currentItem;
QString currentHome;
if(!parent)
currentItem = backupList->firstChild();
else{
currentItem = parent->firstChild();
currentHome = parent->text(BACKUP_LOCATION);
}
uint count = 0;
while( currentItem != 0 ){
if(currentItem->text(HEADER_BACKUP) == "B" ){
if(currentItem->childCount() == 0 ){
if(parent == NULL)
backupFiles += currentItem->text(BACKUP_LOCATION);
else
backupFiles += currentHome + currentItem->text(HEADER_NAME);
backupFiles += " ";