-rw-r--r-- | noncore/tools/formatter/formatter.cpp | 172 |
1 files changed, 85 insertions, 87 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp index bd0bb01..2b8ce7f 100644 --- a/noncore/tools/formatter/formatter.cpp +++ b/noncore/tools/formatter/formatter.cpp | |||
@@ -1,19 +1,19 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** formatter.cpp | 2 | ** formatter.cpp |
3 | ** | 3 | ** |
4 | ** Copyright: Thu Apr 11 11:01:13 2002 | 4 | ** Copyright: Thu Apr 11 11:01:13 2002 |
5 | ** by: L. J. Potter | 5 | ** by: L. J. Potter |
6 | ** | 6 | ** |
7 | ****************************************************************************/ | 7 | ****************************************************************************/ |
8 | 8 | ||
9 | #include "formatter.h" | 9 | #include "formatter.h" |
10 | #include "inputDialog.h" | 10 | #include "inputDialog.h" |
11 | #include "output.h" | 11 | #include "output.h" |
12 | 12 | ||
13 | #include <qpe/qpemenubar.h> | 13 | #include <qpe/qpemenubar.h> |
14 | #include <qpe/qpetoolbar.h> | 14 | #include <qpe/qpetoolbar.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> |
@@ -44,139 +44,137 @@ | |||
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <sys/vfs.h> | 47 | #include <sys/vfs.h> |
48 | #include <mntent.h> | 48 | #include <mntent.h> |
49 | #include <string.h> | 49 | #include <string.h> |
50 | #include <errno.h> | 50 | #include <errno.h> |
51 | 51 | ||
52 | #define BLANK ' ' | 52 | #define BLANK ' ' |
53 | #define DELIMITER '#' | 53 | #define DELIMITER '#' |
54 | 54 | ||
55 | /* | 55 | /* |
56 | Blah blah blah blah */ | 56 | Blah blah blah blah */ |
57 | FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) | 57 | FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) |
58 | : QMainWindow( parent, name, fl ) | 58 | : QMainWindow( parent, name, fl ) |
59 | // : QDialog( parent, name, modal, fl ) | 59 | // : QDialog( parent, name, modal, fl ) |
60 | { | 60 | { |
61 | if ( !name ) | 61 | if ( !name ) |
62 | setName( "FormatterApp" ); | 62 | setName( "FormatterApp" ); |
63 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 63 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
64 | 64 | ||
65 | setCaption( tr( "Formatter" ) ); | 65 | setCaption( tr( "Formatter" ) ); |
66 | FormatterAppLayout = new QGridLayout( this ); | 66 | FormatterAppLayout = new QGridLayout( this ); |
67 | FormatterAppLayout->setSpacing( 2); | 67 | FormatterAppLayout->setSpacing( 2); |
68 | FormatterAppLayout->setMargin( 2 ); | 68 | FormatterAppLayout->setMargin( 2 ); |
69 | 69 | ||
70 | TabWidget = new QTabWidget( this, "TabWidget" ); | 70 | TabWidget = new QTabWidget( this, "TabWidget" ); |
71 | 71 | ||
72 | tab = new QWidget( TabWidget, "tab" ); | 72 | tab = new QWidget( TabWidget, "tab" ); |
73 | tabLayout = new QGridLayout( tab ); | 73 | tabLayout = new QGridLayout( tab ); |
74 | tabLayout->setSpacing( 6); | 74 | tabLayout->setSpacing( 3); |
75 | tabLayout->setMargin( 11); | 75 | tabLayout->setMargin( 2); |
76 | 76 | ||
77 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); | 77 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); |
78 | storageComboBox->setMaximumWidth(220); | ||
78 | 79 | ||
79 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1 ); | 80 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 0 ); |
80 | 81 | ||
81 | TextLabel4 = new QLabel( tab, "TextLabel4" ); | 82 | TextLabel4 = new QLabel( tab, "TextLabel4" ); |
82 | TextLabel4->setText( tr( "Storage Type" ) ); | 83 | TextLabel4->setText( tr( "Storage Type" ) ); |
83 | 84 | ||
84 | tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1 ); | 85 | tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 0 ); |
85 | 86 | ||
86 | TextLabel2 = new QLabel( tab, "TextLabel2" ); | 87 | TextLabel2 = new QLabel( tab, "TextLabel2" ); |
87 | TextLabel2->setText( tr( "File Systems" ) ); | 88 | TextLabel2->setText( tr( "File Systems" ) ); |
88 | 89 | ||
89 | tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1 ); | 90 | tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 0 ); |
90 | 91 | ||
91 | fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); | 92 | fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); |
93 | fileSystemsCombo->setMaximumWidth(220); | ||
92 | 94 | ||
93 | tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1 ); | 95 | tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 0 ); |
94 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 96 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); |
95 | tabLayout->addItem( spacer, 2, 1 ); | 97 | tabLayout->addItem( spacer, 2, 0 ); |
96 | 98 | ||
97 | formatPushButton = new QPushButton( tab, "formatPushButton" ); | 99 | formatPushButton = new QPushButton( tab, "formatPushButton" ); |
98 | formatPushButton->setText( tr( "Format" ) ); | 100 | formatPushButton->setText( tr( "Format" ) ); |
99 | 101 | formatPushButton->setMaximumWidth(170); | |
100 | tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1 ); | 102 | |
101 | QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 103 | tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 0 ); |
104 | QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); | ||
102 | tabLayout->addItem( spacer_2, 5, 0 ); | 105 | tabLayout->addItem( spacer_2, 5, 0 ); |
103 | TabWidget->insertTab( tab, tr( "Main" ) ); | 106 | TabWidget->insertTab( tab, tr( "Main" ) ); |
104 | 107 | ||
105 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 108 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
106 | tabLayout_2 = new QGridLayout( tab_2 ); | 109 | tabLayout_2 = new QGridLayout( tab_2 ); |
107 | tabLayout_2->setSpacing( 6); | 110 | tabLayout_2->setSpacing(3); |
108 | tabLayout_2->setMargin( 11); | 111 | tabLayout_2->setMargin(2); |
109 | 112 | ||
110 | mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); | 113 | mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); |
111 | 114 | ||
112 | tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1 ); | 115 | tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 0 ); |
113 | 116 | ||
114 | deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); | 117 | deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); |
115 | 118 | ||
116 | tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1 ); | 119 | tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 0 ); |
117 | 120 | ||
118 | TextLabel5 = new QLabel( tab_2, "TextLabel5" ); | 121 | TextLabel5 = new QLabel( tab_2, "TextLabel5" ); |
119 | TextLabel5->setText( tr( "CAUTION:\n" | 122 | TextLabel5->setText( tr( "CAUTION:\n" |
120 | "Changing parameters on this \n" | 123 | "Changing parameters on this \n" |
121 | "page may cause your system \n" | 124 | "page may cause your system \n" |
122 | "to stop functioning properly!!" ) );//idiot message | 125 | "to stop functioning properly!!" ) );//idiot message |
123 | 126 | ||
124 | tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1 ); | 127 | tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 0 ); |
125 | 128 | ||
126 | editPushButton = new QPushButton( tab_2, "editPushButton" ); | 129 | editPushButton = new QPushButton( tab_2, "editPushButton" ); |
127 | editPushButton->setText( tr( "Edit fstab" ) ); | 130 | editPushButton->setText( tr( "Edit fstab" ) ); |
128 | 131 | ||
129 | tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); | 132 | tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); |
130 | 133 | ||
131 | fsckButton = new QPushButton( tab_2, "fsckPushButton" ); | 134 | fsckButton = new QPushButton( tab_2, "fsckPushButton" ); |
132 | fsckButton->setText( tr( "Check Disk" ) ); | 135 | fsckButton->setText( tr( "Check Disk" ) ); |
133 | 136 | ||
134 | tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1 ); | 137 | tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 0 ); |
135 | 138 | ||
136 | TextLabel3 = new QLabel( tab_2, "TextLabel3" ); | 139 | TextLabel3 = new QLabel( tab_2, "TextLabel3" ); |
137 | TextLabel3->setText( tr( "Device" ) ); | 140 | TextLabel3->setText( tr( "Device" ) ); |
138 | 141 | ||
139 | tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); | 142 | tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 0 ); |
140 | QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 143 | QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
141 | tabLayout_2->addItem( spacer_3, 5, 0 ); | 144 | tabLayout_2->addItem( spacer_3, 5, 0 ); |
142 | 145 | ||
143 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); | 146 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); |
144 | TextLabel1->setText( tr( "Mount Point" ) ); | 147 | TextLabel1->setText( tr( "Mount Point" ) ); |
145 | 148 | ||
146 | tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); | 149 | tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 0 ); |
147 | QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 150 | QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
148 | tabLayout_2->addItem( spacer_4, 2, 1 ); | 151 | tabLayout_2->addItem( spacer_4, 2, 1 ); |
149 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); | 152 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); |
150 | 153 | ||
151 | FormatterAppLayout->addWidget( TabWidget, 0, 0 ); | 154 | FormatterAppLayout->addWidget( TabWidget, 0, 0 ); |
152 | 155 | ||
153 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); | 156 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); |
154 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); | 157 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); |
155 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); | 158 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); |
156 | 159 | ||
157 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); | 160 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); |
158 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); | 161 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); |
159 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); | 162 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); |
160 | 163 | ||
161 | 164 | ||
162 | fillCombos(); | 165 | fillCombos(); |
163 | } | 166 | } |
164 | 167 | ||
165 | /* | 168 | FormatterApp::~FormatterApp() { |
166 | * Destroys the object and frees any allocated resources | ||
167 | frickin no duh?!? | ||
168 | */ | ||
169 | FormatterApp::~FormatterApp() | ||
170 | { | ||
171 | 169 | ||
172 | } | 170 | } |
173 | 171 | ||
174 | void FormatterApp::doFormat() { | 172 | void FormatterApp::doFormat() { |
175 | int err=0; | 173 | int err=0; |
176 | Output *outDlg; | 174 | Output *outDlg; |
177 | QString umountS, remountS; | 175 | QString umountS, remountS; |
178 | QString text = storageComboBox->currentText(); | 176 | QString text = storageComboBox->currentText(); |
179 | QString currentText = storageComboBox->currentText(); | 177 | QString currentText = storageComboBox->currentText(); |
180 | QString cmd; | 178 | QString cmd; |
181 | QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | 179 | QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); |
182 | QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); | 180 | QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); |
@@ -317,50 +315,50 @@ void FormatterApp::fillCombos() { | |||
317 | QListIterator<FileSystem> it ( fs ); | 315 | QListIterator<FileSystem> it ( fs ); |
318 | QString storage; | 316 | QString storage; |
319 | for( ; it.current(); ++it ){ | 317 | for( ; it.current(); ++it ){ |
320 | const QString name = (*it)->name(); | 318 | const QString name = (*it)->name(); |
321 | const QString path = (*it)->path(); | 319 | const QString path = (*it)->path(); |
322 | const QString disk = (*it)->disk(); | 320 | const QString disk = (*it)->disk(); |
323 | const QString options = (*it)->options(); | 321 | const QString options = (*it)->options(); |
324 | if( name.find( tr("Internal"),0,TRUE) == -1) { | 322 | if( name.find( tr("Internal"),0,TRUE) == -1) { |
325 | storageComboBox->insertItem(name +" -> "+disk); | 323 | storageComboBox->insertItem(name +" -> "+disk); |
326 | } | 324 | } |
327 | // deviceComboBox->insertItem(disk); | 325 | // deviceComboBox->insertItem(disk); |
328 | } | 326 | } |
329 | parsetab("/etc/mtab"); | 327 | parsetab("/etc/mtab"); |
330 | // parsetab("/etc/fstab"); | 328 | // parsetab("/etc/fstab"); |
331 | fileSystemsCombo->insertStringList( fsList,-1); | 329 | fileSystemsCombo->insertStringList( fsList,-1); |
332 | deviceComboBox->insertStringList( deviceList,-1); | 330 | deviceComboBox->insertStringList( deviceList,-1); |
333 | storageComboSelected(0); | 331 | storageComboSelected(0); |
334 | deviceComboSelected(0); | 332 | deviceComboSelected(0); |
335 | } | 333 | } |
336 | 334 | ||
337 | 335 | ||
338 | void FormatterApp::fsComboSelected(int index) { | 336 | void FormatterApp::fsComboSelected(int index) { |
339 | 337 | ||
340 | } | 338 | } |
341 | 339 | ||
342 | void FormatterApp::storageComboSelected(int index ) { | 340 | void FormatterApp::storageComboSelected(int index ) { |
343 | 341 | ||
344 | QString currentText = storageComboBox->text(index); | 342 | QString currentText = storageComboBox->text(index); |
345 | QString nameS = currentText.left( currentText.find("->",0,TRUE)); | 343 | QString nameS = currentText.left( currentText.find("->",0,TRUE)); |
346 | 344 | ||
347 | TextLabel4->setText( tr( "Storage Type : ") + nameS ); | 345 | TextLabel4->setText( tr( "Storage Type : ") + nameS ); |
348 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | 346 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); |
349 | 347 | ||
350 | QString fsType = getFileSystemType((const QString &) currentText); | 348 | QString fsType = getFileSystemType((const QString &) currentText); |
351 | // qDebug(fsType); | 349 | // qDebug(fsType); |
352 | for(int i = 0; i < fileSystemsCombo->count(); i++) { | 350 | for(int i = 0; i < fileSystemsCombo->count(); i++) { |
353 | if( fsType == fileSystemsCombo->text(i)) | 351 | if( fsType == fileSystemsCombo->text(i)) |
354 | fileSystemsCombo->setCurrentItem(i); | 352 | fileSystemsCombo->setCurrentItem(i); |
355 | } | 353 | } |
356 | // deviceComboSelected(index); | 354 | // deviceComboSelected(index); |
357 | } | 355 | } |
358 | 356 | ||
359 | void FormatterApp::deviceComboSelected(int index) { | 357 | void FormatterApp::deviceComboSelected(int index) { |
360 | 358 | ||
361 | StorageInfo storageInfo; | 359 | StorageInfo storageInfo; |
362 | QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; | 360 | QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; |
363 | 361 | ||
364 | selectedText = deviceComboBox->text(index); | 362 | selectedText = deviceComboBox->text(index); |
365 | 363 | ||
366 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 364 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
@@ -382,25 +380,25 @@ void FormatterApp::deviceComboSelected(int index) { | |||
382 | long totalMb = total/1024; | 380 | long totalMb = total/1024; |
383 | long avail = (*it)->availBlocks() * mult / div; | 381 | long avail = (*it)->availBlocks() * mult / div; |
384 | long availMb = avail/1024; | 382 | long availMb = avail/1024; |
385 | long used = total - avail; | 383 | long used = total - avail; |
386 | long usedMb = used/1024; | 384 | long usedMb = used/1024; |
387 | totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); | 385 | totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); |
388 | usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); | 386 | usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); |
389 | avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); | 387 | avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); |
390 | } | 388 | } |
391 | } | 389 | } |
392 | fsType = getFileSystemType((const QString &)selectedText); | 390 | fsType = getFileSystemType((const QString &)selectedText); |
393 | 391 | ||
394 | TextLabel5->setText("Type: "+ nameS+" Formatted with "+ fsType + " \n" + totalS + usedS + avS); | 392 | TextLabel5->setText("Type: "+ nameS+"\nFormatted with "+ fsType + " \n" + totalS + usedS + avS); |
395 | // storageComboSelected(0); | 393 | // storageComboSelected(0); |
396 | } | 394 | } |
397 | 395 | ||
398 | void FormatterApp::cleanUp() { | 396 | void FormatterApp::cleanUp() { |
399 | 397 | ||
400 | } | 398 | } |
401 | 399 | ||
402 | 400 | ||
403 | void FormatterApp::editFstab() { | 401 | void FormatterApp::editFstab() { |
404 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); | 402 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); |
405 | e << (const QString &)"/etc/fstab"; | 403 | e << (const QString &)"/etc/fstab"; |
406 | } | 404 | } |
@@ -412,25 +410,25 @@ void FormatterApp::parsetab(const QString &fileName) { | |||
412 | struct mntent *me; | 410 | struct mntent *me; |
413 | // if(fileName == "/etc/mtab") { | 411 | // if(fileName == "/etc/mtab") { |
414 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 412 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
415 | if ( mntfp ) { | 413 | if ( mntfp ) { |
416 | while ( (me = getmntent( mntfp )) != 0 ) { | 414 | while ( (me = getmntent( mntfp )) != 0 ) { |
417 | QString deviceName = me->mnt_fsname; | 415 | QString deviceName = me->mnt_fsname; |
418 | QString filesystemType = me->mnt_type; | 416 | QString filesystemType = me->mnt_type; |
419 | if(deviceName != "none") { | 417 | if(deviceName != "none") { |
420 | if( fsList.contains(filesystemType) == 0 | 418 | if( fsList.contains(filesystemType) == 0 |
421 | & filesystemType.find("proc",0,TRUE) == -1 | 419 | & filesystemType.find("proc",0,TRUE) == -1 |
422 | & filesystemType.find("cramfs",0,TRUE) == -1 | 420 | & filesystemType.find("cramfs",0,TRUE) == -1 |
423 | & filesystemType.find("auto",0,TRUE) == -1) | 421 | & filesystemType.find("auto",0,TRUE) == -1) |
424 | fsList << filesystemType; | 422 | fsList << filesystemType; |
425 | deviceList << deviceName; | 423 | deviceList << deviceName; |
426 | qDebug(deviceName+"::"+filesystemType); | 424 | qDebug(deviceName+"::"+filesystemType); |
427 | fileSystemTypeList << deviceName+"::"+filesystemType; | 425 | fileSystemTypeList << deviceName+"::"+filesystemType; |
428 | } | 426 | } |
429 | } | 427 | } |
430 | } | 428 | } |
431 | endmntent( mntfp ); | 429 | endmntent( mntfp ); |
432 | // } else if(fileName == "/etc/fstab") { | 430 | // } else if(fileName == "/etc/fstab") { |
433 | // QFile f("/etc/fstab"); | 431 | // QFile f("/etc/fstab"); |
434 | // if ( f.open(IO_ReadOnly) ) { | 432 | // if ( f.open(IO_ReadOnly) ) { |
435 | // QTextStream t (&f); | 433 | // QTextStream t (&f); |
436 | // QString s; | 434 | // QString s; |
@@ -481,82 +479,82 @@ bool FormatterApp::doFsck() { | |||
481 | QString remountS = "mount -v /floppy 2>&1"; | 479 | QString remountS = "mount -v /floppy 2>&1"; |
482 | selectedDevice ="/dev/fd0"; | 480 | selectedDevice ="/dev/fd0"; |
483 | 481 | ||
484 | #endif | 482 | #endif |
485 | 483 | ||
486 | QString fsType = getFileSystemType((const QString &)selectedDevice); | 484 | QString fsType = getFileSystemType((const QString &)selectedDevice); |
487 | QString cmd; | 485 | QString cmd; |
488 | qDebug( selectedDevice +" "+ fsType); | 486 | qDebug( selectedDevice +" "+ fsType); |
489 | if(fsType == "vfat") cmd = "dosfsck -vy "; | 487 | if(fsType == "vfat") cmd = "dosfsck -vy "; |
490 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; | 488 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; |
491 | cmd += selectedDevice + " 2>&1"; | 489 | cmd += selectedDevice + " 2>&1"; |
492 | 490 | ||
493 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | 491 | outDlg = new Output(this, tr("Formatter Output"),FALSE); |
494 | outDlg->showMaximized(); | 492 | outDlg->showMaximized(); |
495 | outDlg->show(); | 493 | outDlg->show(); |
496 | qApp->processEvents(); | 494 | qApp->processEvents(); |
497 | FILE *fp; | 495 | FILE *fp; |
498 | char line[130]; | 496 | char line[130]; |
499 | outDlg->OutputEdit->append( tr("Trying to umount.")); | 497 | outDlg->OutputEdit->append( tr("Trying to umount.")); |
500 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 498 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
501 | 499 | ||
502 | sleep(1); | 500 | sleep(1); |
503 | // qDebug("Command is "+umountS); | 501 | // qDebug("Command is "+umountS); |
504 | fp = popen( (const char *) umountS, "r"); | 502 | fp = popen( (const char *) umountS, "r"); |
505 | // qDebug("%d", fp); | 503 | // qDebug("%d", fp); |
506 | if ( !fp ) { | 504 | if ( !fp ) { |
507 | qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); | 505 | qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); |
508 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); | 506 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); |
509 | pclose(fp); | 507 | pclose(fp); |
510 | return false; | 508 | return false; |
511 | } else { | 509 | } else { |
512 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); | 510 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); |
513 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 511 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
514 | while ( fgets( line, sizeof line, fp)) { | 512 | while ( fgets( line, sizeof line, fp)) { |
515 | if( ((QString)line).find("busy",0,TRUE) != -1) { | 513 | if( ((QString)line).find("busy",0,TRUE) != -1) { |
516 | qDebug("Could not find '" + umountS); | 514 | qDebug("Could not find '" + umountS); |
517 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); | 515 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); |
518 | pclose(fp); | 516 | pclose(fp); |
519 | return false; | 517 | return false; |
520 | } else { | 518 | } else { |
521 | QString lineStr = line; | 519 | QString lineStr = line; |
522 | lineStr=lineStr.left(lineStr.length()-1); | 520 | lineStr=lineStr.left(lineStr.length()-1); |
523 | outDlg->OutputEdit->append(lineStr); | 521 | outDlg->OutputEdit->append(lineStr); |
524 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 522 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
525 | } | 523 | } |
526 | } | 524 | } |
527 | } | 525 | } |
528 | pclose(fp); | 526 | pclose(fp); |
529 | ///////////////////////////////////// | 527 | ///////////////////////////////////// |
530 | fp = popen( (const char *) cmd, "r"); | 528 | fp = popen( (const char *) cmd, "r"); |
531 | while ( fgets( line, sizeof line, fp)) { | 529 | while ( fgets( line, sizeof line, fp)) { |
532 | if( ((QString)line).find("No such device",0,TRUE) != -1) { | 530 | if( ((QString)line).find("No such device",0,TRUE) != -1) { |
533 | qDebug("No such device '" + umountS); | 531 | qDebug("No such device '" + umountS); |
534 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); | 532 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); |
535 | pclose(fp); | 533 | pclose(fp); |
536 | // outDlg->OutputEdit->append("No such device"); | 534 | // outDlg->OutputEdit->append("No such device"); |
537 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 535 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
538 | return false; | 536 | return false; |
539 | } else { | 537 | } else { |
540 | QString lineStr = line; | 538 | QString lineStr = line; |
541 | lineStr=lineStr.left(lineStr.length()-1); | 539 | lineStr=lineStr.left(lineStr.length()-1); |
542 | outDlg->OutputEdit->append(lineStr); | 540 | outDlg->OutputEdit->append(lineStr); |
543 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 541 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
544 | } | 542 | } |
545 | } | 543 | } |
546 | outDlg->OutputEdit->append(tr("You can now close the output window.")); | 544 | outDlg->OutputEdit->append(tr("You can now close the output window.")); |
547 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 545 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
548 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); | 546 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); |
549 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 547 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
550 | pclose(fp); | 548 | pclose(fp); |
551 | 549 | ||
552 | ///////////////////////////////////////// | 550 | ///////////////////////////////////////// |
553 | 551 | ||
554 | return true; | 552 | return true; |
555 | } | 553 | } |
556 | 554 | ||
557 | bool FormatterApp::doFsckCheck() { | 555 | bool FormatterApp::doFsckCheck() { |
558 | 556 | ||
559 | return FALSE; | 557 | return FALSE; |
560 | } | 558 | } |
561 | 559 | ||
562 | int FormatterApp::formatCheck(const QString &deviceStr) { | 560 | int FormatterApp::formatCheck(const QString &deviceStr) { |