-rw-r--r-- | noncore/tools/formatter/formatter.cpp | 125 | ||||
-rw-r--r-- | noncore/tools/formatter/formatter.h | 16 |
2 files changed, 108 insertions, 33 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp index 8c8ef2a..0dd42c8 100644 --- a/noncore/tools/formatter/formatter.cpp +++ b/noncore/tools/formatter/formatter.cpp | |||
@@ -17,64 +17,66 @@ | |||
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 | 21 | ||
22 | #include <qmultilineedit.h> | 22 | #include <qmultilineedit.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qlist.h> | 24 | #include <qlist.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | 28 | ||
29 | #include <qtstream.h> | 29 | #include <qtstream.h> |
30 | 30 | ||
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qwidget.h> | 40 | #include <qwidget.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qvariant.h> | 42 | #include <qvariant.h> |
43 | 43 | ||
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> | ||
50 | #include <errno.h> | ||
49 | 51 | ||
50 | #define BLANK ' ' | 52 | #define BLANK ' ' |
51 | #define DELIMITER '#' | 53 | #define DELIMITER '#' |
52 | 54 | ||
53 | /* | 55 | /* |
54 | Blah blah blah blah */ | 56 | Blah blah blah blah */ |
55 | FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) | 57 | FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) |
56 | : QMainWindow( parent, name, fl ) | 58 | : QMainWindow( parent, name, fl ) |
57 | // : QDialog( parent, name, modal, fl ) | 59 | // : QDialog( parent, name, modal, fl ) |
58 | { | 60 | { |
59 | if ( !name ) | 61 | if ( !name ) |
60 | setName( "FormatterApp" ); | 62 | setName( "FormatterApp" ); |
61 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 63 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
62 | 64 | ||
63 | setCaption( tr( "Formatter" ) ); | 65 | setCaption( tr( "Formatter" ) ); |
64 | FormatterAppLayout = new QGridLayout( this ); | 66 | FormatterAppLayout = new QGridLayout( this ); |
65 | FormatterAppLayout->setSpacing( 2); | 67 | FormatterAppLayout->setSpacing( 2); |
66 | FormatterAppLayout->setMargin( 2 ); | 68 | FormatterAppLayout->setMargin( 2 ); |
67 | 69 | ||
68 | TabWidget = new QTabWidget( this, "TabWidget" ); | 70 | TabWidget = new QTabWidget( this, "TabWidget" ); |
69 | 71 | ||
70 | tab = new QWidget( TabWidget, "tab" ); | 72 | tab = new QWidget( TabWidget, "tab" ); |
71 | tabLayout = new QGridLayout( tab ); | 73 | tabLayout = new QGridLayout( tab ); |
72 | tabLayout->setSpacing( 6); | 74 | tabLayout->setSpacing( 6); |
73 | tabLayout->setMargin( 11); | 75 | tabLayout->setMargin( 11); |
74 | 76 | ||
75 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); | 77 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); |
76 | 78 | ||
77 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1 ); | 79 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1 ); |
78 | 80 | ||
79 | TextLabel4 = new QLabel( tab, "TextLabel4" ); | 81 | TextLabel4 = new QLabel( tab, "TextLabel4" ); |
80 | TextLabel4->setText( tr( "Storage Type" ) ); | 82 | TextLabel4->setText( tr( "Storage Type" ) ); |
@@ -146,146 +148,197 @@ FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFla | |||
146 | tabLayout_2->addItem( spacer_4, 2, 1 ); | 148 | tabLayout_2->addItem( spacer_4, 2, 1 ); |
147 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); | 149 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); |
148 | 150 | ||
149 | FormatterAppLayout->addWidget( TabWidget, 0, 0 ); | 151 | FormatterAppLayout->addWidget( TabWidget, 0, 0 ); |
150 | 152 | ||
151 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); | 153 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); |
152 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); | 154 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); |
153 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); | 155 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); |
154 | 156 | ||
155 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); | 157 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); |
156 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); | 158 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); |
157 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); | 159 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); |
158 | 160 | ||
159 | 161 | ||
160 | fillCombos(); | 162 | fillCombos(); |
161 | } | 163 | } |
162 | 164 | ||
163 | /* | 165 | /* |
164 | * Destroys the object and frees any allocated resources | 166 | * Destroys the object and frees any allocated resources |
165 | frickin no duh?!? | 167 | frickin no duh?!? |
166 | */ | 168 | */ |
167 | FormatterApp::~FormatterApp() | 169 | FormatterApp::~FormatterApp() |
168 | { | 170 | { |
169 | 171 | ||
170 | } | 172 | } |
171 | 173 | ||
172 | void FormatterApp::doFormat() { | 174 | void FormatterApp::doFormat() { |
173 | int err=0; | 175 | int err=0; |
174 | Output *outDlg; | 176 | Output *outDlg; |
175 | QString umountS, remountS; | 177 | QString umountS, remountS; |
176 | QString text = storageComboBox->currentText(); | 178 | QString text = storageComboBox->currentText(); |
177 | QString currentText = storageComboBox->currentText(); | 179 | QString currentText = storageComboBox->currentText(); |
178 | QString cmd = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | 180 | QString cmd; |
181 | QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | ||
182 | QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); | ||
179 | QString fs = fileSystemsCombo->currentText(); | 183 | QString fs = fileSystemsCombo->currentText(); |
180 | 184 | ||
185 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap | ||
186 | #else | ||
187 | currentText = diskDevice = "/dev/fd0"; | ||
188 | umountS = "umount -v /floppy 2>&1"; | ||
189 | remountS = "mount -v /floppy 2>&1"; | ||
190 | #endif | ||
191 | |||
181 | if( currentText.find("CF",0,TRUE) != -1) { | 192 | if( currentText.find("CF",0,TRUE) != -1) { |
182 | umountS = "/sbin/cardctl eject"; | 193 | umountS = "umount "; |
183 | remountS = "/sbin/cardctl insert"; | 194 | remountS = "mount "; |
195 | |||
196 | // umountS = "/sbin/cardctl eject"; | ||
197 | // remountS = "/sbin/cardctl insert"; | ||
184 | } | 198 | } |
185 | if( currentText.find("SD",0,TRUE) != -1) { | 199 | if( currentText.find("SD",0,TRUE) != -1) { |
186 | umountS = "/etc/sdcontrol compeject"; | 200 | umountS = "umount "; |
187 | remountS = "/etc/sdcontrol insert"; | 201 | remountS = "mount "; |
202 | // umountS = "/etc/sdcontrol compeject"; | ||
203 | // remountS = "/etc/sdcontrol insert"; | ||
188 | } | 204 | } |
189 | 205 | ||
190 | switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") + currentText + | 206 | switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") +diskName+" "+ currentText + |
191 | tr("\nwith ") + fs + tr(" filesystem?!?"),tr("Yes"),tr("No"),0,1,1) ) { | 207 | tr("\nwith ") + fs + tr(" filesystem?!?\nYou will loose all data!!"),tr("Yes"),tr("No"),0,1,1) ) { |
192 | case 0: { | 208 | case 0: { |
193 | if(fs == "vfat") | 209 | if(fs == "vfat") |
194 | cmd = "mkdosfs " + cmd; | 210 | cmd = "mkdosfs -v " + diskDevice+" 2>&1"; |
195 | else if(fs == "ext2") | 211 | else if(fs == "ext2") |
196 | cmd = "mke2fs " + cmd; | 212 | cmd = "mke2fs -v " + diskDevice+" 2>&1"; |
197 | else { | 213 | else { |
198 | QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); | 214 | QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); |
199 | break; | 215 | break; |
200 | } | 216 | } |
201 | // cmd = "ls -l"; | 217 | // cmd = "ls -l"; |
202 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | 218 | outDlg = new Output(this, tr("Formatter Output"),FALSE); |
203 | outDlg->showMaximized(); | 219 | outDlg->showMaximized(); |
204 | outDlg->show(); | 220 | outDlg->show(); |
205 | qApp->processEvents(); | 221 | qApp->processEvents(); |
206 | FILE *fp; | 222 | FILE *fp; |
207 | char line[130]; | 223 | char line[130]; |
208 | outDlg->OutputEdit->append( tr("Trying to eject.") + currentText ); | 224 | outDlg->OutputEdit->append( tr("Trying to umount.") + currentText ); |
225 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
226 | |||
209 | sleep(1); | 227 | sleep(1); |
210 | fp = popen( (const char *) umountS, "r"); | 228 | qDebug("Command is "+umountS); |
229 | fp = popen( (const char *) umountS, "r"); | ||
230 | qDebug("%d", fp); | ||
211 | if ( !fp ) { | 231 | if ( !fp ) { |
212 | qDebug("Could not execute '" + umountS + "'! err=%d", fp); | 232 | qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); |
213 | QMessageBox::warning( this, tr("CardMonitor"), tr("Card eject failed!"), tr("&OK") ); | 233 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); |
214 | pclose(fp); | 234 | pclose(fp); |
215 | return; | 235 | return; |
216 | } else { | 236 | } else { |
217 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully ejected.")); | 237 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); |
218 | 238 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | |
219 | while ( fgets( line, sizeof line, fp)) { | 239 | while ( fgets( line, sizeof line, fp)) { |
220 | outDlg->OutputEdit->append(line); | 240 | if( ((QString)line).find("busy",0,TRUE) != -1) { |
241 | qDebug("Could not find '" + umountS); | ||
242 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); | ||
243 | pclose(fp); | ||
244 | return; | ||
245 | } else { | ||
246 | QString lineStr = line; | ||
247 | lineStr=lineStr.left(lineStr.length()-1); | ||
248 | outDlg->OutputEdit->append(lineStr); | ||
249 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
250 | } | ||
221 | } | 251 | } |
222 | } | 252 | } |
223 | pclose(fp); | 253 | pclose(fp); |
224 | // err = system( (const char *) umountS); | ||
225 | 254 | ||
226 | qDebug("Command would be: "+cmd); | 255 | qDebug("Command would be: "+cmd); |
227 | outDlg->OutputEdit->append( tr("Trying to format.") ); | 256 | outDlg->OutputEdit->append( tr("Trying to format.") ); |
257 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
228 | 258 | ||
229 | fp = popen( (const char *) cmd, "r"); | 259 | fp = popen( (const char *) cmd, "r"); |
230 | while ( fgets( line, sizeof line, fp)) { | 260 | while ( fgets( line, sizeof line, fp)) { |
231 | outDlg->OutputEdit->append(line); | 261 | if( ((QString)line).find("No such device",0,TRUE) != -1) { |
262 | qDebug("No such device '" + umountS); | ||
263 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); | ||
264 | pclose(fp); | ||
265 | // outDlg->OutputEdit->append("No such device"); | ||
266 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
267 | return; | ||
268 | } else { | ||
269 | QString lineStr = line; | ||
270 | lineStr=lineStr.left(lineStr.length()-1); | ||
271 | outDlg->OutputEdit->append(lineStr); | ||
272 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
273 | } | ||
232 | } | 274 | } |
233 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); | 275 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); |
276 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
234 | pclose(fp); | 277 | pclose(fp); |
235 | 278 | ||
236 | outDlg->OutputEdit->append( tr("Trying to insert.") + currentText ); | 279 | outDlg->OutputEdit->append( tr("Trying to mount.") + currentText ); |
280 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
237 | fp = popen( (const char *) remountS, "r"); | 281 | fp = popen( (const char *) remountS, "r"); |
238 | if ( !fp) { | 282 | if ( !fp) { |
239 | qDebug("Could not execute '" + remountS + "'! err=%d", err); | 283 | qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); |
240 | QMessageBox::warning( this, tr("Formatter"), tr("Card insert failed!"), tr("&OK") ); | 284 | QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); |
241 | 285 | ||
242 | } else { | 286 | } else { |
243 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully inserted.")); | 287 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully mounted.")); |
244 | while ( fgets( line, sizeof line, fp)) { | 288 | while ( fgets( line, sizeof line, fp)) { |
245 | outDlg->OutputEdit->append(line); | 289 | QString lineStr = line; |
290 | lineStr=lineStr.left(lineStr.length()-1); | ||
291 | outDlg->OutputEdit->append(lineStr); | ||
292 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
246 | } | 293 | } |
247 | } | 294 | } |
248 | pclose(fp); | 295 | pclose(fp); |
249 | sleep(1); | 296 | sleep(1); |
250 | 297 | ||
251 | outDlg->OutputEdit->append(tr("You can now close the output window.")); | 298 | outDlg->OutputEdit->append(tr("You can now close the output window.")); |
252 | outDlg->close(); | 299 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
253 | if(outDlg) | 300 | // outDlg->close(); |
254 | delete outDlg; | 301 | // if(outDlg) |
302 | // delete outDlg; | ||
255 | } | 303 | } |
256 | break; | 304 | break; |
257 | }; | 305 | }; |
258 | } | 306 | } |
259 | 307 | ||
308 | bool FormatterApp::doFdisk() { | ||
309 | return FALSE; | ||
310 | |||
311 | } | ||
312 | |||
260 | void FormatterApp::fillCombos() { | 313 | void FormatterApp::fillCombos() { |
261 | 314 | ||
262 | StorageInfo storageInfo; | 315 | StorageInfo storageInfo; |
263 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 316 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
264 | QListIterator<FileSystem> it ( fs ); | 317 | QListIterator<FileSystem> it ( fs ); |
265 | QString storage; | 318 | QString storage; |
266 | for( ; it.current(); ++it ){ | 319 | for( ; it.current(); ++it ){ |
267 | const QString name = (*it)->name(); | 320 | const QString name = (*it)->name(); |
268 | const QString path = (*it)->path(); | 321 | const QString path = (*it)->path(); |
269 | const QString disk = (*it)->disk(); | 322 | const QString disk = (*it)->disk(); |
270 | const QString options = (*it)->options(); | 323 | const QString options = (*it)->options(); |
271 | if( name.find( tr("Internal"),0,TRUE) == -1) { | 324 | if( name.find( tr("Internal"),0,TRUE) == -1) { |
272 | storageComboBox->insertItem(name +" -> "+disk); | 325 | storageComboBox->insertItem(name +" -> "+disk); |
273 | } | 326 | } |
274 | deviceComboBox->insertItem(disk); | 327 | deviceComboBox->insertItem(disk); |
275 | } | 328 | } |
276 | parsetab(); | 329 | parsetab(); |
277 | fileSystemsCombo->insertStringList( fsList,-1); | 330 | fileSystemsCombo->insertStringList( fsList,-1); |
278 | // for(int i = 0; i < fileSystemsCombo->count(); i++) { | 331 | // for(int i = 0; i < fileSystemsCombo->count(); i++) { |
279 | // if( fsType == fileSystemsCombo->text(i)) | 332 | // if( fsType == fileSystemsCombo->text(i)) |
280 | // fileSystemsCombo->setCurrentItem(i); | 333 | // fileSystemsCombo->setCurrentItem(i); |
281 | // } | 334 | // } |
282 | storageComboSelected(0); | 335 | storageComboSelected(0); |
283 | deviceComboSelected(0); | 336 | deviceComboSelected(0); |
284 | } | 337 | } |
285 | 338 | ||
286 | 339 | ||
287 | void FormatterApp::fsComboSelected(int index) { | 340 | void FormatterApp::fsComboSelected(int index) { |
288 | 341 | ||
289 | } | 342 | } |
290 | 343 | ||
291 | void FormatterApp::storageComboSelected(int index ) { | 344 | void FormatterApp::storageComboSelected(int index ) { |
@@ -377,43 +430,59 @@ void FormatterApp::parsetab() { | |||
377 | 430 | ||
378 | // QFile f("/etc/fstab"); | 431 | // QFile f("/etc/fstab"); |
379 | // if ( f.open(IO_ReadOnly) ) { | 432 | // if ( f.open(IO_ReadOnly) ) { |
380 | // QTextStream t (&f); | 433 | // QTextStream t (&f); |
381 | // QString s; | 434 | // QString s; |
382 | // while (! t.eof()) { | 435 | // while (! t.eof()) { |
383 | // s=t.readLine(); | 436 | // s=t.readLine(); |
384 | // s=s.simplifyWhiteSpace(); | 437 | // s=s.simplifyWhiteSpace(); |
385 | // if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { | 438 | // if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { |
386 | // s=s.remove(0,s.find(BLANK)+1 ); // devicename | 439 | // s=s.remove(0,s.find(BLANK)+1 ); // devicename |
387 | // s=s.remove(0,s.find(BLANK)+1 ); // mountpoint | 440 | // s=s.remove(0,s.find(BLANK)+1 ); // mountpoint |
388 | // s=s.remove(0,s.find(BLANK)+1 ); // fs | 441 | // s=s.remove(0,s.find(BLANK)+1 ); // fs |
389 | // } | 442 | // } |
390 | // } | 443 | // } |
391 | // } | 444 | // } |
392 | // f.close(); | 445 | // f.close(); |
393 | } | 446 | } |
394 | 447 | ||
395 | QString FormatterApp::getFileSystemType(const QString ¤tText) { | 448 | QString FormatterApp::getFileSystemType(const QString ¤tText) { |
396 | 449 | ||
397 | parsetab(); //why did TT forget filesystem type? | 450 | parsetab(); //why did TT forget filesystem type? |
398 | 451 | ||
399 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 452 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
400 | QString temp = (*it); | 453 | QString temp = (*it); |
401 | if( temp.find( currentText,0,TRUE) != -1) { | 454 | if( temp.find( currentText,0,TRUE) != -1) { |
402 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 455 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
403 | // qDebug(fsType); | 456 | // qDebug(fsType); |
404 | } | 457 | } |
405 | } | 458 | } |
406 | return ""; | 459 | return ""; |
407 | } | 460 | } |
408 | 461 | ||
409 | void FormatterApp::doFsck() { | 462 | bool FormatterApp::doFsck() { |
410 | 463 | ||
411 | QString selectedDevice = deviceComboBox->currentText(); | 464 | QString selectedDevice = deviceComboBox->currentText(); |
412 | QString fsType = getFileSystemType((const QString &)selectedDevice); | 465 | QString fsType = getFileSystemType((const QString &)selectedDevice); |
413 | QString cmd; | 466 | QString cmd; |
414 | qDebug( selectedDevice +" "+ fsType); | 467 | qDebug( selectedDevice +" "+ fsType); |
415 | if(fsType == "vfat") cmd = "dosfsck -vy "; | 468 | if(fsType == "vfat") cmd = "dosfsck -vy "; |
416 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; | 469 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; |
417 | cmd += selectedDevice; | 470 | cmd += selectedDevice; |
418 | 471 | ||
472 | |||
473 | return FALSE; | ||
474 | } | ||
475 | |||
476 | bool FormatterApp::doFsckCheck() { | ||
477 | return FALSE; | ||
478 | } | ||
479 | |||
480 | int FormatterApp::formatCheck(const QString &deviceStr) { | ||
481 | |||
482 | return -1; | ||
483 | } | ||
484 | |||
485 | int FormatterApp::runCommand(const QString &command) { | ||
486 | |||
487 | return -1; | ||
419 | } | 488 | } |
diff --git a/noncore/tools/formatter/formatter.h b/noncore/tools/formatter/formatter.h index a566ec0..871054d 100644 --- a/noncore/tools/formatter/formatter.h +++ b/noncore/tools/formatter/formatter.h | |||
@@ -14,46 +14,52 @@ | |||
14 | #include <qmainwindow.h> | 14 | #include <qmainwindow.h> |
15 | 15 | ||
16 | class QVBoxLayout; | 16 | class QVBoxLayout; |
17 | class QHBoxLayout; | 17 | class QHBoxLayout; |
18 | class QGridLayout; | 18 | class QGridLayout; |
19 | class QComboBox; | 19 | class QComboBox; |
20 | class QLabel; | 20 | class QLabel; |
21 | class QLineEdit; | 21 | class QLineEdit; |
22 | class QPushButton; | 22 | class QPushButton; |
23 | class QTabWidget; | 23 | class QTabWidget; |
24 | class QWidget; | 24 | class QWidget; |
25 | class QStringList; | 25 | class QStringList; |
26 | 26 | ||
27 | class FormatterApp : public QMainWindow | 27 | class FormatterApp : public QMainWindow |
28 | //public QDialog | 28 | //public QDialog |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | FormatterApp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 33 | FormatterApp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
34 | ~FormatterApp(); | 34 | ~FormatterApp(); |
35 | 35 | ||
36 | QTabWidget *TabWidget; | 36 | QTabWidget *TabWidget; |
37 | QWidget *tab, *tab_2;; | 37 | QWidget *tab, *tab_2;; |
38 | QLabel *TextLabel1, *TextLabel2, *TextLabel3, *TextLabel4, *TextLabel5; | 38 | QLabel *TextLabel1, *TextLabel2, *TextLabel3, *TextLabel4, *TextLabel5; |
39 | QComboBox *storageComboBox, *fileSystemsCombo, *deviceComboBox; | 39 | QComboBox *storageComboBox, *fileSystemsCombo, *deviceComboBox; |
40 | QPushButton *formatPushButton, *editPushButton, *fsckButton; | 40 | QPushButton *formatPushButton, *editPushButton, *fsckButton; |
41 | QLineEdit* mountPointLineEdit; | 41 | QLineEdit* mountPointLineEdit; |
42 | QStringList fileSystemTypeList, fsList; | 42 | QStringList fileSystemTypeList, fsList; |
43 | protected: | 43 | protected: |
44 | QGridLayout *FormatterAppLayout, *tabLayout, *tabLayout_2; | 44 | QGridLayout *FormatterAppLayout, *tabLayout, *tabLayout_2; |
45 | QString getFileSystemType(const QString &); | 45 | QString getFileSystemType(const QString &); |
46 | |||
47 | void fillCombos(); | ||
48 | void parsetab(); | ||
49 | bool doFdisk(); | ||
50 | int formatCheck(const QString &); | ||
51 | int runCommand(const QString &); | ||
46 | 52 | ||
47 | protected slots: | 53 | protected slots: |
48 | void doFormat(); | ||
49 | void fillCombos(); | ||
50 | void cleanUp(); | 54 | void cleanUp(); |
55 | void doFormat(); | ||
56 | void editFstab(); | ||
57 | bool doFsck(); | ||
58 | bool doFsckCheck(); | ||
59 | |||
51 | void fsComboSelected(int); | 60 | void fsComboSelected(int); |
52 | void storageComboSelected(int ); | 61 | void storageComboSelected(int ); |
53 | void deviceComboSelected(int ); | 62 | void deviceComboSelected(int ); |
54 | void editFstab(); | ||
55 | void parsetab(); | ||
56 | void doFsck(); | ||
57 | }; | 63 | }; |
58 | 64 | ||
59 | #endif // FORMATTERAPP_H | 65 | #endif // FORMATTERAPP_H |