author | eilers <eilers> | 2003-07-04 15:18:38 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-07-04 15:18:38 (UTC) |
commit | 51cb7e4cd9a7ec7f1bf864884928c61b9f2db3b0 (patch) (unidiff) | |
tree | 3afddd69a47a0dc040df163f7796364e9fc2e5f1 /noncore/settings | |
parent | b3dabf7c01cd586408c2d80125076484283e6236 (diff) | |
download | opie-51cb7e4cd9a7ec7f1bf864884928c61b9f2db3b0.zip opie-51cb7e4cd9a7ec7f1bf864884928c61b9f2db3b0.tar.gz opie-51cb7e4cd9a7ec7f1bf864884928c61b9f2db3b0.tar.bz2 |
Merged all changes of opie-backup into HEAD to be able to work on
-rw-r--r-- | noncore/settings/backup/backup.pro | 2 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 115 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.h | 2 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestorebase.ui | 46 | ||||
-rw-r--r-- | noncore/settings/backup/errordialog.ui | 154 | ||||
-rw-r--r-- | noncore/settings/backup/opie-backup.control | 2 |
6 files changed, 289 insertions, 32 deletions
diff --git a/noncore/settings/backup/backup.pro b/noncore/settings/backup/backup.pro index 78842b9..cadb381 100644 --- a/noncore/settings/backup/backup.pro +++ b/noncore/settings/backup/backup.pro | |||
@@ -8,3 +8,3 @@ DEPENDPATH += $(OPIEDIR)/include | |||
8 | LIBS += -lqpe | 8 | LIBS += -lqpe |
9 | INTERFACES= backuprestorebase.ui | 9 | INTERFACES= backuprestorebase.ui errordialog.ui |
10 | TARGET = backup | 10 | TARGET = backup |
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 59e15a2..4ff6be1 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -3,2 +3,3 @@ | |||
3 | //#include "output.h" | 3 | //#include "output.h" |
4 | #include "errordialog.h" | ||
4 | 5 | ||
@@ -20,2 +21,4 @@ | |||
20 | #include <qregexp.h> | 21 | #include <qregexp.h> |
22 | #include <qtextstream.h> | ||
23 | #include <qtextview.h> | ||
21 | 24 | ||
@@ -33,2 +36,5 @@ | |||
33 | 36 | ||
37 | const QString tempFileName = "/tmp/backup.err"; | ||
38 | |||
39 | |||
34 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) | 40 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) |
@@ -46,2 +52,4 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) | |||
46 | this, SLOT(sourceDirChanged(int))); | 52 | this, SLOT(sourceDirChanged(int))); |
53 | connect(updateList, SIGNAL(clicked()), | ||
54 | this, SLOT( fileListUpdate())); | ||
47 | 55 | ||
@@ -129,2 +137,6 @@ BackupAndRestore::~BackupAndRestore(){ | |||
129 | config.writeEntry("Total", count); | 137 | config.writeEntry("Total", count); |
138 | |||
139 | // Remove Temp File | ||
140 | if ( QFile::exists( tempFileName ) ) | ||
141 | QFile::remove( tempFileName ); | ||
130 | } | 142 | } |
@@ -193,4 +205,6 @@ void BackupAndRestore::backupPressed(){ | |||
193 | 205 | ||
194 | QDateTime time = QDateTime::currentDateTime(); | 206 | QDateTime datetime = QDateTime::currentDateTime(); |
195 | QString dateString = time.date().toString().replace(QRegExp(" "), ""); | 207 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + |
208 | QString::number( datetime.date().day() ).rightJustify(2, '0'); | ||
209 | |||
196 | outputFile += "/" + dateString; | 210 | outputFile += "/" + dateString; |
@@ -204,8 +218,18 @@ void BackupAndRestore::backupPressed(){ | |||
204 | 218 | ||
205 | qDebug(QString("system(\"tar -c %1 | gzip > %2\")").arg(backupFiles).arg(outputFile).latin1()); | 219 | // We execute tar and compressing its output with gzip.. |
220 | // The error output will be written into a temp-file which could be provided | ||
221 | // for debugging.. | ||
222 | qDebug( "Storing file: %s", outputFile.latin1() ); | ||
206 | outputFile += EXTENSION; | 223 | outputFile += EXTENSION; |
207 | 224 | ||
208 | int r = system( QString("tar -c %1 | gzip > %2").arg(backupFiles).arg(outputFile).latin1() ); | 225 | qWarning( QString("(tar -c %1 | gzip > %2 ) 2> %3") |
226 | .arg( backupFiles ) | ||
227 | .arg( outputFile.latin1() ) | ||
228 | .arg( tempFileName.latin1() ) ); | ||
209 | 229 | ||
210 | 230 | ||
231 | int r = system( QString("(tar -c %1 | gzip > %2 ) 2> %3") | ||
232 | .arg( backupFiles ) | ||
233 | .arg( outputFile.latin1() ) | ||
234 | .arg( tempFileName.latin1() ) ); | ||
211 | 235 | ||
@@ -213,5 +237,29 @@ void BackupAndRestore::backupPressed(){ | |||
213 | perror("Error: "); | 237 | perror("Error: "); |
214 | QString errorMsg="Error\n"+(QString)strerror(errno); | 238 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); |
239 | |||
240 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" | ||
241 | + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ){ | ||
215 | 242 | ||
216 | QMessageBox::critical(this, "Message", "Backup Failed.\n"+errorMsg, QString("Ok") ); | 243 | case 1: |
244 | qWarning("Details pressed !"); | ||
245 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); | ||
246 | QFile errorFile( tempFileName ); | ||
247 | if ( errorFile.open(IO_ReadOnly) ) { | ||
248 | QTextStream t( &errorFile ); | ||
249 | QString s; | ||
250 | while ( !t.eof() ) { // until end of file... | ||
251 | s += t.readLine(); // line of text excluding '\n' | ||
252 | } | ||
253 | errorFile.close(); | ||
254 | |||
255 | pErrDialog->m_textarea->setText( s ); | ||
256 | }else{ | ||
257 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); | ||
258 | } | ||
259 | pErrDialog->showMaximized(); | ||
260 | pErrDialog->exec(); | ||
261 | delete pErrDialog; | ||
262 | break; | ||
263 | } | ||
264 | setCaption(tr("Backup and Restore.. Failed !!")); | ||
217 | return; | 265 | return; |
@@ -219,3 +267,3 @@ void BackupAndRestore::backupPressed(){ | |||
219 | else{ | 267 | else{ |
220 | QMessageBox::information(this, "Message", "Backup Successfull.",QString("Ok") ); | 268 | QMessageBox::information(this, tr( "Message" ), tr( "Backup Successfull." ), QString(tr( "Ok" ) ) ); |
221 | 269 | ||
@@ -263,2 +311,9 @@ void BackupAndRestore::sourceDirChanged(int selection){ | |||
263 | 311 | ||
312 | void BackupAndRestore::fileListUpdate() | ||
313 | { | ||
314 | qWarning("void BackupAndRestore::fileListUpdate()"); | ||
315 | restoreList->clear(); | ||
316 | rescanFolder( backupLocations[restoreSource->currentText()] ); | ||
317 | } | ||
318 | |||
264 | /** | 319 | /** |
@@ -301,6 +356,8 @@ void BackupAndRestore::restore(){ | |||
301 | if(!restoreItem){ | 356 | if(!restoreItem){ |
302 | QMessageBox::critical(this, "Message", | 357 | QMessageBox::critical(this, tr( "Message" ), |
303 | "Please select something to restore.",QString("Ok") ); | 358 | tr( "Please select something to restore." ),QString( tr( "Ok") ) ); |
304 | return; | 359 | return; |
305 | } | 360 | } |
361 | setCaption(tr("Backup and Restore... working...")); | ||
362 | |||
306 | QString restoreFile = backupLocations[restoreSource->currentText()]; | 363 | QString restoreFile = backupLocations[restoreSource->currentText()]; |
@@ -309,11 +366,41 @@ void BackupAndRestore::restore(){ | |||
309 | 366 | ||
310 | int r = system(QString("tar -C / -zxf %1").arg(restoreFile).latin1()); | 367 | int r = system(QString("tar -C / -zxf %1 2> %3") |
368 | .arg( restoreFile.latin1() ) | ||
369 | .arg( tempFileName.latin1() ) ); | ||
311 | if(r != 0){ | 370 | if(r != 0){ |
312 | QMessageBox::critical(this, "Message", | 371 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); |
313 | "Restore Failed.",QString("Ok") ); | 372 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" |
373 | + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) { | ||
374 | case 1: | ||
375 | qWarning("Details pressed !"); | ||
376 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); | ||
377 | QFile errorFile( tempFileName ); | ||
378 | if ( errorFile.open(IO_ReadOnly) ) { | ||
379 | QTextStream t( &errorFile ); | ||
380 | QString s; | ||
381 | while ( !t.eof() ) { // until end of file... | ||
382 | s += t.readLine(); // line of text excluding '\n' | ||
383 | } | ||
384 | errorFile.close(); | ||
385 | |||
386 | pErrDialog->m_textarea->setText( s ); | ||
387 | }else{ | ||
388 | pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); | ||
389 | } | ||
390 | pErrDialog->showMaximized(); | ||
391 | pErrDialog->exec(); | ||
392 | delete pErrDialog; | ||
393 | |||
394 | setCaption(tr("Backup and Restore.. Failed !!")); | ||
395 | return; | ||
396 | |||
397 | break; | ||
398 | |||
399 | } | ||
314 | } | 400 | } |
315 | else{ | 401 | else{ |
316 | QMessageBox::critical(this, "Message", | 402 | QMessageBox::critical(this, tr( "Message" ), |
317 | "Restore Successfull.",QString("Ok") ); | 403 | tr( "Restore Successfull." ), QString( tr( "Ok") ) ); |
318 | } | 404 | } |
405 | setCaption(tr("Backup and Restore")); | ||
319 | } | 406 | } |
diff --git a/noncore/settings/backup/backuprestore.h b/noncore/settings/backup/backuprestore.h index b0cf4cd..8c733e3 100644 --- a/noncore/settings/backup/backuprestore.h +++ b/noncore/settings/backup/backuprestore.h | |||
@@ -15,2 +15,3 @@ Q_OBJECT | |||
15 | public: | 15 | public: |
16 | |||
16 | BackupAndRestore( QWidget* parent = 0, const char* name = 0); | 17 | BackupAndRestore( QWidget* parent = 0, const char* name = 0); |
@@ -25,2 +26,3 @@ private slots: | |||
25 | void rescanFolder(QString directory); | 26 | void rescanFolder(QString directory); |
27 | void fileListUpdate(); | ||
26 | 28 | ||
diff --git a/noncore/settings/backup/backuprestorebase.ui b/noncore/settings/backup/backuprestorebase.ui index 92e37ee..05dc8a9 100644 --- a/noncore/settings/backup/backuprestorebase.ui +++ b/noncore/settings/backup/backuprestorebase.ui | |||
@@ -13,4 +13,4 @@ | |||
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>234</width> | 14 | <width>235</width> |
15 | <height>216</height> | 15 | <height>275</height> |
16 | </rect> | 16 | </rect> |
@@ -39,2 +39,5 @@ | |||
39 | </property> | 39 | </property> |
40 | <property> | ||
41 | <name>layoutMargin</name> | ||
42 | </property> | ||
40 | <widget> | 43 | <widget> |
@@ -152,3 +155,3 @@ | |||
152 | <name>margin</name> | 155 | <name>margin</name> |
153 | <number>11</number> | 156 | <number>4</number> |
154 | </property> | 157 | </property> |
@@ -165,14 +168,3 @@ | |||
165 | </widget> | 168 | </widget> |
166 | <widget row="0" column="0" > | 169 | <widget row="2" column="0" rowspan="1" colspan="2" > |
167 | <class>QLabel</class> | ||
168 | <property stdset="1"> | ||
169 | <name>name</name> | ||
170 | <cstring>TextLabel1_2</cstring> | ||
171 | </property> | ||
172 | <property stdset="1"> | ||
173 | <name>text</name> | ||
174 | <string>Select Source</string> | ||
175 | </property> | ||
176 | </widget> | ||
177 | <widget row="1" column="0" rowspan="1" colspan="2" > | ||
178 | <class>QListView</class> | 170 | <class>QListView</class> |
@@ -204,3 +196,3 @@ | |||
204 | </widget> | 196 | </widget> |
205 | <widget row="2" column="0" rowspan="1" colspan="2" > | 197 | <widget row="3" column="0" rowspan="1" colspan="2" > |
206 | <class>QPushButton</class> | 198 | <class>QPushButton</class> |
@@ -215,2 +207,24 @@ | |||
215 | </widget> | 207 | </widget> |
208 | <widget row="1" column="0" rowspan="1" colspan="2" > | ||
209 | <class>QPushButton</class> | ||
210 | <property stdset="1"> | ||
211 | <name>name</name> | ||
212 | <cstring>updateList</cstring> | ||
213 | </property> | ||
214 | <property stdset="1"> | ||
215 | <name>text</name> | ||
216 | <string>Update Filelist</string> | ||
217 | </property> | ||
218 | </widget> | ||
219 | <widget row="0" column="0" > | ||
220 | <class>QLabel</class> | ||
221 | <property stdset="1"> | ||
222 | <name>name</name> | ||
223 | <cstring>TextLabel1_2</cstring> | ||
224 | </property> | ||
225 | <property stdset="1"> | ||
226 | <name>text</name> | ||
227 | <string>Select Source</string> | ||
228 | </property> | ||
229 | </widget> | ||
216 | </grid> | 230 | </grid> |
diff --git a/noncore/settings/backup/errordialog.ui b/noncore/settings/backup/errordialog.ui new file mode 100644 index 0000000..b68b3c2 --- a/dev/null +++ b/noncore/settings/backup/errordialog.ui | |||
@@ -0,0 +1,154 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>ErrorDialog</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>ErrorDialog</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>153</width> | ||
15 | <height>223</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Error Info</string> | ||
21 | </property> | ||
22 | <property stdset="1"> | ||
23 | <name>sizeGripEnabled</name> | ||
24 | <bool>true</bool> | ||
25 | </property> | ||
26 | <property> | ||
27 | <name>layoutMargin</name> | ||
28 | </property> | ||
29 | <property> | ||
30 | <name>layoutSpacing</name> | ||
31 | </property> | ||
32 | <vbox> | ||
33 | <property stdset="1"> | ||
34 | <name>margin</name> | ||
35 | <number>2</number> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>spacing</name> | ||
39 | <number>2</number> | ||
40 | </property> | ||
41 | <widget> | ||
42 | <class>QGroupBox</class> | ||
43 | <property stdset="1"> | ||
44 | <name>name</name> | ||
45 | <cstring>GroupBox1</cstring> | ||
46 | </property> | ||
47 | <property stdset="1"> | ||
48 | <name>midLineWidth</name> | ||
49 | <number>2</number> | ||
50 | </property> | ||
51 | <property stdset="1"> | ||
52 | <name>title</name> | ||
53 | <string>Error Message:</string> | ||
54 | </property> | ||
55 | <property> | ||
56 | <name>layoutMargin</name> | ||
57 | </property> | ||
58 | <grid> | ||
59 | <property stdset="1"> | ||
60 | <name>margin</name> | ||
61 | <number>4</number> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>spacing</name> | ||
65 | <number>6</number> | ||
66 | </property> | ||
67 | <widget row="0" column="0" > | ||
68 | <class>QMultiLineEdit</class> | ||
69 | <property stdset="1"> | ||
70 | <name>name</name> | ||
71 | <cstring>m_textarea</cstring> | ||
72 | </property> | ||
73 | <property stdset="1"> | ||
74 | <name>wordWrap</name> | ||
75 | <enum>WidgetWidth</enum> | ||
76 | </property> | ||
77 | </widget> | ||
78 | </grid> | ||
79 | </widget> | ||
80 | <widget> | ||
81 | <class>QFrame</class> | ||
82 | <property stdset="1"> | ||
83 | <name>name</name> | ||
84 | <cstring>Frame3</cstring> | ||
85 | </property> | ||
86 | <property stdset="1"> | ||
87 | <name>sizePolicy</name> | ||
88 | <sizepolicy> | ||
89 | <hsizetype>3</hsizetype> | ||
90 | <vsizetype>4</vsizetype> | ||
91 | </sizepolicy> | ||
92 | </property> | ||
93 | <property stdset="1"> | ||
94 | <name>frameShape</name> | ||
95 | <enum>StyledPanel</enum> | ||
96 | </property> | ||
97 | <property stdset="1"> | ||
98 | <name>frameShadow</name> | ||
99 | <enum>Sunken</enum> | ||
100 | </property> | ||
101 | <property> | ||
102 | <name>layoutMargin</name> | ||
103 | </property> | ||
104 | <property> | ||
105 | <name>layoutSpacing</name> | ||
106 | </property> | ||
107 | <grid> | ||
108 | <property stdset="1"> | ||
109 | <name>margin</name> | ||
110 | <number>2</number> | ||
111 | </property> | ||
112 | <property stdset="1"> | ||
113 | <name>spacing</name> | ||
114 | <number>2</number> | ||
115 | </property> | ||
116 | <widget row="0" column="0" > | ||
117 | <class>QPushButton</class> | ||
118 | <property stdset="1"> | ||
119 | <name>name</name> | ||
120 | <cstring>m_buttonOk</cstring> | ||
121 | </property> | ||
122 | <property stdset="1"> | ||
123 | <name>sizePolicy</name> | ||
124 | <sizepolicy> | ||
125 | <hsizetype>4</hsizetype> | ||
126 | <vsizetype>4</vsizetype> | ||
127 | </sizepolicy> | ||
128 | </property> | ||
129 | <property stdset="1"> | ||
130 | <name>text</name> | ||
131 | <string>&OK</string> | ||
132 | </property> | ||
133 | <property stdset="1"> | ||
134 | <name>autoDefault</name> | ||
135 | <bool>true</bool> | ||
136 | </property> | ||
137 | <property stdset="1"> | ||
138 | <name>default</name> | ||
139 | <bool>true</bool> | ||
140 | </property> | ||
141 | </widget> | ||
142 | </grid> | ||
143 | </widget> | ||
144 | </vbox> | ||
145 | </widget> | ||
146 | <connections> | ||
147 | <connection> | ||
148 | <sender>m_buttonOk</sender> | ||
149 | <signal>clicked()</signal> | ||
150 | <receiver>ErrorDialog</receiver> | ||
151 | <slot>accept()</slot> | ||
152 | </connection> | ||
153 | </connections> | ||
154 | </UI> | ||
diff --git a/noncore/settings/backup/opie-backup.control b/noncore/settings/backup/opie-backup.control index 3f2be85..ebe2ff1 100644 --- a/noncore/settings/backup/opie-backup.control +++ b/noncore/settings/backup/opie-backup.control | |||
@@ -6,3 +6,3 @@ Depends: task-opie-minimal | |||
6 | Architecture: arm | 6 | Architecture: arm |
7 | Maintainer: Benjamin Meyer <meyerb@sharpsec.com> | 7 | Maintainer: Stefan Eilers <Eilers.Stefan@epost.de> |
8 | Section: opie/Settings | 8 | Section: opie/Settings |