author | llornkcor <llornkcor> | 2002-11-14 12:58:48 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-14 12:58:48 (UTC) |
commit | d7d53215cef9420872a4e0f42b547b4148ca33a9 (patch) (unidiff) | |
tree | 32afa92f283c65607fed532e66b7b55d3f748795 | |
parent | d419cd6d7f96341efc16717d68d7f7a0cfc09a80 (diff) | |
download | opie-d7d53215cef9420872a4e0f42b547b4148ca33a9.zip opie-d7d53215cef9420872a4e0f42b547b4148ca33a9.tar.gz opie-d7d53215cef9420872a4e0f42b547b4148ca33a9.tar.bz2 |
no --best option for gzip, buzybox already is set at best
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index fb892d9..02998f0 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -6,71 +6,71 @@ | |||
6 | #include <qpushbutton.h> | 6 | #include <qpushbutton.h> |
7 | #include <qheader.h> | 7 | #include <qheader.h> |
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | #include <qcombobox.h> | 11 | #include <qcombobox.h> |
12 | #include <qlist.h> | 12 | #include <qlist.h> |
13 | #include <stdlib.h> | 13 | #include <stdlib.h> |
14 | #include <qregexp.h> | 14 | #include <qregexp.h> |
15 | 15 | ||
16 | #define HEADER_NAME 0 | 16 | #define HEADER_NAME 0 |
17 | #define HEADER_BACKUP 1 | 17 | #define HEADER_BACKUP 1 |
18 | #define BACKUP_LOCATION 2 | 18 | #define BACKUP_LOCATION 2 |
19 | 19 | ||
20 | #define EXTENSION ".bck" | 20 | #define EXTENSION ".bck" |
21 | 21 | ||
22 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) | 22 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) |
23 | : BackupAndRestoreBase(parent, name){ | 23 | : BackupAndRestoreBase(parent, name){ |
24 | this->showMaximized(); | 24 | this->showMaximized(); |
25 | backupList->header()->hide(); | 25 | backupList->header()->hide(); |
26 | restoreList->header()->hide(); | 26 | restoreList->header()->hide(); |
27 | connect(backupButton, SIGNAL(clicked()), | 27 | connect(backupButton, SIGNAL(clicked()), |
28 | this, SLOT(backupPressed())); | 28 | this, SLOT(backupPressed())); |
29 | connect(restoreButton, SIGNAL(clicked()), | 29 | connect(restoreButton, SIGNAL(clicked()), |
30 | this, SLOT(restore())); | 30 | this, SLOT(restore())); |
31 | connect(backupList, SIGNAL(clicked( QListViewItem * )), | 31 | connect(backupList, SIGNAL(clicked( QListViewItem * )), |
32 | this, SLOT(selectItem(QListViewItem*))); | 32 | this, SLOT(selectItem(QListViewItem*))); |
33 | connect(restoreSource, SIGNAL(activated( int )), | 33 | connect(restoreSource, SIGNAL(activated( int )), |
34 | this, SLOT(sourceDirChanged(int))); | 34 | this, SLOT(sourceDirChanged(int))); |
35 | 35 | ||
36 | systemSettings = new QListViewItem(backupList, "System Settings", "", | 36 | systemSettings = new QListViewItem(backupList, "System Settings", "", |
37 | "/etc"); | 37 | "/etc"); |
38 | selectItem(systemSettings); | 38 | // selectItem(systemSettings); |
39 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", | 39 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", |
40 | QDir::homeDirPath() + "/Settings/"); | 40 | QDir::homeDirPath() + "/Settings/"); |
41 | selectItem(applicationSettings); | 41 | selectItem(applicationSettings); |
42 | documents= new QListViewItem(backupList, "Documents", "", | 42 | documents= new QListViewItem(backupList, "Documents", "", |
43 | QDir::homeDirPath() + "/Documents/"); | 43 | QDir::homeDirPath() + "/Documents/"); |
44 | selectItem(documents); | 44 | // selectItem(documents); |
45 | 45 | ||
46 | scanForApplicationSettings(); | 46 | scanForApplicationSettings(); |
47 | 47 | ||
48 | Config config("BackupAndRestore"); | 48 | Config config("BackupAndRestore"); |
49 | config.setGroup("General"); | 49 | config.setGroup("General"); |
50 | int totalLocations = config.readNumEntry("totalLocations",0); | 50 | int totalLocations = config.readNumEntry("totalLocations",0); |
51 | 51 | ||
52 | //todo make less static here and use Storage class to get infos | 52 | //todo make less static here and use Storage class to get infos |
53 | if(totalLocations == 0){ | 53 | if(totalLocations == 0){ |
54 | backupLocations.insert("Documents", "/root/Documents"); | 54 | backupLocations.insert("Documents", "/root/Documents"); |
55 | backupLocations.insert("CF", "/mnt/cf"); | 55 | backupLocations.insert("CF", "/mnt/cf"); |
56 | backupLocations.insert("SD", "/mnt/card"); | 56 | backupLocations.insert("SD", "/mnt/card"); |
57 | } | 57 | } |
58 | else{ | 58 | else{ |
59 | for(int i = 0; i < totalLocations; i++){ | 59 | for(int i = 0; i < totalLocations; i++){ |
60 | backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)), | 60 | backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)), |
61 | config.readEntry(QString("backupLocation_%1").arg(i))); | 61 | config.readEntry(QString("backupLocation_%1").arg(i))); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | QMap<QString, QString>::Iterator it; | 64 | QMap<QString, QString>::Iterator it; |
65 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){ | 65 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){ |
66 | storeToLocation->insertItem(it.key()); | 66 | storeToLocation->insertItem(it.key()); |
67 | restoreSource->insertItem(it.key()); | 67 | restoreSource->insertItem(it.key()); |
68 | } | 68 | } |
69 | 69 | ||
70 | // Read the list of items to ignore. | 70 | // Read the list of items to ignore. |
71 | QList<QString> dontBackupList; | 71 | QList<QString> dontBackupList; |
72 | dontBackupList.setAutoDelete(true); | 72 | dontBackupList.setAutoDelete(true); |
73 | config.setGroup("DontBackup"); | 73 | config.setGroup("DontBackup"); |
74 | int total = config.readNumEntry("Total", 0); | 74 | int total = config.readNumEntry("Total", 0); |
75 | for(int i = 0; i < total; i++){ | 75 | for(int i = 0; i < total; i++){ |
76 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); | 76 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); |
@@ -149,66 +149,66 @@ void BackupAndRestore::scanForApplicationSettings(){ | |||
149 | selectItem(newItem); | 149 | selectItem(newItem); |
150 | ++it; | 150 | ++it; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * The "Backup" button has been pressed. Get a list of all of the files that | 155 | * The "Backup" button has been pressed. Get a list of all of the files that |
156 | * should be backed up. If there are no files, emit and error and exit. | 156 | * 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 | 157 | * Determine the file name to store the backup in. Backup the file(s) using |
158 | * tar and gzip --best. Report failure or success | 158 | * tar and gzip --best. Report failure or success |
159 | */ | 159 | */ |
160 | void BackupAndRestore::backupPressed(){ | 160 | void BackupAndRestore::backupPressed(){ |
161 | QString backupFiles; | 161 | QString backupFiles; |
162 | if(getBackupFiles(backupFiles, NULL) == 0){ | 162 | if(getBackupFiles(backupFiles, NULL) == 0){ |
163 | QMessageBox::critical(this, "Message", | 163 | QMessageBox::critical(this, "Message", |
164 | "No items selected.",QString("Ok") ); | 164 | "No items selected.",QString("Ok") ); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | 167 | ||
168 | QString outputFile = backupLocations[storeToLocation->currentText()]; | 168 | QString outputFile = backupLocations[storeToLocation->currentText()]; |
169 | 169 | ||
170 | QDateTime time = QDateTime::currentDateTime(); | 170 | QDateTime time = QDateTime::currentDateTime(); |
171 | QString dateString = time.date().toString().replace(QRegExp(" "), ""); | 171 | QString dateString = time.date().toString().replace(QRegExp(" "), ""); |
172 | outputFile += "/" + dateString; | 172 | outputFile += "/" + dateString; |
173 | 173 | ||
174 | QString t = outputFile; | 174 | QString t = outputFile; |
175 | int c = 1; | 175 | int c = 1; |
176 | while(QFile::exists(outputFile + EXTENSION)){ | 176 | while(QFile::exists(outputFile + EXTENSION)){ |
177 | outputFile = t + QString("%1").arg(c); | 177 | outputFile = t + QString("%1").arg(c); |
178 | c++; | 178 | c++; |
179 | } | 179 | } |
180 | outputFile += EXTENSION; | 180 | outputFile += EXTENSION; |
181 | 181 | qDebug("system(\"tar -c %1 | gzip > %2\").arg(backupFiles).arg(outputFile).latin1())"); | |
182 | int r = system(QString("tar -c %1 | gzip --best > %2").arg(backupFiles).arg(outputFile).latin1()); | 182 | int r = system(QString("tar -c %1 | gzip > %2").arg(backupFiles).arg(outputFile).latin1() ); |
183 | if(r != 0){ | 183 | if(r != 0){ |
184 | QMessageBox::critical(this, "Message", "Backup Failed.",QString("Ok") ); | 184 | QMessageBox::critical(this, "Message", "Backup Failed.",QString("Ok") ); |
185 | return; | 185 | return; |
186 | } | 186 | } |
187 | else{ | 187 | else{ |
188 | QMessageBox::critical(this, "Message", "Backup Successfull.",QString("Ok") ); | 188 | QMessageBox::critical(this, "Message", "Backup Successfull.",QString("Ok") ); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | /*** | 192 | /*** |
193 | * Get a list of all of the files to backup. | 193 | * Get a list of all of the files to backup. |
194 | */ | 194 | */ |
195 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){ | 195 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){ |
196 | QListViewItem * currentItem; | 196 | QListViewItem * currentItem; |
197 | QString currentHome; | 197 | QString currentHome; |
198 | if(!parent) | 198 | if(!parent) |
199 | currentItem = backupList->firstChild(); | 199 | currentItem = backupList->firstChild(); |
200 | else{ | 200 | else{ |
201 | currentItem = parent->firstChild(); | 201 | currentItem = parent->firstChild(); |
202 | currentHome = parent->text(BACKUP_LOCATION); | 202 | currentHome = parent->text(BACKUP_LOCATION); |
203 | } | 203 | } |
204 | 204 | ||
205 | uint count = 0; | 205 | uint count = 0; |
206 | while( currentItem != 0 ){ | 206 | while( currentItem != 0 ){ |
207 | if(currentItem->text(HEADER_BACKUP) == "B" ){ | 207 | if(currentItem->text(HEADER_BACKUP) == "B" ){ |
208 | if(currentItem->childCount() == 0 ){ | 208 | if(currentItem->childCount() == 0 ){ |
209 | if(parent == NULL) | 209 | if(parent == NULL) |
210 | backupFiles += currentItem->text(BACKUP_LOCATION); | 210 | backupFiles += currentItem->text(BACKUP_LOCATION); |
211 | else | 211 | else |
212 | backupFiles += currentHome + currentItem->text(HEADER_NAME); | 212 | backupFiles += currentHome + currentItem->text(HEADER_NAME); |
213 | backupFiles += " "; | 213 | backupFiles += " "; |
214 | count++; | 214 | count++; |