summaryrefslogtreecommitdiff
path: root/noncore/tools
Unidiff
Diffstat (limited to 'noncore/tools') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/calc2/engine.cpp10
-rw-r--r--noncore/tools/calculator/calculator.pro4
-rw-r--r--noncore/tools/calculator/calculatorimpl.cpp11
-rw-r--r--noncore/tools/formatter/formatter.cpp36
-rw-r--r--noncore/tools/formatter/formatter.pro10
5 files changed, 40 insertions, 31 deletions
diff --git a/noncore/tools/calc2/engine.cpp b/noncore/tools/calc2/engine.cpp
index a9a47c4..e843e29 100644
--- a/noncore/tools/calc2/engine.cpp
+++ b/noncore/tools/calc2/engine.cpp
@@ -92,25 +92,25 @@ void Engine::pushValue (char v)
92 case rDouble: 92 case rDouble:
93 displayString.append(v); 93 displayString.append(v);
94 num.dbl=displayString.toDouble(&ok); 94 num.dbl=displayString.toDouble(&ok);
95 break; 95 break;
96 case rFraction: 96 case rFraction:
97 break; 97 break;
98 default: 98 default:
99 displayString.append(v); 99 displayString.append(v);
100 num.i=displayString.toInt(&ok, calcBase()); 100 num.i=displayString.toInt(&ok, calcBase());
101 }; 101 };
102 if (!ok) { 102 if (!ok) {
103 state = sError; 103 state = sError;
104 qDebug("pushValue() - num->string conversion"); 104 odebug << "pushValue() - num->string conversion" << oendl;
105 } else { 105 } else {
106 const QString constString = displayString; 106 const QString constString = displayString;
107 emit(display(constString)); 107 emit(display(constString));
108 }; 108 };
109 109
110 } else if (state == sStart) { 110 } else if (state == sStart) {
111 softReset(); 111 softReset();
112 displayString.truncate(0); 112 displayString.truncate(0);
113 state = sAppend; 113 state = sAppend;
114 pushValue (v); 114 pushValue (v);
115 } else if (state == sError) { 115 } else if (state == sError) {
116 qDebug ("in error state"); 116 qDebug ("in error state");
@@ -118,70 +118,70 @@ void Engine::pushValue (char v)
118 } 118 }
119} 119}
120 120
121void Engine::del () 121void Engine::del ()
122{ 122{
123 bool ok; 123 bool ok;
124 switch (currentRep) { 124 switch (currentRep) {
125 case rDouble: 125 case rDouble:
126 displayString.truncate(displayString.length()); 126 displayString.truncate(displayString.length());
127 num.dbl=displayString.toDouble(&ok); 127 num.dbl=displayString.toDouble(&ok);
128 break; 128 break;
129 case rFraction: 129 case rFraction:
130 qDebug("not available"); 130 odebug << "not available" << oendl;
131 break; 131 break;
132 default: 132 default:
133 displayString.truncate(displayString.length()); 133 displayString.truncate(displayString.length());
134 num.i = displayString.toInt(&ok, calcBase()); 134 num.i = displayString.toInt(&ok, calcBase());
135 }; 135 };
136 136
137 if (!ok) { 137 if (!ok) {
138 state = sError; 138 state = sError;
139 qDebug("del() - num->string conversion"); 139 odebug << "del() - num->string conversion" << oendl;
140 } else { 140 } else {
141 const QString constString = displayString; 141 const QString constString = displayString;
142 emit(display(constString)); 142 emit(display(constString));
143 }; 143 };
144} 144}
145 145
146void Engine::displayData(Data d) { 146void Engine::displayData(Data d) {
147 switch (currentRep) { 147 switch (currentRep) {
148 case rDouble: 148 case rDouble:
149 displayString.setNum(d.dbl); 149 displayString.setNum(d.dbl);
150 break; 150 break;
151 case rFraction: 151 case rFraction:
152 qDebug("fractional display not yet impl"); 152 odebug << "fractional display not yet impl" << oendl;
153 break; 153 break;
154 default: 154 default:
155 displayString.setNum(d.i, calcBase()); 155 displayString.setNum(d.i, calcBase());
156 break; 156 break;
157 }; 157 };
158 const QString constString= displayString; 158 const QString constString= displayString;
159 emit(display(constString)); 159 emit(display(constString));
160} 160}
161 161
162// Returns the base when Rep is an integer type 162// Returns the base when Rep is an integer type
163int Engine::calcBase () { 163int Engine::calcBase () {
164 switch (currentRep) { 164 switch (currentRep) {
165 case rBin: 165 case rBin:
166 return 2; 166 return 2;
167 case rOct: 167 case rOct:
168 return 8; 168 return 8;
169 case rDec: 169 case rDec:
170 return 10; 170 return 10;
171 case rHex: 171 case rHex:
172 return 16; 172 return 16;
173 default: 173 default:
174 state = sError; 174 state = sError;
175 qDebug("Error - attempt to calc base for non-integer"); 175 odebug << "Error - attempt to calc base for non-integer" << oendl;
176 return 10; 176 return 10;
177 }; 177 };
178} 178}
179 179
180// Special instruction for internal use only 180// Special instruction for internal use only
181class iOpenBrace:public Instruction { 181class iOpenBrace:public Instruction {
182 public: 182 public:
183 iOpenBrace (Engine *e):Instruction (100) {engine = e;}; 183 iOpenBrace (Engine *e):Instruction (100) {engine = e;};
184 ~iOpenBrace () {}; 184 ~iOpenBrace () {};
185 185
186 Data eval (Data num) { 186 Data eval (Data num) {
187 engine->decBraces(); 187 engine->decBraces();
diff --git a/noncore/tools/calculator/calculator.pro b/noncore/tools/calculator/calculator.pro
index ae6a666..78d4519 100644
--- a/noncore/tools/calculator/calculator.pro
+++ b/noncore/tools/calculator/calculator.pro
@@ -1,11 +1,11 @@
1 CONFIG = qt warn_on quick-app 1 CONFIG = qt warn_on quick-app
2 HEADERS = calculatorimpl.h 2 HEADERS = calculatorimpl.h
3 SOURCES = calculatorimpl.cpp \ 3 SOURCES = calculatorimpl.cpp \
4 main.cpp 4 main.cpp
5INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
6 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
7LIBS += -lqpe -lopiecore2 7LIBS += -lqpe -lopiecore2
8 INTERFACES= calculator.ui 8 INTERFACES= calculator.ui
9 TARGET = calculator 9 TARGET = calculator
10 10
11include ( $(OPIEDIR)/include.pro ) 11include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/tools/calculator/calculatorimpl.cpp b/noncore/tools/calculator/calculatorimpl.cpp
index dead03d..05cb9b5 100644
--- a/noncore/tools/calculator/calculatorimpl.cpp
+++ b/noncore/tools/calculator/calculatorimpl.cpp
@@ -17,38 +17,45 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21/* 21/*
22 * 01/14/2002 Charles-Edouard Ruault <ce@ruault.com> 22 * 01/14/2002 Charles-Edouard Ruault <ce@ruault.com>
23 * Added support for Temperature conversions. 23 * Added support for Temperature conversions.
24 */ 24 */
25// Sat 03-09-2002 L.J. Potter added the inlined pixmaps here 25// Sat 03-09-2002 L.J. Potter added the inlined pixmaps here
26 26
27#include "calculatorimpl.h" 27#include "calculatorimpl.h"
28 28
29/* OPIE */
30#include <opie2/odebug.h>
29#include <qpe/resource.h> 31#include <qpe/resource.h>
30#include <qpe/qmath.h> 32#include <qpe/qmath.h>
31#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34using namespace Opie::Core;
32 35
36/* QT */
33#include <qpushbutton.h> 37#include <qpushbutton.h>
34#include <qcombobox.h> 38#include <qcombobox.h>
35#include <qlabel.h> 39#include <qlabel.h>
36#include <qfont.h> 40#include <qfont.h>
37#include <qlayout.h> 41#include <qlayout.h>
38#include <qstringlist.h> 42#include <qstringlist.h>
39#include <qfile.h> 43#include <qfile.h>
40#include <qtextstream.h> 44#include <qtextstream.h>
41#include <qmessagebox.h> 45#include <qmessagebox.h>
46
47/* STD */
42#include <math.h> 48#include <math.h>
49
43/* XPM */ 50/* XPM */
44static char *oneoverx_xpm[] = { 51static char *oneoverx_xpm[] = {
45/* width height num_colors chars_per_pixel */ 52/* width height num_colors chars_per_pixel */
46" 13 11 2 1", 53" 13 11 2 1",
47/* colors */ 54/* colors */
48". c None", 55". c None",
49"# c #000000", 56"# c #000000",
50/* pixels */ 57/* pixels */
51"......#......", 58"......#......",
52".....##......", 59".....##......",
53"......#......" 60"......#......"
54".....###.....", 61".....###.....",
@@ -224,25 +231,25 @@ CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name,
224 231
225 connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) ); 232 connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) );
226 233
227 captions.append(tr("Standard")); 234 captions.append(tr("Standard"));
228 ComboBoxFunction->insertItem(captions.last()); 235 ComboBoxFunction->insertItem(captions.last());
229 236
230 // now add in the conversion modes 237 // now add in the conversion modes
231 // when the menu gets done, these should be in a submenu 238 // when the menu gets done, these should be in a submenu
232 QString tmp = QPEApplication::qpeDir(); 239 QString tmp = QPEApplication::qpeDir();
233 tmp += "etc/unit_conversion.dat"; 240 tmp += "etc/unit_conversion.dat";
234 QFile myfile(tmp); 241 QFile myfile(tmp);
235 if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) { 242 if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) {
236 qDebug("Data file unit_conversion.dat not found\nNo conversion features will be available\n"+tmp); 243 odebug << "Data file unit_conversion.dat not found\nNo conversion features will be available\n"+tmp << oendl;
237 // disable the f button if no conv file available 244 // disable the f button if no conv file available
238 ComboBoxFunction->setEnabled(FALSE); 245 ComboBoxFunction->setEnabled(FALSE);
239 } 246 }
240 else { 247 else {
241 QString line, line2; 248 QString line, line2;
242 QTextStream ts(&myfile); 249 QTextStream ts(&myfile);
243 250
244 // first pass, see how many conversion types there are in order to allocate for them 251 // first pass, see how many conversion types there are in order to allocate for them
245 while ( ! ts.eof() ) { 252 while ( ! ts.eof() ) {
246 line = ts.readLine(); 253 line = ts.readLine();
247 if ( line.contains ("STARTTYPE" ) ) 254 if ( line.contains ("STARTTYPE" ) )
248 conversion_mode_count++; 255 conversion_mode_count++;
@@ -498,25 +505,25 @@ void CalculatorImpl::execOp( Operation i )
498 case oOpenBrace: { 505 case oOpenBrace: {
499 Op op( 0, oOpenBrace ); 506 Op op( 0, oOpenBrace );
500 operationStack.push( op ); 507 operationStack.push( op );
501 numOpenBraces++; 508 numOpenBraces++;
502 state = sNewNumber; 509 state = sNewNumber;
503 return; 510 return;
504 } 511 }
505 case oCloseBrace: { 512 case oCloseBrace: {
506 if ( numOpenBraces == 0 ) 513 if ( numOpenBraces == 0 )
507 return; 514 return;
508 processStack( oAdd ); 515 processStack( oAdd );
509 if ( operationStack.top().operation != oOpenBrace ) 516 if ( operationStack.top().operation != oOpenBrace )
510 qDebug( "Calculator: internal Error" ); 517 odebug << "Calculator: internal Error" << oendl;
511 operationStack.pop(); 518 operationStack.pop();
512 state = sNewNumber; 519 state = sNewNumber;
513 numOpenBraces--; 520 numOpenBraces--;
514 break; 521 break;
515 } 522 }
516 523
517 case oPoint: 524 case oPoint:
518 flPoint = TRUE; 525 flPoint = TRUE;
519 return; 526 return;
520 527
521 case oPercent: 528 case oPercent:
522 processStack( oPercent ); 529 processStack( oPercent );
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
@@ -2,48 +2,50 @@
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/* 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>
21using 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>
25#include <qstring.h> 26#include <qstring.h>
26#include <qlist.h> 27#include <qlist.h>
27#include <qstringlist.h> 28#include <qstringlist.h>
28#include <qdir.h> 29#include <qdir.h>
29#include <qfile.h> 30#include <qfile.h>
30#include <qtstream.h> 31#include <qtstream.h>
31#include <qcombobox.h> 32#include <qcombobox.h>
32#include <qpopupmenu.h> 33#include <qpopupmenu.h>
33#include <qmessagebox.h> 34#include <qmessagebox.h>
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>
42 44
43/* STD */ 45/* STD */
44#include <unistd.h> 46#include <unistd.h>
45#include <stdio.h> 47#include <stdio.h>
46#include <stdlib.h> 48#include <stdlib.h>
47#include <sys/vfs.h> 49#include <sys/vfs.h>
48#include <mntent.h> 50#include <mntent.h>
49#include <string.h> 51#include <string.h>
@@ -229,92 +231,92 @@ void FormatterApp::doFormat()
229 // cmd = "ls -l"; 231 // cmd = "ls -l";
230 outDlg = new Output(this, tr("Formatter Output"),FALSE); 232 outDlg = new Output(this, tr("Formatter Output"),FALSE);
231 QPEApplication::showDialog( outDlg); 233 QPEApplication::showDialog( outDlg);
232 qApp->processEvents(); 234 qApp->processEvents();
233 FILE *fp; 235 FILE *fp;
234 char line[130]; 236 char line[130];
235 237
236 238
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 }
251 else 253 else
252 { 254 {
253 // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 255 // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
254 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 256 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
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 }
264 else 266 else
265 { 267 {
266 QString lineStr = line; 268 QString lineStr = line;
267 lineStr=lineStr.left(lineStr.length()-1); 269 lineStr=lineStr.left(lineStr.length()-1);
268 outDlg->OutputEdit->append(lineStr); 270 outDlg->OutputEdit->append(lineStr);
269 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 271 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
270 } 272 }
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);
289 return; 291 return;
290 } 292 }
291 else 293 else
292 { 294 {
293 QString lineStr = line; 295 QString lineStr = line;
294 lineStr=lineStr.left(lineStr.length()-1); 296 lineStr=lineStr.left(lineStr.length()-1);
295 outDlg->OutputEdit->append(lineStr); 297 outDlg->OutputEdit->append(lineStr);
296 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 298 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
297 } 299 }
298 } 300 }
299 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); 301 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted."));
300 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 302 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
301 pclose(fp); 303 pclose(fp);
302 304
303 outDlg->OutputEdit->append( tr("Trying to mount %1.").arg( currentText) ); 305 outDlg->OutputEdit->append( tr("Trying to mount %1.").arg( currentText) );
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
313 { 315 {
314 outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText )); 316 outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText ));
315 while ( fgets( line, sizeof line, fp)) 317 while ( fgets( line, sizeof line, fp))
316 { 318 {
317 QString lineStr = line; 319 QString lineStr = line;
318 lineStr=lineStr.left(lineStr.length()-1); 320 lineStr=lineStr.left(lineStr.length()-1);
319 outDlg->OutputEdit->append(lineStr); 321 outDlg->OutputEdit->append(lineStr);
320 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 322 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
@@ -371,25 +373,25 @@ void FormatterApp::fsComboSelected(int )
371{} 373{}
372 374
373void FormatterApp::storageComboSelected(int index ) 375void FormatterApp::storageComboSelected(int index )
374{ 376{
375 377
376 QString currentText = storageComboBox->text(index); 378 QString currentText = storageComboBox->text(index);
377 QString nameS = currentText.left( currentText.find("->",0,TRUE)); 379 QString nameS = currentText.left( currentText.find("->",0,TRUE));
378 380
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);
388 } 390 }
389 // deviceComboSelected(index); 391 // deviceComboSelected(index);
390} 392}
391 393
392void FormatterApp::deviceComboSelected(int index) 394void FormatterApp::deviceComboSelected(int index)
393{ 395{
394 396
395 StorageInfo storageInfo; 397 StorageInfo storageInfo;
@@ -455,25 +457,25 @@ void FormatterApp::parsetab(const QString &fileName)
455 while ( (me = getmntent( mntfp )) != 0 ) 457 while ( (me = getmntent( mntfp )) != 0 )
456 { 458 {
457 QString deviceName = me->mnt_fsname; 459 QString deviceName = me->mnt_fsname;
458 QString filesystemType = me->mnt_type; 460 QString filesystemType = me->mnt_type;
459 if(deviceName != "none") 461 if(deviceName != "none")
460 { 462 {
461 if( fsList.contains(filesystemType) == 0 463 if( fsList.contains(filesystemType) == 0
462 & filesystemType.find("proc",0,TRUE) == -1 464 & filesystemType.find("proc",0,TRUE) == -1
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 }
472 endmntent( mntfp ); 474 endmntent( mntfp );
473 // } else if(fileName == "/etc/fstab") { 475 // } else if(fileName == "/etc/fstab") {
474 // QFile f("/etc/fstab"); 476 // QFile f("/etc/fstab");
475 // if ( f.open(IO_ReadOnly) ) { 477 // if ( f.open(IO_ReadOnly) ) {
476 // QTextStream t (&f); 478 // QTextStream t (&f);
477 // QString s; 479 // QString s;
478 // while (! t.eof()) { 480 // while (! t.eof()) {
479 // s=t.readLine(); 481 // s=t.readLine();
@@ -497,25 +499,25 @@ void FormatterApp::parsetab(const QString &fileName)
497 499
498QString FormatterApp::getFileSystemType(const QString &currentText) 500QString FormatterApp::getFileSystemType(const QString &currentText)
499{ 501{
500 502
501 parsetab("/etc/mtab"); //why did TT forget filesystem type? 503 parsetab("/etc/mtab"); //why did TT forget filesystem type?
502 504
503 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) 505 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it )
504 { 506 {
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}
514 516
515bool FormatterApp::doFsck() 517bool FormatterApp::doFsck()
516{ 518{
517 519
518 Output *outDlg; 520 Output *outDlg;
519 QString selectedDevice; 521 QString selectedDevice;
520 // #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 522 // #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
521 selectedDevice = deviceComboBox->currentText(); 523 selectedDevice = deviceComboBox->currentText();
@@ -524,79 +526,79 @@ bool FormatterApp::doFsck()
524 QString remountS = "mount -v "+mountPoint+" 2>&1"; 526 QString remountS = "mount -v "+mountPoint+" 2>&1";
525 // #else 527 // #else
526 // // for testing 528 // // for testing
527 // // currentText = diskDevice = "/dev/fd0"; 529 // // currentText = diskDevice = "/dev/fd0";
528 // QString umountS = "umount -v /floppy 2>&1"; 530 // QString umountS = "umount -v /floppy 2>&1";
529 // QString remountS = "mount -v /floppy 2>&1"; 531 // QString remountS = "mount -v /floppy 2>&1";
530 // selectedDevice ="/dev/fd0"; 532 // selectedDevice ="/dev/fd0";
531 533
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
541 outDlg = new Output(this, tr("Formatter Output"),FALSE); 543 outDlg = new Output(this, tr("Formatter Output"),FALSE);
542 QPEApplication::showDialog( outDlg ); 544 QPEApplication::showDialog( outDlg );
543 qApp->processEvents(); 545 qApp->processEvents();
544 FILE *fp; 546 FILE *fp;
545 char line[130]; 547 char line[130];
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 }
560 else 562 else
561 { 563 {
562 // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 564 // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
563 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 565 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
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;
573 } 575 }
574 else 576 else
575 { 577 {
576 QString lineStr = line; 578 QString lineStr = line;
577 lineStr=lineStr.left(lineStr.length()-1); 579 lineStr=lineStr.left(lineStr.length()-1);
578 outDlg->OutputEdit->append(lineStr); 580 outDlg->OutputEdit->append(lineStr);
579 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 581 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
580 } 582 }
581 } 583 }
582 } 584 }
583 pclose(fp); 585 pclose(fp);
584 ///////////////////////////////////// 586 /////////////////////////////////////
585 fp = popen( (const char *) cmd, "r"); 587 fp = popen( (const char *) cmd, "r");
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);
595 return false; 597 return false;
596 } 598 }
597 else 599 else
598 { 600 {
599 QString lineStr = line; 601 QString lineStr = line;
600 lineStr=lineStr.left(lineStr.length()-1); 602 lineStr=lineStr.left(lineStr.length()-1);
601 outDlg->OutputEdit->append(lineStr); 603 outDlg->OutputEdit->append(lineStr);
602 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 604 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
diff --git a/noncore/tools/formatter/formatter.pro b/noncore/tools/formatter/formatter.pro
index 913cca8..f6d34c7 100644
--- a/noncore/tools/formatter/formatter.pro
+++ b/noncore/tools/formatter/formatter.pro
@@ -1,9 +1,9 @@
1CONFIG += qt warn_on quick-app 1CONFIG += qt warn_on quick-app
2HEADERS = formatter.h inputDialog.h output.h 2HEADERS = formatter.h inputDialog.h output.h
3SOURCES = formatter.cpp inputDialog.cpp output.cpp main.cpp 3SOURCES = formatter.cpp inputDialog.cpp output.cpp main.cpp
4TARGET = formatter 4TARGET = formatter
5INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
6DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
7LIBS += -lqpe -lopiecore2 7LIBS += -lqpe -lopiecore2
8 8
9include ( $(OPIEDIR)/include.pro ) 9include ( $(OPIEDIR)/include.pro )