summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oglobalsettings.cpp6
-rw-r--r--libopie2/opienet/onetwork.cpp3
-rw-r--r--libopie2/opienet/onetwork.h8
3 files changed, 13 insertions, 4 deletions
diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp
index 184ee69..1799529 100644
--- a/libopie2/opiecore/oglobalsettings.cpp
+++ b/libopie2/opiecore/oglobalsettings.cpp
@@ -379,169 +379,169 @@ QFont OGlobalSettings::windowTitleFont()
379 _windowTitleFont = new QFont("helvetica", 12, QFont::Bold); 379 _windowTitleFont = new QFont("helvetica", 12, QFont::Bold);
380 _windowTitleFont->setPixelSize(12); 380 _windowTitleFont->setPixelSize(12);
381 _windowTitleFont->setStyleHint(QFont::SansSerif); 381 _windowTitleFont->setStyleHint(QFont::SansSerif);
382 382
383 OConfig *c = OGlobal::config(); 383 OConfig *c = OGlobal::config();
384 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 384 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
385 *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency 385 *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency
386 386
387 return *_windowTitleFont; 387 return *_windowTitleFont;
388} 388}
389 389
390QFont OGlobalSettings::taskbarFont() 390QFont OGlobalSettings::taskbarFont()
391{ 391{
392 if(_taskbarFont) 392 if(_taskbarFont)
393 return *_taskbarFont; 393 return *_taskbarFont;
394 394
395 _taskbarFont = new QFont("helvetica", 8); 395 _taskbarFont = new QFont("helvetica", 8);
396 _taskbarFont->setPixelSize(8); 396 _taskbarFont->setPixelSize(8);
397 _taskbarFont->setStyleHint(QFont::SansSerif); 397 _taskbarFont->setStyleHint(QFont::SansSerif);
398 398
399 OConfig *c = OGlobal::config(); 399 OConfig *c = OGlobal::config();
400 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 400 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
401 *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont); 401 *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont);
402 402
403 return *_taskbarFont; 403 return *_taskbarFont;
404} 404}
405 405
406// FIXME: the whole path stuff has to be revised for OPIE 406// FIXME: the whole path stuff has to be revised for OPIE
407 407
408void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. 408void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here.
409{ 409{
410 if ( s_desktopPath != 0 ) 410 if ( s_desktopPath != 0 )
411 return; 411 return;
412 412
413 s_desktopPath = new QString(); 413 s_desktopPath = new QString();
414 s_autostartPath = new QString(); 414 s_autostartPath = new QString();
415 s_trashPath = new QString(); 415 s_trashPath = new QString();
416 s_documentPath = new QString(); 416 s_documentPath = new QString();
417 417
418 OConfig *config = OGlobal::config(); 418 OConfig *config = OGlobal::config();
419 //bool dollarExpansion = config->isDollarExpansion(); 419 //bool dollarExpansion = config->isDollarExpansion();
420 //config->setDollarExpansion(true); 420 //config->setDollarExpansion(true);
421 OConfigGroupSaver cgs( config, "Paths" ); 421 OConfigGroupSaver cgs( config, "Paths" );
422 422
423 // Desktop Path 423 // Desktop Path
424 *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/"; 424 *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/";
425 *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath); 425 *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath);
426 if ( (*s_desktopPath)[0] != '/' ) 426 if ( (*s_desktopPath)[0] != '/' )
427 s_desktopPath->prepend( QDir::homeDirPath() + "/" ); 427 s_desktopPath->prepend( QDir::homeDirPath() + "/" );
428 *s_desktopPath = QDir::cleanDirPath( *s_desktopPath ); 428 *s_desktopPath = QDir::cleanDirPath( *s_desktopPath );
429 if ( s_desktopPath->right(1) != "/") 429 if ( s_desktopPath->right(1) != "/")
430 *s_desktopPath += "/"; 430 *s_desktopPath += "/";
431 431
432 // Trash Path 432 // Trash Path
433 *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/"; 433 *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/";
434 *s_trashPath = config->readEntry( "Trash" , *s_trashPath); 434 *s_trashPath = config->readEntry( "Trash" , *s_trashPath);
435 if ( (*s_trashPath)[0] != '/' ) 435 if ( (*s_trashPath)[0] != '/' )
436 s_trashPath->prepend( QDir::homeDirPath() + "/" ); 436 s_trashPath->prepend( QDir::homeDirPath() + "/" );
437 *s_trashPath = QDir::cleanDirPath( *s_trashPath ); 437 *s_trashPath = QDir::cleanDirPath( *s_trashPath );
438 if ( s_trashPath->right(1) != "/") 438 if ( s_trashPath->right(1) != "/")
439 *s_trashPath += "/"; 439 *s_trashPath += "/";
440 // We need to save it in any case, in case the language changes later on, 440 // We need to save it in any case, in case the language changes later on,
441 if ( !config->hasKey( "Trash" ) ) 441 if ( !config->hasKey( "Trash" ) )
442 { 442 {
443 //config->writePathEntry( "Trash", *s_trashPath, true, true ); 443 //config->writePathEntry( "Trash", *s_trashPath, true, true );
444 config->writeEntry( "Trash", *s_trashPath ); 444 config->writeEntry( "Trash", *s_trashPath );
445 //config->sync(); 445 //config->sync();
446 } 446 }
447 447
448/* // Autostart Path 448/* // Autostart Path
449 *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/"; 449 *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/";
450 *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath); 450 *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath);
451 if ( (*s_autostartPath)[0] != '/' ) 451 if ( (*s_autostartPath)[0] != '/' )
452 s_autostartPath->prepend( QDir::homeDirPath() + "/" ); 452 s_autostartPath->prepend( QDir::homeDirPath() + "/" );
453 *s_autostartPath = QDir::cleanDirPath( *s_autostartPath ); 453 *s_autostartPath = QDir::cleanDirPath( *s_autostartPath );
454 if ( s_autostartPath->right(1) != "/") 454 if ( s_autostartPath->right(1) != "/")
455 *s_autostartPath += "/"; 455 *s_autostartPath += "/";
456*/ 456*/
457 // Document Path 457 // Document Path
458 *s_documentPath = QString::null; 458 *s_documentPath = QString::null;
459 *s_documentPath = config->readEntry( "Documents" , *s_documentPath); 459 *s_documentPath = config->readEntry( "Documents" , *s_documentPath);
460 if ( (*s_documentPath)[0] != '/' ) 460 if ( (*s_documentPath)[0] != '/' )
461 s_documentPath->prepend( QDir::homeDirPath() + "/" ); 461 s_documentPath->prepend( QDir::homeDirPath() + "/" );
462 *s_documentPath = QDir::cleanDirPath( *s_documentPath ); 462 *s_documentPath = QDir::cleanDirPath( *s_documentPath );
463 if ( s_documentPath->right(1) != "/") 463 if ( s_documentPath->right(1) != "/")
464 *s_documentPath += "/"; 464 *s_documentPath += "/";
465 465
466 //config->setDollarExpansion(dollarExpansion); 466 //config->setDollarExpansion(dollarExpansion);
467 467
468 // Make sure this app gets the notifications about those paths 468 // Make sure this app gets the notifications about those paths
469 //if (kapp) 469 //if (kapp)
470 //kapp->addKipcEventMask(KIPC::SettingsChanged); 470 //kapp->addKipcEventMask(KIPC::SettingsChanged);
471} 471}
472 472
473void OGlobalSettings::initColors() 473void OGlobalSettings::initColors()
474{ 474{
475 if ( not OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 ); 475 if ( !OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 );
476 if ( not OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 ); 476 if ( !OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 );
477 if ( not OpieGray ) OpieGray = new QColor( 220, 210, 215 ); 477 if ( !OpieGray ) OpieGray = new QColor( 220, 210, 215 );
478} 478}
479 479
480void OGlobalSettings::rereadFontSettings() 480void OGlobalSettings::rereadFontSettings()
481{ 481{
482 delete _generalFont; 482 delete _generalFont;
483 _generalFont = 0L; 483 _generalFont = 0L;
484 delete _fixedFont; 484 delete _fixedFont;
485 _fixedFont = 0L; 485 _fixedFont = 0L;
486 delete _menuFont; 486 delete _menuFont;
487 _menuFont = 0L; 487 _menuFont = 0L;
488 delete _toolBarFont; 488 delete _toolBarFont;
489 _toolBarFont = 0L; 489 _toolBarFont = 0L;
490 delete _windowTitleFont; 490 delete _windowTitleFont;
491 _windowTitleFont = 0L; 491 _windowTitleFont = 0L;
492 delete _taskbarFont; 492 delete _taskbarFont;
493 _taskbarFont = 0L; 493 _taskbarFont = 0L;
494} 494}
495 495
496void OGlobalSettings::rereadPathSettings() 496void OGlobalSettings::rereadPathSettings()
497{ 497{
498 qDebug( "OGlobalSettings::rereadPathSettings" ); 498 qDebug( "OGlobalSettings::rereadPathSettings" );
499 delete s_autostartPath; 499 delete s_autostartPath;
500 s_autostartPath = 0L; 500 s_autostartPath = 0L;
501 delete s_trashPath; 501 delete s_trashPath;
502 s_trashPath = 0L; 502 s_trashPath = 0L;
503 delete s_desktopPath; 503 delete s_desktopPath;
504 s_desktopPath = 0L; 504 s_desktopPath = 0L;
505 delete s_documentPath; 505 delete s_documentPath;
506 s_documentPath = 0L; 506 s_documentPath = 0L;
507} 507}
508 508
509OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings() 509OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings()
510{ 510{
511 if ( ! s_mouseSettings ) 511 if ( ! s_mouseSettings )
512 { 512 {
513 s_mouseSettings = new OMouseSettings; 513 s_mouseSettings = new OMouseSettings;
514 OMouseSettings & s = *s_mouseSettings; // for convenience 514 OMouseSettings & s = *s_mouseSettings; // for convenience
515 515
516 OConfigGroupSaver cgs( OGlobal::config(), "Mouse" ); 516 OConfigGroupSaver cgs( OGlobal::config(), "Mouse" );
517 QString setting = OGlobal::config()->readEntry("MouseButtonMapping"); 517 QString setting = OGlobal::config()->readEntry("MouseButtonMapping");
518 if (setting == "RightHanded") 518 if (setting == "RightHanded")
519 s.handed = OMouseSettings::RightHanded; 519 s.handed = OMouseSettings::RightHanded;
520 else if (setting == "LeftHanded") 520 else if (setting == "LeftHanded")
521 s.handed = OMouseSettings::LeftHanded; 521 s.handed = OMouseSettings::LeftHanded;
522 else 522 else
523 { 523 {
524 524
525 // FIXME: Implement for Opie / Qt Embedded 525 // FIXME: Implement for Opie / Qt Embedded
526 526
527 } 527 }
528 } 528 }
529 return *s_mouseSettings; 529 return *s_mouseSettings;
530} 530}
531 531
532void OGlobalSettings::rereadMouseSettings() 532void OGlobalSettings::rereadMouseSettings()
533{ 533{
534 delete s_mouseSettings; 534 delete s_mouseSettings;
535 s_mouseSettings = 0L; 535 s_mouseSettings = 0L;
536} 536}
537 537
538// FIXME: This won't be necessary, or will it? :-D 538// FIXME: This won't be necessary, or will it? :-D
539 539
540bool OGlobalSettings::isMultiHead() 540bool OGlobalSettings::isMultiHead()
541{ 541{
542 QCString multiHead = getenv("OPIE_MULTIHEAD"); 542 QCString multiHead = getenv("OPIE_MULTIHEAD");
543 if (!multiHead.isEmpty()) { 543 if (!multiHead.isEmpty()) {
544 return (multiHead.lower() == "true"); 544 return (multiHead.lower() == "true");
545 } 545 }
546 return false; 546 return false;
547} 547}
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 25c70e0..998b50e 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,149 +1,150 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34/* OPIE */ 34/* OPIE */
35 35
36#include <opie2/onetwork.h> 36#include <opie2/onetwork.h>
37 37
38/* QT */ 38/* QT */
39 39
40#include <qfile.h> 40#include <qfile.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42 42
43/* UNIX */ 43/* UNIX */
44 44
45#include <arpa/inet.h> 45#include <arpa/inet.h>
46#include <cerrno> 46#include <cerrno>
47#include <cstring> 47#include <cstring>
48#include <cstdlib> 48#include <cstdlib>
49#include <math.h> 49#include <math.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/types.h> 52#include <sys/types.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <linux/sockios.h>
54#include <linux/wireless.h> 55#include <linux/wireless.h>
55 56
56using namespace std; 57using namespace std;
57 58
58/*====================================================================================== 59/*======================================================================================
59 * ONetwork 60 * ONetwork
60 *======================================================================================*/ 61 *======================================================================================*/
61 62
62ONetwork* ONetwork::_instance = 0; 63ONetwork* ONetwork::_instance = 0;
63 64
64ONetwork::ONetwork() 65ONetwork::ONetwork()
65{ 66{
66 qDebug( "ONetwork::ONetwork()" ); 67 qDebug( "ONetwork::ONetwork()" );
67 synchronize(); 68 synchronize();
68} 69}
69 70
70void ONetwork::synchronize() 71void ONetwork::synchronize()
71{ 72{
72 // gather available interfaces by inspecting /proc/net/dev 73 // gather available interfaces by inspecting /proc/net/dev
73 // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 74 // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
74 75
75 _interfaces.clear(); 76 _interfaces.clear();
76 QString str; 77 QString str;
77 QFile f( "/proc/net/dev" ); 78 QFile f( "/proc/net/dev" );
78 bool hasFile = f.open( IO_ReadOnly ); 79 bool hasFile = f.open( IO_ReadOnly );
79 if ( !hasFile ) 80 if ( !hasFile )
80 { 81 {
81 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); 82 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" );
82 return; 83 return;
83 } 84 }
84 QTextStream s( &f ); 85 QTextStream s( &f );
85 s.readLine(); 86 s.readLine();
86 s.readLine(); 87 s.readLine();
87 while ( !s.atEnd() ) 88 while ( !s.atEnd() )
88 { 89 {
89 s >> str; 90 s >> str;
90 str.truncate( str.find( ':' ) ); 91 str.truncate( str.find( ':' ) );
91 qDebug( "ONetwork: found interface '%s'", (const char*) str ); 92 qDebug( "ONetwork: found interface '%s'", (const char*) str );
92 ONetworkInterface* iface; 93 ONetworkInterface* iface;
93 if ( isWirelessInterface( str ) ) 94 if ( isWirelessInterface( str ) )
94 { 95 {
95 iface = new OWirelessNetworkInterface( str ); 96 iface = new OWirelessNetworkInterface( str );
96 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 97 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
97 } 98 }
98 else 99 else
99 { 100 {
100 iface = new ONetworkInterface( str ); 101 iface = new ONetworkInterface( str );
101 } 102 }
102 _interfaces.insert( str, iface ); 103 _interfaces.insert( str, iface );
103 s.readLine(); 104 s.readLine();
104 } 105 }
105} 106}
106 107
107 108
108ONetworkInterface* ONetwork::interface( QString iface ) const 109ONetworkInterface* ONetwork::interface( QString iface ) const
109{ 110{
110 return _interfaces[iface]; 111 return _interfaces[iface];
111} 112}
112 113
113 114
114ONetwork* ONetwork::instance() 115ONetwork* ONetwork::instance()
115{ 116{
116 if ( !_instance ) _instance = new ONetwork(); 117 if ( !_instance ) _instance = new ONetwork();
117 return _instance; 118 return _instance;
118} 119}
119 120
120 121
121ONetwork::InterfaceIterator ONetwork::iterator() const 122ONetwork::InterfaceIterator ONetwork::iterator() const
122{ 123{
123 return ONetwork::InterfaceIterator( _interfaces ); 124 return ONetwork::InterfaceIterator( _interfaces );
124} 125}
125 126
126 127
127bool ONetwork::isWirelessInterface( const char* name ) const 128bool ONetwork::isWirelessInterface( const char* name ) const
128{ 129{
129 int sfd = socket( AF_INET, SOCK_DGRAM, 0 ); 130 int sfd = socket( AF_INET, SOCK_DGRAM, 0 );
130 iwreqstruct iwr; 131 iwreqstruct iwr;
131 memset( &iwr, 0, sizeof( iwreqstruct ) ); 132 memset( &iwr, 0, sizeof( iwreqstruct ) );
132 strcpy( (char*) &iwr.ifr_name, name ); 133 strcpy( (char*) &iwr.ifr_name, name );
133 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 134 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
134 if ( result == -1 ) 135 if ( result == -1 )
135 qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) ); 136 qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) );
136 else 137 else
137 qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." ); 138 qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." );
138 return ( result != -1 ); 139 return ( result != -1 );
139} 140}
140 141
141/*====================================================================================== 142/*======================================================================================
142 * ONetworkInterface 143 * ONetworkInterface
143 *======================================================================================*/ 144 *======================================================================================*/
144 145
145ONetworkInterface::ONetworkInterface( const QString& name ) 146ONetworkInterface::ONetworkInterface( const QString& name )
146 :_name( name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 147 :_name( name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
147{ 148{
148 qDebug( "ONetworkInterface::ONetworkInterface()" ); 149 qDebug( "ONetworkInterface::ONetworkInterface()" );
149 init(); 150 init();
@@ -632,161 +633,161 @@ void OCiscoMonitoringInterface::setEnabled( bool b )
632 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 633 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
633 QFile f( fname ); 634 QFile f( fname );
634 if ( !f.exists() ) return; 635 if ( !f.exists() ) return;
635 636
636 if ( f.open( IO_WriteOnly ) ) 637 if ( f.open( IO_WriteOnly ) )
637 { 638 {
638 QTextStream s( &f ); 639 QTextStream s( &f );
639 s << "Mode: r"; 640 s << "Mode: r";
640 s << "Mode: y"; 641 s << "Mode: y";
641 s << "XmitPower: 1"; 642 s << "XmitPower: 1";
642 643
643 OMonitoringInterface::setEnabled( b ); 644 OMonitoringInterface::setEnabled( b );
644 645
645 } 646 }
646 647
647 // flushing and closing will be done automatically when f goes out of scope 648 // flushing and closing will be done automatically when f goes out of scope
648} 649}
649 650
650 651
651QString OCiscoMonitoringInterface::name() const 652QString OCiscoMonitoringInterface::name() const
652{ 653{
653 return "cisco"; 654 return "cisco";
654} 655}
655 656
656 657
657void OCiscoMonitoringInterface::setChannel( int ) 658void OCiscoMonitoringInterface::setChannel( int )
658{ 659{
659 // cisco devices automatically switch channels when in monitor mode 660 // cisco devices automatically switch channels when in monitor mode
660} 661}
661 662
662 663
663/*====================================================================================== 664/*======================================================================================
664 * OWlanNGMonitoringInterface 665 * OWlanNGMonitoringInterface
665 *======================================================================================*/ 666 *======================================================================================*/
666 667
667 668
668OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) 669OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface )
669 :OMonitoringInterface( iface ) 670 :OMonitoringInterface( iface )
670{ 671{
671 iface->setMonitoring( this ); 672 iface->setMonitoring( this );
672} 673}
673 674
674 675
675OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 676OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
676{ 677{
677} 678}
678 679
679 680
680void OWlanNGMonitoringInterface::setEnabled( bool b ) 681void OWlanNGMonitoringInterface::setEnabled( bool b )
681{ 682{
682 //FIXME: do nothing if its already in the same mode 683 //FIXME: do nothing if its already in the same mode
683 684
684 QString enable = b ? "true" : "false"; 685 QString enable = b ? "true" : "false";
685 QString cmd; 686 QString cmd;
686 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); 687 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable );
687 system( cmd ); 688 system( cmd );
688 689
689 OMonitoringInterface::setEnabled( b ); 690 OMonitoringInterface::setEnabled( b );
690} 691}
691 692
692 693
693QString OWlanNGMonitoringInterface::name() const 694QString OWlanNGMonitoringInterface::name() const
694{ 695{
695 return "wlan-ng"; 696 return "wlan-ng";
696} 697}
697 698
698 699
699void OWlanNGMonitoringInterface::setChannel( int ) 700void OWlanNGMonitoringInterface::setChannel( int )
700{ 701{
701 // wlan-ng devices automatically switch channels when in monitor mode 702 // wlan-ng devices automatically switch channels when in monitor mode
702} 703}
703 704
704 705
705/*====================================================================================== 706/*======================================================================================
706 * OHostAPMonitoringInterface 707 * OHostAPMonitoringInterface
707 *======================================================================================*/ 708 *======================================================================================*/
708 709
709OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) 710OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface )
710 :OMonitoringInterface( iface ) 711 :OMonitoringInterface( iface )
711{ 712{
712 iface->setMonitoring( this ); 713 iface->setMonitoring( this );
713} 714}
714 715
715OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 716OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
716{ 717{
717} 718}
718 719
719void OHostAPMonitoringInterface::setEnabled( bool b ) 720void OHostAPMonitoringInterface::setEnabled( bool b )
720{ 721{
721 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 722 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
722 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 723 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
723 724
724 #if WIRELESS_EXT > 14 725 #if WIRELESS_EXT > 14
725 _if->_iwr.u.mode = IW_MODE_MONITOR; 726 _if->_iwr.u.mode = IW_MODE_MONITOR;
726 _if->wioctl( SIOCSIWMODE ); 727 _if->wioctl( SIOCSIWMODE );
727 #else 728 #else
728 int* args = (int*) &_if._iwr.u.name; 729 int* args = (int*) &_if->_iwr.u.name;
729 args[0] = 2; 730 args[0] = 2;
730 args[1] = 0; 731 args[1] = 0;
731 _if->wioctl( SIOCDEVPRIVATE ); 732 _if->wioctl( SIOCDEVPRIVATE );
732 #endif 733 #endif
733 734
734 OMonitoringInterface::setEnabled( b ); 735 OMonitoringInterface::setEnabled( b );
735} 736}
736 737
737 738
738QString OHostAPMonitoringInterface::name() const 739QString OHostAPMonitoringInterface::name() const
739{ 740{
740 return "hostap"; 741 return "hostap";
741} 742}
742 743
743 744
744/*====================================================================================== 745/*======================================================================================
745 * OOrinocoNetworkInterface 746 * OOrinocoNetworkInterface
746 *======================================================================================*/ 747 *======================================================================================*/
747 748
748OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) 749OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface )
749 :OMonitoringInterface( iface ) 750 :OMonitoringInterface( iface )
750{ 751{
751 iface->setMonitoring( this ); 752 iface->setMonitoring( this );
752} 753}
753 754
754 755
755OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 756OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
756{ 757{
757} 758}
758 759
759 760
760void OOrinocoMonitoringInterface::setChannel( int c ) 761void OOrinocoMonitoringInterface::setChannel( int c )
761{ 762{
762 // call iwpriv <device> monitor 2 <channel> 763 // call iwpriv <device> monitor 2 <channel>
763 int* args = (int*) &_if->_iwr.u.name; 764 int* args = (int*) &_if->_iwr.u.name;
764 args[0] = 2; 765 args[0] = 2;
765 args[1] = c; 766 args[1] = c;
766 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); 767 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
767} 768}
768 769
769 770
770void OOrinocoMonitoringInterface::setEnabled( bool b ) 771void OOrinocoMonitoringInterface::setEnabled( bool b )
771{ 772{
772 if ( b ) 773 if ( b )
773 { 774 {
774 setChannel( 1 ); 775 setChannel( 1 );
775 } 776 }
776 else 777 else
777 { 778 {
778 // call iwpriv <device> monitor 0 0 779 // call iwpriv <device> monitor 0 0
779 int* args = (int*) &_if->_iwr.u.name; 780 int* args = (int*) &_if->_iwr.u.name;
780 args[0] = 0; 781 args[0] = 0;
781 args[1] = 0; 782 args[1] = 0;
782 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); 783 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
783 } 784 }
784 785
785 OMonitoringInterface::setEnabled( b ); 786 OMonitoringInterface::setEnabled( b );
786} 787}
787 788
788 789
789QString OOrinocoMonitoringInterface::name() const 790QString OOrinocoMonitoringInterface::name() const
790{ 791{
791 return "orinoco"; 792 return "orinoco";
792} 793}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 936ac85..56da5f4 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,150 +1,158 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef ONETWORK_H 34#ifndef ONETWORK_H
35#define ONETWORK_H 35#define ONETWORK_H
36 36
37/* QT */ 37/* QT */
38 38
39#include <qdict.h> 39#include <qdict.h>
40#include <qmap.h> 40#include <qmap.h>
41#include <qobject.h> 41#include <qobject.h>
42#include <qhostaddress.h> 42#include <qhostaddress.h>
43 43
44/* OPIE */ 44/* OPIE */
45 45
46#include <opie2/onetutils.h> 46#include <opie2/onetutils.h>
47 47
48// ML: Yeah, I hate to include kernel headers, but it's necessary here 48// ML: Yeah, I hate to include kernel headers, but it's necessary here
49// ML: Recent RedHat and MandrakePatches to the Kernel and WE broke something 49// ML: Recent RedHat and MandrakePatches to the Kernel and WE broke something
50// ML: #include <net/if.h> e.g. conflicts with #include <linux/wireless.h> 50// ML: #include <net/if.h> e.g. conflicts with #include <linux/wireless.h>
51
52#ifndef IFNAMSIZ
51#define IFNAMSIZ 16 53#define IFNAMSIZ 16
54#endif
55
52#include <linux/wireless.h> 56#include <linux/wireless.h>
53#include <net/if.h> 57#include <net/if.h>
54 58
59#ifndef SIOCIWFIRSTPRIV
60#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
61#endif
62
55class ONetworkInterface; 63class ONetworkInterface;
56class OWirelessNetworkInterface; 64class OWirelessNetworkInterface;
57class OChannelHopper; 65class OChannelHopper;
58class OMonitoringInterface; 66class OMonitoringInterface;
59 67
60typedef struct ifreq ifreqstruct; 68typedef struct ifreq ifreqstruct;
61typedef struct iwreq iwreqstruct; 69typedef struct iwreq iwreqstruct;
62typedef struct iw_event iweventstruct; 70typedef struct iw_event iweventstruct;
63typedef struct iw_freq iwfreqstruct; 71typedef struct iw_freq iwfreqstruct;
64typedef struct iw_priv_args iwprivargsstruct; 72typedef struct iw_priv_args iwprivargsstruct;
65typedef struct iw_range iwrangestruct; 73typedef struct iw_range iwrangestruct;
66 74
67/*====================================================================================== 75/*======================================================================================
68 * ONetwork 76 * ONetwork
69 *======================================================================================*/ 77 *======================================================================================*/
70 78
71class ONetwork : public QObject 79class ONetwork : public QObject
72{ 80{
73 Q_OBJECT 81 Q_OBJECT
74 82
75 public: 83 public:
76 typedef QDict<ONetworkInterface> InterfaceMap; 84 typedef QDict<ONetworkInterface> InterfaceMap;
77 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 85 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
78 86
79 public: 87 public:
80 static ONetwork* instance(); 88 static ONetwork* instance();
81 InterfaceIterator iterator() const; 89 InterfaceIterator iterator() const;
82 bool isWirelessInterface( const char* ) const; 90 bool isWirelessInterface( const char* ) const;
83 ONetworkInterface* interface( QString ) const; 91 ONetworkInterface* interface( QString ) const;
84 92
85 protected: 93 protected:
86 ONetwork(); 94 ONetwork();
87 void synchronize(); 95 void synchronize();
88 96
89 private: 97 private:
90 static ONetwork* _instance; 98 static ONetwork* _instance;
91 InterfaceMap _interfaces; 99 InterfaceMap _interfaces;
92}; 100};
93 101
94 102
95/*====================================================================================== 103/*======================================================================================
96 * ONetworkInterface 104 * ONetworkInterface
97 *======================================================================================*/ 105 *======================================================================================*/
98 106
99class ONetworkInterface 107class ONetworkInterface
100{ 108{
101 friend class OMonitoringInterface; 109 friend class OMonitoringInterface;
102 friend class OCiscoMonitoringInterface; 110 friend class OCiscoMonitoringInterface;
103 friend class OWlanNGMonitoringInterface; 111 friend class OWlanNGMonitoringInterface;
104 friend class OHostAPMonitoringInterface; 112 friend class OHostAPMonitoringInterface;
105 friend class OOrinocoMonitoringInterface; 113 friend class OOrinocoMonitoringInterface;
106 114
107 public: 115 public:
108 ONetworkInterface( const QString& name ); 116 ONetworkInterface( const QString& name );
109 virtual ~ONetworkInterface(); 117 virtual ~ONetworkInterface();
110 118
111 const QString& name() const; 119 const QString& name() const;
112 void setMonitoring( OMonitoringInterface* ); 120 void setMonitoring( OMonitoringInterface* );
113 OMonitoringInterface* monitoring() const; 121 OMonitoringInterface* monitoring() const;
114 bool setPromiscuousMode( bool ); 122 bool setPromiscuousMode( bool );
115 bool promiscuousMode() const; 123 bool promiscuousMode() const;
116 bool setUp( bool ); 124 bool setUp( bool );
117 bool isUp() const; 125 bool isUp() const;
118 bool isLoopback() const; 126 bool isLoopback() const;
119 bool isWireless() const; 127 bool isWireless() const;
120 QString ipV4Address() const; 128 QString ipV4Address() const;
121 OMacAddress macAddress() const; 129 OMacAddress macAddress() const;
122 130
123 protected: 131 protected:
124 const QString _name; 132 const QString _name;
125 const int _sfd; 133 const int _sfd;
126 mutable ifreqstruct _ifr; 134 mutable ifreqstruct _ifr;
127 OMonitoringInterface* _mon; 135 OMonitoringInterface* _mon;
128 136
129 protected: 137 protected:
130 ifreqstruct& ifr() const; 138 ifreqstruct& ifr() const;
131 virtual void init(); 139 virtual void init();
132 bool ioctl( int call ) const; 140 bool ioctl( int call ) const;
133 bool ioctl( int call, ifreqstruct& ) const; 141 bool ioctl( int call, ifreqstruct& ) const;
134}; 142};
135 143
136/*====================================================================================== 144/*======================================================================================
137 * OChannelHopper 145 * OChannelHopper
138 *======================================================================================*/ 146 *======================================================================================*/
139 147
140class OChannelHopper : public QObject 148class OChannelHopper : public QObject
141{ 149{
142 public: 150 public:
143 OChannelHopper( OWirelessNetworkInterface* ); 151 OChannelHopper( OWirelessNetworkInterface* );
144 virtual ~OChannelHopper(); 152 virtual ~OChannelHopper();
145 bool isActive() const; 153 bool isActive() const;
146 int channel() const; 154 int channel() const;
147 virtual void timerEvent( QTimerEvent* ); 155 virtual void timerEvent( QTimerEvent* );
148 void setInterval( int ); 156 void setInterval( int );
149 int interval() const; 157 int interval() const;
150 158