author | mickeyl <mickeyl> | 2004-11-04 15:12:01 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-04 15:12:01 (UTC) |
commit | 5f56ab623c99c12ce246f775e065632fbfbbfc1f (patch) (unidiff) | |
tree | 0035922070d36de69226bfcefc4d959b5a453f61 | |
parent | 18684ddb43d4d79304dee6b20ab62513ee50b883 (diff) | |
download | opie-5f56ab623c99c12ce246f775e065632fbfbbfc1f.zip opie-5f56ab623c99c12ce246f775e065632fbfbbfc1f.tar.gz opie-5f56ab623c99c12ce246f775e065632fbfbbfc1f.tar.bz2 |
- prepare for backing up root file systems (aka clone)
- add file headers
- add version to .pro
-rw-r--r-- | noncore/settings/backup/backup.pro | 2 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 62 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.h | 31 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestorebase.ui | 185 |
4 files changed, 214 insertions, 66 deletions
diff --git a/noncore/settings/backup/backup.pro b/noncore/settings/backup/backup.pro index 390c599..e964c3a 100644 --- a/noncore/settings/backup/backup.pro +++ b/noncore/settings/backup/backup.pro | |||
@@ -1,10 +1,10 @@ | |||
1 | CONFIG = qt warn_on quick-app | 1 | CONFIG = qt warn_on quick-app |
2 | HEADERS = backuprestore.h | 2 | HEADERS = backuprestore.h |
3 | SOURCES = main.cpp backuprestore.cpp | 3 | SOURCES = main.cpp backuprestore.cpp |
4 | INCLUDEPATH+= $(OPIEDIR)/include | 4 | INCLUDEPATH+= $(OPIEDIR)/include |
5 | DEPENDPATH+= $(OPIEDIR)/include | 5 | DEPENDPATH+= $(OPIEDIR)/include |
6 | LIBS += -lqpe -lopiecore2 -lopieui2 | 6 | LIBS += -lqpe -lopiecore2 -lopieui2 |
7 | INTERFACES= backuprestorebase.ui errordialog.ui | 7 | INTERFACES= backuprestorebase.ui errordialog.ui |
8 | TARGET = backup | 8 | TARGET = backup |
9 | 9 | VERSION = 0.8.1 | |
10 | include ( $(OPIEDIR)/include.pro ) | 10 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 1748e8d..c944c6d 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -1,121 +1,147 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002-2004 The Opie Team <opie-devel@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
1 | #include "backuprestore.h" | 29 | #include "backuprestore.h" |
2 | #include "errordialog.h" | 30 | #include "errordialog.h" |
3 | 31 | ||
4 | |||
5 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <qpe/qpeapplication.h> | ||
34 | #include <qpe/resource.h> | ||
35 | #include <qpe/config.h> | ||
6 | #include <opie2/odebug.h> | 36 | #include <opie2/odebug.h> |
7 | #include <opie2/ostorageinfo.h> | 37 | #include <opie2/ostorageinfo.h> |
8 | using namespace Opie::Core; | ||
9 | |||
10 | #include <opie2/ofiledialog.h> | 38 | #include <opie2/ofiledialog.h> |
11 | #include <opie2/owait.h> | 39 | #include <opie2/owait.h> |
40 | using namespace Opie::Core; | ||
12 | using namespace Opie::Ui; | 41 | using namespace Opie::Ui; |
13 | 42 | ||
14 | #include <qpe/qpeapplication.h> | ||
15 | #include <qpe/resource.h> | ||
16 | #include <qpe/config.h> | ||
17 | |||
18 | /* QT */ | 43 | /* QT */ |
19 | #include <qapplication.h> | 44 | #include <qapplication.h> |
20 | #include <qmultilineedit.h> | 45 | #include <qmultilineedit.h> |
21 | #include <qdir.h> | 46 | #include <qdir.h> |
22 | #include <qfile.h> | 47 | #include <qfile.h> |
23 | #include <qfileinfo.h> | 48 | #include <qfileinfo.h> |
24 | #include <qlistview.h> | 49 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
51 | #include <qradiobutton.h> | ||
26 | #include <qheader.h> | 52 | #include <qheader.h> |
27 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
28 | #include <qcombobox.h> | 54 | #include <qcombobox.h> |
29 | #include <qlist.h> | 55 | #include <qlist.h> |
30 | #include <qregexp.h> | 56 | #include <qregexp.h> |
31 | #include <qtextstream.h> | 57 | #include <qtextstream.h> |
32 | #include <qtextview.h> | 58 | #include <qtextview.h> |
33 | #include <qlineedit.h> | 59 | #include <qlineedit.h> |
34 | #include <qstringlist.h> | 60 | #include <qstringlist.h> |
35 | 61 | ||
36 | /* STD */ | 62 | /* STD */ |
37 | #include <errno.h> | 63 | #include <errno.h> |
38 | #include <stdlib.h> | 64 | #include <stdlib.h> |
39 | #include <unistd.h> | 65 | #include <unistd.h> |
40 | #include <sys/stat.h> | 66 | #include <sys/stat.h> |
41 | #include <dirent.h> | 67 | #include <dirent.h> |
42 | 68 | ||
43 | #define HEADER_NAME 0 | 69 | #define HEADER_NAME 0 |
44 | #define HEADER_BACKUP 1 | 70 | #define HEADER_BACKUP 1 |
45 | #define BACKUP_LOCATION 2 | 71 | #define BACKUP_LOCATION 2 |
46 | 72 | ||
47 | #define EXTENSION ".bck" | 73 | #define EXTENSION ".bck" |
48 | 74 | ||
49 | const QString tempFileName = "/tmp/backup.err"; | 75 | const QString tempFileName = "/tmp/backup.err"; |
50 | 76 | ||
51 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) | 77 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) |
52 | : BackupAndRestoreBase(parent, name, fl) | 78 | : BackupAndRestoreBase(parent, name, fl) |
53 | { | 79 | { |
54 | backupList->header()->hide(); | 80 | backupList->header()->hide(); |
55 | restoreList->header()->hide(); | 81 | restoreList->header()->hide(); |
56 | locationList->header()->hide(); | 82 | locationList->header()->hide(); |
57 | connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) ); | 83 | connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) ); |
58 | connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) ); | 84 | connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) ); |
59 | connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) ); | 85 | connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) ); |
60 | connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) ); | 86 | connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) ); |
61 | connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) ); | 87 | connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) ); |
62 | connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) ); | 88 | connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) ); |
63 | connect( saveLocationsButton, SIGNAL( clicked() ), this, SLOT( saveLocations() ) ); | 89 | connect( saveLocationsButton, SIGNAL( clicked() ), this, SLOT( saveLocations() ) ); |
64 | connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) ); | 90 | connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) ); |
65 | 91 | ||
66 | //add directorys for backing up | 92 | //add directorys for backing up |
67 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); | 93 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); |
68 | selectItem(applicationSettings); | 94 | selectItem(applicationSettings); |
69 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); | 95 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); |
70 | selectItem(applicationSettings); | 96 | selectItem(applicationSettings); |
71 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); | 97 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); |
72 | selectItem(documents); | 98 | selectItem(documents); |
73 | 99 | ||
74 | scanForApplicationSettings(); | 100 | scanForApplicationSettings(); |
75 | refreshLocations(); | 101 | refreshLocations(); |
76 | refreshBackupLocations(); | 102 | refreshBackupLocations(); |
77 | 103 | ||
78 | // Read the list of items to ignore. | 104 | // Read the list of items to ignore. |
79 | QList<QString> dontBackupList; | 105 | QList<QString> dontBackupList; |
80 | dontBackupList.setAutoDelete(true); | 106 | dontBackupList.setAutoDelete(true); |
81 | Config config("BackupAndRestore"); | 107 | Config config("BackupAndRestore"); |
82 | config.setGroup("DontBackup"); | 108 | config.setGroup("DontBackup"); |
83 | int total = config.readNumEntry("Total", 0); | 109 | int total = config.readNumEntry("Total", 0); |
84 | for(int i = 0; i < total; i++) | 110 | for(int i = 0; i < total; i++) |
85 | { | 111 | { |
86 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); | 112 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); |
87 | } | 113 | } |
88 | 114 | ||
89 | QList<QListViewItem> list; | 115 | QList<QListViewItem> list; |
90 | getAllItems(backupList->firstChild(), list); | 116 | getAllItems(backupList->firstChild(), list); |
91 | 117 | ||
92 | for(uint i = 0; i < list.count(); i++) | 118 | for(uint i = 0; i < list.count(); i++) |
93 | { | 119 | { |
94 | QString text = list.at(i)->text(HEADER_NAME); | 120 | QString text = list.at(i)->text(HEADER_NAME); |
95 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) | 121 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) |
96 | { | 122 | { |
97 | if(*dontBackupList.at(i2) == text) | 123 | if(*dontBackupList.at(i2) == text) |
98 | { | 124 | { |
99 | selectItem(list.at(i)); | 125 | selectItem(list.at(i)); |
100 | break; | 126 | break; |
101 | } | 127 | } |
102 | } | 128 | } |
103 | } | 129 | } |
104 | QPEApplication::showWidget( this ); | 130 | QPEApplication::showWidget( this ); |
105 | } | 131 | } |
106 | 132 | ||
107 | BackupAndRestore::~BackupAndRestore() | 133 | BackupAndRestore::~BackupAndRestore() |
108 | { | 134 | { |
109 | QList<QListViewItem> list; | 135 | QList<QListViewItem> list; |
110 | getAllItems(backupList->firstChild(), list); | 136 | getAllItems(backupList->firstChild(), list); |
111 | 137 | ||
112 | Config config("BackupAndRestore"); | 138 | Config config("BackupAndRestore"); |
113 | config.setGroup("DontBackup"); | 139 | config.setGroup("DontBackup"); |
114 | config.clearGroup(); | 140 | config.clearGroup(); |
115 | 141 | ||
116 | int count = 0; | 142 | int count = 0; |
117 | for(uint i = 0; i < list.count(); i++) | 143 | for(uint i = 0; i < list.count(); i++) |
118 | { | 144 | { |
119 | if(list.at(i)->text(HEADER_BACKUP) == "") | 145 | if(list.at(i)->text(HEADER_BACKUP) == "") |
120 | { | 146 | { |
121 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); | 147 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); |
@@ -151,431 +177,445 @@ void BackupAndRestore::refreshBackupLocations() | |||
151 | odebug << "Mmc Path: " + storage.mmcPath() << oendl; | 177 | odebug << "Mmc Path: " + storage.mmcPath() << oendl; |
152 | } | 178 | } |
153 | 179 | ||
154 | for ( QListViewItemIterator it( locationList ); it.current(); ++it ) | 180 | for ( QListViewItemIterator it( locationList ); it.current(); ++it ) |
155 | { | 181 | { |
156 | backupLocations.insert( it.current()->text( 0 ), it.current()->text( 0 ) ); | 182 | backupLocations.insert( it.current()->text( 0 ), it.current()->text( 0 ) ); |
157 | } | 183 | } |
158 | 184 | ||
159 | //update QComboBox | 185 | //update QComboBox |
160 | storeToLocation->clear(); | 186 | storeToLocation->clear(); |
161 | restoreSource->clear(); | 187 | restoreSource->clear(); |
162 | 188 | ||
163 | //read last locations | 189 | //read last locations |
164 | Config config("BackupAndRestore"); | 190 | Config config("BackupAndRestore"); |
165 | config.setGroup("LastLocation"); | 191 | config.setGroup("LastLocation"); |
166 | QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); | 192 | QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); |
167 | QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); | 193 | QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); |
168 | int locationIndex = 0; | 194 | int locationIndex = 0; |
169 | 195 | ||
170 | //fill QComboBox | 196 | //fill QComboBox |
171 | QMap<QString, QString>::Iterator it; | 197 | QMap<QString, QString>::Iterator it; |
172 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) | 198 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) |
173 | { | 199 | { |
174 | storeToLocation->insertItem(it.key()); | 200 | storeToLocation->insertItem(it.key()); |
175 | restoreSource->insertItem(it.key()); | 201 | restoreSource->insertItem(it.key()); |
176 | 202 | ||
177 | //check for last locations | 203 | //check for last locations |
178 | if ( it.key() == lastStoreLocation ) | 204 | if ( it.key() == lastStoreLocation ) |
179 | storeToLocation->setCurrentItem( locationIndex ); | 205 | storeToLocation->setCurrentItem( locationIndex ); |
180 | if ( it.key() == lastRestoreLocation ) | 206 | if ( it.key() == lastRestoreLocation ) |
181 | restoreSource->setCurrentItem( locationIndex ); | 207 | restoreSource->setCurrentItem( locationIndex ); |
182 | locationIndex++; | 208 | locationIndex++; |
183 | } | 209 | } |
184 | } | 210 | } |
185 | 211 | ||
186 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) | 212 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) |
187 | { | 213 | { |
188 | while(item) | 214 | while(item) |
189 | { | 215 | { |
190 | if(item->childCount() > 0) | 216 | if(item->childCount() > 0) |
191 | getAllItems(item->firstChild(), list); | 217 | getAllItems(item->firstChild(), list); |
192 | list.append(item); | 218 | list.append(item); |
193 | item = item->nextSibling(); | 219 | item = item->nextSibling(); |
194 | } | 220 | } |
195 | return list; | 221 | return list; |
196 | } | 222 | } |
197 | 223 | ||
198 | /** | 224 | /** |
199 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. | 225 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. |
200 | * and changing the icon to match | 226 | * and changing the icon to match |
201 | * @param currentItem the item to swich the selection choice. | 227 | * @param currentItem the item to swich the selection choice. |
202 | */ | 228 | */ |
203 | void BackupAndRestore::selectItem(QListViewItem *currentItem) | 229 | void BackupAndRestore::selectItem(QListViewItem *currentItem) |
204 | { | 230 | { |
205 | if(!currentItem) | 231 | if(!currentItem) |
206 | return; | 232 | return; |
207 | 233 | ||
208 | if(currentItem->text(HEADER_BACKUP) == "B") | 234 | if(currentItem->text(HEADER_BACKUP) == "B") |
209 | { | 235 | { |
210 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); | 236 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); |
211 | currentItem->setText(HEADER_BACKUP, ""); | 237 | currentItem->setText(HEADER_BACKUP, ""); |
212 | } | 238 | } |
213 | else | 239 | else |
214 | { | 240 | { |
215 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); | 241 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); |
216 | currentItem->setText(HEADER_BACKUP, "B"); | 242 | currentItem->setText(HEADER_BACKUP, "B"); |
217 | } | 243 | } |
218 | } | 244 | } |
219 | 245 | ||
220 | void BackupAndRestore::scanForApplicationSettings() | 246 | void BackupAndRestore::scanForApplicationSettings() |
221 | { | 247 | { |
222 | QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) ); | 248 | QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) ); |
223 | d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); | 249 | d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); |
224 | const QFileInfoList *list = d.entryInfoList(); | 250 | const QFileInfoList *list = d.entryInfoList(); |
225 | QFileInfoListIterator it( *list ); | 251 | QFileInfoListIterator it( *list ); |
226 | QFileInfo *fi; | 252 | QFileInfo *fi; |
227 | while ( (fi=it.current()) ) | 253 | while ( (fi=it.current()) ) |
228 | { | 254 | { |
229 | //odebug << (d.path()+"/"+fi->fileName()).latin1() << oendl; | 255 | //odebug << (d.path()+"/"+fi->fileName()).latin1() << oendl; |
230 | if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) | 256 | if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) |
231 | { | 257 | { |
232 | QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); | 258 | QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); |
233 | selectItem(newItem); | 259 | selectItem(newItem); |
234 | } | 260 | } |
235 | ++it; | 261 | ++it; |
236 | } | 262 | } |
237 | } | 263 | } |
238 | 264 | ||
239 | /** | 265 | /** |
240 | * The "Backup" button has been pressed. Get a list of all of the files that | 266 | * The "Backup" button has been pressed. Get a list of all of the files that |
241 | * should be backed up. If there are no files, emit and error and exit. | 267 | * should be backed up. If there are no files, emit and error and exit. |
242 | * Determine the file name to store the backup in. Backup the file(s) using | 268 | * Determine the file name to store the backup in. Backup the file(s) using |
243 | * tar and gzip --best. Report failure or success | 269 | * tar and gzip --best. Report failure or success |
244 | */ | 270 | */ |
245 | void BackupAndRestore::backup() | 271 | void BackupAndRestore::backup() |
246 | { | 272 | { |
273 | if ( cb_type_userdata->isChecked() ) | ||
274 | backupUserData(); | ||
275 | else | ||
276 | backupRootFs(); | ||
277 | } | ||
278 | |||
279 | |||
280 | void BackupAndRestore::backupRootFs() | ||
281 | { | ||
282 | QMessageBox::critical(this, "Message", "Not Yet Implemented", "Ok" ); | ||
283 | } | ||
284 | |||
285 | void BackupAndRestore::backupUserData() | ||
286 | { | ||
247 | QString backupFiles; | 287 | QString backupFiles; |
248 | if(getBackupFiles(backupFiles, NULL) == 0) | 288 | if(getBackupFiles(backupFiles, NULL) == 0) |
249 | { | 289 | { |
250 | QMessageBox::critical(this, "Message", | 290 | QMessageBox::critical(this, "Message", |
251 | "No items selected.",QString("Ok") ); | 291 | "No items selected.",QString("Ok") ); |
252 | return; | 292 | return; |
253 | } | 293 | } |
254 | 294 | ||
255 | OWait *owait = new OWait(); | 295 | OWait *owait = new OWait(); |
256 | Global::statusMessage( tr( "Backing up..." ) ); | 296 | Global::statusMessage( tr( "Backing up..." ) ); |
257 | owait->show(); | 297 | owait->show(); |
258 | qApp->processEvents(); | 298 | qApp->processEvents(); |
259 | 299 | ||
260 | QString outputFile = backupLocations[storeToLocation->currentText()]; | 300 | QString outputFile = backupLocations[storeToLocation->currentText()]; |
261 | 301 | ||
262 | QDateTime datetime = QDateTime::currentDateTime(); | 302 | QDateTime datetime = QDateTime::currentDateTime(); |
263 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + | 303 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + |
264 | QString::number( datetime.date().day() ).rightJustify(2, '0'); | 304 | QString::number( datetime.date().day() ).rightJustify(2, '0'); |
265 | 305 | ||
266 | outputFile += "/" + dateString; | 306 | outputFile += "/" + dateString; |
267 | 307 | ||
268 | QString t = outputFile; | 308 | QString t = outputFile; |
269 | int c = 1; | 309 | int c = 1; |
270 | while(QFile::exists(outputFile + EXTENSION)) | 310 | while(QFile::exists(outputFile + EXTENSION)) |
271 | { | 311 | { |
272 | outputFile = t + QString("%1").arg(c); | 312 | outputFile = t + QString("%1").arg(c); |
273 | c++; | 313 | c++; |
274 | } | 314 | } |
275 | 315 | ||
276 | // We execute tar and compressing its output with gzip.. | 316 | // We execute tar and compressing its output with gzip.. |
277 | // The error output will be written into a temp-file which could be provided | 317 | // The error output will be written into a temp-file which could be provided |
278 | // for debugging.. | 318 | // for debugging.. |
279 | odebug << "Storing file: " << outputFile.latin1() << "" << oendl; | 319 | odebug << "Storing file: " << outputFile.latin1() << "" << oendl; |
280 | outputFile += EXTENSION; | 320 | outputFile += EXTENSION; |
281 | 321 | ||
282 | QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() ) | 322 | QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() ) |
283 | .arg( getExcludeFile() ) | 323 | .arg( getExcludeFile() ) |
284 | .arg( backupFiles ) | 324 | .arg( backupFiles ) |
285 | .arg( outputFile.latin1() ) | 325 | .arg( outputFile.latin1() ) |
286 | .arg( tempFileName.latin1() ); | 326 | .arg( tempFileName.latin1() ); |
287 | 327 | ||
288 | odebug << commandLine << oendl; | 328 | odebug << commandLine << oendl; |
289 | 329 | ||
290 | int r = system( commandLine ); | 330 | int r = system( commandLine ); |
291 | 331 | ||
292 | owait->hide(); | 332 | owait->hide(); |
293 | delete owait; | 333 | delete owait; |
294 | 334 | ||
295 | //Error-Handling | 335 | //Error-Handling |
296 | if(r != 0) | 336 | if(r != 0) |
297 | { | 337 | { |
298 | perror("Error: "); | 338 | perror("Error: "); |
299 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); | 339 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); |
300 | 340 | ||
301 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" | 341 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" |
302 | + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) | 342 | + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) |
303 | { | 343 | { |
304 | 344 | ||
305 | case 1: | 345 | case 1: |
306 | owarn << "Details pressed !" << oendl; | 346 | owarn << "Details pressed !" << oendl; |
307 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); | 347 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); |
308 | QFile errorFile( tempFileName ); | 348 | QFile errorFile( tempFileName ); |
309 | if ( errorFile.open(IO_ReadOnly) ) | 349 | if ( errorFile.open(IO_ReadOnly) ) |
310 | { | 350 | { |
311 | QTextStream t( &errorFile ); | 351 | QTextStream t( &errorFile ); |
312 | QString s; | 352 | QString s; |
313 | while ( !t.eof() ) | 353 | while ( !t.eof() ) |
314 | { // until end of file... | 354 | { // until end of file... |
315 | s += t.readLine(); // line of text excluding '\n' | 355 | s += t.readLine(); // line of text excluding '\n' |
316 | } | 356 | } |
317 | errorFile.close(); | 357 | errorFile.close(); |
318 | 358 | ||
319 | pErrDialog->m_textarea->setText( s ); | 359 | pErrDialog->m_textarea->setText( s ); |
320 | } | 360 | } |
321 | else | 361 | else |
322 | { | 362 | { |
323 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); | 363 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); |
324 | } | 364 | } |
325 | QPEApplication::execDialog( pErrDialog ); | 365 | QPEApplication::execDialog( pErrDialog ); |
326 | delete pErrDialog; | 366 | delete pErrDialog; |
327 | break; | 367 | break; |
328 | } | 368 | } |
329 | setCaption(tr("Backup and Restore.. Failed !!")); | 369 | setCaption(tr("Backup and Restore.. Failed !!")); |
330 | return; | 370 | return; |
331 | } | 371 | } |
332 | else | 372 | else |
333 | { | 373 | { |
334 | QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); | 374 | QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); |
335 | } | 375 | } |
336 | 376 | ||
337 | //write store-location | 377 | //write store-location |
338 | Config config( "BackupAndRestore" ); | 378 | Config config( "BackupAndRestore" ); |
339 | config.setGroup( "LastLocation" ); | 379 | config.setGroup( "LastLocation" ); |
340 | config.writeEntry( "LastStoreLocation", storeToLocation->currentText() ); | 380 | config.writeEntry( "LastStoreLocation", storeToLocation->currentText() ); |
341 | 381 | ||
342 | setCaption(tr("Backup and Restore")); | 382 | setCaption(tr("Backup and Restore")); |
343 | } | 383 | } |
344 | 384 | ||
345 | /*** | 385 | /*** |
346 | * Get a list of all of the files to backup. | 386 | * Get a list of all of the files to backup. |
347 | */ | 387 | */ |
348 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) | 388 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) |
349 | { | 389 | { |
350 | QListViewItem * currentItem; | 390 | QListViewItem * currentItem; |
351 | QString currentHome; | 391 | QString currentHome; |
352 | if(!parent) | 392 | if(!parent) |
353 | currentItem = backupList->firstChild(); | 393 | currentItem = backupList->firstChild(); |
354 | else | 394 | else |
355 | { | 395 | { |
356 | currentItem = parent->firstChild(); | 396 | currentItem = parent->firstChild(); |
357 | currentHome = parent->text(BACKUP_LOCATION); | 397 | currentHome = parent->text(BACKUP_LOCATION); |
358 | } | 398 | } |
359 | 399 | ||
360 | uint count = 0; | 400 | uint count = 0; |
361 | while( currentItem != 0 ) | 401 | while( currentItem != 0 ) |
362 | { | 402 | { |
363 | if(currentItem->text(HEADER_BACKUP) == "B" ) | 403 | if(currentItem->text(HEADER_BACKUP) == "B" ) |
364 | { | 404 | { |
365 | if(currentItem->childCount() == 0 ) | 405 | if(currentItem->childCount() == 0 ) |
366 | { | 406 | { |
367 | if(parent == NULL) | 407 | if(parent == NULL) |
368 | backupFiles += currentItem->text(BACKUP_LOCATION); | 408 | backupFiles += currentItem->text(BACKUP_LOCATION); |
369 | else | 409 | else |
370 | backupFiles += currentHome + currentItem->text(HEADER_NAME); | 410 | backupFiles += currentHome + currentItem->text(HEADER_NAME); |
371 | backupFiles += " "; | 411 | backupFiles += " "; |
372 | count++; | 412 | count++; |
373 | } | 413 | } |
374 | else | 414 | else |
375 | { | 415 | { |
376 | count += getBackupFiles(backupFiles, currentItem); | 416 | count += getBackupFiles(backupFiles, currentItem); |
377 | } | 417 | } |
378 | } | 418 | } |
379 | currentItem = currentItem->nextSibling(); | 419 | currentItem = currentItem->nextSibling(); |
380 | } | 420 | } |
381 | return count; | 421 | return count; |
382 | } | 422 | } |
383 | 423 | ||
384 | void BackupAndRestore::sourceDirChanged(int selection) | 424 | void BackupAndRestore::sourceDirChanged(int selection) |
385 | { | 425 | { |
386 | restoreList->clear(); | 426 | restoreList->clear(); |
387 | rescanFolder(backupLocations[restoreSource->text(selection)]); | 427 | rescanFolder(backupLocations[restoreSource->text(selection)]); |
388 | } | 428 | } |
389 | 429 | ||
390 | void BackupAndRestore::fileListUpdate() | 430 | void BackupAndRestore::fileListUpdate() |
391 | { | 431 | { |
392 | owarn << "void BackupAndRestore::fileListUpdate()" << oendl; | 432 | owarn << "void BackupAndRestore::fileListUpdate()" << oendl; |
393 | restoreList->clear(); | 433 | restoreList->clear(); |
394 | rescanFolder( backupLocations[restoreSource->currentText()] ); | 434 | rescanFolder( backupLocations[restoreSource->currentText()] ); |
395 | } | 435 | } |
396 | 436 | ||
397 | /** | 437 | /** |
398 | * Scans directory for any backup files. Will recursivly go down, | 438 | * Scans directory for any backup files. Will recursivly go down, |
399 | * but will not follow symlinks. | 439 | * but will not follow symlinks. |
400 | * @param directory - the directory to look in. | 440 | * @param directory - the directory to look in. |
401 | */ | 441 | */ |
402 | void BackupAndRestore::rescanFolder(QString directory) | 442 | void BackupAndRestore::rescanFolder(QString directory) |
403 | { | 443 | { |
404 | //odebug << QString("rescanFolder: ") + directory.latin1() << oendl; | 444 | //odebug << QString("rescanFolder: ") + directory.latin1() << oendl; |
405 | QDir d(directory); | 445 | QDir d(directory); |
406 | if(!d.exists()) | 446 | if(!d.exists()) |
407 | return; | 447 | return; |
408 | 448 | ||
409 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); | 449 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); |
410 | const QFileInfoList *list = d.entryInfoList(); | 450 | const QFileInfoList *list = d.entryInfoList(); |
411 | QFileInfoListIterator it( *list ); | 451 | QFileInfoListIterator it( *list ); |
412 | QFileInfo *file; | 452 | QFileInfo *file; |
413 | while ( (file=it.current()) ) | 453 | while ( (file=it.current()) ) |
414 | { // for each file... | 454 | { // for each file... |
415 | // If it is a dir and not .. or . then add it as a tab and go down. | 455 | // If it is a dir and not .. or . then add it as a tab and go down. |
416 | if(file->isDir()) | 456 | if(file->isDir()) |
417 | { | 457 | { |
418 | if(file->fileName() != ".." && file->fileName() != ".") | 458 | if(file->fileName() != ".." && file->fileName() != ".") |
419 | { | 459 | { |
420 | rescanFolder(directory + "/" + file->fileName()); | 460 | rescanFolder(directory + "/" + file->fileName()); |
421 | } | 461 | } |
422 | } | 462 | } |
423 | else | 463 | else |
424 | { | 464 | { |
425 | // If it is a backup file add to list. | 465 | // If it is a backup file add to list. |
426 | if(file->fileName().contains(EXTENSION)) | 466 | if(file->fileName().contains(EXTENSION)) |
427 | (void)new QListViewItem(restoreList, file->fileName()); | 467 | (void)new QListViewItem(restoreList, file->fileName()); |
428 | } | 468 | } |
429 | ++it; | 469 | ++it; |
430 | } | 470 | } |
431 | } | 471 | } |
432 | 472 | ||
433 | /** | 473 | /** |
434 | * Restore a backup file. | 474 | * Restore a backup file. |
435 | * Report errors or success | 475 | * Report errors or success |
436 | */ | 476 | */ |
437 | void BackupAndRestore::restore() | 477 | void BackupAndRestore::restore() |
438 | { | 478 | { |
439 | QListViewItem *restoreItem = restoreList->currentItem(); | 479 | QListViewItem *restoreItem = restoreList->currentItem(); |
440 | if(!restoreItem) | 480 | if(!restoreItem) |
441 | { | 481 | { |
442 | QMessageBox::critical(this, tr( "Message" ), | 482 | QMessageBox::critical(this, tr( "Message" ), |
443 | tr( "Please select something to restore." ),QString( tr( "Ok") ) ); | 483 | tr( "Please select something to restore." ),QString( tr( "Ok") ) ); |
444 | return; | 484 | return; |
445 | } | 485 | } |
446 | 486 | ||
447 | OWait *owait = new OWait(); | 487 | OWait *owait = new OWait(); |
448 | Global::statusMessage( tr( "Restore Backup..." ) ); | 488 | Global::statusMessage( tr( "Restore Backup..." ) ); |
449 | owait->show(); | 489 | owait->show(); |
450 | qApp->processEvents(); | 490 | qApp->processEvents(); |
451 | 491 | ||
452 | QString restoreFile = backupLocations[restoreSource->currentText()]; | 492 | QString restoreFile = backupLocations[restoreSource->currentText()]; |
453 | 493 | ||
454 | restoreFile += "/" + restoreItem->text(0); | 494 | restoreFile += "/" + restoreItem->text(0); |
455 | 495 | ||
456 | odebug << restoreFile << oendl; | 496 | odebug << restoreFile << oendl; |
457 | 497 | ||
458 | //check if backup file come from opie 1.0.x | 498 | //check if backup file come from opie 1.0.x |
459 | 499 | ||
460 | QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() ); | 500 | QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() ); |
461 | 501 | ||
462 | int r = system( commandLine ); | 502 | int r = system( commandLine ); |
463 | 503 | ||
464 | QString startDir; | 504 | QString startDir; |
465 | 505 | ||
466 | if( r != 0 ) //Applications/backup/exclude not found - old backup file | 506 | if( r != 0 ) //Applications/backup/exclude not found - old backup file |
467 | { | 507 | { |
468 | startDir = QString( "/" ); | 508 | startDir = QString( "/" ); |
469 | } else | 509 | } else |
470 | { | 510 | { |
471 | startDir = QDir::homeDirPath(); | 511 | startDir = QDir::homeDirPath(); |
472 | } | 512 | } |
473 | 513 | ||
474 | //unpack backup file | 514 | //unpack backup file |
475 | commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir ) | 515 | commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir ) |
476 | .arg( restoreFile.latin1() ) | 516 | .arg( restoreFile.latin1() ) |
477 | .arg( tempFileName.latin1() ); | 517 | .arg( tempFileName.latin1() ); |
478 | 518 | ||
479 | odebug << commandLine << oendl; | 519 | odebug << commandLine << oendl; |
480 | 520 | ||
481 | r = system( commandLine ); | 521 | r = system( commandLine ); |
482 | 522 | ||
483 | owait->hide(); | 523 | owait->hide(); |
484 | delete owait; | 524 | delete owait; |
485 | 525 | ||
486 | //error handling | 526 | //error handling |
487 | if(r != 0) | 527 | if(r != 0) |
488 | { | 528 | { |
489 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); | 529 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); |
490 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" | 530 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" |
491 | + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) | 531 | + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) |
492 | { | 532 | { |
493 | case 1: | 533 | case 1: |
494 | owarn << "Details pressed !" << oendl; | 534 | owarn << "Details pressed !" << oendl; |
495 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); | 535 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); |
496 | QFile errorFile( tempFileName ); | 536 | QFile errorFile( tempFileName ); |
497 | if ( errorFile.open(IO_ReadOnly) ) | 537 | if ( errorFile.open(IO_ReadOnly) ) |
498 | { | 538 | { |
499 | QTextStream t( &errorFile ); | 539 | QTextStream t( &errorFile ); |
500 | QString s; | 540 | QString s; |
501 | while ( !t.eof() ) | 541 | while ( !t.eof() ) |
502 | { // until end of file... | 542 | { // until end of file... |
503 | s += t.readLine(); // line of text excluding '\n' | 543 | s += t.readLine(); // line of text excluding '\n' |
504 | } | 544 | } |
505 | errorFile.close(); | 545 | errorFile.close(); |
506 | 546 | ||
507 | pErrDialog->m_textarea->setText( s ); | 547 | pErrDialog->m_textarea->setText( s ); |
508 | } | 548 | } |
509 | else | 549 | else |
510 | { | 550 | { |
511 | pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); | 551 | pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); |
512 | } | 552 | } |
513 | QPEApplication::execDialog( pErrDialog ); | 553 | QPEApplication::execDialog( pErrDialog ); |
514 | delete pErrDialog; | 554 | delete pErrDialog; |
515 | 555 | ||
516 | setCaption(tr("Backup and Restore.. Failed !!")); | 556 | setCaption(tr("Backup and Restore.. Failed !!")); |
517 | return; | 557 | return; |
518 | 558 | ||
519 | break; | 559 | break; |
520 | 560 | ||
521 | } | 561 | } |
522 | } | 562 | } |
523 | else | 563 | else |
524 | { | 564 | { |
525 | QMessageBox::information(this, tr( "Message" ), tr( "Restore Successful." ), QString( tr( "Ok") ) ); | 565 | QMessageBox::information(this, tr( "Message" ), tr( "Restore Successful." ), QString( tr( "Ok") ) ); |
526 | } | 566 | } |
527 | 567 | ||
528 | //write restore-location | 568 | //write restore-location |
529 | Config config( "BackupAndRestore" ); | 569 | Config config( "BackupAndRestore" ); |
530 | config.setGroup( "LastLocation" ); | 570 | config.setGroup( "LastLocation" ); |
531 | config.writeEntry( "LastRestoreLocation", restoreSource->currentText() ); | 571 | config.writeEntry( "LastRestoreLocation", restoreSource->currentText() ); |
532 | 572 | ||
533 | setCaption(tr("Backup and Restore")); | 573 | setCaption(tr("Backup and Restore")); |
534 | } | 574 | } |
535 | 575 | ||
536 | /** | 576 | /** |
537 | * Check for exclude in Applications/backup | 577 | * Check for exclude in Applications/backup |
538 | * If it does not exist, the function will create the file with *.bck as content | 578 | * If it does not exist, the function will create the file with *.bck as content |
539 | * The exclude_files is read by tar and will provide to exclude special files out from backup. | 579 | * The exclude_files is read by tar and will provide to exclude special files out from backup. |
540 | * e.g. alle *.bck files (backup-files) will not be backed up by default | 580 | * e.g. alle *.bck files (backup-files) will not be backed up by default |
541 | */ | 581 | */ |
542 | 582 | ||
543 | QString BackupAndRestore::getExcludeFile() | 583 | QString BackupAndRestore::getExcludeFile() |
544 | { | 584 | { |
545 | QString excludeFileName = Global::applicationFileName( "backup", "exclude" ); | 585 | QString excludeFileName = Global::applicationFileName( "backup", "exclude" ); |
546 | if ( !QFile::exists( excludeFileName ) ) | 586 | if ( !QFile::exists( excludeFileName ) ) |
547 | { | 587 | { |
548 | QFile excludeFile( excludeFileName); | 588 | QFile excludeFile( excludeFileName); |
549 | if ( excludeFile.open( IO_WriteOnly ) == true ) | 589 | if ( excludeFile.open( IO_WriteOnly ) == true ) |
550 | { | 590 | { |
551 | QTextStream writeStream( &excludeFile ); | 591 | QTextStream writeStream( &excludeFile ); |
552 | writeStream << "*.bck" << "\n"; | 592 | writeStream << "*.bck" << "\n"; |
553 | excludeFile.close(); | 593 | excludeFile.close(); |
554 | } | 594 | } |
555 | else | 595 | else |
556 | { | 596 | { |
557 | return QString::null; | 597 | return QString::null; |
558 | } | 598 | } |
559 | } | 599 | } |
560 | 600 | ||
561 | return excludeFileName; | 601 | return excludeFileName; |
562 | } | 602 | } |
563 | 603 | ||
564 | void BackupAndRestore::refreshLocations() | 604 | void BackupAndRestore::refreshLocations() |
565 | { | 605 | { |
566 | locationList->clear(); | 606 | locationList->clear(); |
567 | 607 | ||
568 | //todo: implement add locations | 608 | //todo: implement add locations |
569 | Config config( "BackupAndRestore" ); | 609 | Config config( "BackupAndRestore" ); |
570 | config.setGroup( "Locations" ); | 610 | config.setGroup( "Locations" ); |
571 | 611 | ||
572 | QStringList locations( config.readListEntry( "locations", '|' ) ); | 612 | QStringList locations( config.readListEntry( "locations", '|' ) ); |
573 | 613 | ||
574 | for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it ) { | 614 | for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it ) { |
575 | (void) new QListViewItem( locationList, *it ); | 615 | (void) new QListViewItem( locationList, *it ); |
576 | } | 616 | } |
577 | } | 617 | } |
578 | 618 | ||
579 | void BackupAndRestore::addLocation() | 619 | void BackupAndRestore::addLocation() |
580 | { | 620 | { |
581 | if ( ( !locationEdit->text().isEmpty() ) && | 621 | if ( ( !locationEdit->text().isEmpty() ) && |
diff --git a/noncore/settings/backup/backuprestore.h b/noncore/settings/backup/backuprestore.h index 332123a..015f854 100644 --- a/noncore/settings/backup/backuprestore.h +++ b/noncore/settings/backup/backuprestore.h | |||
@@ -1,54 +1,85 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002-2004 The Opie Team <opie-devel@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
1 | #ifndef WINDOW_H | 29 | #ifndef WINDOW_H |
2 | #define WINDOW_H | 30 | #define WINDOW_H |
3 | 31 | ||
4 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
5 | #include "backuprestorebase.h" | 33 | #include "backuprestorebase.h" |
6 | #include <qmap.h> | 34 | #include <qmap.h> |
7 | #include <qlist.h> | 35 | #include <qlist.h> |
8 | 36 | ||
9 | class QListViewItem; | 37 | class QListViewItem; |
10 | class QStringList; | 38 | class QStringList; |
11 | 39 | ||
12 | class BackupAndRestore : public BackupAndRestoreBase | 40 | class BackupAndRestore : public BackupAndRestoreBase |
13 | { | 41 | { |
14 | 42 | ||
15 | Q_OBJECT | 43 | Q_OBJECT |
16 | 44 | ||
17 | public: | 45 | public: |
18 | 46 | ||
19 | BackupAndRestore( QWidget* parent = 0, const char* name = 0, WFlags fl = 0); | 47 | BackupAndRestore( QWidget* parent = 0, const char* name = 0, WFlags fl = 0); |
20 | ~BackupAndRestore(); | 48 | ~BackupAndRestore(); |
21 | 49 | ||
22 | static QString appName() { return QString::fromLatin1("backup"); } | 50 | static QString appName() { return QString::fromLatin1("backup"); } |
23 | 51 | ||
24 | private slots: | 52 | private slots: |
25 | void backup(); | 53 | void backup(); |
26 | void restore(); | 54 | void restore(); |
27 | void selectItem(QListViewItem *currentItem); | 55 | void selectItem(QListViewItem *currentItem); |
28 | void sourceDirChanged(int); | 56 | void sourceDirChanged(int); |
29 | void rescanFolder(QString directory); | 57 | void rescanFolder(QString directory); |
30 | void fileListUpdate(); | 58 | void fileListUpdate(); |
31 | 59 | ||
32 | void addLocation(); | 60 | void addLocation(); |
33 | void removeLocation(); | 61 | void removeLocation(); |
34 | void saveLocations(); | 62 | void saveLocations(); |
35 | void selectLocation(); | 63 | void selectLocation(); |
36 | 64 | ||
37 | private: | 65 | private: |
38 | void scanForApplicationSettings(); | 66 | void scanForApplicationSettings(); |
39 | int getBackupFiles(QString &backupFiles, QListViewItem *parent); | 67 | int getBackupFiles(QString &backupFiles, QListViewItem *parent); |
40 | QString getExcludeFile(); | 68 | QString getExcludeFile(); |
41 | QMap<QString, QString> backupLocations; | 69 | QMap<QString, QString> backupLocations; |
42 | QList<QListViewItem> getAllItems(QListViewItem *item, QList<QListViewItem> &list); | 70 | QList<QListViewItem> getAllItems(QListViewItem *item, QList<QListViewItem> &list); |
43 | void refreshBackupLocations(); | 71 | void refreshBackupLocations(); |
44 | void refreshLocations(); | 72 | void refreshLocations(); |
45 | 73 | ||
74 | void backupUserData(); | ||
75 | void backupRootFs(); | ||
76 | |||
46 | QListViewItem *systemSettings; | 77 | QListViewItem *systemSettings; |
47 | QListViewItem *applicationSettings; | 78 | QListViewItem *applicationSettings; |
48 | QListViewItem *documents; | 79 | QListViewItem *documents; |
49 | }; | 80 | }; |
50 | 81 | ||
51 | #endif | 82 | #endif |
52 | 83 | ||
53 | // backuprestore.h | 84 | // backuprestore.h |
54 | 85 | ||
diff --git a/noncore/settings/backup/backuprestorebase.ui b/noncore/settings/backup/backuprestorebase.ui index b464556..6186d68 100644 --- a/noncore/settings/backup/backuprestorebase.ui +++ b/noncore/settings/backup/backuprestorebase.ui | |||
@@ -1,220 +1,297 @@ | |||
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>282</width> | 14 | <width>278</width> |
15 | <height>243</height> | 15 | <height>298</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 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
27 | </property> | 27 | </property> |
28 | <vbox> | 28 | <vbox> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>0</number> | 31 | <number>0</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>0</number> | 35 | <number>0</number> |
36 | </property> | 36 | </property> |
37 | <widget> | 37 | <widget> |
38 | <class>QTabWidget</class> | 38 | <class>QTabWidget</class> |
39 | <property stdset="1"> | 39 | <property stdset="1"> |
40 | <name>name</name> | 40 | <name>name</name> |
41 | <cstring>tabWidget</cstring> | 41 | <cstring>tabWidget</cstring> |
42 | </property> | 42 | </property> |
43 | <property> | 43 | <property> |
44 | <name>layoutMargin</name> | 44 | <name>layoutMargin</name> |
45 | </property> | 45 | </property> |
46 | <property> | 46 | <property> |
47 | <name>layoutSpacing</name> | 47 | <name>layoutSpacing</name> |
48 | </property> | 48 | </property> |
49 | <widget> | 49 | <widget> |
50 | <class>QWidget</class> | 50 | <class>QWidget</class> |
51 | <property stdset="1"> | 51 | <property stdset="1"> |
52 | <name>name</name> | 52 | <name>name</name> |
53 | <cstring>Widget2</cstring> | 53 | <cstring>Widget2</cstring> |
54 | </property> | 54 | </property> |
55 | <attribute> | 55 | <attribute> |
56 | <name>title</name> | 56 | <name>title</name> |
57 | <string>Backup</string> | 57 | <string>Backup</string> |
58 | </attribute> | 58 | </attribute> |
59 | <grid> | 59 | <grid> |
60 | <property stdset="1"> | 60 | <property stdset="1"> |
61 | <name>margin</name> | 61 | <name>margin</name> |
62 | <number>4</number> | 62 | <number>4</number> |
63 | </property> | 63 | </property> |
64 | <property stdset="1"> | 64 | <property stdset="1"> |
65 | <name>spacing</name> | 65 | <name>spacing</name> |
66 | <number>4</number> | 66 | <number>2</number> |
67 | </property> | 67 | </property> |
68 | <widget row="0" column="0" > | 68 | <widget row="0" column="0" > |
69 | <class>QLabel</class> | 69 | <class>QLayoutWidget</class> |
70 | <property stdset="1"> | ||
71 | <name>name</name> | ||
72 | <cstring>TextLabel1</cstring> | ||
73 | </property> | ||
74 | <property stdset="1"> | ||
75 | <name>text</name> | ||
76 | <string>Save To</string> | ||
77 | </property> | ||
78 | </widget> | ||
79 | <widget row="0" column="1" > | ||
80 | <class>QComboBox</class> | ||
81 | <property stdset="1"> | 70 | <property stdset="1"> |
82 | <name>name</name> | 71 | <name>name</name> |
83 | <cstring>storeToLocation</cstring> | 72 | <cstring>Layout1</cstring> |
84 | </property> | 73 | </property> |
85 | </widget> | 74 | <grid> |
86 | <widget row="2" column="0" rowspan="1" colspan="2" > | 75 | <property stdset="1"> |
87 | <class>QPushButton</class> | 76 | <name>margin</name> |
88 | <property stdset="1"> | 77 | <number>0</number> |
89 | <name>name</name> | ||
90 | <cstring>backupButton</cstring> | ||
91 | </property> | ||
92 | <property stdset="1"> | ||
93 | <name>text</name> | ||
94 | <string>&Backup</string> | ||
95 | </property> | ||
96 | </widget> | ||
97 | <widget row="1" column="0" rowspan="1" colspan="2" > | ||
98 | <class>QListView</class> | ||
99 | <column> | ||
100 | <property> | ||
101 | <name>text</name> | ||
102 | <string>Applications</string> | ||
103 | </property> | 78 | </property> |
104 | <property> | 79 | <property stdset="1"> |
105 | <name>clickable</name> | 80 | <name>spacing</name> |
106 | <bool>true</bool> | 81 | <number>6</number> |
107 | </property> | ||
108 | <property> | ||
109 | <name>resizeable</name> | ||
110 | <bool>true</bool> | ||
111 | </property> | 82 | </property> |
112 | </column> | 83 | <widget row="1" column="1" > |
113 | <property stdset="1"> | 84 | <class>QComboBox</class> |
114 | <name>name</name> | 85 | <property stdset="1"> |
115 | <cstring>backupList</cstring> | 86 | <name>name</name> |
116 | </property> | 87 | <cstring>storeToLocation</cstring> |
117 | <property stdset="1"> | 88 | </property> |
118 | <name>allColumnsShowFocus</name> | 89 | <property stdset="1"> |
119 | <bool>true</bool> | 90 | <name>sizePolicy</name> |
120 | </property> | 91 | <sizepolicy> |
121 | <property stdset="1"> | 92 | <hsizetype>3</hsizetype> |
122 | <name>rootIsDecorated</name> | 93 | <vsizetype>1</vsizetype> |
123 | <bool>true</bool> | 94 | </sizepolicy> |
124 | </property> | 95 | </property> |
96 | </widget> | ||
97 | <widget row="1" column="0" > | ||
98 | <class>QLabel</class> | ||
99 | <property stdset="1"> | ||
100 | <name>name</name> | ||
101 | <cstring>TextLabel1</cstring> | ||
102 | </property> | ||
103 | <property stdset="1"> | ||
104 | <name>text</name> | ||
105 | <string>Destination</string> | ||
106 | </property> | ||
107 | </widget> | ||
108 | <widget row="3" column="0" rowspan="1" colspan="2" > | ||
109 | <class>QPushButton</class> | ||
110 | <property stdset="1"> | ||
111 | <name>name</name> | ||
112 | <cstring>backupButton</cstring> | ||
113 | </property> | ||
114 | <property stdset="1"> | ||
115 | <name>text</name> | ||
116 | <string>&Backup</string> | ||
117 | </property> | ||
118 | </widget> | ||
119 | <widget row="0" column="0" rowspan="1" colspan="2" > | ||
120 | <class>QButtonGroup</class> | ||
121 | <property stdset="1"> | ||
122 | <name>name</name> | ||
123 | <cstring>frame_type</cstring> | ||
124 | </property> | ||
125 | <property stdset="1"> | ||
126 | <name>title</name> | ||
127 | <string>Type</string> | ||
128 | </property> | ||
129 | <property> | ||
130 | <name>layoutMargin</name> | ||
131 | </property> | ||
132 | <property> | ||
133 | <name>layoutSpacing</name> | ||
134 | </property> | ||
135 | <vbox> | ||
136 | <property stdset="1"> | ||
137 | <name>margin</name> | ||
138 | <number>4</number> | ||
139 | </property> | ||
140 | <property stdset="1"> | ||
141 | <name>spacing</name> | ||
142 | <number>2</number> | ||
143 | </property> | ||
144 | <widget> | ||
145 | <class>QRadioButton</class> | ||
146 | <property stdset="1"> | ||
147 | <name>name</name> | ||
148 | <cstring>cb_type_userdata</cstring> | ||
149 | </property> | ||
150 | <property stdset="1"> | ||
151 | <name>text</name> | ||
152 | <string>User Data (Configuration + PIM)</string> | ||
153 | </property> | ||
154 | <property stdset="1"> | ||
155 | <name>checked</name> | ||
156 | <bool>true</bool> | ||
157 | </property> | ||
158 | </widget> | ||
159 | <widget> | ||
160 | <class>QRadioButton</class> | ||
161 | <property stdset="1"> | ||
162 | <name>name</name> | ||
163 | <cstring>cb_type_fullbackup</cstring> | ||
164 | </property> | ||
165 | <property stdset="1"> | ||
166 | <name>text</name> | ||
167 | <string>Full Backup (Root File System)</string> | ||
168 | </property> | ||
169 | </widget> | ||
170 | </vbox> | ||
171 | </widget> | ||
172 | <widget row="2" column="0" rowspan="1" colspan="2" > | ||
173 | <class>QListView</class> | ||
174 | <column> | ||
175 | <property> | ||
176 | <name>text</name> | ||
177 | <string>Applications</string> | ||
178 | </property> | ||
179 | <property> | ||
180 | <name>clickable</name> | ||
181 | <bool>true</bool> | ||
182 | </property> | ||
183 | <property> | ||
184 | <name>resizeable</name> | ||
185 | <bool>true</bool> | ||
186 | </property> | ||
187 | </column> | ||
188 | <property stdset="1"> | ||
189 | <name>name</name> | ||
190 | <cstring>backupList</cstring> | ||
191 | </property> | ||
192 | <property stdset="1"> | ||
193 | <name>allColumnsShowFocus</name> | ||
194 | <bool>true</bool> | ||
195 | </property> | ||
196 | <property stdset="1"> | ||
197 | <name>rootIsDecorated</name> | ||
198 | <bool>true</bool> | ||
199 | </property> | ||
200 | </widget> | ||
201 | </grid> | ||
125 | </widget> | 202 | </widget> |
126 | </grid> | 203 | </grid> |
127 | </widget> | 204 | </widget> |
128 | <widget> | 205 | <widget> |
129 | <class>QWidget</class> | 206 | <class>QWidget</class> |
130 | <property stdset="1"> | 207 | <property stdset="1"> |
131 | <name>name</name> | 208 | <name>name</name> |
132 | <cstring>Widget3</cstring> | 209 | <cstring>Widget3</cstring> |
133 | </property> | 210 | </property> |
134 | <attribute> | 211 | <attribute> |
135 | <name>title</name> | 212 | <name>title</name> |
136 | <string>Restore</string> | 213 | <string>Restore</string> |
137 | </attribute> | 214 | </attribute> |
138 | <grid> | 215 | <grid> |
139 | <property stdset="1"> | 216 | <property stdset="1"> |
140 | <name>margin</name> | 217 | <name>margin</name> |
141 | <number>4</number> | 218 | <number>4</number> |
142 | </property> | 219 | </property> |
143 | <property stdset="1"> | 220 | <property stdset="1"> |
144 | <name>spacing</name> | 221 | <name>spacing</name> |
145 | <number>4</number> | 222 | <number>4</number> |
146 | </property> | 223 | </property> |
147 | <widget row="0" column="1" > | 224 | <widget row="0" column="1" > |
148 | <class>QComboBox</class> | 225 | <class>QComboBox</class> |
149 | <property stdset="1"> | 226 | <property stdset="1"> |
150 | <name>name</name> | 227 | <name>name</name> |
151 | <cstring>restoreSource</cstring> | 228 | <cstring>restoreSource</cstring> |
152 | </property> | 229 | </property> |
153 | </widget> | 230 | </widget> |
154 | <widget row="2" column="0" rowspan="1" colspan="2" > | 231 | <widget row="2" column="0" rowspan="1" colspan="2" > |
155 | <class>QPushButton</class> | 232 | <class>QPushButton</class> |
156 | <property stdset="1"> | 233 | <property stdset="1"> |
157 | <name>name</name> | 234 | <name>name</name> |
158 | <cstring>restoreButton</cstring> | 235 | <cstring>restoreButton</cstring> |
159 | </property> | 236 | </property> |
160 | <property stdset="1"> | 237 | <property stdset="1"> |
161 | <name>text</name> | 238 | <name>text</name> |
162 | <string>&Restore</string> | 239 | <string>&Restore</string> |
163 | </property> | 240 | </property> |
164 | </widget> | 241 | </widget> |
165 | <widget row="0" column="0" > | 242 | <widget row="0" column="0" > |
166 | <class>QLabel</class> | 243 | <class>QLabel</class> |
167 | <property stdset="1"> | 244 | <property stdset="1"> |
168 | <name>name</name> | 245 | <name>name</name> |
169 | <cstring>TextLabel1_2</cstring> | 246 | <cstring>TextLabel1_2</cstring> |
170 | </property> | 247 | </property> |
171 | <property stdset="1"> | 248 | <property stdset="1"> |
172 | <name>text</name> | 249 | <name>text</name> |
173 | <string>Select Source</string> | 250 | <string>Select Source</string> |
174 | </property> | 251 | </property> |
175 | </widget> | 252 | </widget> |
176 | <widget row="1" column="0" rowspan="1" colspan="2" > | 253 | <widget row="1" column="0" rowspan="1" colspan="2" > |
177 | <class>QListView</class> | 254 | <class>QListView</class> |
178 | <column> | 255 | <column> |
179 | <property> | 256 | <property> |
180 | <name>text</name> | 257 | <name>text</name> |
181 | <string>Column 1</string> | 258 | <string>Column 1</string> |
182 | </property> | 259 | </property> |
183 | <property> | 260 | <property> |
184 | <name>clickable</name> | 261 | <name>clickable</name> |
185 | <bool>true</bool> | 262 | <bool>true</bool> |
186 | </property> | 263 | </property> |
187 | <property> | 264 | <property> |
188 | <name>resizeable</name> | 265 | <name>resizeable</name> |
189 | <bool>true</bool> | 266 | <bool>true</bool> |
190 | </property> | 267 | </property> |
191 | </column> | 268 | </column> |
192 | <property stdset="1"> | 269 | <property stdset="1"> |
193 | <name>name</name> | 270 | <name>name</name> |
194 | <cstring>restoreList</cstring> | 271 | <cstring>restoreList</cstring> |
195 | </property> | 272 | </property> |
196 | <property stdset="1"> | 273 | <property stdset="1"> |
197 | <name>minimumSize</name> | 274 | <name>minimumSize</name> |
198 | <size> | 275 | <size> |
199 | <width>0</width> | 276 | <width>0</width> |
200 | <height>100</height> | 277 | <height>100</height> |
201 | </size> | 278 | </size> |
202 | </property> | 279 | </property> |
203 | </widget> | 280 | </widget> |
204 | </grid> | 281 | </grid> |
205 | </widget> | 282 | </widget> |
206 | <widget> | 283 | <widget> |
207 | <class>QWidget</class> | 284 | <class>QWidget</class> |
208 | <property stdset="1"> | 285 | <property stdset="1"> |
209 | <name>name</name> | 286 | <name>name</name> |
210 | <cstring>tab</cstring> | 287 | <cstring>tab</cstring> |
211 | </property> | 288 | </property> |
212 | <attribute> | 289 | <attribute> |
213 | <name>title</name> | 290 | <name>title</name> |
214 | <string>Locations</string> | 291 | <string>Locations</string> |
215 | </attribute> | 292 | </attribute> |
216 | <grid> | 293 | <grid> |
217 | <property stdset="1"> | 294 | <property stdset="1"> |
218 | <name>margin</name> | 295 | <name>margin</name> |
219 | <number>4</number> | 296 | <number>4</number> |
220 | </property> | 297 | </property> |