summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-10 02:24:48 (UTC)
committer mickeyl <mickeyl>2003-10-10 02:24:48 (UTC)
commit2b2620fee2bbd6f7045b237aa33c277c47512345 (patch) (side-by-side diff)
tree31f92a166da4ae596d55fe5079f058dd4a16fce4
parentc1a897e63513c9647666970794c1684b2439501e (diff)
downloadopie-2b2620fee2bbd6f7045b237aa33c277c47512345.zip
opie-2b2620fee2bbd6f7045b237aa33c277c47512345.tar.gz
opie-2b2620fee2bbd6f7045b237aa33c277c47512345.tar.bz2
This patch adds scanning the "network neighbourhood" in networksettings-wlan
(powered by the Wellenreiter II scanning engine found in libopienet2). Detected networks are put in a list and you can select parameters by clicking on an entry in the list. See http://opie.net.wox.org/images/wlanplugin.png Two inherent drawbacks: 1.) networksettingsplugin-wlan now needs libopienet2. Well, my library work pays off. If you like to rewrite the stuff so that libopienet2 is not needed, then just go ahead ;) 2.) Scanning won't work on linux distributions without patched monitor mode drivers. I think we can live with these two "issues". Feel free to revert, if you don't like my work :D
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/config.in4
-rw-r--r--noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control2
-rw-r--r--noncore/settings/networksettings/wlan/wlan.pro2
-rw-r--r--noncore/settings/networksettings/wlan/wlan.ui402
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp216
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.h15
-rw-r--r--pics/networksettings/adhoc.pngbin0 -> 694 bytes
-rw-r--r--pics/networksettings/managed.pngbin0 -> 410 bytes
9 files changed, 446 insertions, 197 deletions
diff --git a/noncore/settings/networksettings/wlan/config.in b/noncore/settings/networksettings/wlan/config.in
index 53bcb1e..e459788 100644
--- a/noncore/settings/networksettings/wlan/config.in
+++ b/noncore/settings/networksettings/wlan/config.in
@@ -3,2 +3,4 @@
default "n" if NETWORKSETUP
- depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES && LIBOPIE2NET
+ #comment "opie-networksettingsplugin-wlan needs libopie, libopie2net and networksetup"
+ #depends !( LIBOPIE2NET && LIBOPIE && NETWORKSETUP) \ No newline at end of file
diff --git a/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control b/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
index 719337f..ec3078d 100644
--- a/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
+++ b/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
@@ -6,3 +6,3 @@ Maintainer: Patrick S. Vogt <tille@handhelds.org>
Architecture: arm
-Depends: opie-networksettings
+Depends: opie-networksettings, libopie2net (1.8.1)
Description: Network settings wavelan plugin.
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro
index 552c669..82a5b2f 100644
--- a/noncore/settings/networksettings/wlan/wlan.pro
+++ b/noncore/settings/networksettings/wlan/wlan.pro
@@ -10,3 +10,3 @@ INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -L../interfaces/ -linterfaces
+LIBS += -lqpe -L../interfaces/ -linterfaces -lopienet2
INTERFACES = wlan.ui info.ui
diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui
index 7e39e23..195ead9 100644
--- a/noncore/settings/networksettings/wlan/wlan.ui
+++ b/noncore/settings/networksettings/wlan/wlan.ui
@@ -13,4 +13,4 @@
<y>0</y>
- <width>247</width>
- <height>299</height>
+ <width>216</width>
+ <height>342</height>
</rect>
@@ -47,2 +47,8 @@
</property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
<widget>
@@ -57,31 +63,47 @@
</attribute>
- <spacer>
- <property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>3</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>2</number>
+ </property>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
<name>name</name>
- <cstring>Spacer31</cstring>
+ <cstring>Layout1</cstring>
</property>
+ <grid>
<property stdset="1">
- <name>orientation</name>
- <enum>Vertical</enum>
+ <name>margin</name>
+ <number>0</number>
</property>
<property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
+ <name>spacing</name>
+ <number>6</number>
</property>
+ <widget row="1" column="1" >
+ <class>QComboBox</class>
+ <item>
<property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <name>text</name>
+ <string>any</string>
</property>
- </spacer>
- <widget>
- <class>QLabel</class>
+ </item>
<property stdset="1">
<name>name</name>
- <cstring>modeLabel</cstring>
+ <cstring>essid</cstring>
</property>
<property stdset="1">
- <name>enabled</name>
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>editable</name>
<bool>true</bool>
@@ -89,23 +111,19 @@
<property stdset="1">
- <name>geometry</name>
- <rect>
- <x>11</x>
- <y>11</y>
- <width>84</width>
- <height>29</height>
- </rect>
+ <name>currentItem</name>
+ <number>0</number>
</property>
<property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
- </sizepolicy>
+ <name>sizeLimit</name>
+ <number>5</number>
</property>
<property stdset="1">
- <name>text</name>
- <string>Mode</string>
+ <name>autoCompletion</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>duplicatesEnabled</name>
+ <bool>false</bool>
</property>
</widget>
- <widget>
+ <widget row="1" column="0" >
<class>QLabel</class>
@@ -120,11 +138,2 @@
<property stdset="1">
- <name>geometry</name>
- <rect>
- <x>11</x>
- <y>46</y>
- <width>84</width>
- <height>29</height>
- </rect>
- </property>
- <property stdset="1">
<name>sizePolicy</name>
@@ -137,42 +146,34 @@
<name>text</name>
- <string>ESS-ID</string>
+ <string>SSID</string>
</property>
</widget>
- <widget>
- <class>QSpinBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>networkChannel</cstring>
- </property>
- <property stdset="1">
- <name>enabled</name>
- <bool>false</bool>
- </property>
- <property stdset="1">
- <name>geometry</name>
- <rect>
- <x>146</x>
- <y>139</y>
- <width>58</width>
- <height>25</height>
- </rect>
+ <widget row="0" column="1" >
+ <class>QComboBox</class>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Infrastructure</string>
</property>
- <property stdset="1">
- <name>maxValue</name>
- <number>15</number>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Auto</string>
</property>
- <property stdset="1">
- <name>minValue</name>
- <number>1</number>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Managed</string>
</property>
- <property stdset="1">
- <name>value</name>
- <number>1</number>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Ad-Hoc</string>
</property>
- </widget>
- <widget>
- <class>QLineEdit</class>
+ </item>
<property stdset="1">
<name>name</name>
- <cstring>macEdit</cstring>
+ <cstring>mode</cstring>
</property>
@@ -180,12 +181,3 @@
<name>enabled</name>
- <bool>false</bool>
- </property>
- <property stdset="1">
- <name>geometry</name>
- <rect>
- <x>56</x>
- <y>108</y>
- <width>182</width>
- <height>25</height>
- </rect>
+ <bool>true</bool>
</property>
@@ -194,4 +186,4 @@
<sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>1</vsizetype>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
</sizepolicy>
@@ -199,3 +191,3 @@
</widget>
- <widget>
+ <widget row="0" column="0" >
<class>QLabel</class>
@@ -203,3 +195,3 @@
<name>name</name>
- <cstring>macLabel</cstring>
+ <cstring>modeLabel</cstring>
</property>
@@ -207,12 +199,10 @@
<name>enabled</name>
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property stdset="1">
- <name>geometry</name>
- <rect>
- <x>11</x>
- <y>108</y>
- <width>39</width>
- <height>25</height>
- </rect>
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
</property>
@@ -220,5 +210,7 @@
<name>text</name>
- <string>MAC</string>
+ <string>Mode</string>
</property>
</widget>
+ </grid>
+ </widget>
<widget>
@@ -230,11 +222,2 @@
<property stdset="1">
- <name>geometry</name>
- <rect>
- <x>11</x>
- <y>81</y>
- <width>227</width>
- <height>21</height>
- </rect>
- </property>
- <property stdset="1">
<name>text</name>
@@ -244,62 +227,40 @@
<widget>
- <class>QCheckBox</class>
+ <class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>specifyChan</cstring>
+ <cstring>Layout3</cstring>
</property>
+ <hbox>
<property stdset="1">
- <name>geometry</name>
- <rect>
- <x>11</x>
- <y>141</y>
- <width>129</width>
- <height>21</height>
- </rect>
+ <name>margin</name>
+ <number>0</number>
</property>
<property stdset="1">
- <name>text</name>
- <string>Specify &amp;Channel</string>
+ <name>spacing</name>
+ <number>6</number>
</property>
- </widget>
- <spacer>
- <property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
<name>name</name>
- <cstring>Spacer10</cstring>
+ <cstring>macLabel</cstring>
</property>
<property stdset="1">
- <name>orientation</name>
- <enum>Horizontal</enum>
+ <name>enabled</name>
+ <bool>false</bool>
</property>
<property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
- </property>
- <property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- <widget>
- <class>QComboBox</class>
- <item>
- <property>
<name>text</name>
- <string>any</string>
+ <string>MAC</string>
</property>
- </item>
+ </widget>
+ <widget>
+ <class>QLineEdit</class>
<property stdset="1">
<name>name</name>
- <cstring>essid</cstring>
+ <cstring>macEdit</cstring>
</property>
<property stdset="1">
- <name>geometry</name>
- <rect>
- <x>101</x>
- <y>46</y>
- <width>103</width>
- <height>29</height>
- </rect>
+ <name>enabled</name>
+ <bool>false</bool>
</property>
@@ -309,11 +270,17 @@
<hsizetype>7</hsizetype>
- <vsizetype>0</vsizetype>
+ <vsizetype>1</vsizetype>
</sizepolicy>
</property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
<property stdset="1">
- <name>editable</name>
- <bool>true</bool>
+ <name>name</name>
+ <cstring>Layout4</cstring>
</property>
+ <hbox>
<property stdset="1">
- <name>currentItem</name>
+ <name>margin</name>
<number>0</number>
@@ -321,65 +288,116 @@
<property stdset="1">
- <name>sizeLimit</name>
- <number>5</number>
+ <name>spacing</name>
+ <number>6</number>
</property>
+ <widget>
+ <class>QCheckBox</class>
<property stdset="1">
- <name>autoCompletion</name>
- <bool>true</bool>
+ <name>name</name>
+ <cstring>specifyChan</cstring>
</property>
<property stdset="1">
- <name>duplicatesEnabled</name>
+ <name>text</name>
+ <string>Specify &amp;Channel</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QSpinBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>networkChannel</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
<bool>false</bool>
</property>
+ <property stdset="1">
+ <name>maxValue</name>
+ <number>15</number>
+ </property>
+ <property stdset="1">
+ <name>minValue</name>
+ <number>1</number>
+ </property>
+ <property stdset="1">
+ <name>value</name>
+ <number>1</number>
+ </property>
+ </widget>
+ </hbox>
</widget>
<widget>
- <class>QComboBox</class>
- <item>
- <property>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>rescanButton</cstring>
+ </property>
+ <property stdset="1">
<name>text</name>
- <string>Infrastructure</string>
+ <string>Rescan Neighbourhood</string>
</property>
- </item>
- <item>
+ </widget>
+ <widget>
+ <class>QListView</class>
+ <column>
<property>
<name>text</name>
- <string>Auto</string>
+ <string></string>
</property>
- </item>
- <item>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
<property>
<name>text</name>
- <string>Managed</string>
+ <string>SSID</string>
</property>
- </item>
- <item>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
<property>
<name>text</name>
- <string>Ad-Hoc</string>
+ <string>Chn</string>
</property>
- </item>
- <property stdset="1">
- <name>name</name>
- <cstring>mode</cstring>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
</property>
- <property stdset="1">
- <name>enabled</name>
+ <property>
+ <name>resizeable</name>
<bool>true</bool>
</property>
- <property stdset="1">
- <name>geometry</name>
- <rect>
- <x>101</x>
- <y>11</y>
- <width>103</width>
- <height>29</height>
- </rect>
+ </column>
+ <column>
+ <property>
+ <name>text</name>
+ <string>MAC</string>
+ </property>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
</property>
+ </column>
<property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
- </sizepolicy>
+ <name>name</name>
+ <cstring>netView</cstring>
</property>
</widget>
+ </vbox>
</widget>
@@ -398,3 +416,3 @@
<name>margin</name>
- <number>11</number>
+ <number>7</number>
</property>
@@ -402,3 +420,3 @@
<name>spacing</name>
- <number>6</number>
+ <number>3</number>
</property>
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 8bf004f..719be1b 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -220,3 +220,3 @@ void WLANImp::accept(){
if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){
- QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok);
+ QMessageBox::information(this, "Error", "Please enter a SSID.", QMessageBox::Ok);
return;
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index 26e3aa9..7ce096f 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -4,4 +4,12 @@
+#include "../interfaces/interface.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include <qapplication.h>
#include <qfile.h>
#include <qdir.h>
+#include <qdialog.h>
#include <qtextstream.h>
@@ -12,2 +20,3 @@
#include <qradiobutton.h>
+#include <qpushbutton.h>
#include <qcheckbox.h>
@@ -15,5 +24,11 @@
#include <qcombobox.h>
+#include <qlistview.h>
+#include <qvbox.h>
+#include <qprogressbar.h>
#ifdef QWS
+ #include <qpe/resource.h>
#include <opie/oprocess.h>
+ #include <opie2/onetwork.h>
+ #include <opie2/opcap.h>
#else
@@ -24,3 +39,3 @@
#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
-#define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools"
+#define PREUP "/etc/network/if-pre-up.d/wireless-tools"
@@ -39,2 +54,9 @@ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, W
}
+
+ 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 );
+
}
@@ -276 +298,193 @@ void WLANImp::writeOpts() {
}
+
+/*
+ * 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 );
+
+ 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 :(" );
+ return;
+ }
+ else
+ {
+ qDebug( "rescanNeighbourhood(): device type seems to be '%s'", (const char*) devicetype );
+ }
+
+ // 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 :(" );
+ return;
+ }
+
+ wiface->setMonitorMode( true );
+ if ( !wiface->monitorMode() )
+ {
+ qWarning( "rescanNeighbourhood(): Unable to bring device into monitor mode (%s).", strerror( errno ) );
+ return;
+ }
+
+ // open a packet capturer
+ OPacketCapturer* cap = new OPacketCapturer();
+ cap->open( name );
+ if ( !cap->isOpen() )
+ {
+ qWarning( "rescanNeighbourhood(): Unable to open libpcap (%s).", strerror( errno ) );
+ 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 );
+ OPacket* p = cap->next( 1000 );
+ if ( !p )
+ {
+ qDebug( "rescanNeighbourhood(): nothing received on channel %d", i );
+ }
+ else
+ {
+ qDebug( "rescanNeighbourhood(): TADAA - something came in on channel %d", i );
+ handlePacket( p );
+ }
+ }
+
+ cap->close();
+ wiface->setMonitorMode( false );
+ wiface->setPromiscuousMode( true );
+
+ 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!" );
+ 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
+ {
+ QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() );
+ QString name;
+ name.sprintf( "networksettings/%s", (const char*) mode );
+ item->setPixmap( col_mode, Resource::loadPixmap( name ) );
+ qApp->processEvents();
+ }
+
+}
+
+
+void WLANImp::selectNetwork( QListViewItem* item )
+{
+ bool ok;
+ if ( item )
+ {
+ specifyAp->setChecked(true);
+ macEdit->setText( item->text( col_mac ) );
+ specifyChan->setChecked( item->text( col_mode ) == "A" );
+ networkChannel->setValue( item->text( col_chn ).toInt( &ok ) );
+ essid->setEditText( item->text( col_ssid ) );
+ if ( item->text( col_mode ) == "A" )
+ mode->setCurrentItem( 3 );
+ else
+ mode->setCurrentItem( 2 );
+ }
+}
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.h b/noncore/settings/networksettings/wlan/wlanimp2.h
index 992d09a..a777203 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.h
+++ b/noncore/settings/networksettings/wlan/wlanimp2.h
@@ -6,2 +6,3 @@
#include <qstringlist.h>
+#include <opie2/onetutils.h>
@@ -10,2 +11,9 @@ class Interface;
class Config;
+class OPacket;
+class QListViewItem;
+
+const int col_mode= 0;
+const int col_ssid = 1;
+const int col_chn = 2;
+const int col_mac = 3;
@@ -19,2 +27,6 @@ public:
+public slots:
+ void rescanNeighbourhood();
+ void selectNetwork( QListViewItem* );
+
protected:
@@ -28,2 +40,5 @@ private:
+ void handlePacket( OPacket* );
+ void displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac );
+
InterfaceSetupImp *interfaceSetup;
diff --git a/pics/networksettings/adhoc.png b/pics/networksettings/adhoc.png
new file mode 100644
index 0000000..dcf5ad2
--- a/dev/null
+++ b/pics/networksettings/adhoc.png
Binary files differ
diff --git a/pics/networksettings/managed.png b/pics/networksettings/managed.png
new file mode 100644
index 0000000..4554533
--- a/dev/null
+++ b/pics/networksettings/managed.png
Binary files differ