summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backup.pro2
-rw-r--r--noncore/settings/backup/backuprestore.cpp115
-rw-r--r--noncore/settings/backup/backuprestore.h2
-rw-r--r--noncore/settings/backup/backuprestorebase.ui46
-rw-r--r--noncore/settings/backup/errordialog.ui154
-rw-r--r--noncore/settings/backup/opie-backup.control2
6 files changed, 289 insertions, 32 deletions
diff --git a/noncore/settings/backup/backup.pro b/noncore/settings/backup/backup.pro
index 78842b9..cadb381 100644
--- a/noncore/settings/backup/backup.pro
+++ b/noncore/settings/backup/backup.pro
@@ -1,35 +1,35 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 #CONFIG = qt warn_on debug 2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release 3 CONFIG = qt warn_on release
4 HEADERS = backuprestore.h 4 HEADERS = backuprestore.h
5 SOURCES = main.cpp backuprestore.cpp 5 SOURCES = main.cpp backuprestore.cpp
6 INCLUDEPATH+= $(OPIEDIR)/include 6 INCLUDEPATH+= $(OPIEDIR)/include
7 DEPENDPATH+= $(OPIEDIR)/include 7 DEPENDPATH+= $(OPIEDIR)/include
8LIBS += -lqpe 8LIBS += -lqpe
9 INTERFACES= backuprestorebase.ui 9 INTERFACES= backuprestorebase.ui errordialog.ui
10 TARGET = backup 10 TARGET = backup
11 DESTDIR = $(OPIEDIR)/bin 11 DESTDIR = $(OPIEDIR)/bin
12 12
13TRANSLATIONS = ../../../i18n/de/backup.ts \ 13TRANSLATIONS = ../../../i18n/de/backup.ts \
14 ../../../i18n/nl/backup.ts \ 14 ../../../i18n/nl/backup.ts \
15 ../../../i18n/xx/backup.ts \ 15 ../../../i18n/xx/backup.ts \
16 ../../../i18n/en/backup.ts \ 16 ../../../i18n/en/backup.ts \
17 ../../../i18n/es/backup.ts \ 17 ../../../i18n/es/backup.ts \
18 ../../../i18n/fr/backup.ts \ 18 ../../../i18n/fr/backup.ts \
19 ../../../i18n/hu/backup.ts \ 19 ../../../i18n/hu/backup.ts \
20 ../../../i18n/ja/backup.ts \ 20 ../../../i18n/ja/backup.ts \
21 ../../../i18n/ko/backup.ts \ 21 ../../../i18n/ko/backup.ts \
22 ../../../i18n/no/backup.ts \ 22 ../../../i18n/no/backup.ts \
23 ../../../i18n/pl/backup.ts \ 23 ../../../i18n/pl/backup.ts \
24 ../../../i18n/pt/backup.ts \ 24 ../../../i18n/pt/backup.ts \
25 ../../../i18n/pt_BR/backup.ts \ 25 ../../../i18n/pt_BR/backup.ts \
26 ../../../i18n/sl/backup.ts \ 26 ../../../i18n/sl/backup.ts \
27 ../../../i18n/zh_CN/backup.ts \ 27 ../../../i18n/zh_CN/backup.ts \
28 ../../../i18n/zh_TW/backup.ts \ 28 ../../../i18n/zh_TW/backup.ts \
29 ../../../i18n/it/backup.ts \ 29 ../../../i18n/it/backup.ts \
30 ../../../i18n/da/backup.ts 30 ../../../i18n/da/backup.ts
31 31
32 32
33 33
34 34
35include ( $(OPIEDIR)/include.pro ) 35include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 59e15a2..4ff6be1 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -1,322 +1,409 @@
1 1
2#include "backuprestore.h" 2#include "backuprestore.h"
3//#include "output.h" 3//#include "output.h"
4#include "errordialog.h"
4 5
5#include <qapplication.h> 6#include <qapplication.h>
6#include <qmultilineedit.h> 7#include <qmultilineedit.h>
7 8
8#include <qdir.h> 9#include <qdir.h>
9#include <qfile.h> 10#include <qfile.h>
10#include <qfileinfo.h> 11#include <qfileinfo.h>
11#include <qlistview.h> 12#include <qlistview.h>
12#include <qpushbutton.h> 13#include <qpushbutton.h>
13#include <qheader.h> 14#include <qheader.h>
14#include <qpe/resource.h> 15#include <qpe/resource.h>
15#include <qpe/config.h> 16#include <qpe/config.h>
16#include <qmessagebox.h> 17#include <qmessagebox.h>
17#include <qcombobox.h> 18#include <qcombobox.h>
18#include <qlist.h> 19#include <qlist.h>
19#include <stdlib.h> 20#include <stdlib.h>
20#include <qregexp.h> 21#include <qregexp.h>
22#include <qtextstream.h>
23#include <qtextview.h>
21 24
22#include <errno.h> 25#include <errno.h>
23#include <stdlib.h> 26#include <stdlib.h>
24#include <unistd.h> 27#include <unistd.h>
25#include <sys/stat.h> 28#include <sys/stat.h>
26#include <dirent.h> 29#include <dirent.h>
27 30
28#define HEADER_NAME 0 31#define HEADER_NAME 0
29#define HEADER_BACKUP 1 32#define HEADER_BACKUP 1
30#define BACKUP_LOCATION 2 33#define BACKUP_LOCATION 2
31 34
32#define EXTENSION ".bck" 35#define EXTENSION ".bck"
33 36
37const QString tempFileName = "/tmp/backup.err";
38
39
34BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) 40BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name)
35 : BackupAndRestoreBase(parent, name){ 41 : BackupAndRestoreBase(parent, name){
36 this->showMaximized(); 42 this->showMaximized();
37 backupList->header()->hide(); 43 backupList->header()->hide();
38 restoreList->header()->hide(); 44 restoreList->header()->hide();
39 connect(backupButton, SIGNAL(clicked()), 45 connect(backupButton, SIGNAL(clicked()),
40 this, SLOT(backupPressed())); 46 this, SLOT(backupPressed()));
41 connect(restoreButton, SIGNAL(clicked()), 47 connect(restoreButton, SIGNAL(clicked()),
42 this, SLOT(restore())); 48 this, SLOT(restore()));
43 connect(backupList, SIGNAL(clicked( QListViewItem * )), 49 connect(backupList, SIGNAL(clicked( QListViewItem * )),
44 this, SLOT(selectItem(QListViewItem*))); 50 this, SLOT(selectItem(QListViewItem*)));
45 connect(restoreSource, SIGNAL(activated( int )), 51 connect(restoreSource, SIGNAL(activated( int )),
46 this, SLOT(sourceDirChanged(int))); 52 this, SLOT(sourceDirChanged(int)));
53 connect(updateList, SIGNAL(clicked()),
54 this, SLOT( fileListUpdate()));
47 55
48 applicationSettings = new QListViewItem(backupList, "Application Settings", "", 56 applicationSettings = new QListViewItem(backupList, "Application Settings", "",
49 QDir::homeDirPath() + "/Settings/"); 57 QDir::homeDirPath() + "/Settings/");
50 selectItem(applicationSettings); 58 selectItem(applicationSettings);
51 applicationSettings = new QListViewItem(backupList, "Application Data", "", 59 applicationSettings = new QListViewItem(backupList, "Application Data", "",
52 QDir::homeDirPath() + "/Applications/"); 60 QDir::homeDirPath() + "/Applications/");
53 selectItem(applicationSettings); 61 selectItem(applicationSettings);
54 documents= new QListViewItem(backupList, "Documents", "", 62 documents= new QListViewItem(backupList, "Documents", "",
55 QDir::homeDirPath() + "/Documents/"); 63 QDir::homeDirPath() + "/Documents/");
56 selectItem(documents); 64 selectItem(documents);
57 65
58 scanForApplicationSettings(); 66 scanForApplicationSettings();
59 67
60 Config config("BackupAndRestore"); 68 Config config("BackupAndRestore");
61 config.setGroup("General"); 69 config.setGroup("General");
62 int totalLocations = config.readNumEntry("totalLocations",0); 70 int totalLocations = config.readNumEntry("totalLocations",0);
63 71
64//todo make less static here and use Storage class to get infos 72//todo make less static here and use Storage class to get infos
65 if(totalLocations == 0){ 73 if(totalLocations == 0){
66 74
67/* Ramses has a CF-Slot, but that one is internal and you have to dismount the 75/* Ramses has a CF-Slot, but that one is internal and you have to dismount the
68 * the case. There's also almost always a WLAN card inserted there 76 * the case. There's also almost always a WLAN card inserted there
69*/ 77*/
70 78
71 backupLocations.insert("Documents", "/root/Documents"); 79 backupLocations.insert("Documents", "/root/Documents");
72#if defined(QT_QWS_RAMSES) 80#if defined(QT_QWS_RAMSES)
73 backupLocations.insert("MMC", "/mnt/card"); 81 backupLocations.insert("MMC", "/mnt/card");
74#else 82#else
75 backupLocations.insert("CF", "/mnt/cf"); 83 backupLocations.insert("CF", "/mnt/cf");
76 backupLocations.insert("SD", "/mnt/card"); 84 backupLocations.insert("SD", "/mnt/card");
77#endif 85#endif
78 } 86 }
79 else{ 87 else{
80 for(int i = 0; i < totalLocations; i++){ 88 for(int i = 0; i < totalLocations; i++){
81 backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)), 89 backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)),
82 config.readEntry(QString("backupLocation_%1").arg(i))); 90 config.readEntry(QString("backupLocation_%1").arg(i)));
83 } 91 }
84 } 92 }
85 QMap<QString, QString>::Iterator it; 93 QMap<QString, QString>::Iterator it;
86 for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){ 94 for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){
87 storeToLocation->insertItem(it.key()); 95 storeToLocation->insertItem(it.key());
88 restoreSource->insertItem(it.key()); 96 restoreSource->insertItem(it.key());
89 } 97 }
90 98
91 // Read the list of items to ignore. 99 // Read the list of items to ignore.
92 QList<QString> dontBackupList; 100 QList<QString> dontBackupList;
93 dontBackupList.setAutoDelete(true); 101 dontBackupList.setAutoDelete(true);
94 config.setGroup("DontBackup"); 102 config.setGroup("DontBackup");
95 int total = config.readNumEntry("Total", 0); 103 int total = config.readNumEntry("Total", 0);
96 for(int i = 0; i < total; i++){ 104 for(int i = 0; i < total; i++){
97 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); 105 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
98 } 106 }
99 107
100 QList<QListViewItem> list; 108 QList<QListViewItem> list;
101 getAllItems(backupList->firstChild(), list); 109 getAllItems(backupList->firstChild(), list);
102 110
103 for(uint i = 0; i < list.count(); i++){ 111 for(uint i = 0; i < list.count(); i++){
104 QString text = list.at(i)->text(HEADER_NAME); 112 QString text = list.at(i)->text(HEADER_NAME);
105 for(uint i2 = 0; i2 < dontBackupList.count(); i2++){ 113 for(uint i2 = 0; i2 < dontBackupList.count(); i2++){
106 if(*dontBackupList.at(i2) == text){ 114 if(*dontBackupList.at(i2) == text){
107 selectItem(list.at(i)); 115 selectItem(list.at(i));
108 break; 116 break;
109 } 117 }
110 } 118 }
111 } 119 }
112} 120}
113 121
114BackupAndRestore::~BackupAndRestore(){ 122BackupAndRestore::~BackupAndRestore(){
115 QList<QListViewItem> list; 123 QList<QListViewItem> list;
116 getAllItems(backupList->firstChild(), list); 124 getAllItems(backupList->firstChild(), list);
117 125
118 Config config("BackupAndRestore"); 126 Config config("BackupAndRestore");
119 config.setGroup("DontBackup"); 127 config.setGroup("DontBackup");
120 config.clearGroup(); 128 config.clearGroup();
121 129
122 int count = 0; 130 int count = 0;
123 for(uint i = 0; i < list.count(); i++){ 131 for(uint i = 0; i < list.count(); i++){
124 if(list.at(i)->text(HEADER_BACKUP) == ""){ 132 if(list.at(i)->text(HEADER_BACKUP) == ""){
125 config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); 133 config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME));
126 count++; 134 count++;
127 } 135 }
128 } 136 }
129 config.writeEntry("Total", count); 137 config.writeEntry("Total", count);
138
139 // Remove Temp File
140 if ( QFile::exists( tempFileName ) )
141 QFile::remove( tempFileName );
130} 142}
131 143
132QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list){ 144QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list){
133 while(item){ 145 while(item){
134 if(item->childCount() > 0) 146 if(item->childCount() > 0)
135 getAllItems(item->firstChild(), list); 147 getAllItems(item->firstChild(), list);
136 list.append(item); 148 list.append(item);
137 item = item->nextSibling(); 149 item = item->nextSibling();
138 } 150 }
139 return list; 151 return list;
140} 152}
141 153
142/** 154/**
143 * Selects and unselects the item by setting the HEADER_BACKUP to B or !. 155 * Selects and unselects the item by setting the HEADER_BACKUP to B or !.
144 * and changing the icon to match 156 * and changing the icon to match
145 * @param currentItem the item to swich the selection choice. 157 * @param currentItem the item to swich the selection choice.
146 */ 158 */
147void BackupAndRestore::selectItem(QListViewItem *currentItem){ 159void BackupAndRestore::selectItem(QListViewItem *currentItem){
148 if(!currentItem) 160 if(!currentItem)
149 return; 161 return;
150 162
151 if(currentItem->text(HEADER_BACKUP) == "B"){ 163 if(currentItem->text(HEADER_BACKUP) == "B"){
152 currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); 164 currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null"));
153 currentItem->setText(HEADER_BACKUP, ""); 165 currentItem->setText(HEADER_BACKUP, "");
154 } 166 }
155 else{ 167 else{
156 currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); 168 currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check"));
157 currentItem->setText(HEADER_BACKUP, "B"); 169 currentItem->setText(HEADER_BACKUP, "B");
158 } 170 }
159} 171}
160 172
161void BackupAndRestore::scanForApplicationSettings(){ 173void BackupAndRestore::scanForApplicationSettings(){
162 QDir d(applicationSettings->text(BACKUP_LOCATION)); 174 QDir d(applicationSettings->text(BACKUP_LOCATION));
163 d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); 175 d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks );
164 const QFileInfoList *list = d.entryInfoList(); 176 const QFileInfoList *list = d.entryInfoList();
165 QFileInfoListIterator it( *list ); 177 QFileInfoListIterator it( *list );
166 QFileInfo *fi; 178 QFileInfo *fi;
167 while ( (fi=it.current()) ) { 179 while ( (fi=it.current()) ) {
168 // qDebug((d.path()+fi->fileName()).latin1()); 180 // qDebug((d.path()+fi->fileName()).latin1());
169 if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) { 181 if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) {
170 QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); 182 QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName());
171 selectItem(newItem); 183 selectItem(newItem);
172 } 184 }
173 ++it; 185 ++it;
174 } 186 }
175} 187}
176 188
177/** 189/**
178 * The "Backup" button has been pressed. Get a list of all of the files that 190 * The "Backup" button has been pressed. Get a list of all of the files that
179 * should be backed up. If there are no files, emit and error and exit. 191 * should be backed up. If there are no files, emit and error and exit.
180 * Determine the file name to store the backup in. Backup the file(s) using 192 * Determine the file name to store the backup in. Backup the file(s) using
181 * tar and gzip --best. Report failure or success 193 * tar and gzip --best. Report failure or success
182 */ 194 */
183void BackupAndRestore::backupPressed(){ 195void BackupAndRestore::backupPressed(){
184 QString backupFiles; 196 QString backupFiles;
185 if(getBackupFiles(backupFiles, NULL) == 0){ 197 if(getBackupFiles(backupFiles, NULL) == 0){
186 QMessageBox::critical(this, "Message", 198 QMessageBox::critical(this, "Message",
187 "No items selected.",QString("Ok") ); 199 "No items selected.",QString("Ok") );
188 return; 200 return;
189 } 201 }
190 202
191 setCaption(tr("Backup and Restore... working...")); 203 setCaption(tr("Backup and Restore... working..."));
192 QString outputFile = backupLocations[storeToLocation->currentText()]; 204 QString outputFile = backupLocations[storeToLocation->currentText()];
193 205
194 QDateTime time = QDateTime::currentDateTime(); 206 QDateTime datetime = QDateTime::currentDateTime();
195 QString dateString = time.date().toString().replace(QRegExp(" "), ""); 207 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') +
208 QString::number( datetime.date().day() ).rightJustify(2, '0');
209
196 outputFile += "/" + dateString; 210 outputFile += "/" + dateString;
197 211
198 QString t = outputFile; 212 QString t = outputFile;
199 int c = 1; 213 int c = 1;
200 while(QFile::exists(outputFile + EXTENSION)){ 214 while(QFile::exists(outputFile + EXTENSION)){
201 outputFile = t + QString("%1").arg(c); 215 outputFile = t + QString("%1").arg(c);
202 c++; 216 c++;
203 } 217 }
204 218
205 qDebug(QString("system(\"tar -c %1 | gzip > %2\")").arg(backupFiles).arg(outputFile).latin1()); 219 // We execute tar and compressing its output with gzip..
220 // The error output will be written into a temp-file which could be provided
221 // for debugging..
222 qDebug( "Storing file: %s", outputFile.latin1() );
206 outputFile += EXTENSION; 223 outputFile += EXTENSION;
207 224
208 int r = system( QString("tar -c %1 | gzip > %2").arg(backupFiles).arg(outputFile).latin1() ); 225 qWarning( QString("(tar -c %1 | gzip > %2 ) 2> %3")
226 .arg( backupFiles )
227 .arg( outputFile.latin1() )
228 .arg( tempFileName.latin1() ) );
209 229
210 230
231 int r = system( QString("(tar -c %1 | gzip > %2 ) 2> %3")
232 .arg( backupFiles )
233 .arg( outputFile.latin1() )
234 .arg( tempFileName.latin1() ) );
211 235
212 if(r != 0){ 236 if(r != 0){
213 perror("Error: "); 237 perror("Error: ");
214 QString errorMsg="Error\n"+(QString)strerror(errno); 238 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno );
239
240 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n"
241 + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ){
215 242
216 QMessageBox::critical(this, "Message", "Backup Failed.\n"+errorMsg, QString("Ok") ); 243 case 1:
244 qWarning("Details pressed !");
245 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true );
246 QFile errorFile( tempFileName );
247 if ( errorFile.open(IO_ReadOnly) ) {
248 QTextStream t( &errorFile );
249 QString s;
250 while ( !t.eof() ) { // until end of file...
251 s += t.readLine(); // line of text excluding '\n'
252 }
253 errorFile.close();
254
255 pErrDialog->m_textarea->setText( s );
256 }else{
257 pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" );
258 }
259 pErrDialog->showMaximized();
260 pErrDialog->exec();
261 delete pErrDialog;
262 break;
263 }
264 setCaption(tr("Backup and Restore.. Failed !!"));
217 return; 265 return;
218 } 266 }
219 else{ 267 else{
220 QMessageBox::information(this, "Message", "Backup Successfull.",QString("Ok") ); 268 QMessageBox::information(this, tr( "Message" ), tr( "Backup Successfull." ), QString(tr( "Ok" ) ) );
221 269
222 } 270 }
223 setCaption(tr("Backup and Restore")); 271 setCaption(tr("Backup and Restore"));
224} 272}
225 273
226/*** 274/***
227 * Get a list of all of the files to backup. 275 * Get a list of all of the files to backup.
228 */ 276 */
229int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){ 277int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){
230 QListViewItem * currentItem; 278 QListViewItem * currentItem;
231 QString currentHome; 279 QString currentHome;
232 if(!parent) 280 if(!parent)
233 currentItem = backupList->firstChild(); 281 currentItem = backupList->firstChild();
234 else{ 282 else{
235 currentItem = parent->firstChild(); 283 currentItem = parent->firstChild();
236 currentHome = parent->text(BACKUP_LOCATION); 284 currentHome = parent->text(BACKUP_LOCATION);
237 } 285 }
238 286
239 uint count = 0; 287 uint count = 0;
240 while( currentItem != 0 ){ 288 while( currentItem != 0 ){
241 if(currentItem->text(HEADER_BACKUP) == "B" ){ 289 if(currentItem->text(HEADER_BACKUP) == "B" ){
242 if(currentItem->childCount() == 0 ){ 290 if(currentItem->childCount() == 0 ){
243 if(parent == NULL) 291 if(parent == NULL)
244 backupFiles += currentItem->text(BACKUP_LOCATION); 292 backupFiles += currentItem->text(BACKUP_LOCATION);
245 else 293 else
246 backupFiles += currentHome + currentItem->text(HEADER_NAME); 294 backupFiles += currentHome + currentItem->text(HEADER_NAME);
247 backupFiles += " "; 295 backupFiles += " ";
248 count++; 296 count++;
249 } 297 }
250 else{ 298 else{
251 count += getBackupFiles(backupFiles, currentItem); 299 count += getBackupFiles(backupFiles, currentItem);
252 } 300 }
253 } 301 }
254 currentItem = currentItem->nextSibling(); 302 currentItem = currentItem->nextSibling();
255 } 303 }
256 return count; 304 return count;
257} 305}
258 306
259void BackupAndRestore::sourceDirChanged(int selection){ 307void BackupAndRestore::sourceDirChanged(int selection){
260 restoreList->clear(); 308 restoreList->clear();
261 rescanFolder(backupLocations[restoreSource->text(selection)]); 309 rescanFolder(backupLocations[restoreSource->text(selection)]);
262} 310}
263 311
312void BackupAndRestore::fileListUpdate()
313{
314 qWarning("void BackupAndRestore::fileListUpdate()");
315 restoreList->clear();
316 rescanFolder( backupLocations[restoreSource->currentText()] );
317}
318
264/** 319/**
265 * Scans directory for any backup files. Will recursivly go down, 320 * Scans directory for any backup files. Will recursivly go down,
266 * but will not follow symlinks. 321 * but will not follow symlinks.
267 * @param directory - the directory to look in. 322 * @param directory - the directory to look in.
268 */ 323 */
269void BackupAndRestore::rescanFolder(QString directory){ 324void BackupAndRestore::rescanFolder(QString directory){
270 //qDebug(QString("rescanFolder: ") + directory.latin1()); 325 //qDebug(QString("rescanFolder: ") + directory.latin1());
271 QDir d(directory); 326 QDir d(directory);
272 if(!d.exists()) 327 if(!d.exists())
273 return; 328 return;
274 329
275 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); 330 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs);
276 const QFileInfoList *list = d.entryInfoList(); 331 const QFileInfoList *list = d.entryInfoList();
277 QFileInfoListIterator it( *list ); 332 QFileInfoListIterator it( *list );
278 QFileInfo *file; 333 QFileInfo *file;
279 while ( (file=it.current()) ) { // for each file... 334 while ( (file=it.current()) ) { // for each file...
280 // If it is a dir and not .. or . then add it as a tab and go down. 335 // If it is a dir and not .. or . then add it as a tab and go down.
281 if(file->isDir()){ 336 if(file->isDir()){
282 if(file->fileName() != ".." && file->fileName() != ".") { 337 if(file->fileName() != ".." && file->fileName() != ".") {
283 rescanFolder(directory + "/" + file->fileName()); 338 rescanFolder(directory + "/" + file->fileName());
284 } 339 }
285 } 340 }
286 else{ 341 else{
287 // If it is a backup file add to list. 342 // If it is a backup file add to list.
288 if(file->fileName().contains(EXTENSION)) 343 if(file->fileName().contains(EXTENSION))
289 (void)new QListViewItem(restoreList, file->fileName()); 344 (void)new QListViewItem(restoreList, file->fileName());
290 } 345 }
291 ++it; 346 ++it;
292 } 347 }
293} 348}
294 349
295/** 350/**
296 * Restore a backup file. 351 * Restore a backup file.
297 * Report errors or success 352 * Report errors or success
298 */ 353 */
299void BackupAndRestore::restore(){ 354void BackupAndRestore::restore(){
300 QListViewItem *restoreItem = restoreList->currentItem(); 355 QListViewItem *restoreItem = restoreList->currentItem();
301 if(!restoreItem){ 356 if(!restoreItem){
302 QMessageBox::critical(this, "Message", 357 QMessageBox::critical(this, tr( "Message" ),
303 "Please select something to restore.",QString("Ok") ); 358 tr( "Please select something to restore." ),QString( tr( "Ok") ) );
304 return; 359 return;
305 } 360 }
361 setCaption(tr("Backup and Restore... working..."));
362
306 QString restoreFile = backupLocations[restoreSource->currentText()]; 363 QString restoreFile = backupLocations[restoreSource->currentText()];
307 364
308 restoreFile += "/" + restoreItem->text(0); 365 restoreFile += "/" + restoreItem->text(0);
309 366
310 int r = system(QString("tar -C / -zxf %1").arg(restoreFile).latin1()); 367 int r = system(QString("tar -C / -zxf %1 2> %3")
368 .arg( restoreFile.latin1() )
369 .arg( tempFileName.latin1() ) );
311 if(r != 0){ 370 if(r != 0){
312 QMessageBox::critical(this, "Message", 371 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno );
313 "Restore Failed.",QString("Ok") ); 372 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n"
373 + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) {
374 case 1:
375 qWarning("Details pressed !");
376 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true );
377 QFile errorFile( tempFileName );
378 if ( errorFile.open(IO_ReadOnly) ) {
379 QTextStream t( &errorFile );
380 QString s;
381 while ( !t.eof() ) { // until end of file...
382 s += t.readLine(); // line of text excluding '\n'
383 }
384 errorFile.close();
385
386 pErrDialog->m_textarea->setText( s );
387 }else{
388 pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) );
389 }
390 pErrDialog->showMaximized();
391 pErrDialog->exec();
392 delete pErrDialog;
393
394 setCaption(tr("Backup and Restore.. Failed !!"));
395 return;
396
397 break;
398
399 }
314 } 400 }
315 else{ 401 else{
316 QMessageBox::critical(this, "Message", 402 QMessageBox::critical(this, tr( "Message" ),
317 "Restore Successfull.",QString("Ok") ); 403 tr( "Restore Successfull." ), QString( tr( "Ok") ) );
318 } 404 }
405 setCaption(tr("Backup and Restore"));
319} 406}
320 407
321// backuprestore.cpp 408// backuprestore.cpp
322 409
diff --git a/noncore/settings/backup/backuprestore.h b/noncore/settings/backup/backuprestore.h
index b0cf4cd..8c733e3 100644
--- a/noncore/settings/backup/backuprestore.h
+++ b/noncore/settings/backup/backuprestore.h
@@ -1,42 +1,44 @@
1#ifndef WINDOW_H 1#ifndef WINDOW_H
2#define WINDOW_H 2#define WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include "backuprestorebase.h" 5#include "backuprestorebase.h"
6#include <qmap.h> 6#include <qmap.h>
7#include <qlist.h> 7#include <qlist.h>
8 8
9class QListViewItem; 9class QListViewItem;
10 10
11class BackupAndRestore : public BackupAndRestoreBase { 11class BackupAndRestore : public BackupAndRestoreBase {
12 12
13Q_OBJECT 13Q_OBJECT
14 14
15public: 15public:
16
16 BackupAndRestore( QWidget* parent = 0, const char* name = 0); 17 BackupAndRestore( QWidget* parent = 0, const char* name = 0);
17 ~BackupAndRestore(); 18 ~BackupAndRestore();
18 19
19 20
20private slots: 21private slots:
21 void backupPressed(); 22 void backupPressed();
22 void restore(); 23 void restore();
23 void selectItem(QListViewItem *currentItem); 24 void selectItem(QListViewItem *currentItem);
24 void sourceDirChanged(int); 25 void sourceDirChanged(int);
25 void rescanFolder(QString directory); 26 void rescanFolder(QString directory);
27 void fileListUpdate();
26 28
27private: 29private:
28 void scanForApplicationSettings(); 30 void scanForApplicationSettings();
29 int getBackupFiles(QString &backupFiles, QListViewItem *parent); 31 int getBackupFiles(QString &backupFiles, QListViewItem *parent);
30 QMap<QString, QString> backupLocations; 32 QMap<QString, QString> backupLocations;
31 QList<QListViewItem> getAllItems(QListViewItem *item, QList<QListViewItem> &list); 33 QList<QListViewItem> getAllItems(QListViewItem *item, QList<QListViewItem> &list);
32 34
33 QListViewItem *systemSettings; 35 QListViewItem *systemSettings;
34 QListViewItem *applicationSettings; 36 QListViewItem *applicationSettings;
35 QListViewItem *documents; 37 QListViewItem *documents;
36 38
37}; 39};
38 40
39#endif 41#endif
40 42
41// backuprestore.h 43// backuprestore.h
42 44
diff --git a/noncore/settings/backup/backuprestorebase.ui b/noncore/settings/backup/backuprestorebase.ui
index 92e37ee..05dc8a9 100644
--- a/noncore/settings/backup/backuprestorebase.ui
+++ b/noncore/settings/backup/backuprestorebase.ui
@@ -1,221 +1,235 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>BackupAndRestoreBase</class> 2<class>BackupAndRestoreBase</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>BackupAndRestoreBase</cstring> 7 <cstring>BackupAndRestoreBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>234</width> 14 <width>235</width>
15 <height>216</height> 15 <height>275</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Backup And Restore</string> 20 <string>Backup And Restore</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <vbox> 25 <vbox>
26 <property stdset="1"> 26 <property stdset="1">
27 <name>margin</name> 27 <name>margin</name>
28 <number>0</number> 28 <number>0</number>
29 </property> 29 </property>
30 <property stdset="1"> 30 <property stdset="1">
31 <name>spacing</name> 31 <name>spacing</name>
32 <number>6</number> 32 <number>6</number>
33 </property> 33 </property>
34 <widget> 34 <widget>
35 <class>QTabWidget</class> 35 <class>QTabWidget</class>
36 <property stdset="1"> 36 <property stdset="1">
37 <name>name</name> 37 <name>name</name>
38 <cstring>tabWidget</cstring> 38 <cstring>tabWidget</cstring>
39 </property> 39 </property>
40 <property>
41 <name>layoutMargin</name>
42 </property>
40 <widget> 43 <widget>
41 <class>QWidget</class> 44 <class>QWidget</class>
42 <property stdset="1"> 45 <property stdset="1">
43 <name>name</name> 46 <name>name</name>
44 <cstring>Widget2</cstring> 47 <cstring>Widget2</cstring>
45 </property> 48 </property>
46 <attribute> 49 <attribute>
47 <name>title</name> 50 <name>title</name>
48 <string>Backup</string> 51 <string>Backup</string>
49 </attribute> 52 </attribute>
50 <grid> 53 <grid>
51 <property stdset="1"> 54 <property stdset="1">
52 <name>margin</name> 55 <name>margin</name>
53 <number>11</number> 56 <number>11</number>
54 </property> 57 </property>
55 <property stdset="1"> 58 <property stdset="1">
56 <name>spacing</name> 59 <name>spacing</name>
57 <number>6</number> 60 <number>6</number>
58 </property> 61 </property>
59 <widget row="1" column="0" rowspan="1" colspan="3" > 62 <widget row="1" column="0" rowspan="1" colspan="3" >
60 <class>QListView</class> 63 <class>QListView</class>
61 <column> 64 <column>
62 <property> 65 <property>
63 <name>text</name> 66 <name>text</name>
64 <string>Applications</string> 67 <string>Applications</string>
65 </property> 68 </property>
66 <property> 69 <property>
67 <name>clickable</name> 70 <name>clickable</name>
68 <bool>true</bool> 71 <bool>true</bool>
69 </property> 72 </property>
70 <property> 73 <property>
71 <name>resizeable</name> 74 <name>resizeable</name>
72 <bool>true</bool> 75 <bool>true</bool>
73 </property> 76 </property>
74 </column> 77 </column>
75 <property stdset="1"> 78 <property stdset="1">
76 <name>name</name> 79 <name>name</name>
77 <cstring>backupList</cstring> 80 <cstring>backupList</cstring>
78 </property> 81 </property>
79 <property stdset="1"> 82 <property stdset="1">
80 <name>allColumnsShowFocus</name> 83 <name>allColumnsShowFocus</name>
81 <bool>true</bool> 84 <bool>true</bool>
82 </property> 85 </property>
83 <property stdset="1"> 86 <property stdset="1">
84 <name>rootIsDecorated</name> 87 <name>rootIsDecorated</name>
85 <bool>true</bool> 88 <bool>true</bool>
86 </property> 89 </property>
87 </widget> 90 </widget>
88 <widget row="0" column="1" > 91 <widget row="0" column="1" >
89 <class>QComboBox</class> 92 <class>QComboBox</class>
90 <property stdset="1"> 93 <property stdset="1">
91 <name>name</name> 94 <name>name</name>
92 <cstring>storeToLocation</cstring> 95 <cstring>storeToLocation</cstring>
93 </property> 96 </property>
94 </widget> 97 </widget>
95 <widget row="0" column="0" > 98 <widget row="0" column="0" >
96 <class>QLabel</class> 99 <class>QLabel</class>
97 <property stdset="1"> 100 <property stdset="1">
98 <name>name</name> 101 <name>name</name>
99 <cstring>TextLabel1</cstring> 102 <cstring>TextLabel1</cstring>
100 </property> 103 </property>
101 <property stdset="1"> 104 <property stdset="1">
102 <name>text</name> 105 <name>text</name>
103 <string>Save To</string> 106 <string>Save To</string>
104 </property> 107 </property>
105 </widget> 108 </widget>
106 <spacer row="0" column="2" > 109 <spacer row="0" column="2" >
107 <property> 110 <property>
108 <name>name</name> 111 <name>name</name>
109 <cstring>Spacer1</cstring> 112 <cstring>Spacer1</cstring>
110 </property> 113 </property>
111 <property stdset="1"> 114 <property stdset="1">
112 <name>orientation</name> 115 <name>orientation</name>
113 <enum>Horizontal</enum> 116 <enum>Horizontal</enum>
114 </property> 117 </property>
115 <property stdset="1"> 118 <property stdset="1">
116 <name>sizeType</name> 119 <name>sizeType</name>
117 <enum>Expanding</enum> 120 <enum>Expanding</enum>
118 </property> 121 </property>
119 <property> 122 <property>
120 <name>sizeHint</name> 123 <name>sizeHint</name>
121 <size> 124 <size>
122 <width>20</width> 125 <width>20</width>
123 <height>20</height> 126 <height>20</height>
124 </size> 127 </size>
125 </property> 128 </property>
126 </spacer> 129 </spacer>
127 <widget row="2" column="0" rowspan="1" colspan="3" > 130 <widget row="2" column="0" rowspan="1" colspan="3" >
128 <class>QPushButton</class> 131 <class>QPushButton</class>
129 <property stdset="1"> 132 <property stdset="1">
130 <name>name</name> 133 <name>name</name>
131 <cstring>backupButton</cstring> 134 <cstring>backupButton</cstring>
132 </property> 135 </property>
133 <property stdset="1"> 136 <property stdset="1">
134 <name>text</name> 137 <name>text</name>
135 <string>&amp;Backup</string> 138 <string>&amp;Backup</string>
136 </property> 139 </property>
137 </widget> 140 </widget>
138 </grid> 141 </grid>
139 </widget> 142 </widget>
140 <widget> 143 <widget>
141 <class>QWidget</class> 144 <class>QWidget</class>
142 <property stdset="1"> 145 <property stdset="1">
143 <name>name</name> 146 <name>name</name>
144 <cstring>Widget3</cstring> 147 <cstring>Widget3</cstring>
145 </property> 148 </property>
146 <attribute> 149 <attribute>
147 <name>title</name> 150 <name>title</name>
148 <string>Restore</string> 151 <string>Restore</string>
149 </attribute> 152 </attribute>
150 <grid> 153 <grid>
151 <property stdset="1"> 154 <property stdset="1">
152 <name>margin</name> 155 <name>margin</name>
153 <number>11</number> 156 <number>4</number>
154 </property> 157 </property>
155 <property stdset="1"> 158 <property stdset="1">
156 <name>spacing</name> 159 <name>spacing</name>
157 <number>6</number> 160 <number>6</number>
158 </property> 161 </property>
159 <widget row="0" column="1" > 162 <widget row="0" column="1" >
160 <class>QComboBox</class> 163 <class>QComboBox</class>
161 <property stdset="1"> 164 <property stdset="1">
162 <name>name</name> 165 <name>name</name>
163 <cstring>restoreSource</cstring> 166 <cstring>restoreSource</cstring>
164 </property> 167 </property>
165 </widget> 168 </widget>
166 <widget row="0" column="0" > 169 <widget row="2" column="0" rowspan="1" colspan="2" >
167 <class>QLabel</class>
168 <property stdset="1">
169 <name>name</name>
170 <cstring>TextLabel1_2</cstring>
171 </property>
172 <property stdset="1">
173 <name>text</name>
174 <string>Select Source</string>
175 </property>
176 </widget>
177 <widget row="1" column="0" rowspan="1" colspan="2" >
178 <class>QListView</class> 170 <class>QListView</class>
179 <column> 171 <column>
180 <property> 172 <property>
181 <name>text</name> 173 <name>text</name>
182 <string>Column 1</string> 174 <string>Column 1</string>
183 </property> 175 </property>
184 <property> 176 <property>
185 <name>clickable</name> 177 <name>clickable</name>
186 <bool>true</bool> 178 <bool>true</bool>
187 </property> 179 </property>
188 <property> 180 <property>
189 <name>resizeable</name> 181 <name>resizeable</name>
190 <bool>true</bool> 182 <bool>true</bool>
191 </property> 183 </property>
192 </column> 184 </column>
193 <property stdset="1"> 185 <property stdset="1">
194 <name>name</name> 186 <name>name</name>
195 <cstring>restoreList</cstring> 187 <cstring>restoreList</cstring>
196 </property> 188 </property>
197 <property stdset="1"> 189 <property stdset="1">
198 <name>minimumSize</name> 190 <name>minimumSize</name>
199 <size> 191 <size>
200 <width>0</width> 192 <width>0</width>
201 <height>100</height> 193 <height>100</height>
202 </size> 194 </size>
203 </property> 195 </property>
204 </widget> 196 </widget>
205 <widget row="2" column="0" rowspan="1" colspan="2" > 197 <widget row="3" column="0" rowspan="1" colspan="2" >
206 <class>QPushButton</class> 198 <class>QPushButton</class>
207 <property stdset="1"> 199 <property stdset="1">
208 <name>name</name> 200 <name>name</name>
209 <cstring>restoreButton</cstring> 201 <cstring>restoreButton</cstring>
210 </property> 202 </property>
211 <property stdset="1"> 203 <property stdset="1">
212 <name>text</name> 204 <name>text</name>
213 <string>&amp;Restore</string> 205 <string>&amp;Restore</string>
214 </property> 206 </property>
215 </widget> 207 </widget>
208 <widget row="1" column="0" rowspan="1" colspan="2" >
209 <class>QPushButton</class>
210 <property stdset="1">
211 <name>name</name>
212 <cstring>updateList</cstring>
213 </property>
214 <property stdset="1">
215 <name>text</name>
216 <string>Update Filelist</string>
217 </property>
218 </widget>
219 <widget row="0" column="0" >
220 <class>QLabel</class>
221 <property stdset="1">
222 <name>name</name>
223 <cstring>TextLabel1_2</cstring>
224 </property>
225 <property stdset="1">
226 <name>text</name>
227 <string>Select Source</string>
228 </property>
229 </widget>
216 </grid> 230 </grid>
217 </widget> 231 </widget>
218 </widget> 232 </widget>
219 </vbox> 233 </vbox>
220</widget> 234</widget>
221</UI> 235</UI>
diff --git a/noncore/settings/backup/errordialog.ui b/noncore/settings/backup/errordialog.ui
new file mode 100644
index 0000000..b68b3c2
--- a/dev/null
+++ b/noncore/settings/backup/errordialog.ui
@@ -0,0 +1,154 @@
1<!DOCTYPE UI><UI>
2<class>ErrorDialog</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>ErrorDialog</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>153</width>
15 <height>223</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Error Info</string>
21 </property>
22 <property stdset="1">
23 <name>sizeGripEnabled</name>
24 <bool>true</bool>
25 </property>
26 <property>
27 <name>layoutMargin</name>
28 </property>
29 <property>
30 <name>layoutSpacing</name>
31 </property>
32 <vbox>
33 <property stdset="1">
34 <name>margin</name>
35 <number>2</number>
36 </property>
37 <property stdset="1">
38 <name>spacing</name>
39 <number>2</number>
40 </property>
41 <widget>
42 <class>QGroupBox</class>
43 <property stdset="1">
44 <name>name</name>
45 <cstring>GroupBox1</cstring>
46 </property>
47 <property stdset="1">
48 <name>midLineWidth</name>
49 <number>2</number>
50 </property>
51 <property stdset="1">
52 <name>title</name>
53 <string>Error Message:</string>
54 </property>
55 <property>
56 <name>layoutMargin</name>
57 </property>
58 <grid>
59 <property stdset="1">
60 <name>margin</name>
61 <number>4</number>
62 </property>
63 <property stdset="1">
64 <name>spacing</name>
65 <number>6</number>
66 </property>
67 <widget row="0" column="0" >
68 <class>QMultiLineEdit</class>
69 <property stdset="1">
70 <name>name</name>
71 <cstring>m_textarea</cstring>
72 </property>
73 <property stdset="1">
74 <name>wordWrap</name>
75 <enum>WidgetWidth</enum>
76 </property>
77 </widget>
78 </grid>
79 </widget>
80 <widget>
81 <class>QFrame</class>
82 <property stdset="1">
83 <name>name</name>
84 <cstring>Frame3</cstring>
85 </property>
86 <property stdset="1">
87 <name>sizePolicy</name>
88 <sizepolicy>
89 <hsizetype>3</hsizetype>
90 <vsizetype>4</vsizetype>
91 </sizepolicy>
92 </property>
93 <property stdset="1">
94 <name>frameShape</name>
95 <enum>StyledPanel</enum>
96 </property>
97 <property stdset="1">
98 <name>frameShadow</name>
99 <enum>Sunken</enum>
100 </property>
101 <property>
102 <name>layoutMargin</name>
103 </property>
104 <property>
105 <name>layoutSpacing</name>
106 </property>
107 <grid>
108 <property stdset="1">
109 <name>margin</name>
110 <number>2</number>
111 </property>
112 <property stdset="1">
113 <name>spacing</name>
114 <number>2</number>
115 </property>
116 <widget row="0" column="0" >
117 <class>QPushButton</class>
118 <property stdset="1">
119 <name>name</name>
120 <cstring>m_buttonOk</cstring>
121 </property>
122 <property stdset="1">
123 <name>sizePolicy</name>
124 <sizepolicy>
125 <hsizetype>4</hsizetype>
126 <vsizetype>4</vsizetype>
127 </sizepolicy>
128 </property>
129 <property stdset="1">
130 <name>text</name>
131 <string>&amp;OK</string>
132 </property>
133 <property stdset="1">
134 <name>autoDefault</name>
135 <bool>true</bool>
136 </property>
137 <property stdset="1">
138 <name>default</name>
139 <bool>true</bool>
140 </property>
141 </widget>
142 </grid>
143 </widget>
144 </vbox>
145</widget>
146<connections>
147 <connection>
148 <sender>m_buttonOk</sender>
149 <signal>clicked()</signal>
150 <receiver>ErrorDialog</receiver>
151 <slot>accept()</slot>
152 </connection>
153</connections>
154</UI>
diff --git a/noncore/settings/backup/opie-backup.control b/noncore/settings/backup/opie-backup.control
index 3f2be85..ebe2ff1 100644
--- a/noncore/settings/backup/opie-backup.control
+++ b/noncore/settings/backup/opie-backup.control
@@ -1,9 +1,9 @@
1Package: opie-backup 1Package: opie-backup
2Files: bin/backup pics/backup apps/Settings/backup.desktop 2Files: bin/backup pics/backup apps/Settings/backup.desktop
3Priority: optional 3Priority: optional
4Version: $QPE_VERSION-$SUB_VERSION 4Version: $QPE_VERSION-$SUB_VERSION
5Depends: task-opie-minimal 5Depends: task-opie-minimal
6Architecture: arm 6Architecture: arm
7Maintainer: Benjamin Meyer <meyerb@sharpsec.com> 7Maintainer: Stefan Eilers <Eilers.Stefan@epost.de>
8Section: opie/Settings 8Section: opie/Settings
9Description: Backup and Restore utility. 9Description: Backup and Restore utility.