Diffstat (limited to 'noncore/tools/formatter/formatter.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/tools/formatter/formatter.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp index 4204d73..642196e 100644 --- a/noncore/tools/formatter/formatter.cpp +++ b/noncore/tools/formatter/formatter.cpp | |||
@@ -10,15 +10,16 @@ | |||
10 | #include "inputDialog.h" | 10 | #include "inputDialog.h" |
11 | #include "output.h" | 11 | #include "output.h" |
12 | 12 | ||
13 | /* OPIE */ | 13 | /* OPIE */ |
14 | #include <qtoolbar.h> | 14 | #include <opie2/odebug.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/mimetype.h> | 18 | #include <qpe/mimetype.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/storage.h> | 20 | #include <qpe/storage.h> |
21 | using namespace Opie::Core; | ||
21 | 22 | ||
22 | /* QT */ | 23 | /* QT */ |
23 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
24 | #include <qmultilineedit.h> | 25 | #include <qmultilineedit.h> |
@@ -34,8 +35,9 @@ | |||
34 | #include <qregexp.h> | 35 | #include <qregexp.h> |
35 | #include <qlabel.h> | 36 | #include <qlabel.h> |
36 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
37 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qtoolbar.h> | ||
38 | #include <qtabwidget.h> | 40 | #include <qtabwidget.h> |
39 | #include <qwidget.h> | 41 | #include <qwidget.h> |
40 | #include <qlayout.h> | 42 | #include <qlayout.h> |
41 | #include <qvariant.h> | 43 | #include <qvariant.h> |
@@ -237,14 +239,14 @@ void FormatterApp::doFormat() | |||
237 | outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) ); | 239 | outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) ); |
238 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 240 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
239 | 241 | ||
240 | sleep(1); | 242 | sleep(1); |
241 | qDebug("Command is "+umountS); | 243 | odebug << "Command is "+umountS << oendl; |
242 | fp = popen( (const char *) umountS, "r"); | 244 | fp = popen( (const char *) umountS, "r"); |
243 | // qDebug("%d", fp); | 245 | // odebug << "" << fp << "" << oendl; |
244 | if ( !fp ) | 246 | if ( !fp ) |
245 | { | 247 | { |
246 | qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); | 248 | odebug << "Could not execute '" + umountS + "'! err=" << err << "\n" +(QString)strerror(errno) << oendl; |
247 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); | 249 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); |
248 | pclose(fp); | 250 | pclose(fp); |
249 | return; | 251 | return; |
250 | } | 252 | } |
@@ -255,9 +257,9 @@ void FormatterApp::doFormat() | |||
255 | while ( fgets( line, sizeof line, fp)) | 257 | while ( fgets( line, sizeof line, fp)) |
256 | { | 258 | { |
257 | if( ((QString)line).find("busy",0,TRUE) != -1) | 259 | if( ((QString)line).find("busy",0,TRUE) != -1) |
258 | { | 260 | { |
259 | qDebug("Could not find '" + umountS); | 261 | odebug << "Could not find '" + umountS << oendl; |
260 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); | 262 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); |
261 | pclose(fp); | 263 | pclose(fp); |
262 | return; | 264 | return; |
263 | } | 265 | } |
@@ -271,18 +273,18 @@ void FormatterApp::doFormat() | |||
271 | } | 273 | } |
272 | } | 274 | } |
273 | pclose(fp); | 275 | pclose(fp); |
274 | 276 | ||
275 | qDebug("Command would be: "+cmd); | 277 | odebug << "Command would be: "+cmd << oendl; |
276 | outDlg->OutputEdit->append( tr("Trying to format.") ); | 278 | outDlg->OutputEdit->append( tr("Trying to format.") ); |
277 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 279 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
278 | 280 | ||
279 | fp = popen( (const char *) cmd, "r"); | 281 | fp = popen( (const char *) cmd, "r"); |
280 | while ( fgets( line, sizeof line, fp)) | 282 | while ( fgets( line, sizeof line, fp)) |
281 | { | 283 | { |
282 | if( ((QString)line).find("No such device",0,TRUE) != -1) | 284 | if( ((QString)line).find("No such device",0,TRUE) != -1) |
283 | { | 285 | { |
284 | qDebug("No such device '" + umountS); | 286 | odebug << "No such device '" + umountS << oendl; |
285 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); | 287 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); |
286 | pclose(fp); | 288 | pclose(fp); |
287 | // outDlg->OutputEdit->append("No such device"); | 289 | // outDlg->OutputEdit->append("No such device"); |
288 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 290 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
@@ -304,9 +306,9 @@ void FormatterApp::doFormat() | |||
304 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 306 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
305 | fp = popen( (const char *) remountS, "r"); | 307 | fp = popen( (const char *) remountS, "r"); |
306 | if ( !fp) | 308 | if ( !fp) |
307 | { | 309 | { |
308 | qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); | 310 | odebug << "Could not execute '" + remountS + "'! err=" << err << "\n" +(QString)strerror(errno) << oendl; |
309 | QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); | 311 | QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); |
310 | 312 | ||
311 | } | 313 | } |
312 | else | 314 | else |
@@ -379,9 +381,9 @@ void FormatterApp::storageComboSelected(int index ) | |||
379 | TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) ); | 381 | TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) ); |
380 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | 382 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); |
381 | 383 | ||
382 | QString fsType = getFileSystemType((const QString &) currentText); | 384 | QString fsType = getFileSystemType((const QString &) currentText); |
383 | // qDebug(fsType); | 385 | // odebug << fsType << oendl; |
384 | for(int i = 0; i < fileSystemsCombo->count(); i++) | 386 | for(int i = 0; i < fileSystemsCombo->count(); i++) |
385 | { | 387 | { |
386 | if( fsType == fileSystemsCombo->text(i)) | 388 | if( fsType == fileSystemsCombo->text(i)) |
387 | fileSystemsCombo->setCurrentItem(i); | 389 | fileSystemsCombo->setCurrentItem(i); |
@@ -463,9 +465,9 @@ void FormatterApp::parsetab(const QString &fileName) | |||
463 | & filesystemType.find("cramfs",0,TRUE) == -1 | 465 | & filesystemType.find("cramfs",0,TRUE) == -1 |
464 | & filesystemType.find("auto",0,TRUE) == -1) | 466 | & filesystemType.find("auto",0,TRUE) == -1) |
465 | fsList << filesystemType; | 467 | fsList << filesystemType; |
466 | deviceList << deviceName; | 468 | deviceList << deviceName; |
467 | qDebug(deviceName+"::"+filesystemType); | 469 | odebug << deviceName+"::"+filesystemType << oendl; |
468 | fileSystemTypeList << deviceName+"::"+filesystemType; | 470 | fileSystemTypeList << deviceName+"::"+filesystemType; |
469 | } | 471 | } |
470 | } | 472 | } |
471 | } | 473 | } |
@@ -505,9 +507,9 @@ QString FormatterApp::getFileSystemType(const QString ¤tText) | |||
505 | QString temp = (*it); | 507 | QString temp = (*it); |
506 | if( temp.find( currentText,0,TRUE) != -1) | 508 | if( temp.find( currentText,0,TRUE) != -1) |
507 | { | 509 | { |
508 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 510 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
509 | // qDebug(fsType); | 511 | // odebug << fsType << oendl; |
510 | } | 512 | } |
511 | } | 513 | } |
512 | return ""; | 514 | return ""; |
513 | } | 515 | } |
@@ -532,9 +534,9 @@ bool FormatterApp::doFsck() | |||
532 | // #endif | 534 | // #endif |
533 | 535 | ||
534 | QString fsType = getFileSystemType((const QString &)selectedDevice); | 536 | QString fsType = getFileSystemType((const QString &)selectedDevice); |
535 | QString cmd; | 537 | QString cmd; |
536 | qDebug( selectedDevice +" "+ fsType); | 538 | odebug << selectedDevice +" "+ fsType << oendl; |
537 | if(fsType == "vfat") cmd = "dosfsck -vy "; | 539 | if(fsType == "vfat") cmd = "dosfsck -vy "; |
538 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; | 540 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; |
539 | cmd += selectedDevice + " 2>&1"; | 541 | cmd += selectedDevice + " 2>&1"; |
540 | 542 | ||
@@ -546,14 +548,14 @@ bool FormatterApp::doFsck() | |||
546 | outDlg->OutputEdit->append( tr("Trying to umount.")); | 548 | outDlg->OutputEdit->append( tr("Trying to umount.")); |
547 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 549 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
548 | 550 | ||
549 | sleep(1); | 551 | sleep(1); |
550 | // qDebug("Command is "+umountS); | 552 | // odebug << "Command is "+umountS << oendl; |
551 | fp = popen( (const char *) umountS, "r"); | 553 | fp = popen( (const char *) umountS, "r"); |
552 | // qDebug("%d", fp); | 554 | // odebug << "" << fp << "" << oendl; |
553 | if ( !fp ) | 555 | if ( !fp ) |
554 | { | 556 | { |
555 | qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); | 557 | odebug << "Could not execute '" + umountS + "'!\n" +(QString)strerror(errno) << oendl; |
556 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); | 558 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); |
557 | pclose(fp); | 559 | pclose(fp); |
558 | return false; | 560 | return false; |
559 | } | 561 | } |
@@ -564,9 +566,9 @@ bool FormatterApp::doFsck() | |||
564 | while ( fgets( line, sizeof line, fp)) | 566 | while ( fgets( line, sizeof line, fp)) |
565 | { | 567 | { |
566 | if( ((QString)line).find("busy",0,TRUE) != -1) | 568 | if( ((QString)line).find("busy",0,TRUE) != -1) |
567 | { | 569 | { |
568 | qDebug("Could not find '" + umountS); | 570 | odebug << "Could not find '" + umountS << oendl; |
569 | QMessageBox::warning( this, tr("Formatter"), | 571 | QMessageBox::warning( this, tr("Formatter"), |
570 | tr("Could not umount.\nDevice is busy!"), tr("&OK") ); | 572 | tr("Could not umount.\nDevice is busy!"), tr("&OK") ); |
571 | pclose(fp); | 573 | pclose(fp); |
572 | return false; | 574 | return false; |
@@ -586,9 +588,9 @@ bool FormatterApp::doFsck() | |||
586 | while ( fgets( line, sizeof line, fp)) | 588 | while ( fgets( line, sizeof line, fp)) |
587 | { | 589 | { |
588 | if( ((QString)line).find("No such device",0,TRUE) != -1) | 590 | if( ((QString)line).find("No such device",0,TRUE) != -1) |
589 | { | 591 | { |
590 | qDebug("No such device '" + umountS); | 592 | odebug << "No such device '" + umountS << oendl; |
591 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); | 593 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); |
592 | pclose(fp); | 594 | pclose(fp); |
593 | // outDlg->OutputEdit->append("No such device"); | 595 | // outDlg->OutputEdit->append("No such device"); |
594 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 596 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |