summaryrefslogtreecommitdiff
path: root/noncore/tools/formatter/formatter.cpp
Unidiff
Diffstat (limited to 'noncore/tools/formatter/formatter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/formatter/formatter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index 21de4d2..49f6355 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -307,193 +307,194 @@ void FormatterApp::doFormat() {
307 outDlg->OutputEdit->append(tr("You can now close the output window.")); 307 outDlg->OutputEdit->append(tr("You can now close the output window."));
308 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 308 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
309// outDlg->close(); 309// outDlg->close();
310// if(outDlg) 310// if(outDlg)
311// delete outDlg; 311// delete outDlg;
312 } 312 }
313 break; 313 break;
314 }; 314 };
315} 315}
316 316
317bool FormatterApp::doFdisk() { 317bool FormatterApp::doFdisk() {
318 return FALSE; 318 return FALSE;
319 319
320} 320}
321 321
322void FormatterApp::fillCombos() { 322void FormatterApp::fillCombos() {
323 323
324 StorageInfo storageInfo; 324 StorageInfo storageInfo;
325 const QList<FileSystem> &fs = storageInfo.fileSystems(); 325 const QList<FileSystem> &fs = storageInfo.fileSystems();
326 QListIterator<FileSystem> it ( fs ); 326 QListIterator<FileSystem> it ( fs );
327 QString storage; 327 QString storage;
328 for( ; it.current(); ++it ){ 328 for( ; it.current(); ++it ){
329 const QString name = (*it)->name(); 329 const QString name = (*it)->name();
330 const QString path = (*it)->path(); 330 const QString path = (*it)->path();
331 const QString disk = (*it)->disk(); 331 const QString disk = (*it)->disk();
332 const QString options = (*it)->options(); 332 const QString options = (*it)->options();
333 if( name.find( tr("Internal"),0,TRUE) == -1) { 333 if( name.find( tr("Internal"),0,TRUE) == -1) {
334 storageComboBox->insertItem(name +" -> "+disk); 334 storageComboBox->insertItem(name +" -> "+disk);
335 } 335 }
336// deviceComboBox->insertItem(disk); 336// deviceComboBox->insertItem(disk);
337 } 337 }
338 parsetab("/etc/mtab"); 338 parsetab("/etc/mtab");
339// parsetab("/etc/fstab"); 339// parsetab("/etc/fstab");
340 fileSystemsCombo->insertStringList( fsList,-1); 340 fileSystemsCombo->insertStringList( fsList,-1);
341 deviceComboBox->insertStringList( deviceList,-1); 341 deviceComboBox->insertStringList( deviceList,-1);
342 storageComboSelected(0); 342 storageComboSelected(0);
343 deviceComboSelected(0); 343 deviceComboSelected(0);
344} 344}
345 345
346 346
347void FormatterApp::fsComboSelected(int ) { 347void FormatterApp::fsComboSelected(int ) {
348 348
349} 349}
350 350
351void FormatterApp::storageComboSelected(int index ) { 351void FormatterApp::storageComboSelected(int index ) {
352 352
353 QString currentText = storageComboBox->text(index); 353 QString currentText = storageComboBox->text(index);
354 QString nameS = currentText.left( currentText.find("->",0,TRUE)); 354 QString nameS = currentText.left( currentText.find("->",0,TRUE));
355 355
356 TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) ); 356 TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) );
357 currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 357 currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
358 358
359 QString fsType = getFileSystemType((const QString &) currentText); 359 QString fsType = getFileSystemType((const QString &) currentText);
360// qDebug(fsType); 360// qDebug(fsType);
361 for(int i = 0; i < fileSystemsCombo->count(); i++) { 361 for(int i = 0; i < fileSystemsCombo->count(); i++) {
362 if( fsType == fileSystemsCombo->text(i)) 362 if( fsType == fileSystemsCombo->text(i))
363 fileSystemsCombo->setCurrentItem(i); 363 fileSystemsCombo->setCurrentItem(i);
364 } 364 }
365// deviceComboSelected(index); 365// deviceComboSelected(index);
366} 366}
367 367
368void FormatterApp::deviceComboSelected(int index) { 368void FormatterApp::deviceComboSelected(int index) {
369 369
370 StorageInfo storageInfo; 370 StorageInfo storageInfo;
371 QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; 371 QString totalS, usedS, avS, diskS, nameS, fsType, selectedText;
372 372
373 selectedText = deviceComboBox->text(index); 373 selectedText = deviceComboBox->text(index);
374 374
375 const QList<FileSystem> &fs = storageInfo.fileSystems(); 375 const QList<FileSystem> &fs = storageInfo.fileSystems();
376 QListIterator<FileSystem> it ( fs ); 376 QListIterator<FileSystem> it ( fs );
377 QString storage; 377 QString storage;
378 for( ; it.current(); ++it ){ 378 for( ; it.current(); ++it ){
379 const QString name = (*it)->name(); 379 const QString name = (*it)->name();
380 const QString path = (*it)->path(); 380 const QString path = (*it)->path();
381 const QString disk = (*it)->disk(); 381 const QString disk = (*it)->disk();
382// const QString options = (*it)->options(); 382// const QString options = (*it)->options();
383 if( selectedText == disk) { 383 if( selectedText == disk) {
384 diskS = disk; nameS= name; 384 diskS = disk; nameS= name;
385 mountPointLineEdit->setText(path); 385 mountPointLineEdit->setText(path);
386 long mult = (*it)->blockSize() / 1024; 386 long mult = (*it)->blockSize() / 1024;
387 long div = 1024 / (*it)->blockSize(); 387 long div = 1024 / (*it)->blockSize();
388 if ( !mult ) mult = 1; 388 if ( !mult ) mult = 1;
389 if ( !div ) div = 1; 389 if ( !div ) div = 1;
390 long total = (*it)->totalBlocks() * mult / div; 390 long total = (*it)->totalBlocks() * mult / div;
391 long totalMb = total/1024; 391 long totalMb = total/1024;
392 long avail = (*it)->availBlocks() * mult / div; 392 long avail = (*it)->availBlocks() * mult / div;
393 long availMb = avail/1024; 393 long availMb = avail/1024;
394 long used = total - avail; 394 long used = total - avail;
395 long usedMb = used/1024; 395 long usedMb = used/1024;
396 totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); 396 totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb );
397 usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); 397 usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb);
398 avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); 398 avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb );
399 } 399 }
400 } 400 }
401 fsType = getFileSystemType((const QString &)selectedText); 401 fsType = getFileSystemType((const QString &)selectedText);
402 402
403 TextLabel5->setText(tr("Type: %1\nFormatted with %1\n%1, %1, %1").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS )); 403 TextLabel5->setText(tr("Type: %1\nFormatted with %2\n%3, %4, %5").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS ));
404 TextLabel5->setTextFormat( Qt::RichText );
404// storageComboSelected(0); 405// storageComboSelected(0);
405} 406}
406 407
407void FormatterApp::cleanUp() { 408void FormatterApp::cleanUp() {
408 409
409} 410}
410 411
411 412
412void FormatterApp::editFstab() { 413void FormatterApp::editFstab() {
413 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); 414 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)");
414 e << (const QString &)"/etc/fstab"; 415 e << (const QString &)"/etc/fstab";
415} 416}
416 417
417void FormatterApp::parsetab(const QString &fileName) { 418void FormatterApp::parsetab(const QString &fileName) {
418 419
419 fileSystemTypeList.clear(); 420 fileSystemTypeList.clear();
420 fsList.clear(); 421 fsList.clear();
421 struct mntent *me; 422 struct mntent *me;
422// if(fileName == "/etc/mtab") { 423// if(fileName == "/etc/mtab") {
423 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 424 FILE *mntfp = setmntent( fileName.latin1(), "r" );
424 if ( mntfp ) { 425 if ( mntfp ) {
425 while ( (me = getmntent( mntfp )) != 0 ) { 426 while ( (me = getmntent( mntfp )) != 0 ) {
426 QString deviceName = me->mnt_fsname; 427 QString deviceName = me->mnt_fsname;
427 QString filesystemType = me->mnt_type; 428 QString filesystemType = me->mnt_type;
428 if(deviceName != "none") { 429 if(deviceName != "none") {
429 if( fsList.contains(filesystemType) == 0 430 if( fsList.contains(filesystemType) == 0
430 & filesystemType.find("proc",0,TRUE) == -1 431 & filesystemType.find("proc",0,TRUE) == -1
431 & filesystemType.find("cramfs",0,TRUE) == -1 432 & filesystemType.find("cramfs",0,TRUE) == -1
432 & filesystemType.find("auto",0,TRUE) == -1) 433 & filesystemType.find("auto",0,TRUE) == -1)
433 fsList << filesystemType; 434 fsList << filesystemType;
434 deviceList << deviceName; 435 deviceList << deviceName;
435 qDebug(deviceName+"::"+filesystemType); 436 qDebug(deviceName+"::"+filesystemType);
436 fileSystemTypeList << deviceName+"::"+filesystemType; 437 fileSystemTypeList << deviceName+"::"+filesystemType;
437 } 438 }
438 } 439 }
439 } 440 }
440 endmntent( mntfp ); 441 endmntent( mntfp );
441// } else if(fileName == "/etc/fstab") { 442// } else if(fileName == "/etc/fstab") {
442// QFile f("/etc/fstab"); 443// QFile f("/etc/fstab");
443// if ( f.open(IO_ReadOnly) ) { 444// if ( f.open(IO_ReadOnly) ) {
444// QTextStream t (&f); 445// QTextStream t (&f);
445// QString s; 446// QString s;
446// while (! t.eof()) { 447// while (! t.eof()) {
447// s=t.readLine(); 448// s=t.readLine();
448// s=s.simplifyWhiteSpace(); 449// s=s.simplifyWhiteSpace();
449// if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { 450// if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) {
450// // = me->mnt_fsname; 451// // = me->mnt_fsname;
451// QString filesystemType = me->mnt_type; 452// QString filesystemType = me->mnt_type;
452// QString deviceName = s.left(0,s.find(BLANK) ); 453// QString deviceName = s.left(0,s.find(BLANK) );
453// s=s.remove(0,s.find(BLANK)+1 ); // devicename 454// s=s.remove(0,s.find(BLANK)+1 ); // devicename
454 455
455// s=s.remove(0,s.find(BLANK)+1 ); // mountpoint 456// s=s.remove(0,s.find(BLANK)+1 ); // mountpoint
456// QStringt mountPoint= s.left(0,s.find(BLANK) ); 457// QStringt mountPoint= s.left(0,s.find(BLANK) );
457// s=s.remove(0,s.find(BLANK)+1 ); // fs 458// s=s.remove(0,s.find(BLANK)+1 ); // fs
458// QString filesystemType= s.left(0,s.find(BLANK) ); 459// QString filesystemType= s.left(0,s.find(BLANK) );
459// } 460// }
460// } 461// }
461// } 462// }
462// f.close(); 463// f.close();
463// } 464// }
464} 465}
465 466
466QString FormatterApp::getFileSystemType(const QString &currentText) { 467QString FormatterApp::getFileSystemType(const QString &currentText) {
467 468
468 parsetab("/etc/mtab"); //why did TT forget filesystem type? 469 parsetab("/etc/mtab"); //why did TT forget filesystem type?
469 470
470 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 471 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
471 QString temp = (*it); 472 QString temp = (*it);
472 if( temp.find( currentText,0,TRUE) != -1) { 473 if( temp.find( currentText,0,TRUE) != -1) {
473 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 474 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
474// qDebug(fsType); 475// qDebug(fsType);
475 } 476 }
476 } 477 }
477 return ""; 478 return "";
478} 479}
479 480
480bool FormatterApp::doFsck() { 481bool FormatterApp::doFsck() {
481 482
482 Output *outDlg; 483 Output *outDlg;
483 QString selectedDevice; 484 QString selectedDevice;
484// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 485// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
485 selectedDevice = deviceComboBox->currentText(); 486 selectedDevice = deviceComboBox->currentText();
486 QString mountPoint = mountPointLineEdit->text(); 487 QString mountPoint = mountPointLineEdit->text();
487 QString umountS = "umount -v "+mountPoint+" 2>&1"; 488 QString umountS = "umount -v "+mountPoint+" 2>&1";
488 QString remountS = "mount -v "+mountPoint+" 2>&1"; 489 QString remountS = "mount -v "+mountPoint+" 2>&1";
489// #else 490// #else
490// // for testing 491// // for testing
491// // currentText = diskDevice = "/dev/fd0"; 492// // currentText = diskDevice = "/dev/fd0";
492// QString umountS = "umount -v /floppy 2>&1"; 493// QString umountS = "umount -v /floppy 2>&1";
493// QString remountS = "mount -v /floppy 2>&1"; 494// QString remountS = "mount -v /floppy 2>&1";
494// selectedDevice ="/dev/fd0"; 495// selectedDevice ="/dev/fd0";
495 496
496// #endif 497// #endif
497 498
498 QString fsType = getFileSystemType((const QString &)selectedDevice); 499 QString fsType = getFileSystemType((const QString &)selectedDevice);
499 QString cmd; 500 QString cmd;