summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/wlan/wlanimp2.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/wlan/wlanimp2.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index eeebe7f..e483efe 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -31,49 +31,49 @@
#include <opie2/oprocess.h>
#include <opie2/onetwork.h>
#include <opie2/opcap.h>
#else
#define OProcess KProcess
#include <kprocess.h>
#endif
#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
#define PREUP "/etc/network/if-pre-up.d/wireless-tools"
/**
* Constructor, read in the wireless.opts file for parsing later.
*/
using namespace Opie::Net;
using namespace Opie::Core;
WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") {
interfaces = new Interfaces();
interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
tabWidget->insertTab(interfaceSetup, "TCP/IP");
// Check sanity - the existance of the wireless-tools if-pre-up script
QFile file(QString(PREUP));
if (file.exists()) {
- qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools"));
+ owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl;
}
connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) );
connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) );
netView->setColumnAlignment( col_chn, AlignCenter );
netView->setItemMargin( 3 );
netView->setAllColumnsShowFocus( true );
}
WLANImp::~WLANImp() {
//FIXME: delete interfaces;
}
/**
* Change the profile for both wireless settings and network settings.
*/
void WLANImp::setProfile(const QString &profile){
interfaceSetup->setProfile(profile);
parseOpts();
}
void WLANImp::parseOpts() {
bool error;
@@ -212,49 +212,49 @@ void WLANImp::accept() {
QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
return;
}
if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
return;
}
// Try to save the interfaces settings.
writeOpts();
// Close out the dialog
// FIXME: QDialog::accept();
}
void WLANImp::writeOpts() {
// eh can't really do anything about it other then return. :-D
if(!interfaces->isInterfaceSet()){
QMessageBox::warning(0,"Inface not set","should not happen!!!");
return;
}
bool error = false;
- qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() );
+ odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl;
if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!");
interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
if (specifyAp->isChecked()) {
interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
} else {
interfaces->removeInterfaceOption(QString("wireless_ap"));
}
if (specifyChan->isChecked()) {
interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
} else {
interfaces->removeInterfaceOption(QString("wireless_channel"));
}
if (wepEnabled->isChecked()) {
QStringList keyList;
if (! keyLineEdit0->text().isNull()) {
keyList += keyLineEdit0->text();
keyList += "[1]";
@@ -286,181 +286,181 @@ void WLANImp::writeOpts() {
keyList += "[3]";
} else if (keyRadio3->isChecked()) {
keyList += "[4]";
}
interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" ")));
} else {
interfaces->removeInterfaceOption(QString("wireless_key"));
}
interfaces->removeInterfaceOption(QString("wireless_enc"));
if(!interfaceSetup->saveChanges())
return;
QDialog::accept();
}
/*
* Scan for possible wireless networks around...
* ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org>
*/
void WLANImp::rescanNeighbourhood()
{
QString name = interface->getInterfaceName();
- qDebug( "rescanNeighbourhood via '%s'", (const char*) name );
+ odebug << "rescanNeighbourhood via '" << (const char*) name << "'" << oendl;
OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) );
assert( wiface );
// try to guess device type
QString devicetype;
QFile m( "/proc/modules" );
if ( m.open( IO_ReadOnly ) )
{
QString line;
QTextStream modules( &m );
while( !modules.atEnd() && !devicetype )
{
modules >> line;
if ( line.contains( "cisco" ) ) devicetype = "cisco";
else if ( line.contains( "hostap" ) ) devicetype = "hostap";
else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */
else if ( line.contains( "orinoco" ) ) devicetype = "orinoco";
}
}
if ( devicetype.isEmpty() )
{
- qWarning( "rescanNeighbourhood(): couldn't guess device type :(" );
+ owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl;
return;
}
else
{
- qDebug( "rescanNeighbourhood(): device type seems to be '%s'", (const char*) devicetype );
+ odebug << "rescanNeighbourhood(): device type seems to be '" << (const char*) devicetype << "'" << oendl;
}
// configure interface to receive 802.11 management frames
wiface->setUp( true );
wiface->setPromiscuousMode( true );
if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) );
else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) );
else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) );
else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) );
else
{
- qDebug( "rescanNeighbourhood(): unsupported device type for monitoring :(" );
+ odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl;
return;
}
wiface->setMode( "monitor" );
if ( wiface->mode() != "monitor" )
{
- qWarning( "rescanNeighbourhood(): Unable to bring device into monitor mode (%s).", strerror( errno ) );
+ owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl;
return;
}
// open a packet capturer
OPacketCapturer* cap = new OPacketCapturer();
cap->open( name );
if ( !cap->isOpen() )
{
- qWarning( "rescanNeighbourhood(): Unable to open libpcap (%s).", strerror( errno ) );
+ owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl;
return;
}
// display splash screen
QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize );
splash->setLineWidth( 2 );
splash->setFrameStyle( QFrame::Panel | QFrame::Raised );
QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 );
QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash );
QProgressBar* pb = new QProgressBar( wiface->channels(), splash );
vbox->addWidget( lab );
vbox->addWidget( pb );
pb->setCenterIndicator( true );
pb->setFixedHeight( pb->sizeHint().height() );
QWidget* widgetDesktop = qApp->desktop();
int dw = widgetDesktop->width();
int dh = widgetDesktop->height();
int pw = vbox->sizeHint().width();
int ph = vbox->sizeHint().height();
splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph);
splash->show();
splash->raise();
qApp->processEvents();
// set capturer to non-blocking mode
cap->setBlocking( false );
for ( int i = 1; i <= wiface->channels(); ++i )
{
wiface->setChannel( i );
pb->setProgress( i );
qApp->processEvents();
- qDebug( "rescanNeighbourhood(): listening on channel %d...", i );
+ odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl;
OPacket* p = cap->next( 1000 );
if ( !p )
{
- qDebug( "rescanNeighbourhood(): nothing received on channel %d", i );
+ odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl;
}
else
{
- qDebug( "rescanNeighbourhood(): TADAA - something came in on channel %d", i );
+ odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl;
handlePacket( p );
}
}
cap->close();
wiface->setMode( "managed" ); // TODO: use previous mode
wiface->setPromiscuousMode( false );
splash->hide();
delete splash;
}
void WLANImp::handlePacket( OPacket* p )
{
// check if we received a beacon frame
OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
if ( beacon && beacon->managementType() == "Beacon" )
{
QString type;
if ( beacon->canIBSS() )
{
type = "adhoc";
}
else if ( beacon->canESS() )
{
type = "managed";
}
else
{
- qWarning( "handlePacket(): invalid frame [possibly noise] detected!" );
+ owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl;
return;
}
OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
QString essid = ssid ? ssid->ID() : QString("<unknown>");
OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
int channel = ds ? ds->channel() : -1;
OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
displayFoundNetwork( type, channel, essid, header->macAddress2() );
}
}
void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac )
{
qDebug( "found network: <%s>, chn %d, ssid '%s', mac '%s'", (const char*) mode, channel,
(const char*) ssid,
(const char*) mac.toString() );
QListViewItemIterator it( netView );
while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it;
if ( !it.current() ) // ssid didn't show up yet
{