summaryrefslogtreecommitdiff
path: root/noncore/settings/backup/backuprestore.cpp
Unidiff
Diffstat (limited to 'noncore/settings/backup/backuprestore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 58e5c71..2eccdfe 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -1,13 +1,14 @@
1
2#include "backuprestore.h" 1#include "backuprestore.h"
3#include "errordialog.h" 2#include "errordialog.h"
4 3
5/* OPIE */ 4/* OPIE */
5#include <opie2/odebug.h>
6#include <opie2/ostorageinfo.h> 6#include <opie2/ostorageinfo.h>
7#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
8using namespace Opie::Core;
8 9
9/* QT */ 10/* QT */
10#include <qapplication.h> 11#include <qapplication.h>
11#include <qmultilineedit.h> 12#include <qmultilineedit.h>
12#include <qdir.h> 13#include <qdir.h>
13#include <qfile.h> 14#include <qfile.h>
@@ -37,13 +38,12 @@
37#define BACKUP_LOCATION 2 38#define BACKUP_LOCATION 2
38 39
39#define EXTENSION ".bck" 40#define EXTENSION ".bck"
40 41
41const QString tempFileName = "/tmp/backup.err"; 42const QString tempFileName = "/tmp/backup.err";
42 43
43
44BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) 44BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl)
45 : BackupAndRestoreBase(parent, name, fl) 45 : BackupAndRestoreBase(parent, name, fl)
46{ 46{
47 backupList->header()->hide(); 47 backupList->header()->hide();
48 restoreList->header()->hide(); 48 restoreList->header()->hide();
49 connect(backupButton, SIGNAL(clicked()), 49 connect(backupButton, SIGNAL(clicked()),
@@ -70,23 +70,23 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f
70 Opie::Core::OStorageInfo storage; 70 Opie::Core::OStorageInfo storage;
71 71
72 backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); 72 backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" );
73 if ( storage.hasCf() ) 73 if ( storage.hasCf() )
74 { 74 {
75 backupLocations.insert( "CF", storage.cfPath() ); 75 backupLocations.insert( "CF", storage.cfPath() );
76 qDebug( "Cf Path: " + storage.cfPath() ); 76 odebug << "Cf Path: " + storage.cfPath() << oendl;
77 } 77 }
78 if ( storage.hasSd() ) 78 if ( storage.hasSd() )
79 { 79 {
80 backupLocations.insert( "SD", storage.sdPath() ); 80 backupLocations.insert( "SD", storage.sdPath() );
81 qDebug( " Sd Path: " + storage.sdPath() ); 81 odebug << " Sd Path: " + storage.sdPath() << oendl;
82 } 82 }
83 if ( storage.hasMmc() ) 83 if ( storage.hasMmc() )
84 { 84 {
85 backupLocations.insert( "MMC", storage.mmcPath() ); 85 backupLocations.insert( "MMC", storage.mmcPath() );
86 qDebug( "Mmc Path: " + storage.mmcPath() ); 86 odebug << "Mmc Path: " + storage.mmcPath() << oendl;
87 } 87 }
88 88
89 Config config("BackupAndRestore"); 89 Config config("BackupAndRestore");
90 //read last locations 90 //read last locations
91 config.setGroup("LastLocation"); 91 config.setGroup("LastLocation");
92 QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); 92 QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" );
@@ -200,13 +200,13 @@ void BackupAndRestore::scanForApplicationSettings()
200 d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); 200 d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks );
201 const QFileInfoList *list = d.entryInfoList(); 201 const QFileInfoList *list = d.entryInfoList();
202 QFileInfoListIterator it( *list ); 202 QFileInfoListIterator it( *list );
203 QFileInfo *fi; 203 QFileInfo *fi;
204 while ( (fi=it.current()) ) 204 while ( (fi=it.current()) )
205 { 205 {
206 //qDebug((d.path()+"/"+fi->fileName()).latin1()); 206 //odebug << (d.path()+"/"+fi->fileName()).latin1() << oendl;
207 if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) 207 if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) )
208 { 208 {
209 QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); 209 QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName());
210 selectItem(newItem); 210 selectItem(newItem);
211 } 211 }
212 ++it; 212 ++it;
@@ -246,22 +246,22 @@ void BackupAndRestore::backup()
246 c++; 246 c++;
247 } 247 }
248 248
249 // We execute tar and compressing its output with gzip.. 249 // We execute tar and compressing its output with gzip..
250 // The error output will be written into a temp-file which could be provided 250 // The error output will be written into a temp-file which could be provided
251 // for debugging.. 251 // for debugging..
252 qDebug( "Storing file: %s", outputFile.latin1() ); 252 odebug << "Storing file: " << outputFile.latin1() << "" << oendl;
253 outputFile += EXTENSION; 253 outputFile += EXTENSION;
254 254
255 QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() ) 255 QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() )
256 .arg( getExcludeFile() ) 256 .arg( getExcludeFile() )
257 .arg( backupFiles ) 257 .arg( backupFiles )
258 .arg( outputFile.latin1() ) 258 .arg( outputFile.latin1() )
259 .arg( tempFileName.latin1() ); 259 .arg( tempFileName.latin1() );
260 260
261 qDebug( commandLine ); 261 odebug << commandLine << oendl;
262 262
263 int r = system( commandLine ); 263 int r = system( commandLine );
264 264
265 if(r != 0) 265 if(r != 0)
266 { 266 {
267 perror("Error: "); 267 perror("Error: ");
@@ -269,13 +269,13 @@ void BackupAndRestore::backup()
269 269
270 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" 270 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n"
271 + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) 271 + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) )
272 { 272 {
273 273
274 case 1: 274 case 1:
275 qWarning("Details pressed !"); 275 owarn << "Details pressed !" << oendl;
276 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); 276 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true );
277 QFile errorFile( tempFileName ); 277 QFile errorFile( tempFileName );
278 if ( errorFile.open(IO_ReadOnly) ) 278 if ( errorFile.open(IO_ReadOnly) )
279 { 279 {
280 QTextStream t( &errorFile ); 280 QTextStream t( &errorFile );
281 QString s; 281 QString s;
@@ -356,25 +356,25 @@ void BackupAndRestore::sourceDirChanged(int selection)
356 restoreList->clear(); 356 restoreList->clear();
357 rescanFolder(backupLocations[restoreSource->text(selection)]); 357 rescanFolder(backupLocations[restoreSource->text(selection)]);
358} 358}
359 359
360void BackupAndRestore::fileListUpdate() 360void BackupAndRestore::fileListUpdate()
361{ 361{
362 qWarning("void BackupAndRestore::fileListUpdate()"); 362 owarn << "void BackupAndRestore::fileListUpdate()" << oendl;
363 restoreList->clear(); 363 restoreList->clear();
364 rescanFolder( backupLocations[restoreSource->currentText()] ); 364 rescanFolder( backupLocations[restoreSource->currentText()] );
365} 365}
366 366
367/** 367/**
368 * Scans directory for any backup files. Will recursivly go down, 368 * Scans directory for any backup files. Will recursivly go down,
369 * but will not follow symlinks. 369 * but will not follow symlinks.
370 * @param directory - the directory to look in. 370 * @param directory - the directory to look in.
371 */ 371 */
372void BackupAndRestore::rescanFolder(QString directory) 372void BackupAndRestore::rescanFolder(QString directory)
373{ 373{
374 //qDebug(QString("rescanFolder: ") + directory.latin1()); 374 //odebug << QString("rescanFolder: ") + directory.latin1() << oendl;
375 QDir d(directory); 375 QDir d(directory);
376 if(!d.exists()) 376 if(!d.exists())
377 return; 377 return;
378 378
379 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); 379 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs);
380 const QFileInfoList *list = d.entryInfoList(); 380 const QFileInfoList *list = d.entryInfoList();
@@ -416,13 +416,13 @@ void BackupAndRestore::restore()
416 setCaption(tr("Backup and Restore... working...")); 416 setCaption(tr("Backup and Restore... working..."));
417 417
418 QString restoreFile = backupLocations[restoreSource->currentText()]; 418 QString restoreFile = backupLocations[restoreSource->currentText()];
419 419
420 restoreFile += "/" + restoreItem->text(0); 420 restoreFile += "/" + restoreItem->text(0);
421 421
422 qDebug( restoreFile ); 422 odebug << restoreFile << oendl;
423 423
424 //check if backup file come from opie 1.0.x 424 //check if backup file come from opie 1.0.x
425 425
426 QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() ); 426 QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() );
427 427
428 int r = system( commandLine ); 428 int r = system( commandLine );
@@ -439,25 +439,25 @@ void BackupAndRestore::restore()
439 439
440 //unpack backup file 440 //unpack backup file
441 commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir ) 441 commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir )
442 .arg( restoreFile.latin1() ) 442 .arg( restoreFile.latin1() )
443 .arg( tempFileName.latin1() ); 443 .arg( tempFileName.latin1() );
444 444
445 qDebug( commandLine ); 445 odebug << commandLine << oendl;
446 446
447 r = system( commandLine ); 447 r = system( commandLine );
448 448
449 //error handling 449 //error handling
450 if(r != 0) 450 if(r != 0)
451 { 451 {
452 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); 452 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno );
453 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" 453 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n"
454 + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) 454 + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) )
455 { 455 {
456 case 1: 456 case 1:
457 qWarning("Details pressed !"); 457 owarn << "Details pressed !" << oendl;
458 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); 458 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true );
459 QFile errorFile( tempFileName ); 459 QFile errorFile( tempFileName );
460 if ( errorFile.open(IO_ReadOnly) ) 460 if ( errorFile.open(IO_ReadOnly) )
461 { 461 {
462 QTextStream t( &errorFile ); 462 QTextStream t( &errorFile );
463 QString s; 463 QString s;