summaryrefslogtreecommitdiff
path: root/noncore/settings/backup/backuprestore.cpp
authorllornkcor <llornkcor>2002-11-14 12:58:48 (UTC)
committer llornkcor <llornkcor>2002-11-14 12:58:48 (UTC)
commitd7d53215cef9420872a4e0f42b547b4148ca33a9 (patch) (unidiff)
tree32afa92f283c65607fed532e66b7b55d3f748795 /noncore/settings/backup/backuprestore.cpp
parentd419cd6d7f96341efc16717d68d7f7a0cfc09a80 (diff)
downloadopie-d7d53215cef9420872a4e0f42b547b4148ca33a9.zip
opie-d7d53215cef9420872a4e0f42b547b4148ca33a9.tar.gz
opie-d7d53215cef9420872a4e0f42b547b4148ca33a9.tar.bz2
no --best option for gzip, buzybox already is set at best
Diffstat (limited to 'noncore/settings/backup/backuprestore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp8
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
@@ -14,55 +14,55 @@
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
22BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) 22BackupAndRestore::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 }
@@ -157,50 +157,50 @@ void BackupAndRestore::scanForApplicationSettings(){
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 */
160void BackupAndRestore::backupPressed(){ 160void 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 */
195int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent){ 195int 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 ){