summaryrefslogtreecommitdiff
path: root/noncore/tools/formatter/formatter.cpp
Unidiff
Diffstat (limited to 'noncore/tools/formatter/formatter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/formatter/formatter.cpp174
1 files changed, 111 insertions, 63 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index 532ee40..e869317 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -12,3 +12,3 @@
12 12
13#include <qmenubar.h> 13/* OPIE */
14#include <qpe/qpetoolbar.h> 14#include <qpe/qpetoolbar.h>
@@ -21,2 +21,4 @@
21 21
22/* QT */
23#include <qmenubar.h>
22#include <qmultilineedit.h> 24#include <qmultilineedit.h>
@@ -27,5 +29,3 @@
27#include <qfile.h> 29#include <qfile.h>
28
29#include <qtstream.h> 30#include <qtstream.h>
30
31#include <qcombobox.h> 31#include <qcombobox.h>
@@ -34,3 +34,2 @@
34#include <qregexp.h> 34#include <qregexp.h>
35
36#include <qlabel.h> 35#include <qlabel.h>
@@ -43,2 +42,3 @@
43 42
43/* STD */
44#include <unistd.h> 44#include <unistd.h>
@@ -170,7 +170,7 @@ FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool
170 170
171FormatterApp::~FormatterApp() { 171FormatterApp::~FormatterApp()
172 172{}
173}
174 173
175void FormatterApp::doFormat() { 174void FormatterApp::doFormat()
175{
176 int err=0; 176 int err=0;
@@ -192,3 +192,4 @@ void FormatterApp::doFormat() {
192 192
193 if( currentText.find("CF",0,TRUE) != -1) { 193 if( currentText.find("CF",0,TRUE) != -1)
194 {
194 umountS = "umount "; 195 umountS = "umount ";
@@ -199,3 +200,4 @@ void FormatterApp::doFormat() {
199 } 200 }
200 if( currentText.find("SD",0,TRUE) != -1) { 201 if( currentText.find("SD",0,TRUE) != -1)
202 {
201 umountS = "umount "; 203 umountS = "umount ";
@@ -213,4 +215,6 @@ void FormatterApp::doFormat() {
213 ,1 215 ,1
214 ,1) ) { 216 ,1) )
215 case 0: { 217 {
218 case 0:
219 {
216 if(fs == "vfat") 220 if(fs == "vfat")
@@ -219,3 +223,4 @@ void FormatterApp::doFormat() {
219 cmd = "mke2fs -v " + diskDevice+" 2>&1"; 223 cmd = "mke2fs -v " + diskDevice+" 2>&1";
220 else { 224 else
225 {
221 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); 226 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok"));
@@ -225,4 +230,3 @@ void FormatterApp::doFormat() {
225 outDlg = new Output(this, tr("Formatter Output"),FALSE); 230 outDlg = new Output(this, tr("Formatter Output"),FALSE);
226 outDlg->showMaximized(); 231 QPEApplication::showDialog( outDlg);
227 outDlg->show();
228 qApp->processEvents(); 232 qApp->processEvents();
@@ -239,3 +243,4 @@ void FormatterApp::doFormat() {
239 // qDebug("%d", fp); 243 // qDebug("%d", fp);
240 if ( !fp ) { 244 if ( !fp )
245 {
241 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); 246 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err);
@@ -244,7 +249,11 @@ void FormatterApp::doFormat() {
244 return; 249 return;
245 } else { 250 }
251 else
252 {
246// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 253// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
247// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 254// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
248 while ( fgets( line, sizeof line, fp)) { 255 while ( fgets( line, sizeof line, fp))
249 if( ((QString)line).find("busy",0,TRUE) != -1) { 256 {
257 if( ((QString)line).find("busy",0,TRUE) != -1)
258 {
250 qDebug("Could not find '" + umountS); 259 qDebug("Could not find '" + umountS);
@@ -253,3 +262,5 @@ void FormatterApp::doFormat() {
253 return; 262 return;
254 } else { 263 }
264 else
265 {
255 QString lineStr = line; 266 QString lineStr = line;
@@ -268,4 +279,6 @@ void FormatterApp::doFormat() {
268 fp = popen( (const char *) cmd, "r"); 279 fp = popen( (const char *) cmd, "r");
269 while ( fgets( line, sizeof line, fp)) { 280 while ( fgets( line, sizeof line, fp))
270 if( ((QString)line).find("No such device",0,TRUE) != -1) { 281 {
282 if( ((QString)line).find("No such device",0,TRUE) != -1)
283 {
271 qDebug("No such device '" + umountS); 284 qDebug("No such device '" + umountS);
@@ -276,3 +289,5 @@ void FormatterApp::doFormat() {
276 return; 289 return;
277 } else { 290 }
291 else
292 {
278 QString lineStr = line; 293 QString lineStr = line;
@@ -290,3 +305,4 @@ void FormatterApp::doFormat() {
290 fp = popen( (const char *) remountS, "r"); 305 fp = popen( (const char *) remountS, "r");
291 if ( !fp) { 306 if ( !fp)
307 {
292 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); 308 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err);
@@ -294,5 +310,8 @@ void FormatterApp::doFormat() {
294 310
295 } else { 311 }
312 else
313 {
296 outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText )); 314 outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText ));
297 while ( fgets( line, sizeof line, fp)) { 315 while ( fgets( line, sizeof line, fp))
316 {
298 QString lineStr = line; 317 QString lineStr = line;
@@ -316,3 +335,4 @@ void FormatterApp::doFormat() {
316 335
317bool FormatterApp::doFdisk() { 336bool FormatterApp::doFdisk()
337{
318 return FALSE; 338 return FALSE;
@@ -321,3 +341,4 @@ bool FormatterApp::doFdisk() {
321 341
322void FormatterApp::fillCombos() { 342void FormatterApp::fillCombos()
343{
323 344
@@ -327,3 +348,4 @@ void FormatterApp::fillCombos() {
327 QString storage; 348 QString storage;
328 for( ; it.current(); ++it ){ 349 for( ; it.current(); ++it )
350 {
329 const QString name = (*it)->name(); 351 const QString name = (*it)->name();
@@ -332,3 +354,4 @@ void FormatterApp::fillCombos() {
332 const QString options = (*it)->options(); 354 const QString options = (*it)->options();
333 if( name.find( tr("Internal"),0,TRUE) == -1) { 355 if( name.find( tr("Internal"),0,TRUE) == -1)
356 {
334 storageComboBox->insertItem(name +" -> "+disk); 357 storageComboBox->insertItem(name +" -> "+disk);
@@ -346,7 +369,7 @@ void FormatterApp::fillCombos() {
346 369
347void FormatterApp::fsComboSelected(int ) { 370void FormatterApp::fsComboSelected(int )
371{}
348 372
349} 373void FormatterApp::storageComboSelected(int index )
350 374{
351void FormatterApp::storageComboSelected(int index ) {
352 375
@@ -360,3 +383,4 @@ void FormatterApp::storageComboSelected(int index ) {
360// qDebug(fsType); 383// qDebug(fsType);
361 for(int i = 0; i < fileSystemsCombo->count(); i++) { 384 for(int i = 0; i < fileSystemsCombo->count(); i++)
385 {
362 if( fsType == fileSystemsCombo->text(i)) 386 if( fsType == fileSystemsCombo->text(i))
@@ -367,3 +391,4 @@ void FormatterApp::storageComboSelected(int index ) {
367 391
368void FormatterApp::deviceComboSelected(int index) { 392void FormatterApp::deviceComboSelected(int index)
393{
369 394
@@ -377,3 +402,4 @@ void FormatterApp::deviceComboSelected(int index) {
377 QString storage; 402 QString storage;
378 for( ; it.current(); ++it ){ 403 for( ; it.current(); ++it )
404 {
379 const QString name = (*it)->name(); 405 const QString name = (*it)->name();
@@ -382,3 +408,4 @@ void FormatterApp::deviceComboSelected(int index) {
382// const QString options = (*it)->options(); 408// const QString options = (*it)->options();
383 if( selectedText == disk) { 409 if( selectedText == disk)
410 {
384 diskS = disk; nameS= name; 411 diskS = disk; nameS= name;
@@ -407,8 +434,8 @@ void FormatterApp::deviceComboSelected(int index) {
407 434
408void FormatterApp::cleanUp() { 435void FormatterApp::cleanUp()
409 436{}
410}
411 437
412 438
413void FormatterApp::editFstab() { 439void FormatterApp::editFstab()
440{
414 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); 441 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)");
@@ -417,3 +444,4 @@ void FormatterApp::editFstab() {
417 444
418void FormatterApp::parsetab(const QString &fileName) { 445void FormatterApp::parsetab(const QString &fileName)
446{
419 447
@@ -424,7 +452,10 @@ void FormatterApp::parsetab(const QString &fileName) {
424 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 452 FILE *mntfp = setmntent( fileName.latin1(), "r" );
425 if ( mntfp ) { 453 if ( mntfp )
426 while ( (me = getmntent( mntfp )) != 0 ) { 454 {
455 while ( (me = getmntent( mntfp )) != 0 )
456 {
427 QString deviceName = me->mnt_fsname; 457 QString deviceName = me->mnt_fsname;
428 QString filesystemType = me->mnt_type; 458 QString filesystemType = me->mnt_type;
429 if(deviceName != "none") { 459 if(deviceName != "none")
460 {
430 if( fsList.contains(filesystemType) == 0 461 if( fsList.contains(filesystemType) == 0
@@ -466,3 +497,4 @@ void FormatterApp::parsetab(const QString &fileName) {
466 497
467QString FormatterApp::getFileSystemType(const QString &currentText) { 498QString FormatterApp::getFileSystemType(const QString &currentText)
499{
468 500
@@ -470,5 +502,7 @@ QString FormatterApp::getFileSystemType(const QString &currentText) {
470 502
471 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 503 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it )
504 {
472 QString temp = (*it); 505 QString temp = (*it);
473 if( temp.find( currentText,0,TRUE) != -1) { 506 if( temp.find( currentText,0,TRUE) != -1)
507 {
474 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 508 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
@@ -480,3 +514,4 @@ QString FormatterApp::getFileSystemType(const QString &currentText) {
480 514
481bool FormatterApp::doFsck() { 515bool FormatterApp::doFsck()
516{
482 517
@@ -506,4 +541,3 @@ bool FormatterApp::doFsck() {
506 outDlg = new Output(this, tr("Formatter Output"),FALSE); 541 outDlg = new Output(this, tr("Formatter Output"),FALSE);
507 outDlg->showMaximized(); 542 QPEApplication::showDialog( outDlg );
508 outDlg->show();
509 qApp->processEvents(); 543 qApp->processEvents();
@@ -518,3 +552,4 @@ bool FormatterApp::doFsck() {
518// qDebug("%d", fp); 552// qDebug("%d", fp);
519 if ( !fp ) { 553 if ( !fp )
554 {
520 qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); 555 qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno));
@@ -523,7 +558,11 @@ bool FormatterApp::doFsck() {
523 return false; 558 return false;
524 } else { 559 }
560 else
561 {
525// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 562// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
526// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 563// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
527 while ( fgets( line, sizeof line, fp)) { 564 while ( fgets( line, sizeof line, fp))
528 if( ((QString)line).find("busy",0,TRUE) != -1) { 565 {
566 if( ((QString)line).find("busy",0,TRUE) != -1)
567 {
529 qDebug("Could not find '" + umountS); 568 qDebug("Could not find '" + umountS);
@@ -533,3 +572,5 @@ bool FormatterApp::doFsck() {
533 return false; 572 return false;
534 } else { 573 }
574 else
575 {
535 QString lineStr = line; 576 QString lineStr = line;
@@ -544,4 +585,6 @@ bool FormatterApp::doFsck() {
544 fp = popen( (const char *) cmd, "r"); 585 fp = popen( (const char *) cmd, "r");
545 while ( fgets( line, sizeof line, fp)) { 586 while ( fgets( line, sizeof line, fp))
546 if( ((QString)line).find("No such device",0,TRUE) != -1) { 587 {
588 if( ((QString)line).find("No such device",0,TRUE) != -1)
589 {
547 qDebug("No such device '" + umountS); 590 qDebug("No such device '" + umountS);
@@ -552,3 +595,5 @@ bool FormatterApp::doFsck() {
552 return false; 595 return false;
553 } else { 596 }
597 else
598 {
554 QString lineStr = line; 599 QString lineStr = line;
@@ -570,3 +615,4 @@ bool FormatterApp::doFsck() {
570 615
571bool FormatterApp::doFsckCheck() { 616bool FormatterApp::doFsckCheck()
617{
572 618
@@ -575,3 +621,4 @@ bool FormatterApp::doFsckCheck() {
575 621
576int FormatterApp::formatCheck(const QString &) { 622int FormatterApp::formatCheck(const QString &)
623{
577 624
@@ -580,3 +627,4 @@ int FormatterApp::formatCheck(const QString &) {
580 627
581int FormatterApp::runCommand(const QString &) { 628int FormatterApp::runCommand(const QString &)
629{
582 630