author | llornkcor <llornkcor> | 2002-11-14 13:33:20 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-14 13:33:20 (UTC) |
commit | b65957131fd1e12079aafe78abff9ad31356da72 (patch) (unidiff) | |
tree | b02895370efa055d9a830229a2adb557beb633a5 | |
parent | d7d53215cef9420872a4e0f42b547b4148ca33a9 (diff) | |
download | opie-b65957131fd1e12079aafe78abff9ad31356da72.zip opie-b65957131fd1e12079aafe78abff9ad31356da72.tar.gz opie-b65957131fd1e12079aafe78abff9ad31356da72.tar.bz2 |
caption
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 02998f0..618ce24 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -1,27 +1,39 @@ | |||
1 | |||
1 | #include "backuprestore.h" | 2 | #include "backuprestore.h" |
3 | #include "output.h" | ||
4 | |||
5 | #include <qapplication.h> | ||
6 | #include <qmultilineedit.h> | ||
7 | |||
2 | #include <qdir.h> | 8 | #include <qdir.h> |
3 | #include <qfile.h> | 9 | #include <qfile.h> |
4 | #include <qfileinfo.h> | 10 | #include <qfileinfo.h> |
5 | #include <qlistview.h> | 11 | #include <qlistview.h> |
6 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
7 | #include <qheader.h> | 13 | #include <qheader.h> |
8 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
9 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
10 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
11 | #include <qcombobox.h> | 17 | #include <qcombobox.h> |
12 | #include <qlist.h> | 18 | #include <qlist.h> |
13 | #include <stdlib.h> | 19 | #include <stdlib.h> |
14 | #include <qregexp.h> | 20 | #include <qregexp.h> |
15 | 21 | ||
22 | #include <errno.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <unistd.h> | ||
25 | #include <sys/stat.h> | ||
26 | #include <dirent.h> | ||
27 | |||
16 | #define HEADER_NAME 0 | 28 | #define HEADER_NAME 0 |
17 | #define HEADER_BACKUP 1 | 29 | #define HEADER_BACKUP 1 |
18 | #define BACKUP_LOCATION 2 | 30 | #define BACKUP_LOCATION 2 |
19 | 31 | ||
20 | #define EXTENSION ".bck" | 32 | #define EXTENSION ".bck" |
21 | 33 | ||
22 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) | 34 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) |
23 | : BackupAndRestoreBase(parent, name){ | 35 | : BackupAndRestoreBase(parent, name){ |
24 | this->showMaximized(); | 36 | this->showMaximized(); |
25 | backupList->header()->hide(); | 37 | backupList->header()->hide(); |
26 | restoreList->header()->hide(); | 38 | restoreList->header()->hide(); |
27 | connect(backupButton, SIGNAL(clicked()), | 39 | connect(backupButton, SIGNAL(clicked()), |
@@ -156,46 +168,57 @@ void BackupAndRestore::scanForApplicationSettings(){ | |||
156 | * should be backed up. If there are no files, emit and error and exit. | 168 | * should be backed up. If there are no files, emit and error and exit. |
157 | * Determine the file name to store the backup in. Backup the file(s) using | 169 | * Determine the file name to store the backup in. Backup the file(s) using |
158 | * tar and gzip --best. Report failure or success | 170 | * tar and gzip --best. Report failure or success |
159 | */ | 171 | */ |
160 | void BackupAndRestore::backupPressed(){ | 172 | void BackupAndRestore::backupPressed(){ |
161 | QString backupFiles; | 173 | QString backupFiles; |
162 | if(getBackupFiles(backupFiles, NULL) == 0){ | 174 | if(getBackupFiles(backupFiles, NULL) == 0){ |
163 | QMessageBox::critical(this, "Message", | 175 | QMessageBox::critical(this, "Message", |
164 | "No items selected.",QString("Ok") ); | 176 | "No items selected.",QString("Ok") ); |
165 | return; | 177 | return; |
166 | } | 178 | } |
167 | 179 | ||
180 | setCaption(tr("Backup and Restore... working...")); | ||
168 | QString outputFile = backupLocations[storeToLocation->currentText()]; | 181 | QString outputFile = backupLocations[storeToLocation->currentText()]; |
169 | 182 | ||
170 | QDateTime time = QDateTime::currentDateTime(); | 183 | QDateTime time = QDateTime::currentDateTime(); |
171 | QString dateString = time.date().toString().replace(QRegExp(" "), ""); | 184 | QString dateString = time.date().toString().replace(QRegExp(" "), ""); |
172 | outputFile += "/" + dateString; | 185 | outputFile += "/" + dateString; |
173 | 186 | ||
174 | QString t = outputFile; | 187 | QString t = outputFile; |
175 | int c = 1; | 188 | int c = 1; |
176 | while(QFile::exists(outputFile + EXTENSION)){ | 189 | while(QFile::exists(outputFile + EXTENSION)){ |
177 | outputFile = t + QString("%1").arg(c); | 190 | outputFile = t + QString("%1").arg(c); |
178 | c++; | 191 | c++; |
179 | } | 192 | } |
193 | |||
194 | qDebug(QString("system(\"tar -c %1 | gzip > %2\")").arg(backupFiles).arg(outputFile).latin1()); | ||
180 | outputFile += EXTENSION; | 195 | outputFile += EXTENSION; |
181 | qDebug("system(\"tar -c %1 | gzip > %2\").arg(backupFiles).arg(outputFile).latin1())"); | 196 | |
182 | int r = system(QString("tar -c %1 | gzip > %2").arg(backupFiles).arg(outputFile).latin1() ); | 197 | int r = system( QString("tar -c %1 | gzip > %2").arg(backupFiles).arg(outputFile).latin1() ); |
183 | if(r != 0){ | 198 | |
184 | QMessageBox::critical(this, "Message", "Backup Failed.",QString("Ok") ); | 199 | |
185 | return; | 200 | |
186 | } | 201 | if(r != 0){ |
187 | else{ | 202 | perror("Error: "); |
188 | QMessageBox::critical(this, "Message", "Backup Successfull.",QString("Ok") ); | 203 | QString errorMsg="Error\n"+(QString)strerror(errno); |
189 | } | 204 | |
205 | QMessageBox::critical(this, "Message", "Backup Failed.\n"+errorMsg, QString("Ok") ); | ||
206 | return; | ||
207 | } | ||
208 | else{ | ||
209 | QMessageBox::critical(this, "Message", "Backup Successfull.",QString("Ok") ); | ||
210 | |||
211 | } | ||
212 | setCaption(tr("Backup and Restore")); | ||
190 | } | 213 | } |
191 | 214 | ||
192 | /*** | 215 | /*** |
193 | * Get a list of all of the files to backup. | 216 | * Get a list of all of the files to backup. |
194 | */ | 217 | */ |
195 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){ | 218 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){ |
196 | QListViewItem * currentItem; | 219 | QListViewItem * currentItem; |
197 | QString currentHome; | 220 | QString currentHome; |
198 | if(!parent) | 221 | if(!parent) |
199 | currentItem = backupList->firstChild(); | 222 | currentItem = backupList->firstChild(); |
200 | else{ | 223 | else{ |
201 | currentItem = parent->firstChild(); | 224 | currentItem = parent->firstChild(); |