summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/formatter/formatter.cpp510
-rw-r--r--noncore/tools/opie-sh/opie-sh.cpp492
-rw-r--r--noncore/tools/remote/learntab.cpp311
-rw-r--r--noncore/tools/remote/remote.cpp102
4 files changed, 738 insertions, 677 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index 532ee40..e869317 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -10,7 +10,7 @@
10#include "inputDialog.h" 10#include "inputDialog.h"
11#include "output.h" 11#include "output.h"
12 12
13#include <qmenubar.h> 13/* OPIE */
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>
@@ -19,20 +19,19 @@
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/* QT */
23#include <qmenubar.h>
22#include <qmultilineedit.h> 24#include <qmultilineedit.h>
23#include <qstring.h> 25#include <qstring.h>
24#include <qlist.h> 26#include <qlist.h>
25#include <qstringlist.h> 27#include <qstringlist.h>
26#include <qdir.h> 28#include <qdir.h>
27#include <qfile.h> 29#include <qfile.h>
28
29#include <qtstream.h> 30#include <qtstream.h>
30
31#include <qcombobox.h> 31#include <qcombobox.h>
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
36#include <qlabel.h> 35#include <qlabel.h>
37#include <qlineedit.h> 36#include <qlineedit.h>
38#include <qpushbutton.h> 37#include <qpushbutton.h>
@@ -41,6 +40,7 @@
41#include <qlayout.h> 40#include <qlayout.h>
42#include <qvariant.h> 41#include <qvariant.h>
43 42
43/* STD */
44#include <unistd.h> 44#include <unistd.h>
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
@@ -52,25 +52,25 @@
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 */
57FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool modal ) 57FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool modal )
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( 3); 74 tabLayout->setSpacing( 3);
75 tabLayout->setMargin( 2); 75 tabLayout->setMargin( 2);
76 76
@@ -99,15 +99,15 @@ FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool
99 formatPushButton = new QPushButton( tab, "formatPushButton" ); 99 formatPushButton = new QPushButton( tab, "formatPushButton" );
100 formatPushButton->setText( tr( "Format" ) ); 100 formatPushButton->setText( tr( "Format" ) );
101 formatPushButton->setMaximumWidth(170); 101 formatPushButton->setMaximumWidth(170);
102 102
103 tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1); 103 tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1);
104 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); 104 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
105 tabLayout->addItem( spacer_2, 5, 0 ); 105 tabLayout->addItem( spacer_2, 5, 0 );
106 106
107 TabWidget->insertTab( tab, tr( "Main" ) ); 107 TabWidget->insertTab( tab, tr( "Main" ) );
108 108
109 tab_2 = new QWidget( TabWidget, "tab_2" ); 109 tab_2 = new QWidget( TabWidget, "tab_2" );
110 tabLayout_2 = new QGridLayout( tab_2 ); 110 tabLayout_2 = new QGridLayout( tab_2 );
111 tabLayout_2->setSpacing(3); 111 tabLayout_2->setSpacing(3);
112 tabLayout_2->setMargin(2); 112 tabLayout_2->setMargin(2);
113 113
@@ -130,7 +130,7 @@ FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool
130 editPushButton = new QPushButton( tab_2, "editPushButton" ); 130 editPushButton = new QPushButton( tab_2, "editPushButton" );
131 editPushButton->setText( tr( "Edit fstab" ) ); 131 editPushButton->setText( tr( "Edit fstab" ) );
132 editPushButton->setMaximumWidth(100); 132 editPushButton->setMaximumWidth(100);
133 133
134 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); 134 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 );
135 135
136 fsckButton = new QPushButton( tab_2, "fsckPushButton" ); 136 fsckButton = new QPushButton( tab_2, "fsckPushButton" );
@@ -164,15 +164,15 @@ FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool
164 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); 164 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) ));
165 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); 165 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) ));
166 166
167 167
168 fillCombos(); 168 fillCombos();
169} 169}
170 170
171FormatterApp::~FormatterApp() { 171FormatterApp::~FormatterApp()
172 172{}
173}
174 173
175void FormatterApp::doFormat() { 174void FormatterApp::doFormat()
175{
176 int err=0; 176 int err=0;
177 Output *outDlg; 177 Output *outDlg;
178 QString umountS, remountS; 178 QString umountS, remountS;
@@ -190,165 +190,188 @@ void FormatterApp::doFormat() {
190 remountS = "mount -v /floppy 2>&1"; 190 remountS = "mount -v /floppy 2>&1";
191#endif 191#endif
192 192
193 if( currentText.find("CF",0,TRUE) != -1) { 193 if( currentText.find("CF",0,TRUE) != -1)
194 {
194 umountS = "umount "; 195 umountS = "umount ";
195 remountS = "mount "; 196 remountS = "mount ";
196 197
197// umountS = "/sbin/cardctl eject"; 198 // umountS = "/sbin/cardctl eject";
198// remountS = "/sbin/cardctl insert"; 199 // remountS = "/sbin/cardctl insert";
199 } 200 }
200 if( currentText.find("SD",0,TRUE) != -1) { 201 if( currentText.find("SD",0,TRUE) != -1)
202 {
201 umountS = "umount "; 203 umountS = "umount ";
202 remountS = "mount "; 204 remountS = "mount ";
203// umountS = "/etc/sdcontrol compeject"; 205 // umountS = "/etc/sdcontrol compeject";
204// remountS = "/etc/sdcontrol insert"; 206 // remountS = "/etc/sdcontrol insert";
205 } 207 }
206 208
207 switch ( QMessageBox::warning(this,tr("Format?") 209 switch ( QMessageBox::warning(this,tr("Format?")
208 , tr("Really format\n") +diskName+" "+ currentText + 210 , tr("Really format\n") +diskName+" "+ currentText +
209 tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs ) 211 tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs )
210 ,tr("Yes") 212 ,tr("Yes")
211 ,tr("No") 213 ,tr("No")
212 ,0 214 ,0
213 ,1 215 ,1
214 ,1) ) { 216 ,1) )
215 case 0: { 217 {
216 if(fs == "vfat") 218 case 0:
217 cmd = "mkdosfs -v " + diskDevice+" 2>&1"; 219 {
218 else if(fs == "ext2") 220 if(fs == "vfat")
219 cmd = "mke2fs -v " + diskDevice+" 2>&1"; 221 cmd = "mkdosfs -v " + diskDevice+" 2>&1";
220 else { 222 else if(fs == "ext2")
221 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); 223 cmd = "mke2fs -v " + diskDevice+" 2>&1";
222 break; 224 else
223 } 225 {
224// cmd = "ls -l"; 226 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok"));
225 outDlg = new Output(this, tr("Formatter Output"),FALSE); 227 break;
226 outDlg->showMaximized(); 228 }
227 outDlg->show(); 229 // cmd = "ls -l";
228 qApp->processEvents(); 230 outDlg = new Output(this, tr("Formatter Output"),FALSE);
229 FILE *fp; 231 QPEApplication::showDialog( outDlg);
230 char line[130]; 232 qApp->processEvents();
231 233 FILE *fp;
232 234 char line[130];
233 outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) ); 235
234 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 236
235 237 outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) );
236 sleep(1); 238 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
237 qDebug("Command is "+umountS); 239
238 fp = popen( (const char *) umountS, "r"); 240 sleep(1);
239 // qDebug("%d", fp); 241 qDebug("Command is "+umountS);
240 if ( !fp ) { 242 fp = popen( (const char *) umountS, "r");
241 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); 243 // qDebug("%d", fp);
242 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); 244 if ( !fp )
243 pclose(fp); 245 {
244 return; 246 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err);
245 } else { 247 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") );
246// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 248 pclose(fp);
247// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 249 return;
248 while ( fgets( line, sizeof line, fp)) { 250 }
249 if( ((QString)line).find("busy",0,TRUE) != -1) { 251 else
250 qDebug("Could not find '" + umountS); 252 {
251 QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); 253 // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
252 pclose(fp); 254 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
253 return; 255 while ( fgets( line, sizeof line, fp))
254 } else { 256 {
255 QString lineStr = line; 257 if( ((QString)line).find("busy",0,TRUE) != -1)
256 lineStr=lineStr.left(lineStr.length()-1); 258 {
257 outDlg->OutputEdit->append(lineStr); 259 qDebug("Could not find '" + umountS);
258 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 260 QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") );
259 } 261 pclose(fp);
260 } 262 return;
261 } 263 }
262 pclose(fp); 264 else
263 265 {
264 qDebug("Command would be: "+cmd); 266 QString lineStr = line;
265 outDlg->OutputEdit->append( tr("Trying to format.") ); 267 lineStr=lineStr.left(lineStr.length()-1);
266 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 268 outDlg->OutputEdit->append(lineStr);
267 269 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
268 fp = popen( (const char *) cmd, "r"); 270 }
269 while ( fgets( line, sizeof line, fp)) { 271 }
270 if( ((QString)line).find("No such device",0,TRUE) != -1) { 272 }
271 qDebug("No such device '" + umountS); 273 pclose(fp);
272 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); 274
273 pclose(fp); 275 qDebug("Command would be: "+cmd);
274// outDlg->OutputEdit->append("No such device"); 276 outDlg->OutputEdit->append( tr("Trying to format.") );
275// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 277 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
276 return; 278
277 } else { 279 fp = popen( (const char *) cmd, "r");
278 QString lineStr = line; 280 while ( fgets( line, sizeof line, fp))
279 lineStr=lineStr.left(lineStr.length()-1); 281 {
280 outDlg->OutputEdit->append(lineStr); 282 if( ((QString)line).find("No such device",0,TRUE) != -1)
281 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 283 {
282 } 284 qDebug("No such device '" + umountS);
283 } 285 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") );
284 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); 286 pclose(fp);
285 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 287 // outDlg->OutputEdit->append("No such device");
286 pclose(fp); 288 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
287 289 return;
288 outDlg->OutputEdit->append( tr("Trying to mount %1.").arg( currentText) ); 290 }
289 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 291 else
290 fp = popen( (const char *) remountS, "r"); 292 {
291 if ( !fp) { 293 QString lineStr = line;
292 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); 294 lineStr=lineStr.left(lineStr.length()-1);
293 QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); 295 outDlg->OutputEdit->append(lineStr);
294 296 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
295 } else { 297 }
296 outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText )); 298 }
297 while ( fgets( line, sizeof line, fp)) { 299 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted."));
298 QString lineStr = line; 300 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
299 lineStr=lineStr.left(lineStr.length()-1); 301 pclose(fp);
300 outDlg->OutputEdit->append(lineStr); 302
301 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 303 outDlg->OutputEdit->append( tr("Trying to mount %1.").arg( currentText) );
302 } 304 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
303 } 305 fp = popen( (const char *) remountS, "r");
304 pclose(fp); 306 if ( !fp)
305 sleep(1); 307 {
306 308 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err);
307 outDlg->OutputEdit->append(tr("You can now close the output window.")); 309 QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") );
308 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 310
309// outDlg->close(); 311 }
310// if(outDlg) 312 else
311// delete outDlg; 313 {
312 } 314 outDlg->OutputEdit->append(tr("%1\nhas been successfully mounted.").arg( currentText ));
313 break; 315 while ( fgets( line, sizeof line, fp))
316 {
317 QString lineStr = line;
318 lineStr=lineStr.left(lineStr.length()-1);
319 outDlg->OutputEdit->append(lineStr);
320 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
321 }
322 }
323 pclose(fp);
324 sleep(1);
325
326 outDlg->OutputEdit->append(tr("You can now close the output window."));
327 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
328 // outDlg->close();
329 // if(outDlg)
330 // delete outDlg;
331 }
332 break;
314 }; 333 };
315} 334}
316 335
317bool FormatterApp::doFdisk() { 336bool FormatterApp::doFdisk()
337{
318 return FALSE; 338 return FALSE;
319 339
320} 340}
321 341
322void FormatterApp::fillCombos() { 342void FormatterApp::fillCombos()
343{
323 344
324 StorageInfo storageInfo; 345 StorageInfo storageInfo;
325 const QList<FileSystem> &fs = storageInfo.fileSystems(); 346 const QList<FileSystem> &fs = storageInfo.fileSystems();
326 QListIterator<FileSystem> it ( fs ); 347 QListIterator<FileSystem> it ( fs );
327 QString storage; 348 QString storage;
328 for( ; it.current(); ++it ){ 349 for( ; it.current(); ++it )
350 {
329 const QString name = (*it)->name(); 351 const QString name = (*it)->name();
330 const QString path = (*it)->path(); 352 const QString path = (*it)->path();
331 const QString disk = (*it)->disk(); 353 const QString disk = (*it)->disk();
332 const QString options = (*it)->options(); 354 const QString options = (*it)->options();
333 if( name.find( tr("Internal"),0,TRUE) == -1) { 355 if( name.find( tr("Internal"),0,TRUE) == -1)
356 {
334 storageComboBox->insertItem(name +" -> "+disk); 357 storageComboBox->insertItem(name +" -> "+disk);
335 } 358 }
336// deviceComboBox->insertItem(disk); 359 // deviceComboBox->insertItem(disk);
337 } 360 }
338 parsetab("/etc/mtab"); 361 parsetab("/etc/mtab");
339// parsetab("/etc/fstab"); 362 // parsetab("/etc/fstab");
340 fileSystemsCombo->insertStringList( fsList,-1); 363 fileSystemsCombo->insertStringList( fsList,-1);
341 deviceComboBox->insertStringList( deviceList,-1); 364 deviceComboBox->insertStringList( deviceList,-1);
342 storageComboSelected(0); 365 storageComboSelected(0);
343 deviceComboSelected(0); 366 deviceComboSelected(0);
344} 367}
345 368
346 369
347void FormatterApp::fsComboSelected(int ) { 370void FormatterApp::fsComboSelected(int )
371{}
348 372
349} 373void FormatterApp::storageComboSelected(int index )
350 374{
351void FormatterApp::storageComboSelected(int index ) {
352 375
353 QString currentText = storageComboBox->text(index); 376 QString currentText = storageComboBox->text(index);
354 QString nameS = currentText.left( currentText.find("->",0,TRUE)); 377 QString nameS = currentText.left( currentText.find("->",0,TRUE));
@@ -357,15 +380,17 @@ void FormatterApp::storageComboSelected(int index ) {
357 currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 380 currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
358 381
359 QString fsType = getFileSystemType((const QString &) currentText); 382 QString fsType = getFileSystemType((const QString &) currentText);
360// qDebug(fsType); 383 // qDebug(fsType);
361 for(int i = 0; i < fileSystemsCombo->count(); i++) { 384 for(int i = 0; i < fileSystemsCombo->count(); i++)
385 {
362 if( fsType == fileSystemsCombo->text(i)) 386 if( fsType == fileSystemsCombo->text(i))
363 fileSystemsCombo->setCurrentItem(i); 387 fileSystemsCombo->setCurrentItem(i);
364 } 388 }
365// deviceComboSelected(index); 389 // deviceComboSelected(index);
366} 390}
367 391
368void FormatterApp::deviceComboSelected(int index) { 392void FormatterApp::deviceComboSelected(int index)
393{
369 394
370 StorageInfo storageInfo; 395 StorageInfo storageInfo;
371 QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; 396 QString totalS, usedS, avS, diskS, nameS, fsType, selectedText;
@@ -375,12 +400,14 @@ void FormatterApp::deviceComboSelected(int index) {
375 const QList<FileSystem> &fs = storageInfo.fileSystems(); 400 const QList<FileSystem> &fs = storageInfo.fileSystems();
376 QListIterator<FileSystem> it ( fs ); 401 QListIterator<FileSystem> it ( fs );
377 QString storage; 402 QString storage;
378 for( ; it.current(); ++it ){ 403 for( ; it.current(); ++it )
404 {
379 const QString name = (*it)->name(); 405 const QString name = (*it)->name();
380 const QString path = (*it)->path(); 406 const QString path = (*it)->path();
381 const QString disk = (*it)->disk(); 407 const QString disk = (*it)->disk();
382// const QString options = (*it)->options(); 408 // const QString options = (*it)->options();
383 if( selectedText == disk) { 409 if( selectedText == disk)
410 {
384 diskS = disk; nameS= name; 411 diskS = disk; nameS= name;
385 mountPointLineEdit->setText(path); 412 mountPointLineEdit->setText(path);
386 long mult = (*it)->blockSize() / 1024; 413 long mult = (*it)->blockSize() / 1024;
@@ -400,37 +427,41 @@ void FormatterApp::deviceComboSelected(int index) {
400 } 427 }
401 fsType = getFileSystemType((const QString &)selectedText); 428 fsType = getFileSystemType((const QString &)selectedText);
402 429
403 TextLabel5->setText(tr("Type: %1\nFormatted with %2\n%3, %4, %5").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS )); 430 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 ); 431 TextLabel5->setTextFormat( Qt::RichText );
405// storageComboSelected(0); 432 // storageComboSelected(0);
406} 433}
407 434
408void FormatterApp::cleanUp() { 435void FormatterApp::cleanUp()
436{}
409 437
410}
411 438
412 439void FormatterApp::editFstab()
413void FormatterApp::editFstab() { 440{
414 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); 441 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)");
415 e << (const QString &)"/etc/fstab"; 442 e << (const QString &)"/etc/fstab";
416} 443}
417 444
418void FormatterApp::parsetab(const QString &fileName) { 445void FormatterApp::parsetab(const QString &fileName)
446{
419 447
420 fileSystemTypeList.clear(); 448 fileSystemTypeList.clear();
421 fsList.clear(); 449 fsList.clear();
422 struct mntent *me; 450 struct mntent *me;
423// if(fileName == "/etc/mtab") { 451 // if(fileName == "/etc/mtab") {
424 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 452 FILE *mntfp = setmntent( fileName.latin1(), "r" );
425 if ( mntfp ) { 453 if ( mntfp )
426 while ( (me = getmntent( mntfp )) != 0 ) { 454 {
455 while ( (me = getmntent( mntfp )) != 0 )
456 {
427 QString deviceName = me->mnt_fsname; 457 QString deviceName = me->mnt_fsname;
428 QString filesystemType = me->mnt_type; 458 QString filesystemType = me->mnt_type;
429 if(deviceName != "none") { 459 if(deviceName != "none")
460 {
430 if( fsList.contains(filesystemType) == 0 461 if( fsList.contains(filesystemType) == 0
431 & filesystemType.find("proc",0,TRUE) == -1 462 & filesystemType.find("proc",0,TRUE) == -1
432 & filesystemType.find("cramfs",0,TRUE) == -1 463 & filesystemType.find("cramfs",0,TRUE) == -1
433 & filesystemType.find("auto",0,TRUE) == -1) 464 & filesystemType.find("auto",0,TRUE) == -1)
434 fsList << filesystemType; 465 fsList << filesystemType;
435 deviceList << deviceName; 466 deviceList << deviceName;
436 qDebug(deviceName+"::"+filesystemType); 467 qDebug(deviceName+"::"+filesystemType);
@@ -439,62 +470,66 @@ void FormatterApp::parsetab(const QString &fileName) {
439 } 470 }
440 } 471 }
441 endmntent( mntfp ); 472 endmntent( mntfp );
442// } else if(fileName == "/etc/fstab") { 473 // } else if(fileName == "/etc/fstab") {
443// QFile f("/etc/fstab"); 474 // QFile f("/etc/fstab");
444// if ( f.open(IO_ReadOnly) ) { 475 // if ( f.open(IO_ReadOnly) ) {
445// QTextStream t (&f); 476 // QTextStream t (&f);
446// QString s; 477 // QString s;
447// while (! t.eof()) { 478 // while (! t.eof()) {
448// s=t.readLine(); 479 // s=t.readLine();
449// s=s.simplifyWhiteSpace(); 480 // s=s.simplifyWhiteSpace();
450// if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { 481 // if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) {
451// // = me->mnt_fsname; 482 // // = me->mnt_fsname;
452// QString filesystemType = me->mnt_type; 483 // QString filesystemType = me->mnt_type;
453// QString deviceName = s.left(0,s.find(BLANK) ); 484 // QString deviceName = s.left(0,s.find(BLANK) );
454// s=s.remove(0,s.find(BLANK)+1 ); // devicename 485 // s=s.remove(0,s.find(BLANK)+1 ); // devicename
455 486
456// s=s.remove(0,s.find(BLANK)+1 ); // mountpoint 487 // s=s.remove(0,s.find(BLANK)+1 ); // mountpoint
457// QStringt mountPoint= s.left(0,s.find(BLANK) ); 488 // QStringt mountPoint= s.left(0,s.find(BLANK) );
458// s=s.remove(0,s.find(BLANK)+1 ); // fs 489 // s=s.remove(0,s.find(BLANK)+1 ); // fs
459// QString filesystemType= s.left(0,s.find(BLANK) ); 490 // QString filesystemType= s.left(0,s.find(BLANK) );
460// } 491 // }
461// } 492 // }
462// } 493 // }
463// f.close(); 494 // f.close();
464// } 495 // }
465} 496}
466 497
467QString FormatterApp::getFileSystemType(const QString &currentText) { 498QString FormatterApp::getFileSystemType(const QString &currentText)
499{
468 500
469 parsetab("/etc/mtab"); //why did TT forget filesystem type? 501 parsetab("/etc/mtab"); //why did TT forget filesystem type?
470 502
471 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 503 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it )
504 {
472 QString temp = (*it); 505 QString temp = (*it);
473 if( temp.find( currentText,0,TRUE) != -1) { 506 if( temp.find( currentText,0,TRUE) != -1)
507 {
474 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 508 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
475// qDebug(fsType); 509 // qDebug(fsType);
476 } 510 }
477 } 511 }
478 return ""; 512 return "";
479} 513}
480 514
481bool FormatterApp::doFsck() { 515bool FormatterApp::doFsck()
516{
482 517
483 Output *outDlg; 518 Output *outDlg;
484 QString selectedDevice; 519 QString selectedDevice;
485// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 520 // #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
486 selectedDevice = deviceComboBox->currentText(); 521 selectedDevice = deviceComboBox->currentText();
487 QString mountPoint = mountPointLineEdit->text(); 522 QString mountPoint = mountPointLineEdit->text();
488 QString umountS = "umount -v "+mountPoint+" 2>&1"; 523 QString umountS = "umount -v "+mountPoint+" 2>&1";
489 QString remountS = "mount -v "+mountPoint+" 2>&1"; 524 QString remountS = "mount -v "+mountPoint+" 2>&1";
490// #else 525 // #else
491// // for testing 526 // // for testing
492// // currentText = diskDevice = "/dev/fd0"; 527 // // currentText = diskDevice = "/dev/fd0";
493// QString umountS = "umount -v /floppy 2>&1"; 528 // QString umountS = "umount -v /floppy 2>&1";
494// QString remountS = "mount -v /floppy 2>&1"; 529 // QString remountS = "mount -v /floppy 2>&1";
495// selectedDevice ="/dev/fd0"; 530 // selectedDevice ="/dev/fd0";
496 531
497// #endif 532 // #endif
498 533
499 QString fsType = getFileSystemType((const QString &)selectedDevice); 534 QString fsType = getFileSystemType((const QString &)selectedDevice);
500 QString cmd; 535 QString cmd;
@@ -504,8 +539,7 @@ bool FormatterApp::doFsck() {
504 cmd += selectedDevice + " 2>&1"; 539 cmd += selectedDevice + " 2>&1";
505 540
506 outDlg = new Output(this, tr("Formatter Output"),FALSE); 541 outDlg = new Output(this, tr("Formatter Output"),FALSE);
507 outDlg->showMaximized(); 542 QPEApplication::showDialog( outDlg );
508 outDlg->show();
509 qApp->processEvents(); 543 qApp->processEvents();
510 FILE *fp; 544 FILE *fp;
511 char line[130]; 545 char line[130];
@@ -513,25 +547,32 @@ bool FormatterApp::doFsck() {
513 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 547 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
514 548
515 sleep(1); 549 sleep(1);
516// qDebug("Command is "+umountS); 550 // qDebug("Command is "+umountS);
517 fp = popen( (const char *) umountS, "r"); 551 fp = popen( (const char *) umountS, "r");
518// qDebug("%d", fp); 552 // qDebug("%d", fp);
519 if ( !fp ) { 553 if ( !fp )
520 qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); 554 {
555 qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno));
521 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); 556 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") );
522 pclose(fp); 557 pclose(fp);
523 return false; 558 return false;
524 } else { 559 }
525// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 560 else
526// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 561 {
527 while ( fgets( line, sizeof line, fp)) { 562 // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
528 if( ((QString)line).find("busy",0,TRUE) != -1) { 563 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
529 qDebug("Could not find '" + umountS); 564 while ( fgets( line, sizeof line, fp))
565 {
566 if( ((QString)line).find("busy",0,TRUE) != -1)
567 {
568 qDebug("Could not find '" + umountS);
530 QMessageBox::warning( this, tr("Formatter"), 569 QMessageBox::warning( this, tr("Formatter"),
531 tr("Could not umount.\nDevice is busy!"), tr("&OK") ); 570 tr("Could not umount.\nDevice is busy!"), tr("&OK") );
532 pclose(fp); 571 pclose(fp);
533 return false; 572 return false;
534 } else { 573 }
574 else
575 {
535 QString lineStr = line; 576 QString lineStr = line;
536 lineStr=lineStr.left(lineStr.length()-1); 577 lineStr=lineStr.left(lineStr.length()-1);
537 outDlg->OutputEdit->append(lineStr); 578 outDlg->OutputEdit->append(lineStr);
@@ -539,18 +580,22 @@ bool FormatterApp::doFsck() {
539 } 580 }
540 } 581 }
541 } 582 }
542 pclose(fp); 583 pclose(fp);
543///////////////////////////////////// 584 /////////////////////////////////////
544 fp = popen( (const char *) cmd, "r"); 585 fp = popen( (const char *) cmd, "r");
545 while ( fgets( line, sizeof line, fp)) { 586 while ( fgets( line, sizeof line, fp))
546 if( ((QString)line).find("No such device",0,TRUE) != -1) { 587 {
547 qDebug("No such device '" + umountS); 588 if( ((QString)line).find("No such device",0,TRUE) != -1)
589 {
590 qDebug("No such device '" + umountS);
548 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); 591 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") );
549 pclose(fp); 592 pclose(fp);
550// outDlg->OutputEdit->append("No such device"); 593 // outDlg->OutputEdit->append("No such device");
551// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 594 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
552 return false; 595 return false;
553 } else { 596 }
597 else
598 {
554 QString lineStr = line; 599 QString lineStr = line;
555 lineStr=lineStr.left(lineStr.length()-1); 600 lineStr=lineStr.left(lineStr.length()-1);
556 outDlg->OutputEdit->append(lineStr); 601 outDlg->OutputEdit->append(lineStr);
@@ -559,26 +604,29 @@ bool FormatterApp::doFsck() {
559 } 604 }
560 outDlg->OutputEdit->append(tr("You can now close the output window.")); 605 outDlg->OutputEdit->append(tr("You can now close the output window."));
561 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 606 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
562// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); 607 // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted."));
563// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 608 // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
564 pclose(fp); 609 pclose(fp);
565 610
566///////////////////////////////////////// 611 /////////////////////////////////////////
567 612
568 return true; 613 return true;
569} 614}
570 615
571bool FormatterApp::doFsckCheck() { 616bool FormatterApp::doFsckCheck()
617{
572 618
573 return FALSE; 619 return FALSE;
574} 620}
575 621
576int FormatterApp::formatCheck(const QString &) { 622int FormatterApp::formatCheck(const QString &)
623{
577 624
578 return -1; 625 return -1;
579} 626}
580 627
581int FormatterApp::runCommand(const QString &) { 628int FormatterApp::runCommand(const QString &)
629{
582 630
583 return -1; 631 return -1;
584} 632}
diff --git a/noncore/tools/opie-sh/opie-sh.cpp b/noncore/tools/opie-sh/opie-sh.cpp
index a353d3f..7d54a03 100644
--- a/noncore/tools/opie-sh/opie-sh.cpp
+++ b/noncore/tools/opie-sh/opie-sh.cpp
@@ -1,284 +1,290 @@
1/* 1/*
2Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) 2Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts)
3Copyright (C) 2002 Thomas Stephens 3Copyright (C) 2002 Thomas Stephens
4 4
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17
18#include "mbox.h"
19#include "fviewer.h"
20#include "inputdialog.h"
21
22/* OPIE */
23#include <qpe/qpeapplication.h>
24
25/* QT */
17#include <qstring.h> 26#include <qstring.h>
18#include <qstringlist.h> 27#include <qstringlist.h>
19#include <qpe/qpeapplication.h>
20#include <qmessagebox.h> 28#include <qmessagebox.h>
21#include <qwidget.h> 29#include <qwidget.h>
22 30
31/* STD */
23#include <stdio.h> 32#include <stdio.h>
24 33
25#include "mbox.h"
26#include "fviewer.h"
27#include "inputdialog.h"
28 34
29int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args) 35int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args)
30{ 36{
31 int i, type=0; 37 int i, type=0;
32 QString button0Text, button1Text, button2Text, string, title; 38 QString button0Text, button1Text, button2Text, string, title;
33 bool full=true; 39 bool full=true;
34 40
35 for(i=0; i<argc; i++) 41 for(i=0; i<argc; i++)
36 { 42 {
37 if(args[i] == "-t") 43 if(args[i] == "-t")
38 { 44 {
39 title = args[i+1]; 45 title = args[i+1];
40 } 46 }
41 47
42 if(args[i] == "-M") 48 if(args[i] == "-M")
43 { 49 {
44 string = args[i+1]; 50 string = args[i+1];
45 } 51 }
46 52
47 if(args[i] == "-0") 53 if(args[i] == "-0")
48 { 54 {
49 button0Text = args[i+1]; 55 button0Text = args[i+1];
50 } 56 }
51 57
52 if(args[i] == "-1") 58 if(args[i] == "-1")
53 { 59 {
54 button1Text = args[i+1]; 60 button1Text = args[i+1];
55 } 61 }
56 62
57 if(args[i] == "-2") 63 if(args[i] == "-2")
58 { 64 {
59 button2Text = args[i+1]; 65 button2Text = args[i+1];
60 } 66 }
61 67
62 if(args[i] == "-I") 68 if(args[i] == "-I")
63 { 69 {
64 type=0; 70 type=0;
65 } 71 }
66 72
67 if(args[i] == "-w") 73 if(args[i] == "-w")
68 { 74 {
69 type = 1; 75 type = 1;
70 } 76 }
71 77
72 if(args[i] == "-e") 78 if(args[i] == "-e")
73 { 79 {
74 type = 2; 80 type = 2;
75 } 81 }
76 82
77 if(args[i] == "-g") 83 if(args[i] == "-g")
78 { 84 {
79 full = false; 85 full = false;
80 } 86 }
81 } 87 }
82 88
83 MBox *mbox = new MBox(wi, h, (int)type, title, string, &button0Text, &button1Text, &button2Text, w, (QString)"messagebox"); 89 MBox *mbox = new MBox(wi, h, (int)type, title, string, &button0Text, &button1Text, &button2Text, w, (QString)"messagebox");
84 if(full) 90 if(full)
85 { 91 {
86 w->setCaption(title); 92 w->setCaption(title);
87 w->showMaximized(); 93 QPEApplication::showWidget( w );
88 } 94 }
89 //mbox->show(); 95 //mbox->show();
90 switch(mbox->exec() ) 96 switch(mbox->exec() )
91 { 97 {
92 case 0: 98 case 0:
93 return -1; 99 return -1;
94 case 1: 100 case 1:
95 return -1; 101 return -1;
96 case 2: 102 case 2:
97 return 0; 103 return 0;
98 case 3: 104 case 3:
99 return 1; 105 return 1;
100 case 4: 106 case 4:
101 return 2; 107 return 2;
102 default: return -1; 108 default: return -1;
103 } 109 }
104} 110}
105 111
106void printusage() 112void printusage()
107{ 113{
108 printf("Usage instructions for Opie-sh\n"); 114 printf("Usage instructions for Opie-sh\n");
109 printf("Usage: opie-sh [dialog type] [type specific options]\n"); 115 printf("Usage: opie-sh [dialog type] [type specific options]\n");
110 printf("Types:\n"); 116 printf("Types:\n");
111 printf(" -m Message Box\n"); 117 printf(" -m Message Box\n");
112 printf(" -f [filename] View file [Default = stdin]\n"); 118 printf(" -f [filename] View file [Default = stdin]\n");
113 printf(" -i Input dialog\n"); 119 printf(" -i Input dialog\n");
114 printf(" -h --help These instructions\n"); 120 printf(" -h --help These instructions\n");
115 printf(" -t [title] The window/dialog title\n"); 121 printf(" -t [title] The window/dialog title\n");
116 printf("Message box options:\n"); 122 printf("Message box options:\n");
117 printf(" -M [message] The message to display\n"); 123 printf(" -M [message] The message to display\n");
118 printf(" -I Use information icon\n"); 124 printf(" -I Use information icon\n");
119 printf(" -w Use the warning icon\n"); 125 printf(" -w Use the warning icon\n");
120 printf(" -e Use the error icon\n"); 126 printf(" -e Use the error icon\n");
121 printf(" -0 [text] First button text [Default = OK]\n"); 127 printf(" -0 [text] First button text [Default = OK]\n");
122 printf(" -1 [text] Second button text\n"); 128 printf(" -1 [text] Second button text\n");
123 printf(" -2 [text] Third button text\n"); 129 printf(" -2 [text] Third button text\n");
124 printf(" -g Disable fullscreen\n"); 130 printf(" -g Disable fullscreen\n");
125 printf("Input Dialog options:\n"); 131 printf("Input Dialog options:\n");
126 printf(" -s A single line of input (output to console)\n"); 132 printf(" -s A single line of input (output to console)\n");
127 printf(" -l List input (newline separated list read in from file)\n"); 133 printf(" -l List input (newline separated list read in from file)\n");
128 printf(" -b A list box, enabling multiple selections (input same as -l)\n"); 134 printf(" -b A list box, enabling multiple selections (input same as -l)\n");
129 printf(" -p Password input (display '*'s)\n"); 135 printf(" -p Password input (display '*'s)\n");
130 printf(" -L [label] The label for the input field\n"); 136 printf(" -L [label] The label for the input field\n");
131 printf(" -F [filename] An input file (for when it makes sense) [Default = stdin]\n"); 137 printf(" -F [filename] An input file (for when it makes sense) [Default = stdin]\n");
132 printf(" -E Makes list input editable\n"); 138 printf(" -E Makes list input editable\n");
133 printf(" -g Disable fullscreen\n"); 139 printf(" -g Disable fullscreen\n");
134} 140}
135 141
136int fileviewer(QPEApplication *a, int argc, QStringList args) 142int fileviewer(QPEApplication *a, int argc, QStringList args)
137{ 143{
138 int i; 144 int i;
139 QString filename, title, icon; 145 QString filename, title, icon;
140 bool update=false; 146 bool update=false;
141 147
142 for(i=0; i < argc; i++) 148 for(i=0; i < argc; i++)
143 { 149 {
144 if(args[i] == "-f") 150 if(args[i] == "-f")
145 { 151 {
146 if(args[i+1][0] != '-') 152 if(args[i+1][0] != '-')
147 { 153 {
148 filename = args[i+1]; 154 filename = args[i+1];
149 } 155 }
150 } 156 }
151 157
152 if(args[i] == "-I") 158 if(args[i] == "-I")
153 { 159 {
154 icon=args[i+1]; 160 icon=args[i+1];
155 } 161 }
156 162
157 if(args[i] == "-t") 163 if(args[i] == "-t")
158 { 164 {
159 title = args[i+1]; 165 title = args[i+1];
160 } 166 }
161 } 167 }
162 FViewer *fview = new FViewer(icon, filename, title, 0, (QString) "fileviewer"); 168 FViewer *fview = new FViewer(icon, filename, title, 0, (QString) "fileviewer");
163 a->setMainWidget(fview); 169 a->setMainWidget(fview);
164 fview->showMaximized(); 170 QPEApplication::showWidget( fview );
165 return a->exec(); 171 return a->exec();
166} 172}
167 173
168int input(int wi, int h, QWidget *w, int argc, QStringList args) 174int input(int wi, int h, QWidget *w, int argc, QStringList args)
169{ 175{
170 int i, type = 0; 176 int i, type = 0;
171 QString title, label, filename; 177 QString title, label, filename;
172 bool edit=false, full=true; 178 bool edit=false, full=true;
173 179
174 for(i=0; i < argc; i++) 180 for(i=0; i < argc; i++)
175 { 181 {
176 if(args[i] == "-s") 182 if(args[i] == "-s")
177 { 183 {
178 type = 0; 184 type = 0;
179 } 185 }
180 186
181 if(args[i] == "-l") 187 if(args[i] == "-l")
182 { 188 {
183 type = 1; 189 type = 1;
184 } 190 }
185 191
186 if(args[i] == "-b") 192 if(args[i] == "-b")
187 { 193 {
188 type = 2; 194 type = 2;
189 } 195 }
190 196
191 if(args[i] == "-p") 197 if(args[i] == "-p")
192 { 198 {
193 type = 3; 199 type = 3;
194 } 200 }
195 201
196 if(args[i] == "-t") 202 if(args[i] == "-t")
197 { 203 {
198 title = args[i+1]; 204 title = args[i+1];
199 } 205 }
200 206
201 if(args[i] == "-L") 207 if(args[i] == "-L")
202 { 208 {
203 label = args[i+1]; 209 label = args[i+1];
204 } 210 }
205 211
206 if(args[i] == "-F") 212 if(args[i] == "-F")
207 { 213 {
208 if(args[i+1][0] != '-') 214 if(args[i+1][0] != '-')
209 { 215 {
210 filename = args[i+1]; 216 filename = args[i+1];
211 } 217 }
212 } 218 }
213 219
214 if(args[i] =="-E") 220 if(args[i] =="-E")
215 { 221 {
216 edit = true; 222 edit = true;
217 } 223 }
218 224
219 if(args[i] == "-g") 225 if(args[i] == "-g")
220 { 226 {
221 full = false; 227 full = false;
222 } 228 }
223 } 229 }
224 InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w); 230 InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w);
225 if(full) 231 if(full)
226 { 232 {
227 w->setCaption(title); 233 w->setCaption(title);
228 w->showMaximized(); 234 QPEApplication::showWidget( w );
229 } 235 }
230 if( id->exec() == 1) 236 if( id->exec() == 1)
231 { 237 {
232 printf("%s\n", id->getString().latin1()); 238 printf("%s\n", id->getString().latin1());
233 return 0; 239 return 0;
234 } 240 }
235 else 241 else
236 { 242 {
237 return -1; 243 return -1;
238 } 244 }
239} 245}
240 246
241int main(int argc, char **argv) 247int main(int argc, char **argv)
242{ 248{
243 int i; 249 int i;
244 QStringList args; 250 QStringList args;
245 QPEApplication a(argc, argv); 251 QPEApplication a(argc, argv);
246 QWidget w; 252 QWidget w;
247 a.setMainWidget(&w); 253 a.setMainWidget(&w);
248 QWidget *d = a.desktop(); 254 QWidget *d = a.desktop();
249 int width=d->width(); 255 int width=d->width();
250 int height=d->height(); 256 int height=d->height();
251 257
252 for(i=0; i < argc; i++) 258 for(i=0; i < argc; i++)
253 { 259 {
254 args += argv[i]; 260 args += argv[i];
255 } 261 }
256 262
257 for(i=0; i < argc; i++) 263 for(i=0; i < argc; i++)
258 { 264 {
259 if(args[i] == "-m") 265 if(args[i] == "-m")
260 { 266 {
261 return myMessageBox(width, height, &w, argc, args); 267 return myMessageBox(width, height, &w, argc, args);
262 } 268 }
263 269
264 if(args[i] == "-f") 270 if(args[i] == "-f")
265 { 271 {
266 return fileviewer(&a, argc, args); 272 return fileviewer(&a, argc, args);
267 } 273 }
268 274
269 if(args[i] == "-i") 275 if(args[i] == "-i")
270 { 276 {
271 return input(width, height, &w, argc, args); 277 return input(width, height, &w, argc, args);
272 } 278 }
273 279
274 if(args[i] == "-h" || args[i] =="--help") 280 if(args[i] == "-h" || args[i] =="--help")
275 { 281 {
276 printusage(); 282 printusage();
277 return -1; 283 return -1;
278 } 284 }
279 } 285 }
280 286
281 printusage(); 287 printusage();
282 return -1; 288 return -1;
283} 289}
284 290
diff --git a/noncore/tools/remote/learntab.cpp b/noncore/tools/remote/learntab.cpp
index 7582161..335a3e9 100644
--- a/noncore/tools/remote/learntab.cpp
+++ b/noncore/tools/remote/learntab.cpp
@@ -1,191 +1,192 @@
1/* 1/*
2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. 2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie.
3Copyright (C) 2002 Thomas Stephens 3Copyright (C) 2002 Thomas Stephens
4 4
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include "learntab.h" 17#include "learntab.h"
18 18
19/* OPIE */
20#include <qpe/qpeapplication.h>
21
19LearnTab::LearnTab(QWidget *parent, const char *name):QWidget(parent,name) 22LearnTab::LearnTab(QWidget *parent, const char *name):QWidget(parent,name)
20{ 23{
21 QVBoxLayout *layout = new QVBoxLayout(this); 24 QVBoxLayout *layout = new QVBoxLayout(this);
22 QHBoxLayout *bottomLayout = new QHBoxLayout(this); 25 QHBoxLayout *bottomLayout = new QHBoxLayout(this);
23 26
24 layout->insertSpacing(0,5); 27 layout->insertSpacing(0,5);
25 remotesBox = new QListBox(this, "remotesBox"); 28 remotesBox = new QListBox(this, "remotesBox");
26 layout->insertWidget(0, remotesBox, 1); 29 layout->insertWidget(0, remotesBox, 1);
27 remotesBox->insertStringList(getRemotes()); 30 remotesBox->insertStringList(getRemotes());
28 31
29 layout->insertSpacing(-1,5); 32 layout->insertSpacing(-1,5);
30 layout->insertLayout(-1, bottomLayout); 33 layout->insertLayout(-1, bottomLayout);
31 layout->insertSpacing(-1,5); 34 layout->insertSpacing(-1,5);
32 35
33 QPushButton *add = new QPushButton("Add", this, "add"); 36 QPushButton *add = new QPushButton("Add", this, "add");
34 bottomLayout->insertSpacing(-1, 5); 37 bottomLayout->insertSpacing(-1, 5);
35 bottomLayout->insertWidget(-1, add); 38 bottomLayout->insertWidget(-1, add);
36 bottomLayout->insertSpacing(-1, 5); 39 bottomLayout->insertSpacing(-1, 5);
37 QPushButton *edit = new QPushButton("Edit", this, "edit"); 40 QPushButton *edit = new QPushButton("Edit", this, "edit");
38 bottomLayout->insertWidget(-1, edit); 41 bottomLayout->insertWidget(-1, edit);
39 bottomLayout->insertSpacing(-1, 5); 42 bottomLayout->insertSpacing(-1, 5);
40 QPushButton *del = new QPushButton("Delete", this, "delete"); 43 QPushButton *del = new QPushButton("Delete", this, "delete");
41 bottomLayout->insertWidget(-1, del); 44 bottomLayout->insertWidget(-1, del);
42 bottomLayout->insertSpacing(-1, 5); 45 bottomLayout->insertSpacing(-1, 5);
43 46
44 connect(add, SIGNAL(clicked()), this, SLOT(add()) ); 47 connect(add, SIGNAL(clicked()), this, SLOT(add()) );
45 connect(edit, SIGNAL(clicked()), this, SLOT(edit()) ); 48 connect(edit, SIGNAL(clicked()), this, SLOT(edit()) );
46 connect(del, SIGNAL(clicked()), this, SLOT(del()) ); 49 connect(del, SIGNAL(clicked()), this, SLOT(del()) );
47} 50}
48 51
49void LearnTab::add() 52void LearnTab::add()
50{ 53{
51 printf("LearnTab::add: add pressed\n"); 54 printf("LearnTab::add: add pressed\n");
52 RecordDialog *dialog = new RecordDialog(this); 55 RecordDialog *dialog = new RecordDialog(this);
53 dialog->showMaximized(); 56 QPEApplication::showDialog( dialog );
54} 57}
55 58
56void LearnTab::edit() 59void LearnTab::edit()
57{ 60{}
58}
59 61
60void LearnTab::del() 62void LearnTab::del()
61{ 63{}
62}
63 64
64QStringList LearnTab::getRemotes() 65QStringList LearnTab::getRemotes()
65{ 66{
66 const char write_buffer[] = "LIST\n"; 67 const char write_buffer[] = "LIST\n";
67 const char *readbuffer; 68 const char *readbuffer;
68 int i, numlines; 69 int i, numlines;
69 QStringList list; 70 QStringList list;
70 71
71 addr.sun_family=AF_UNIX; 72 addr.sun_family=AF_UNIX;
72 strcpy(addr.sun_path,"/dev/lircd"); 73 strcpy(addr.sun_path,"/dev/lircd");
73 74
74 fd = socket(AF_UNIX, SOCK_STREAM, 0); 75 fd = socket(AF_UNIX, SOCK_STREAM, 0);
75 if(fd == -1) 76 if(fd == -1)
76 { 77 {
77 QMessageBox *mb = new QMessageBox("Error!", 78 QMessageBox *mb = new QMessageBox("Error!",
78 "couldnt connect to socket", 79 "couldnt connect to socket",
79 QMessageBox::NoIcon, 80 QMessageBox::NoIcon,
80 QMessageBox::Ok, 81 QMessageBox::Ok,
81 QMessageBox::NoButton, 82 QMessageBox::NoButton,
82 QMessageBox::NoButton); 83 QMessageBox::NoButton);
83 mb->exec(); 84 mb->exec();
84 perror("LearnTab::GetRemotes"); 85 perror("LearnTab::GetRemotes");
85 return NULL; 86 return NULL;
86 } 87 }
87 88
88 if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) 89 if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1)
89 { 90 {
90 QMessageBox *mb = new QMessageBox("Error!", 91 QMessageBox *mb = new QMessageBox("Error!",
91 "couldnt connect to socket", 92 "couldnt connect to socket",
92 QMessageBox::NoIcon, 93 QMessageBox::NoIcon,
93 QMessageBox::Ok, 94 QMessageBox::Ok,
94 QMessageBox::NoButton, 95 QMessageBox::NoButton,
95 QMessageBox::NoButton); 96 QMessageBox::NoButton);
96 mb->exec(); 97 mb->exec();
97 perror("LearnTab::GetRemotes"); 98 perror("LearnTab::GetRemotes");
98 return NULL; 99 return NULL;
99 } 100 }
100 101
101 write(fd, write_buffer, strlen(write_buffer)); 102 write(fd, write_buffer, strlen(write_buffer));
102 103
103 for(i=0; i<5; i++) 104 for(i=0; i<5; i++)
104 { 105 {
105 printf("%d\n", i); 106 printf("%d\n", i);
106 readbuffer = readPacket(); 107 readbuffer = readPacket();
107 printf("%s", readbuffer); 108 printf("%s", readbuffer);
108 printf("%d\n", i); 109 printf("%d\n", i);
109 } 110 }
110 111
111 numlines = atoi(readbuffer); 112 numlines = atoi(readbuffer);
112 113
113 for(i=0; i<numlines; i++) 114 for(i=0; i<numlines; i++)
114 { 115 {
115 list+=readPacket(); 116 list+=readPacket();
116 } 117 }
117 118
118 if(strcasecmp(readPacket(), "END") != 0) 119 if(strcasecmp(readPacket(), "END") != 0)
119 { 120 {
120 QMessageBox *mb = new QMessageBox("Error!", 121 QMessageBox *mb = new QMessageBox("Error!",
121 "bad packet", 122 "bad packet",
122 QMessageBox::NoIcon, 123 QMessageBox::NoIcon,
123 QMessageBox::Ok, 124 QMessageBox::Ok,
124 QMessageBox::NoButton, 125 QMessageBox::NoButton,
125 QMessageBox::NoButton); 126 QMessageBox::NoButton);
126 mb->exec(); 127 mb->exec();
127 perror("LearnTab::GetRemotes"); 128 perror("LearnTab::GetRemotes");
128 return NULL; 129 return NULL;
129 } 130 }
130 131
131 ::close(fd); 132 ::close(fd);
132 return list; 133 return list;
133} 134}
134 135
135//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html 136//this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html
136const char *LearnTab::readPacket() 137const char *LearnTab::readPacket()
137{ 138{
138 static char buffer[PACKET_SIZE+1]=""; 139 static char buffer[PACKET_SIZE+1]="";
139 char *end; 140 char *end;
140 static int ptr=0,end_len=0; 141 static int ptr=0,end_len=0;
141 ssize_t ret; 142 ssize_t ret;
142 timeout = 0; 143 timeout = 0;
143 144
144 if(ptr>0) 145 if(ptr>0)
145 { 146 {
146 memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); 147 memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1);
147 ptr=strlen(buffer); 148 ptr=strlen(buffer);
148 end=strchr(buffer,'\n'); 149 end=strchr(buffer,'\n');
149 } 150 }
150 else 151 else
151 { 152 {
152 end=NULL; 153 end=NULL;
153 } 154 }
154 alarm(TIMEOUT); 155 alarm(TIMEOUT);
155 while(end==NULL) 156 while(end==NULL)
156 { 157 {
157 if(PACKET_SIZE<=ptr) 158 if(PACKET_SIZE<=ptr)
158 { 159 {
159 fprintf(stderr,"bad packet\n"); 160 fprintf(stderr,"bad packet\n");
160 ptr=0; 161 ptr=0;
161 return(NULL); 162 return(NULL);
162 } 163 }
163 ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); 164 ret=read(fd,buffer+ptr,PACKET_SIZE-ptr);
164 165
165 if(ret<=0 || timeout) 166 if(ret<=0 || timeout)
166 { 167 {
167 if(timeout) 168 if(timeout)
168 { 169 {
169 fprintf(stderr,"timeout\n"); 170 fprintf(stderr,"timeout\n");
170 } 171 }
171 else 172 else
172 { 173 {
173 alarm(0); 174 alarm(0);
174 } 175 }
175 ptr=0; 176 ptr=0;
176 return(NULL); 177 return(NULL);
177 } 178 }
178 buffer[ptr+ret]=0; 179 buffer[ptr+ret]=0;
179 ptr=strlen(buffer); 180 ptr=strlen(buffer);
180 end=strchr(buffer,'\n'); 181 end=strchr(buffer,'\n');
181 } 182 }
182 alarm(0);timeout=0; 183 alarm(0);timeout=0;
183 184
184 end[0]=0; 185 end[0]=0;
185 ptr=strlen(buffer)+1; 186 ptr=strlen(buffer)+1;
186//# ifdef DEBUG 187 //# ifdef DEBUG
187 //printf("buffer: -%s-\n",buffer); 188 //printf("buffer: -%s-\n",buffer);
188//# endif 189 //# endif
189 return(buffer); 190 return(buffer);
190} 191}
191 192
diff --git a/noncore/tools/remote/remote.cpp b/noncore/tools/remote/remote.cpp
index 7972def..638629f 100644
--- a/noncore/tools/remote/remote.cpp
+++ b/noncore/tools/remote/remote.cpp
@@ -1,28 +1,35 @@
1/* 1/*
2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. 2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie.
3Copyright (C) 2002 Thomas Stephens 3Copyright (C) 2002 Thomas Stephens
4 4
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include "mainview.h"
18
19/* OPIE */
17#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
18#include <qpe/resource.h> 21#include <qpe/resource.h>
19#include <qpe/config.h> 22#include <qpe/config.h>
23
24/* QT */
20#include <qpushbutton.h> 25#include <qpushbutton.h>
21#include <qtabwidget.h> 26#include <qtabwidget.h>
22#include <qlayout.h> 27#include <qlayout.h>
23#include <qmessagebox.h> 28#include <qmessagebox.h>
24#include <qpaintdevice.h> 29#include <qpaintdevice.h>
25#include <qobject.h> 30#include <qobject.h>
31
32/* STD */
26#include <sys/socket.h> 33#include <sys/socket.h>
27#include <sys/types.h> 34#include <sys/types.h>
28#include <sys/un.h> 35#include <sys/un.h>
@@ -30,16 +37,15 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30#include <stdio.h> 37#include <stdio.h>
31#include <signal.h> 38#include <signal.h>
32 39
33#include "mainview.h"
34 40
35/*void reconnect(int &fd) 41/*void reconnect(int &fd)
36{ 42{
37 //struct sockaddr_un addr; 43 //struct sockaddr_un addr;
38 44
39 addr.sun_family=AF_UNIX; 45 addr.sun_family=AF_UNIX;
40 strcpy(addr.sun_path,"/dev/lircd"); 46 strcpy(addr.sun_path,"/dev/lircd");
41 fd = socket(AF_UNIX, SOCK_STREAM, 0); 47 fd = socket(AF_UNIX, SOCK_STREAM, 0);
42 48
43 if(connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) 49 if(connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1)
44 { 50 {
45 QMessageBox *mb = new QMessageBox("error", 51 QMessageBox *mb = new QMessageBox("error",
@@ -55,46 +61,46 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
55 61
56int main( int argc, char **argv ) 62int main( int argc, char **argv )
57{ 63{
58 QPEApplication a( argc, argv ); 64 QPEApplication a( argc, argv );
59 MainView w; 65 MainView w;
60 66
61 int fd; 67 int fd;
62 //struct sockaddr_un addr; 68 //struct sockaddr_un addr;
63 //char read_buffer[BUFFERSIZE+1]; 69 //char read_buffer[BUFFERSIZE+1];
64 //char write_buffer[] = "LIST\n"; 70 //char write_buffer[] = "LIST\n";
65 71
66 //addr.sun_family=AF_UNIX; 72 //addr.sun_family=AF_UNIX;
67 //strcpy(addr.sun_path,"/dev/lircd"); 73 //strcpy(addr.sun_path,"/dev/lircd");
68 //fd = socket(AF_UNIX, SOCK_STREAM, 0); 74 //fd = socket(AF_UNIX, SOCK_STREAM, 0);
69 75
70 //printf("fd1: %d\n", fd); 76 //printf("fd1: %d\n", fd);
71/* 77 /*
72 if(connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) 78 if(connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1)
73 { 79 {
74 QMessageBox *mb = new QMessageBox("error", 80 QMessageBox *mb = new QMessageBox("error",
75 "couldnt connect to socket", 81 "couldnt connect to socket",
76 QMessageBox::NoIcon, 82 QMessageBox::NoIcon,
77 QMessageBox::Ok, 83 QMessageBox::Ok,
78 QMessageBox::NoButton, 84 QMessageBox::NoButton,
79 QMessageBox::NoButton); 85 QMessageBox::NoButton);
80 mb->exec(); 86 mb->exec();
81 } 87 }
82*/ 88 */
83 89
84 //printf("%d\n", write(fd, write_buffer, sizeof(write_buffer) ) ); 90 //printf("%d\n", write(fd, write_buffer, sizeof(write_buffer) ) );
85 91
86 //printf("%d\n", read(fd, read_buffer, BUFFERSIZE ) ); 92 //printf("%d\n", read(fd, read_buffer, BUFFERSIZE ) );
87 93
88 //QMessageBox *mbtest = new QMessageBox("lirc test", 94 //QMessageBox *mbtest = new QMessageBox("lirc test",
89 // *new QString((const char *) read_buffer), 95 // *new QString((const char *) read_buffer),
90 // QMessageBox::NoIcon, 96 // QMessageBox::NoIcon,
91 // QMessageBox::Ok, 97 // QMessageBox::Ok,
92 // QMessageBox::NoButton, 98 // QMessageBox::NoButton,
93 // QMessageBox::NoButton); 99 // QMessageBox::NoButton);
94 //mbtest->exec(); 100 //mbtest->exec();
95 101
96 a.setMainWidget( &w ); 102 a.setMainWidget( &w );
97 w.setIRSocket(fd); 103 w.setIRSocket(fd);
98 w.showMaximized(); 104 QPEApplication::showWidget( &w );
99 return a.exec(); 105 return a.exec();
100} 106}