summaryrefslogtreecommitdiff
path: root/noncore/settings/backup/backuprestore.cpp
Unidiff
Diffstat (limited to 'noncore/settings/backup/backuprestore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp9
1 files changed, 0 insertions, 9 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 4ff6be1..922523b 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -26,108 +26,99 @@
26#include <stdlib.h> 26#include <stdlib.h>
27#include <unistd.h> 27#include <unistd.h>
28#include <sys/stat.h> 28#include <sys/stat.h>
29#include <dirent.h> 29#include <dirent.h>
30 30
31#define HEADER_NAME 0 31#define HEADER_NAME 0
32#define HEADER_BACKUP 1 32#define HEADER_BACKUP 1
33#define BACKUP_LOCATION 2 33#define BACKUP_LOCATION 2
34 34
35#define EXTENSION ".bck" 35#define EXTENSION ".bck"
36 36
37const QString tempFileName = "/tmp/backup.err"; 37const QString tempFileName = "/tmp/backup.err";
38 38
39 39
40BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) 40BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name)
41 : BackupAndRestoreBase(parent, name){ 41 : BackupAndRestoreBase(parent, name){
42 this->showMaximized(); 42 this->showMaximized();
43 backupList->header()->hide(); 43 backupList->header()->hide();
44 restoreList->header()->hide(); 44 restoreList->header()->hide();
45 connect(backupButton, SIGNAL(clicked()), 45 connect(backupButton, SIGNAL(clicked()),
46 this, SLOT(backupPressed())); 46 this, SLOT(backupPressed()));
47 connect(restoreButton, SIGNAL(clicked()), 47 connect(restoreButton, SIGNAL(clicked()),
48 this, SLOT(restore())); 48 this, SLOT(restore()));
49 connect(backupList, SIGNAL(clicked( QListViewItem * )), 49 connect(backupList, SIGNAL(clicked( QListViewItem * )),
50 this, SLOT(selectItem(QListViewItem*))); 50 this, SLOT(selectItem(QListViewItem*)));
51 connect(restoreSource, SIGNAL(activated( int )), 51 connect(restoreSource, SIGNAL(activated( int )),
52 this, SLOT(sourceDirChanged(int))); 52 this, SLOT(sourceDirChanged(int)));
53 connect(updateList, SIGNAL(clicked()), 53 connect(updateList, SIGNAL(clicked()),
54 this, SLOT( fileListUpdate())); 54 this, SLOT( fileListUpdate()));
55 55
56 applicationSettings = new QListViewItem(backupList, "Application Settings", "", 56 applicationSettings = new QListViewItem(backupList, "Application Settings", "",
57 QDir::homeDirPath() + "/Settings/"); 57 QDir::homeDirPath() + "/Settings/");
58 selectItem(applicationSettings); 58 selectItem(applicationSettings);
59 applicationSettings = new QListViewItem(backupList, "Application Data", "", 59 applicationSettings = new QListViewItem(backupList, "Application Data", "",
60 QDir::homeDirPath() + "/Applications/"); 60 QDir::homeDirPath() + "/Applications/");
61 selectItem(applicationSettings); 61 selectItem(applicationSettings);
62 documents= new QListViewItem(backupList, "Documents", "", 62 documents= new QListViewItem(backupList, "Documents", "",
63 QDir::homeDirPath() + "/Documents/"); 63 QDir::homeDirPath() + "/Documents/");
64 selectItem(documents); 64 selectItem(documents);
65 65
66 scanForApplicationSettings(); 66 scanForApplicationSettings();
67 67
68 Config config("BackupAndRestore"); 68 Config config("BackupAndRestore");
69 config.setGroup("General"); 69 config.setGroup("General");
70 int totalLocations = config.readNumEntry("totalLocations",0); 70 int totalLocations = config.readNumEntry("totalLocations",0);
71 71
72//todo make less static here and use Storage class to get infos 72//todo make less static here and use Storage class to get infos
73 if(totalLocations == 0){ 73 if(totalLocations == 0){
74
75/* Ramses has a CF-Slot, but that one is internal and you have to dismount the
76 * the case. There's also almost always a WLAN card inserted there
77*/
78
79 backupLocations.insert("Documents", "/root/Documents"); 74 backupLocations.insert("Documents", "/root/Documents");
80#if defined(QT_QWS_RAMSES)
81 backupLocations.insert("MMC", "/mnt/card");
82#else
83 backupLocations.insert("CF", "/mnt/cf"); 75 backupLocations.insert("CF", "/mnt/cf");
84 backupLocations.insert("SD", "/mnt/card"); 76 backupLocations.insert("SD", "/mnt/card");
85#endif
86 } 77 }
87 else{ 78 else{
88 for(int i = 0; i < totalLocations; i++){ 79 for(int i = 0; i < totalLocations; i++){
89 backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)), 80 backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)),
90 config.readEntry(QString("backupLocation_%1").arg(i))); 81 config.readEntry(QString("backupLocation_%1").arg(i)));
91 } 82 }
92 } 83 }
93 QMap<QString, QString>::Iterator it; 84 QMap<QString, QString>::Iterator it;
94 for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){ 85 for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){
95 storeToLocation->insertItem(it.key()); 86 storeToLocation->insertItem(it.key());
96 restoreSource->insertItem(it.key()); 87 restoreSource->insertItem(it.key());
97 } 88 }
98 89
99 // Read the list of items to ignore. 90 // Read the list of items to ignore.
100 QList<QString> dontBackupList; 91 QList<QString> dontBackupList;
101 dontBackupList.setAutoDelete(true); 92 dontBackupList.setAutoDelete(true);
102 config.setGroup("DontBackup"); 93 config.setGroup("DontBackup");
103 int total = config.readNumEntry("Total", 0); 94 int total = config.readNumEntry("Total", 0);
104 for(int i = 0; i < total; i++){ 95 for(int i = 0; i < total; i++){
105 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); 96 dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
106 } 97 }
107 98
108 QList<QListViewItem> list; 99 QList<QListViewItem> list;
109 getAllItems(backupList->firstChild(), list); 100 getAllItems(backupList->firstChild(), list);
110 101
111 for(uint i = 0; i < list.count(); i++){ 102 for(uint i = 0; i < list.count(); i++){
112 QString text = list.at(i)->text(HEADER_NAME); 103 QString text = list.at(i)->text(HEADER_NAME);
113 for(uint i2 = 0; i2 < dontBackupList.count(); i2++){ 104 for(uint i2 = 0; i2 < dontBackupList.count(); i2++){
114 if(*dontBackupList.at(i2) == text){ 105 if(*dontBackupList.at(i2) == text){
115 selectItem(list.at(i)); 106 selectItem(list.at(i));
116 break; 107 break;
117 } 108 }
118 } 109 }
119 } 110 }
120} 111}
121 112
122BackupAndRestore::~BackupAndRestore(){ 113BackupAndRestore::~BackupAndRestore(){
123 QList<QListViewItem> list; 114 QList<QListViewItem> list;
124 getAllItems(backupList->firstChild(), list); 115 getAllItems(backupList->firstChild(), list);
125 116
126 Config config("BackupAndRestore"); 117 Config config("BackupAndRestore");
127 config.setGroup("DontBackup"); 118 config.setGroup("DontBackup");
128 config.clearGroup(); 119 config.clearGroup();
129 120
130 int count = 0; 121 int count = 0;
131 for(uint i = 0; i < list.count(); i++){ 122 for(uint i = 0; i < list.count(); i++){
132 if(list.at(i)->text(HEADER_BACKUP) == ""){ 123 if(list.at(i)->text(HEADER_BACKUP) == ""){
133 config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); 124 config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME));