summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-01-31 22:29:55 (UTC)
committer mickeyl <mickeyl>2005-01-31 22:29:55 (UTC)
commit9fb5fc66d59a91bfd4840ff17dc8338c34fce90c (patch) (unidiff)
tree9d377a3028d66b0d6d57268e840d990f3eb7154c
parente92a75664daf9df85a358a42ff2b66f6779c998f (diff)
downloadopie-9fb5fc66d59a91bfd4840ff17dc8338c34fce90c.zip
opie-9fb5fc66d59a91bfd4840ff17dc8338c34fce90c.tar.gz
opie-9fb5fc66d59a91bfd4840ff17dc8338c34fce90c.tar.bz2
enable clone for SL5000 and SL5500 - it's not fully working yet due to
Mr. RAM Hog 'mkfs.jffs2' getting SIGTERMed by the OOM :/
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp51
-rw-r--r--share/backup/device_table-minimal.txt20
2 files changed, 55 insertions, 16 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 869c1b8..d028379 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -1,747 +1,766 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 =. 3 =.
4             .=l. Copyright (c) 2002-2004 The Opie Team <opie-devel@handhelds.org> 4             .=l. Copyright (c) 2002-2004 The Opie Team <opie-devel@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "backuprestore.h" 29#include "backuprestore.h"
30#include "errordialog.h" 30#include "errordialog.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#include <opie2/odevice.h> 37#include <opie2/odevice.h>
38#include <opie2/ostorageinfo.h> 38#include <opie2/ostorageinfo.h>
39#include <opie2/ofiledialog.h> 39#include <opie2/ofiledialog.h>
40#include <opie2/owait.h> 40#include <opie2/owait.h>
41using namespace Opie::Core; 41using namespace Opie::Core;
42using namespace Opie::Ui; 42using namespace Opie::Ui;
43 43
44/* QT */ 44/* QT */
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qmultilineedit.h> 46#include <qmultilineedit.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qfileinfo.h> 49#include <qfileinfo.h>
50#include <qlistview.h> 50#include <qlistview.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qradiobutton.h> 52#include <qradiobutton.h>
53#include <qheader.h> 53#include <qheader.h>
54#include <qmessagebox.h> 54#include <qmessagebox.h>
55#include <qcombobox.h> 55#include <qcombobox.h>
56#include <qlist.h> 56#include <qlist.h>
57#include <qregexp.h> 57#include <qregexp.h>
58#include <qtextstream.h> 58#include <qtextstream.h>
59#include <qtextview.h> 59#include <qtextview.h>
60#include <qlineedit.h> 60#include <qlineedit.h>
61#include <qstringlist.h> 61#include <qstringlist.h>
62 62
63/* STD */ 63/* STD */
64#include <errno.h> 64#include <errno.h>
65#include <stdlib.h> 65#include <stdlib.h>
66#include <unistd.h> 66#include <unistd.h>
67#include <sys/stat.h> 67#include <sys/stat.h>
68#include <dirent.h> 68#include <dirent.h>
69 69
70#define HEADER_NAME 0 70#define HEADER_NAME 0
71#define HEADER_BACKUP 1 71#define HEADER_BACKUP 1
72#define BACKUP_LOCATION 2 72#define BACKUP_LOCATION 2
73 73
74#define EXTENSION ".bck" 74#define EXTENSION ".bck"
75 75
76const QString tempFileName = "/tmp/backup.err"; 76const QString tempFileName = "/tmp/backup.err";
77 77
78BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) 78BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl)
79 : BackupAndRestoreBase(parent, name, fl) 79 : BackupAndRestoreBase(parent, name, fl)
80{ 80{
81 backupList->header()->hide(); 81 backupList->header()->hide();
82 restoreList->header()->hide(); 82 restoreList->header()->hide();
83 locationList->header()->hide(); 83 locationList->header()->hide();
84 connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) ); 84 connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) );
85 connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) ); 85 connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) );
86 connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) ); 86 connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) );
87 connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) ); 87 connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) );
88 connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) ); 88 connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) );
89 connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) ); 89 connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) );
90 connect( saveLocationsButton, SIGNAL( clicked() ), this, SLOT( saveLocations() ) ); 90 connect( saveLocationsButton, SIGNAL( clicked() ), this, SLOT( saveLocations() ) );
91 connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) ); 91 connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) );
92 92
93 //add directorys for backing up 93 //add directorys for backing up
94 applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); 94 applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/");
95 selectItem(applicationSettings); 95 selectItem(applicationSettings);
96 applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); 96 applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/");
97 selectItem(applicationSettings); 97 selectItem(applicationSettings);
98 documents= new QListViewItem(backupList, "Documents", "", "Documents/"); 98 documents= new QListViewItem(backupList, "Documents", "", "Documents/");
99 selectItem(documents); 99 selectItem(documents);
100 100
101 scanForApplicationSettings(); 101 scanForApplicationSettings();
102 refreshLocations(); 102 refreshLocations();
103 refreshBackupLocations(); 103 refreshBackupLocations();
104 104
105 // Read the list of items to ignore. 105 // Read the list of items to ignore.
106 QList<QString> dontBackupList; 106 QList<QString> dontBackupList;
107 dontBackupList.setAutoDelete(true); 107 dontBackupList.setAutoDelete(true);
108 Config config("BackupAndRestore"); 108 Config config("BackupAndRestore");
109 config.setGroup("DontBackup"); 109 config.setGroup("DontBackup");
110 int total = config.readNumEntry("Total", 0); 110 int total = config.readNumEntry("Total", 0);
111 for(int i = 0; i < total; i++) 111 for(int i = 0; i < total; i++)
112 { 112 {
113 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); 113 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
114 } 114 }
115 115
116 QList<QListViewItem> list; 116 QList<QListViewItem> list;
117 getAllItems(backupList->firstChild(), list); 117 getAllItems(backupList->firstChild(), list);
118 118
119 for(uint i = 0; i < list.count(); i++) 119 for(uint i = 0; i < list.count(); i++)
120 { 120 {
121 QString text = list.at(i)->text(HEADER_NAME); 121 QString text = list.at(i)->text(HEADER_NAME);
122 for(uint i2 = 0; i2 < dontBackupList.count(); i2++) 122 for(uint i2 = 0; i2 < dontBackupList.count(); i2++)
123 { 123 {
124 if(*dontBackupList.at(i2) == text) 124 if(*dontBackupList.at(i2) == text)
125 { 125 {
126 selectItem(list.at(i)); 126 selectItem(list.at(i));
127 break; 127 break;
128 } 128 }
129 } 129 }
130 } 130 }
131 QPEApplication::showWidget( this ); 131 QPEApplication::showWidget( this );
132} 132}
133 133
134BackupAndRestore::~BackupAndRestore() 134BackupAndRestore::~BackupAndRestore()
135{ 135{
136 QList<QListViewItem> list; 136 QList<QListViewItem> list;
137 getAllItems(backupList->firstChild(), list); 137 getAllItems(backupList->firstChild(), list);
138 138
139 Config config("BackupAndRestore"); 139 Config config("BackupAndRestore");
140 config.setGroup("DontBackup"); 140 config.setGroup("DontBackup");
141 config.clearGroup(); 141 config.clearGroup();
142 142
143 int count = 0; 143 int count = 0;
144 for(uint i = 0; i < list.count(); i++) 144 for(uint i = 0; i < list.count(); i++)
145 { 145 {
146 if(list.at(i)->text(HEADER_BACKUP) == "") 146 if(list.at(i)->text(HEADER_BACKUP) == "")
147 { 147 {
148 config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); 148 config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME));
149 count++; 149 count++;
150 } 150 }
151 } 151 }
152 config.writeEntry("Total", count); 152 config.writeEntry("Total", count);
153 153
154 // Remove Temp File 154 // Remove Temp File
155 if ( QFile::exists( tempFileName ) ) 155 if ( QFile::exists( tempFileName ) )
156 QFile::remove( tempFileName ); 156 QFile::remove( tempFileName );
157} 157}
158 158
159void BackupAndRestore::refreshBackupLocations() 159void BackupAndRestore::refreshBackupLocations()
160{ 160{
161 backupLocations.clear(); 161 backupLocations.clear();
162 // Add cards 162 // Add cards
163 Opie::Core::OStorageInfo storage; 163 Opie::Core::OStorageInfo storage;
164 backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); 164 backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" );
165 if ( storage.hasCf() ) 165 if ( storage.hasCf() )
166 { 166 {
167 backupLocations.insert( "CF", storage.cfPath() ); 167 backupLocations.insert( "CF", storage.cfPath() );
168 odebug << "Cf Path: " + storage.cfPath() << oendl; 168 odebug << "Cf Path: " + storage.cfPath() << oendl;
169 } 169 }
170 if ( storage.hasSd() ) 170 if ( storage.hasSd() )
171 { 171 {
172 backupLocations.insert( "SD", storage.sdPath() ); 172 backupLocations.insert( "SD", storage.sdPath() );
173 odebug << " Sd Path: " + storage.sdPath() << oendl; 173 odebug << " Sd Path: " + storage.sdPath() << oendl;
174 } 174 }
175 if ( storage.hasMmc() ) 175 if ( storage.hasMmc() )
176 { 176 {
177 backupLocations.insert( "MMC", storage.mmcPath() ); 177 backupLocations.insert( "MMC", storage.mmcPath() );
178 odebug << "Mmc Path: " + storage.mmcPath() << oendl; 178 odebug << "Mmc Path: " + storage.mmcPath() << oendl;
179 } 179 }
180 180
181 for ( QListViewItemIterator it( locationList ); it.current(); ++it ) 181 for ( QListViewItemIterator it( locationList ); it.current(); ++it )
182 { 182 {
183 backupLocations.insert( it.current()->text( 0 ), it.current()->text( 0 ) ); 183 backupLocations.insert( it.current()->text( 0 ), it.current()->text( 0 ) );
184 } 184 }
185 185
186 //update QComboBox 186 //update QComboBox
187 storeToLocation->clear(); 187 storeToLocation->clear();
188 restoreSource->clear(); 188 restoreSource->clear();
189 189
190 //read last locations 190 //read last locations
191 Config config("BackupAndRestore"); 191 Config config("BackupAndRestore");
192 config.setGroup("LastLocation"); 192 config.setGroup("LastLocation");
193 QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); 193 QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" );
194 QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); 194 QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" );
195 int locationIndex = 0; 195 int locationIndex = 0;
196 196
197 //fill QComboBox 197 //fill QComboBox
198 QMap<QString, QString>::Iterator it; 198 QMap<QString, QString>::Iterator it;
199 for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) 199 for( it = backupLocations.begin(); it != backupLocations.end(); ++it )
200 { 200 {
201 storeToLocation->insertItem(it.key()); 201 storeToLocation->insertItem(it.key());
202 restoreSource->insertItem(it.key()); 202 restoreSource->insertItem(it.key());
203 203
204 //check for last locations 204 //check for last locations
205 if ( it.key() == lastStoreLocation ) 205 if ( it.key() == lastStoreLocation )
206 storeToLocation->setCurrentItem( locationIndex ); 206 storeToLocation->setCurrentItem( locationIndex );
207 if ( it.key() == lastRestoreLocation ) 207 if ( it.key() == lastRestoreLocation )
208 restoreSource->setCurrentItem( locationIndex ); 208 restoreSource->setCurrentItem( locationIndex );
209 locationIndex++; 209 locationIndex++;
210 } 210 }
211} 211}
212 212
213QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) 213QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list)
214{ 214{
215 while(item) 215 while(item)
216 { 216 {
217 if(item->childCount() > 0) 217 if(item->childCount() > 0)
218 getAllItems(item->firstChild(), list); 218 getAllItems(item->firstChild(), list);
219 list.append(item); 219 list.append(item);
220 item = item->nextSibling(); 220 item = item->nextSibling();
221 } 221 }
222 return list; 222 return list;
223} 223}
224 224
225/** 225/**
226 * Selects and unselects the item by setting the HEADER_BACKUP to B or !. 226 * Selects and unselects the item by setting the HEADER_BACKUP to B or !.
227 * and changing the icon to match 227 * and changing the icon to match
228 * @param currentItem the item to swich the selection choice. 228 * @param currentItem the item to swich the selection choice.
229 */ 229 */
230void BackupAndRestore::selectItem(QListViewItem *currentItem) 230void BackupAndRestore::selectItem(QListViewItem *currentItem)
231{ 231{
232 if(!currentItem) 232 if(!currentItem)
233 return; 233 return;
234 234
235 if(currentItem->text(HEADER_BACKUP) == "B") 235 if(currentItem->text(HEADER_BACKUP) == "B")
236 { 236 {
237 currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); 237 currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null"));
238 currentItem->setText(HEADER_BACKUP, ""); 238 currentItem->setText(HEADER_BACKUP, "");
239 } 239 }
240 else 240 else
241 { 241 {
242 currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); 242 currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check"));
243 currentItem->setText(HEADER_BACKUP, "B"); 243 currentItem->setText(HEADER_BACKUP, "B");
244 } 244 }
245} 245}
246 246
247void BackupAndRestore::scanForApplicationSettings() 247void BackupAndRestore::scanForApplicationSettings()
248{ 248{
249 QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) ); 249 QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) );
250 d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); 250 d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks );
251 const QFileInfoList *list = d.entryInfoList(); 251 const QFileInfoList *list = d.entryInfoList();
252 QFileInfoListIterator it( *list ); 252 QFileInfoListIterator it( *list );
253 QFileInfo *fi; 253 QFileInfo *fi;
254 while ( (fi=it.current()) ) 254 while ( (fi=it.current()) )
255 { 255 {
256 //odebug << (d.path()+"/"+fi->fileName()).latin1() << oendl; 256 //odebug << (d.path()+"/"+fi->fileName()).latin1() << oendl;
257 if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) 257 if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) )
258 { 258 {
259 QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); 259 QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName());
260 selectItem(newItem); 260 selectItem(newItem);
261 } 261 }
262 ++it; 262 ++it;
263 } 263 }
264} 264}
265 265
266/** 266/**
267 * The "Backup" button has been pressed. Get a list of all of the files that 267 * The "Backup" button has been pressed. Get a list of all of the files that
268 * should be backed up. If there are no files, emit and error and exit. 268 * should be backed up. If there are no files, emit and error and exit.
269 * Determine the file name to store the backup in. Backup the file(s) using 269 * Determine the file name to store the backup in. Backup the file(s) using
270 * tar and gzip --best. Report failure or success 270 * tar and gzip --best. Report failure or success
271 */ 271 */
272void BackupAndRestore::backup() 272void BackupAndRestore::backup()
273{ 273{
274 if ( cb_type_userdata->isChecked() ) 274 if ( cb_type_userdata->isChecked() )
275 backupUserData(); 275 backupUserData();
276 else 276 else
277 backupRootFs(); 277 backupRootFs();
278} 278}
279 279
280 280
281void BackupAndRestore::backupRootFs() 281void BackupAndRestore::backupRootFs()
282{ 282{
283//#define MDEBUG 283 if ( ( ODevice::inst()->model() != Model_Zaurus_SL5000 ) && ( ODevice::inst()->model() != Model_Zaurus_SL5500 ) )
284#ifndef MDEBUG 284 {
285 QMessageBox::critical( this, "Opie-Backup", "<qt>This feature is not yet implemented.</qt>", "Bummer!" ); 285 QMessageBox::critical( this, "Not yet implemented!", "<qt>Sorry, support for this model is not yet done.</qt>", "Ok" );
286 return; 286 return;
287#endif 287 }
288
289 if ( !QFile::exists( "/usr/bin/mkfs.jffs2" ) && !QFile::exists( "/usr/sbin/mkfs.jffs2" ) )
290 {
291 QMessageBox::critical( this, "Can't find utility!", "<qt>Can't find mkfs.jffs2 - Install mtd-utils.</qt>", "Ok" );
292 return;
293 }
294
288 // call 'mount' and parse its output to gather the device on which the root partition is mounted 295 // call 'mount' and parse its output to gather the device on which the root partition is mounted
289 FILE* mountp = popen( "mount", "r" ); 296 FILE* mountp = popen( "mount", "r" );
290 QString device; 297 QString device;
291 QString mountpoint; 298 QString mountpoint;
292 { 299 {
293 QTextStream mounto( mountp, IO_ReadOnly ); 300 QTextStream mounto( mountp, IO_ReadOnly );
294 QString on; 301 QString on;
295 QString type; 302 QString type;
296 QString filesystem; 303 QString filesystem;
297 QString options; 304 QString options;
298 while ( !mounto.atEnd() ) 305 while ( !mounto.atEnd() )
299 { 306 {
300 mounto >> device >> on >> mountpoint >> type >> filesystem >> options; 307 mounto >> device >> on >> mountpoint >> type >> filesystem >> options;
301 if ( mountpoint == "/" ) break; 308 if ( mountpoint == "/" ) break;
302 } 309 }
303 odebug << device << " is formatted w/ " << filesystem << " and mounted on " << mountpoint << oendl; 310 odebug << device << " is formatted w/ '" << filesystem << "' and mounted on '" << mountpoint << "'" << oendl;
304 311
305 if ( !mountpoint.startsWith( "/dev/mtdblock" ) ) 312 if ( !device.startsWith( "/dev/mtdblock" ) )
306 { 313 {
307 QMessageBox::critical( this, "Can't backup!", QString( "<qt>unsupported rootfs %1 - needs to be /dev/mtdblockN</qt>").arg( device ), "Ok" ); 314 QMessageBox::critical( this, "Can't backup!", QString( "<qt>unsupported root device '%1' - needs to be /dev/mtdblockN</qt>").arg( device ), "Ok" );
308#ifndef MDEBUG
309 return; 315 return;
310#endif
311 } 316 }
312 } // at this point, the QTextStream has been destroy and we can close the FILE* 317 } // at this point, the QTextStream has been destroy and we can close the FILE*
313 pclose( mountp ); 318 pclose( mountp );
314 319
315#ifndef MDEBUG 320#if 1
316 int rootmtd = device.right( 1 ).toInt(); 321 int rootmtd = device.right( 1 ).toInt();
317#else 322#else
318 int rootmtd = 0; 323 int rootmtd = 0;
319#endif 324#endif
320 odebug << "root mtdblock seems to be '" << rootmtd << "'" << oendl; 325 odebug << "root mtdblock seems to be '" << rootmtd << "'" << oendl;
321 326
322 // scan /proc/mtd to gather the size and erasesize of the root mtdblock 327 // scan /proc/mtd to gather the size and erasesize of the root mtdblock
323 QFile procmtdf( "/proc/mtd" ); 328 QFile procmtdf( "/proc/mtd" );
324 if ( !procmtdf.open( IO_ReadOnly ) ) 329 if ( !procmtdf.open( IO_ReadOnly ) )
325 { 330 {
326 QMessageBox::critical( this, "Can't backup!", "<qt>Can't open /proc/mtd</qt>", "Ok" ); 331 QMessageBox::critical( this, "Can't backup!", "<qt>Can't open /proc/mtd</qt>", "Ok" );
332 return;
327 } 333 }
328 334
329 QTextStream procmtd( &procmtdf ); 335 QTextStream procmtd( &procmtdf );
330 for ( int i = 0; i <= rootmtd; ++i ) procmtd.readLine(); // skip uninteresting things 336 for ( int i = 0; i <= rootmtd; ++i ) procmtd.readLine(); // skip uninteresting things
331 QString dev; 337 QString dev;
332 QString size; 338 QString size;
333 QString erasesize; 339 QString erasesize;
334 QString devname; 340 QString devname;
335 procmtd >> dev >> size >> erasesize >> devname; 341 procmtd >> dev >> size >> erasesize >> devname;
336 342
337 odebug << "device " << dev << " size = " << size << ", erase size = " << erasesize << ", name = " << devname << "\"" << oendl; 343 odebug << "device " << dev << " size = " << size << ", erase size = " << erasesize << ", name = " << devname << "\"" << oendl;
338 344
339 // compute pad 345 // compute pad
340 QString pad = "--pad"; 346 QString pad = "--pad";
341 switch ( ODevice::inst()->model() ) 347 switch ( ODevice::inst()->model() )
342 { 348 {
343 case Model_Zaurus_SL5000: pad = "--pad=14680064"; break; 349 case Model_Zaurus_SL5000: pad = "--pad=14680064"; break;
344 case Model_Zaurus_SL5500: pad = "--pad=14680064"; break; 350 case Model_Zaurus_SL5500: pad = "--pad=14680064"; break;
345 // FIXME: Add Beagle and SIMpad 351 // FIXME: Add Beagle and SIMpad
346 } 352 }
347 353
348 // compute eraseblock 354 // compute eraseblock
349 QString eraseblock = "--eraseblock=0x" + erasesize; 355 QString eraseblock = "--eraseblock=0x" + erasesize;
350 356
351 // compute output 357 // compute output
352 QString outputFile = "--output=" + backupLocations[storeToLocation->currentText()]; 358 QString outputFile = "--output=" + backupLocations[storeToLocation->currentText()];
353 QDateTime datetime = QDateTime::currentDateTime(); 359 QDateTime datetime = QDateTime::currentDateTime();
354 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + 360 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') +
355 QString::number( datetime.date().day() ).rightJustify(2, '0'); 361 QString::number( datetime.date().day() ).rightJustify(2, '0');
356 outputFile += "/initrd.bin-" + dateString; 362 outputFile += "/initrd.bin-" + dateString;
357 363
358 // call mkfs.jffs2 to create the backup 364 // call mkfs.jffs2 to create the backup
359 QString cmdline = QString( "mkfs.jffs2 --root=/ %1 --little-endian %2 %3 -n" ).arg( outputFile ).arg( pad ).arg( eraseblock ); 365 QString cmdline = QString( "mkfs.jffs2 --faketime --root=/ %1 --little-endian %2 %3 -n" ).arg( outputFile ).arg( pad ).arg( eraseblock );
366 cmdline.append( " --ignore=/tmp --ignore=/mnt --ignore=/var --ignore=/proc" );
360 owarn << "Calling '" << cmdline << "'" << oendl; 367 owarn << "Calling '" << cmdline << "'" << oendl;
361 368
362#ifndef MDEBUG 369 OWait *owait = new OWait();
363 ::system( cmdline ); 370 Global::statusMessage( tr( "Backing up..." ) );
364#endif 371 owait->show();
372 qApp->processEvents();
365 373
366 // FIXME: Add image postprocessing for C7x0 and C8x0, for Beagle, for SIMpad 374 int r = ::system( cmdline );
375
376 owait->hide();
377 delete owait;
378
379 if ( r != 0 )
380 {
381 perror("Error: ");
382 QString errorMsg = QString( tr( "<qt>%1</qt>" ).arg( strerror( errno ) ) );
383 QMessageBox::critical(this, tr( "Backup Failed!" ), errorMsg, QString( tr( "Ok" ) ) );
384 }
367 385
386 // FIXME: Add image postprocessing for C7x0 and C8x0, for Beagle, for SIMpad
368} 387}
369 388
370void BackupAndRestore::backupUserData() 389void BackupAndRestore::backupUserData()
371{ 390{
372 QString backupFiles; 391 QString backupFiles;
373 if(getBackupFiles(backupFiles, NULL) == 0) 392 if(getBackupFiles(backupFiles, NULL) == 0)
374 { 393 {
375 QMessageBox::critical(this, "Message", 394 QMessageBox::critical(this, "Message",
376 "No items selected.",QString("Ok") ); 395 "No items selected.",QString("Ok") );
377 return; 396 return;
378 } 397 }
379 398
380 OWait *owait = new OWait(); 399 OWait *owait = new OWait();
381 Global::statusMessage( tr( "Backing up..." ) ); 400 Global::statusMessage( tr( "Backing up..." ) );
382 owait->show(); 401 owait->show();
383 qApp->processEvents(); 402 qApp->processEvents();
384 403
385 QString outputFile = backupLocations[storeToLocation->currentText()]; 404 QString outputFile = backupLocations[storeToLocation->currentText()];
386 405
387 QDateTime datetime = QDateTime::currentDateTime(); 406 QDateTime datetime = QDateTime::currentDateTime();
388 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + 407 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') +
389 QString::number( datetime.date().day() ).rightJustify(2, '0'); 408 QString::number( datetime.date().day() ).rightJustify(2, '0');
390 409
391 outputFile += "/" + dateString; 410 outputFile += "/" + dateString;
392 411
393 QString t = outputFile; 412 QString t = outputFile;
394 int c = 1; 413 int c = 1;
395 while(QFile::exists(outputFile + EXTENSION)) 414 while(QFile::exists(outputFile + EXTENSION))
396 { 415 {
397 outputFile = t + QString("%1").arg(c); 416 outputFile = t + QString("%1").arg(c);
398 c++; 417 c++;
399 } 418 }
400 419
401 // We execute tar and compressing its output with gzip.. 420 // We execute tar and compressing its output with gzip..
402 // The error output will be written into a temp-file which could be provided 421 // The error output will be written into a temp-file which could be provided
403 // for debugging.. 422 // for debugging..
404 odebug << "Storing file: " << outputFile.latin1() << "" << oendl; 423 odebug << "Storing file: " << outputFile.latin1() << "" << oendl;
405 outputFile += EXTENSION; 424 outputFile += EXTENSION;
406 425
407 QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() ) 426 QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() )
408 .arg( getExcludeFile() ) 427 .arg( getExcludeFile() )
409 .arg( backupFiles ) 428 .arg( backupFiles )
410 .arg( outputFile.latin1() ) 429 .arg( outputFile.latin1() )
411 .arg( tempFileName.latin1() ); 430 .arg( tempFileName.latin1() );
412 431
413 odebug << commandLine << oendl; 432 odebug << commandLine << oendl;
414 433
415 int r = system( commandLine ); 434 int r = system( commandLine );
416 435
417 owait->hide(); 436 owait->hide();
418 delete owait; 437 delete owait;
419 438
420 //Error-Handling 439 //Error-Handling
421 if(r != 0) 440 if(r != 0)
422 { 441 {
423 perror("Error: "); 442 perror("Error: ");
424 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); 443 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno );
425 444
426 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" 445 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n"
427 + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) 446 + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) )
428 { 447 {
429 448
430 case 1: 449 case 1:
431 owarn << "Details pressed !" << oendl; 450 owarn << "Details pressed !" << oendl;
432 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); 451 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true );
433 QFile errorFile( tempFileName ); 452 QFile errorFile( tempFileName );
434 if ( errorFile.open(IO_ReadOnly) ) 453 if ( errorFile.open(IO_ReadOnly) )
435 { 454 {
436 QTextStream t( &errorFile ); 455 QTextStream t( &errorFile );
437 QString s; 456 QString s;
438 while ( !t.eof() ) 457 while ( !t.eof() )
439 { // until end of file... 458 { // until end of file...
440 s += t.readLine(); // line of text excluding '\n' 459 s += t.readLine(); // line of text excluding '\n'
441 } 460 }
442 errorFile.close(); 461 errorFile.close();
443 462
444 pErrDialog->m_textarea->setText( s ); 463 pErrDialog->m_textarea->setText( s );
445 } 464 }
446 else 465 else
447 { 466 {
448 pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); 467 pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" );
449 } 468 }
450 QPEApplication::execDialog( pErrDialog ); 469 QPEApplication::execDialog( pErrDialog );
451 delete pErrDialog; 470 delete pErrDialog;
452 break; 471 break;
453 } 472 }
454 setCaption(tr("Backup and Restore.. Failed !!")); 473 setCaption(tr("Backup and Restore.. Failed !!"));
455 return; 474 return;
456 } 475 }
457 else 476 else
458 { 477 {
459 QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); 478 QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) );
460 } 479 }
461 480
462 //write store-location 481 //write store-location
463 Config config( "BackupAndRestore" ); 482 Config config( "BackupAndRestore" );
464 config.setGroup( "LastLocation" ); 483 config.setGroup( "LastLocation" );
465 config.writeEntry( "LastStoreLocation", storeToLocation->currentText() ); 484 config.writeEntry( "LastStoreLocation", storeToLocation->currentText() );
466 485
467 setCaption(tr("Backup and Restore")); 486 setCaption(tr("Backup and Restore"));
468} 487}
469 488
470/*** 489/***
471 * Get a list of all of the files to backup. 490 * Get a list of all of the files to backup.
472 */ 491 */
473int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) 492int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent)
474{ 493{
475 QListViewItem * currentItem; 494 QListViewItem * currentItem;
476 QString currentHome; 495 QString currentHome;
477 if(!parent) 496 if(!parent)
478 currentItem = backupList->firstChild(); 497 currentItem = backupList->firstChild();
479 else 498 else
480 { 499 {
481 currentItem = parent->firstChild(); 500 currentItem = parent->firstChild();
482 currentHome = parent->text(BACKUP_LOCATION); 501 currentHome = parent->text(BACKUP_LOCATION);
483 } 502 }
484 503
485 uint count = 0; 504 uint count = 0;
486 while( currentItem != 0 ) 505 while( currentItem != 0 )
487 { 506 {
488 if(currentItem->text(HEADER_BACKUP) == "B" ) 507 if(currentItem->text(HEADER_BACKUP) == "B" )
489 { 508 {
490 if(currentItem->childCount() == 0 ) 509 if(currentItem->childCount() == 0 )
491 { 510 {
492 if(parent == NULL) 511 if(parent == NULL)
493 backupFiles += currentItem->text(BACKUP_LOCATION); 512 backupFiles += currentItem->text(BACKUP_LOCATION);
494 else 513 else
495 backupFiles += currentHome + currentItem->text(HEADER_NAME); 514 backupFiles += currentHome + currentItem->text(HEADER_NAME);
496 backupFiles += " "; 515 backupFiles += " ";
497 count++; 516 count++;
498 } 517 }
499 else 518 else
500 { 519 {
501 count += getBackupFiles(backupFiles, currentItem); 520 count += getBackupFiles(backupFiles, currentItem);
502 } 521 }
503 } 522 }
504 currentItem = currentItem->nextSibling(); 523 currentItem = currentItem->nextSibling();
505 } 524 }
506 return count; 525 return count;
507} 526}
508 527
509void BackupAndRestore::sourceDirChanged(int selection) 528void BackupAndRestore::sourceDirChanged(int selection)
510{ 529{
511 restoreList->clear(); 530 restoreList->clear();
512 rescanFolder(backupLocations[restoreSource->text(selection)]); 531 rescanFolder(backupLocations[restoreSource->text(selection)]);
513} 532}
514 533
515void BackupAndRestore::fileListUpdate() 534void BackupAndRestore::fileListUpdate()
516{ 535{
517 owarn << "void BackupAndRestore::fileListUpdate()" << oendl; 536 owarn << "void BackupAndRestore::fileListUpdate()" << oendl;
518 restoreList->clear(); 537 restoreList->clear();
519 rescanFolder( backupLocations[restoreSource->currentText()] ); 538 rescanFolder( backupLocations[restoreSource->currentText()] );
520} 539}
521 540
522/** 541/**
523 * Scans directory for any backup files. Will recursivly go down, 542 * Scans directory for any backup files. Will recursivly go down,
524 * but will not follow symlinks. 543 * but will not follow symlinks.
525 * @param directory - the directory to look in. 544 * @param directory - the directory to look in.
526 */ 545 */
527void BackupAndRestore::rescanFolder(QString directory) 546void BackupAndRestore::rescanFolder(QString directory)
528{ 547{
529 //odebug << QString("rescanFolder: ") + directory.latin1() << oendl; 548 //odebug << QString("rescanFolder: ") + directory.latin1() << oendl;
530 QDir d(directory); 549 QDir d(directory);
531 if(!d.exists()) 550 if(!d.exists())
532 return; 551 return;
533 552
534 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); 553 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs);
535 const QFileInfoList *list = d.entryInfoList(); 554 const QFileInfoList *list = d.entryInfoList();
536 QFileInfoListIterator it( *list ); 555 QFileInfoListIterator it( *list );
537 QFileInfo *file; 556 QFileInfo *file;
538 while ( (file=it.current()) ) 557 while ( (file=it.current()) )
539 { // for each file... 558 { // for each file...
540 // If it is a dir and not .. or . then add it as a tab and go down. 559 // If it is a dir and not .. or . then add it as a tab and go down.
541 if(file->isDir()) 560 if(file->isDir())
542 { 561 {
543 if(file->fileName() != ".." && file->fileName() != ".") 562 if(file->fileName() != ".." && file->fileName() != ".")
544 { 563 {
545 rescanFolder(directory + "/" + file->fileName()); 564 rescanFolder(directory + "/" + file->fileName());
546 } 565 }
547 } 566 }
548 else 567 else
549 { 568 {
550 // If it is a backup file add to list. 569 // If it is a backup file add to list.
551 if(file->fileName().contains(EXTENSION)) 570 if(file->fileName().contains(EXTENSION))
552 (void)new QListViewItem(restoreList, file->fileName()); 571 (void)new QListViewItem(restoreList, file->fileName());
553 } 572 }
554 ++it; 573 ++it;
555 } 574 }
556} 575}
557 576
558/** 577/**
559 * Restore a backup file. 578 * Restore a backup file.
560 * Report errors or success 579 * Report errors or success
561 */ 580 */
562void BackupAndRestore::restore() 581void BackupAndRestore::restore()
563{ 582{
564 QListViewItem *restoreItem = restoreList->currentItem(); 583 QListViewItem *restoreItem = restoreList->currentItem();
565 if(!restoreItem) 584 if(!restoreItem)
566 { 585 {
567 QMessageBox::critical(this, tr( "Message" ), 586 QMessageBox::critical(this, tr( "Message" ),
568 tr( "Please select something to restore." ),QString( tr( "Ok") ) ); 587 tr( "Please select something to restore." ),QString( tr( "Ok") ) );
569 return; 588 return;
570 } 589 }
571 590
572 OWait *owait = new OWait(); 591 OWait *owait = new OWait();
573 Global::statusMessage( tr( "Restore Backup..." ) ); 592 Global::statusMessage( tr( "Restore Backup..." ) );
574 owait->show(); 593 owait->show();
575 qApp->processEvents(); 594 qApp->processEvents();
576 595
577 QString restoreFile = backupLocations[restoreSource->currentText()]; 596 QString restoreFile = backupLocations[restoreSource->currentText()];
578 597
579 restoreFile += "/" + restoreItem->text(0); 598 restoreFile += "/" + restoreItem->text(0);
580 599
581 odebug << restoreFile << oendl; 600 odebug << restoreFile << oendl;
582 601
583 //check if backup file come from opie 1.0.x 602 //check if backup file come from opie 1.0.x
584 603
585 QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() ); 604 QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() );
586 605
587 int r = system( commandLine ); 606 int r = system( commandLine );
588 607
589 QString startDir; 608 QString startDir;
590 609
591 if( r != 0 ) //Applications/backup/exclude not found - old backup file 610 if( r != 0 ) //Applications/backup/exclude not found - old backup file
592 { 611 {
593 startDir = QString( "/" ); 612 startDir = QString( "/" );
594 } else 613 } else
595 { 614 {
596 startDir = QDir::homeDirPath(); 615 startDir = QDir::homeDirPath();
597 } 616 }
598 617
599 //unpack backup file 618 //unpack backup file
600 commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir ) 619 commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir )
601 .arg( restoreFile.latin1() ) 620 .arg( restoreFile.latin1() )
602 .arg( tempFileName.latin1() ); 621 .arg( tempFileName.latin1() );
603 622
604 odebug << commandLine << oendl; 623 odebug << commandLine << oendl;
605 624
606 r = system( commandLine ); 625 r = system( commandLine );
607 626
608 owait->hide(); 627 owait->hide();
609 delete owait; 628 delete owait;
610 629
611 //error handling 630 //error handling
612 if(r != 0) 631 if(r != 0)
613 { 632 {
614 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); 633 QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno );
615 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" 634 switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n"
616 + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) 635 + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) )
617 { 636 {
618 case 1: 637 case 1:
619 owarn << "Details pressed !" << oendl; 638 owarn << "Details pressed !" << oendl;
620 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); 639 ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true );
621 QFile errorFile( tempFileName ); 640 QFile errorFile( tempFileName );
622 if ( errorFile.open(IO_ReadOnly) ) 641 if ( errorFile.open(IO_ReadOnly) )
623 { 642 {
624 QTextStream t( &errorFile ); 643 QTextStream t( &errorFile );
625 QString s; 644 QString s;
626 while ( !t.eof() ) 645 while ( !t.eof() )
627 { // until end of file... 646 { // until end of file...
628 s += t.readLine(); // line of text excluding '\n' 647 s += t.readLine(); // line of text excluding '\n'
629 } 648 }
630 errorFile.close(); 649 errorFile.close();
631 650
632 pErrDialog->m_textarea->setText( s ); 651 pErrDialog->m_textarea->setText( s );
633 } 652 }
634 else 653 else
635 { 654 {
636 pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); 655 pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) );
637 } 656 }
638 QPEApplication::execDialog( pErrDialog ); 657 QPEApplication::execDialog( pErrDialog );
639 delete pErrDialog; 658 delete pErrDialog;
640 659
641 setCaption(tr("Backup and Restore.. Failed !!")); 660 setCaption(tr("Backup and Restore.. Failed !!"));
642 return; 661 return;
643 662
644 break; 663 break;
645 664
646 } 665 }
647 } 666 }
648 else 667 else
649 { 668 {
650 QMessageBox::information(this, tr( "Message" ), tr( "Restore Successful." ), QString( tr( "Ok") ) ); 669 QMessageBox::information(this, tr( "Message" ), tr( "Restore Successful." ), QString( tr( "Ok") ) );
651 } 670 }
652 671
653 //write restore-location 672 //write restore-location
654 Config config( "BackupAndRestore" ); 673 Config config( "BackupAndRestore" );
655 config.setGroup( "LastLocation" ); 674 config.setGroup( "LastLocation" );
656 config.writeEntry( "LastRestoreLocation", restoreSource->currentText() ); 675 config.writeEntry( "LastRestoreLocation", restoreSource->currentText() );
657 676
658 setCaption(tr("Backup and Restore")); 677 setCaption(tr("Backup and Restore"));
659} 678}
660 679
661/** 680/**
662 * Check for exclude in Applications/backup 681 * Check for exclude in Applications/backup
663 * If it does not exist, the function will create the file with *.bck as content 682 * If it does not exist, the function will create the file with *.bck as content
664 * The exclude_files is read by tar and will provide to exclude special files out from backup. 683 * The exclude_files is read by tar and will provide to exclude special files out from backup.
665 * e.g. alle *.bck files (backup-files) will not be backed up by default 684 * e.g. alle *.bck files (backup-files) will not be backed up by default
666 */ 685 */
667 686
668QString BackupAndRestore::getExcludeFile() 687QString BackupAndRestore::getExcludeFile()
669{ 688{
670 QString excludeFileName = Global::applicationFileName( "backup", "exclude" ); 689 QString excludeFileName = Global::applicationFileName( "backup", "exclude" );
671 if ( !QFile::exists( excludeFileName ) ) 690 if ( !QFile::exists( excludeFileName ) )
672 { 691 {
673 QFile excludeFile( excludeFileName); 692 QFile excludeFile( excludeFileName);
674 if ( excludeFile.open( IO_WriteOnly ) == true ) 693 if ( excludeFile.open( IO_WriteOnly ) == true )
675 { 694 {
676 QTextStream writeStream( &excludeFile ); 695 QTextStream writeStream( &excludeFile );
677 writeStream << "*.bck" << "\n"; 696 writeStream << "*.bck" << "\n";
678 excludeFile.close(); 697 excludeFile.close();
679 } 698 }
680 else 699 else
681 { 700 {
682 return QString::null; 701 return QString::null;
683 } 702 }
684 } 703 }
685 704
686 return excludeFileName; 705 return excludeFileName;
687} 706}
688 707
689void BackupAndRestore::refreshLocations() 708void BackupAndRestore::refreshLocations()
690{ 709{
691 locationList->clear(); 710 locationList->clear();
692 711
693 //todo: implement add locations 712 //todo: implement add locations
694 Config config( "BackupAndRestore" ); 713 Config config( "BackupAndRestore" );
695 config.setGroup( "Locations" ); 714 config.setGroup( "Locations" );
696 715
697 QStringList locations( config.readListEntry( "locations", '|' ) ); 716 QStringList locations( config.readListEntry( "locations", '|' ) );
698 717
699 for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it ) { 718 for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it ) {
700 (void) new QListViewItem( locationList, *it ); 719 (void) new QListViewItem( locationList, *it );
701 } 720 }
702} 721}
703 722
704void BackupAndRestore::addLocation() 723void BackupAndRestore::addLocation()
705{ 724{
706 if ( ( !locationEdit->text().isEmpty() ) && 725 if ( ( !locationEdit->text().isEmpty() ) &&
707 ( QDir( locationEdit->text() ).exists() ) ) 726 ( QDir( locationEdit->text() ).exists() ) )
708 { 727 {
709 (void) new QListViewItem( locationList, locationEdit->text() ); 728 (void) new QListViewItem( locationList, locationEdit->text() );
710 locationEdit->setText( "" ); 729 locationEdit->setText( "" );
711 } 730 }
712} 731}
713 732
714void BackupAndRestore::removeLocation() 733void BackupAndRestore::removeLocation()
715{ 734{
716 if ( locationList->selectedItem() ) 735 if ( locationList->selectedItem() )
717 { 736 {
718 delete( locationList->selectedItem() ); 737 delete( locationList->selectedItem() );
719 } 738 }
720} 739}
721 740
722void BackupAndRestore::saveLocations() 741void BackupAndRestore::saveLocations()
723{ 742{
724 Config config("BackupAndRestore"); 743 Config config("BackupAndRestore");
725 config.setGroup("Locations"); 744 config.setGroup("Locations");
726 745
727 QStringList locations; 746 QStringList locations;
728 for ( QListViewItemIterator it( locationList ); it.current(); ++it ) 747 for ( QListViewItemIterator it( locationList ); it.current(); ++it )
729 { 748 {
730 locations.append( it.current()->text( 0 ) ); 749 locations.append( it.current()->text( 0 ) );
731 } 750 }
732 config.writeEntry( "locations", locations, '|' ); 751 config.writeEntry( "locations", locations, '|' );
733 752
734 refreshBackupLocations(); 753 refreshBackupLocations();
735} 754}
736 755
737void BackupAndRestore::selectLocation() 756void BackupAndRestore::selectLocation()
738{ 757{
739 QString location = OFileDialog::getDirectory( OFileSelector::DIRECTORYSELECTOR ); 758 QString location = OFileDialog::getDirectory( OFileSelector::DIRECTORYSELECTOR );
740 if ( !location.isEmpty() ) 759 if ( !location.isEmpty() )
741 { 760 {
742 locationEdit->setText( location ); 761 locationEdit->setText( location );
743 } 762 }
744} 763}
745 764
746// backuprestore.cpp 765// backuprestore.cpp
747 766
diff --git a/share/backup/device_table-minimal.txt b/share/backup/device_table-minimal.txt
new file mode 100644
index 0000000..66cafae
--- a/dev/null
+++ b/share/backup/device_table-minimal.txt
@@ -0,0 +1,20 @@
1 /dev/initctl p 600 0 0 - - --
2 /dev/apm_bios c 660 0 46 10 134 - --
3 /dev/fb0 c 600 0 0 29 0 - --
4 /dev/hda b 660 0 6 3 0 - --
5 /dev/hda b 660 0 6 3 1 1 120
6 /dev/kmem c 640 0 15 1 2 - --
7 /dev/mem c 640 0 15 1 1 - --
8 /dev/null c 666 0 0 1 3 - --
9 /dev/ram b 640 0 0 1 0 0 14
10 /dev/tty c 662 0 5 5 0 - --
11 /dev/tty c 666 0 5 4 0 0 19
12 /dev/ttyS c 640 0 5 4 64 0 11
13 /dev/ttySA c 640 0 5 204 5 0 11
14 /dev/zero c 644 0 0 1 5 --
15 /dev/mtd c 660 0 6 90 0 0 28
16 /dev/mtdblock b 640 0 0 31 0 0 18
17 /dev/console c 662 0 5 5 1 --
18 /bin/tinylogin f 4755 0 0 - - --
19 /bin/mount f 4755 0 0 - - --
20 /bin/umount f 4755 0 0 - - --