Diffstat (limited to 'noncore/settings/networksettings2/wlan') (more/less context) (ignore whitespace changes)
10 files changed, 59 insertions, 120 deletions
diff --git a/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control b/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control index 14afd21..90f195a 100644 --- a/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control +++ b/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control @@ -1,7 +1,7 @@ -Package: opie-networksettingsplugin2-wlan +Package: opie-networksettings2plugin-wlan Files: plugins/networksettings2/libwlan.so* Priority: optional Section: opie/settings Maintainer: Wim Delvaux <wimpie@handhelds.org> Architecture: arm Depends: opie-networksettings2, libopiecore2, libopienet2 diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp index e4c3f60..36a5c33 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp @@ -1,17 +1,25 @@ +#include <resources.h> #include "wlan_NN.h" #include "wlan_NNI.h" static const char * WLanNeeds[] = { 0 }; +static const char * WLanProvides[] = + { "device", + 0 + }; + /** * Constructor, find all of the possible interfaces */ WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) { + NSResources->addSystemFile( + "interfaces", "/etc/network/interfaces", 1 ); InstanceCount = 2; } /** * Delete any interfaces that we own. */ @@ -31,14 +39,14 @@ ANetNodeInstance * WLanNetNode::createInstance( void ) { } const char ** WLanNetNode::needs( void ) { return WLanNeeds; } -const char * WLanNetNode::provides( void ) { - return "device"; +const char ** WLanNetNode::provides( void ) { + return WLanProvides; } QString WLanNetNode::genNic( long nr ) { QString S; return S.sprintf( "wlan%ld", nr ); } diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h index c13c05c..4bffd3d 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.h +++ b/noncore/settings/networksettings2/wlan/wlan_NN.h @@ -17,13 +17,13 @@ public: virtual const QString pixmapName() { return "Devices/wlan"; } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); virtual long instanceCount( void ) { return InstanceCount; } virtual QString genNic( long ); private: diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp index 0e4fc4c..d5b1014 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp @@ -76,39 +76,37 @@ QString AWLan::acceptable( void ) { void AWLan::commit( void ) { if( GUI && GUI->commit( Data ) ) setModified( 1 ); } -short AWLan::generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, +short AWLan::generateFileEmbedded( SystemFile & SF, long DevNr ) { short rvl, rvd; rvl = 1; - if( ID == "interfaces" ) { - Log(("Generate WLanNNI for %s\n", ID.latin1() )); - TS << " wireless_essid \"" + if( SF.name() == "interfaces" ) { + Log(("Generate WLanNNI for %s\n", SF.name().latin1() )); + SF << " wireless_essid \"" << Data.ESSID << "\"" << endl; if( ! Data.NodeName.isEmpty() ) { if( Data.NodeName == tr("<UseHostName>") ) { char Buf[100]; if( gethostname(Buf, sizeof(Buf) ) == 0 ) { Buf[99] = '\0'; // just to make sure - TS << " wireless_nick " + SF << " wireless_nick " << Buf << endl; } } else { - TS << " wireless_nick \"" + SF << " wireless_nick \"" << Data.NodeName << "\"" << endl; } } @@ -121,31 +119,31 @@ short AWLan::generateFileEmbedded( const QString & ID, break; case 2 : M = "Ad-Hoc"; break; } - TS << " wireless_mode " + SF << " wireless_mode " << M << endl; if( Data.Encrypted ) { for( int i = 0; i < 4; i ++ ) { if( ! Data.Key[i].isEmpty() ) { - TS << " wireless_key" + SF << " wireless_key" << i << " " << Data.Key[i] << endl; } } - TS << " wireless_keymode " + SF << " wireless_keymode " << ((Data.AcceptNonEncrypted) ? "open" : "restricted") << endl; } rvl = 0; } - rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr); + rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr); return (rvd == 2 || rvl == 2 ) ? 2 : (rvd == 0 || rvl == 0 ) ? 0 : 1; } diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h index a9be65f..e3251c7 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.h +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h @@ -23,15 +23,13 @@ public : QString acceptable( void ); void commit( void ); virtual void * data( void ) { return (void *)&Data; } - virtual short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFileEmbedded( SystemFile & Sf, long DevNr ); protected : virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); diff --git a/noncore/settings/networksettings2/wlan/wlandata.h b/noncore/settings/networksettings2/wlan/wlandata.h index 36990a9..f3cc1ab 100644 --- a/noncore/settings/networksettings2/wlan/wlandata.h +++ b/noncore/settings/networksettings2/wlan/wlandata.h @@ -1,16 +1,17 @@ #ifndef WLAN_DATA_H #define WLAN_DATA_H #include <qstring.h> -typedef struct WLanData { +class WLanData { +public : QString ESSID; QString NodeName; short Mode; bool SpecificAP; QString APMac; bool Encrypted; QString Key[4]; bool AcceptNonEncrypted; -} WLanData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/wlan/wlanedit.cpp b/noncore/settings/networksettings2/wlan/wlanedit.cpp index 8d3979e..74174bf 100644 --- a/noncore/settings/networksettings2/wlan/wlanedit.cpp +++ b/noncore/settings/networksettings2/wlan/wlanedit.cpp @@ -17,13 +17,13 @@ WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : InterfaceInfo * II; NNI = TNNI; Dev = NNI->runtime()->device(); WE = 0; - if( ( II = Dev->assignedInterface() ) ) { + if( ( II = NNI->connection()->assignedInterface() ) ) { // show data WE = new WExtensions( II->Name ); if( WE->doesHaveWirelessExtensions() ) { QString S; Station_LBL->setText( WE->station() ); @@ -58,13 +58,13 @@ QString WLanEdit::acceptable( void ) { APMac_LE->text().isEmpty() ) { return QString("APMac must have value"); } return QString(); } -void WLanEdit::showData( WLanData_t & Data ) { +void WLanEdit::showData( WLanData & Data ) { Mode_CB->setCurrentItem( Data.Mode ); ESSID_LE->setText( Data.ESSID ); NodeName_LE->setText( Data.NodeName ); SpecifyAP_CB->setChecked( Data.SpecificAP ); APMac_LE->setText( Data.APMac ); @@ -73,13 +73,13 @@ void WLanEdit::showData( WLanData_t & Data ) { Key1_LE->setText( Data.Key[0] ); Key2_LE->setText( Data.Key[1] ); Key3_LE->setText( Data.Key[2] ); Key4_LE->setText( Data.Key[3] ); } -bool WLanEdit::commit( WLanData_t & Data ) { +bool WLanEdit::commit( WLanData & Data ) { bool SM = 0; TXTM( Data.ESSID, ESSID_LE, SM ); TXTM( Data.NodeName, NodeName_LE, SM ); TXTM( Data.APMac, APMac_LE, SM ); TXTM( Data.Key[0], Key1_LE, SM ); diff --git a/noncore/settings/networksettings2/wlan/wlanedit.h b/noncore/settings/networksettings2/wlan/wlanedit.h index e550c14..8f219d9 100644 --- a/noncore/settings/networksettings2/wlan/wlanedit.h +++ b/noncore/settings/networksettings2/wlan/wlanedit.h @@ -1,32 +1,32 @@ #include <qtimer.h> #include <wextensions.h> #include "wlandata.h" #include "wlanGUI.h" class ANetNodeInstance; -class AsDevice; +class RuntimeInfo; class WExtensions; class WLanEdit : public WLanGUI { public : WLanEdit( QWidget * parent, ANetNodeInstance * NNI ); ~WLanEdit( void ); QString acceptable( void ); - void showData( WLanData_t & Data ); - bool commit( WLanData_t & Data ); + void showData( WLanData & Data ); + bool commit( WLanData & Data ); public slots : void SLOT_AutoRefresh( bool ); void SLOT_Refresh( void ); private : ANetNodeInstance * NNI; - AsDevice * Dev; + RuntimeInfo * Dev; QTimer RefreshTimer; WExtensions * WE; }; diff --git a/noncore/settings/networksettings2/wlan/wlanrun.cpp b/noncore/settings/networksettings2/wlan/wlanrun.cpp index 3f1d4a9..fe49c4e 100644 --- a/noncore/settings/networksettings2/wlan/wlanrun.cpp +++ b/noncore/settings/networksettings2/wlan/wlanrun.cpp @@ -2,18 +2,19 @@ #include <qfile.h> #include <qtextstream.h> #include <qstringlist.h> #include <resources.h> #include "wlanrun.h" -void WLanRun::detectState( NodeCollection * NC ) { +State_t WLanRun::detectState( void ) { // unavailable : no card found // available : card found and assigned to us or free // up : card found and assigned to us and up + NodeCollection * NC = nodeCollection(); QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); System & Sys = NSResources->system(); InterfaceInfo * Run; QFile F( S ); @@ -26,32 +27,29 @@ void WLanRun::detectState( NodeCollection * NC ) { if( handlesInterface( X ) ) { for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); It.current(); ++It ) { Run = It.current(); if( X == Run->Name ) { - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; + NC->assignInterface( Run ); + return IsUp; } } } } - if( ( Run = assignedInterface() ) ) { + if( ( Run = NC->assignedInterface() ) ) { // we already have an interface assigned -> still present ? if( ! Run->IsUp ) { // usb is still free -> keep assignment - NC->setCurrentState( Available ); - return; + return Available; } // else interface is up but NOT us -> some other profile } // nothing (valid) assigned to us - assignInterface( 0 ); + NC->assignInterface( 0 ); // find possible interface for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); It.current(); ++It ) { Run = It.current(); @@ -61,87 +59,24 @@ void WLanRun::detectState( NodeCollection * NC ) { || Run->CardType == ARPHRD_IEEE1394 #endif ) && ! Run->IsUp ) { // proper type, and Not UP -> free - NC->setCurrentState( Off ); - return; + return Off; } } - // no free found - NC->setCurrentState( Unavailable ); + return Unavailable; } -bool WLanRun::setState( NodeCollection * NC, Action_t A, bool ) { +QString WLanRun::setMyState( NodeCollection * , Action_t , bool ) { // we only handle activate and deactivate - switch( A ) { - case Activate : - { - if( NC->currentState() != Off ) { - return 0; - } - InterfaceInfo * N = getInterface(); - if( ! N ) { - // no interface available - NC->setCurrentState( Unavailable ); - return 0; - } - // because we were OFF the interface - // we get back is NOT assigned - N->assignNode( netNode() ); - assignInterface( N ); - NC->setCurrentState( Available ); - return 1; - } - case Deactivate : - if( NC->currentState() == IsUp ) { - // bring down first - if( ! connection()->setState( Down ) ) - // could not ... - return 0; - } else if( NC->currentState() != Available ) { - return 1; - } - assignedInterface()->assignNode( 0 ); // release - assignInterface( 0 ); - NC->setCurrentState( Off ); - return 1; - default : - // FT - break; - } - return 0; -} - -bool WLanRun::canSetState( State_t Curr, Action_t A ) { - // we only handle up down activate and deactivate - switch( A ) { - case Activate : - { // at least available - if( Curr == Available ) { - return 1; - } - // or we can make one available - InterfaceInfo * N = getInterface(); - if( ! N || N->assignedNode() != 0 ) { - // non available or assigned - return 0; - } - return 1; - } - case Deactivate : - return ( Curr >= Available ); - default : - // FT - break; - } - return 0; + return QString(); } // get interface that is free or assigned to us InterfaceInfo * WLanRun::getInterface( void ) { System & S = NSResources->system(); @@ -156,16 +91,16 @@ InterfaceInfo * WLanRun::getInterface( void ) { #ifdef ARPHRD_IEEE1394 || Run->CardType == ARPHRD_IEEE1394 #endif ) ) { // this is a LAN card - if( Run->assignedNode() == netNode() ) { + if( Run->assignedConnection() == netNode()->connection() ) { // assigned to us return Run; - } else if( Run->assignedNode() == 0 ) { + } else if( Run->assignedConnection() == 0 ) { // free best = Run; } } } return best; // can be 0 diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h index 25d5b96..fd325d4 100644 --- a/noncore/settings/networksettings2/wlan/wlanrun.h +++ b/noncore/settings/networksettings2/wlan/wlanrun.h @@ -1,35 +1,34 @@ #ifndef WLANRUN_H #define WLANRUN_H #include <qregexp.h> -#include <asdevice.h> +#include <netnode.h> #include "wlandata.h" -class WLanRun : public AsDevice { +class WLanRun : public RuntimeInfo { public : WLanRun( ANetNodeInstance * NNI, WLanData & Data ) : - AsDevice( NNI ), - Pat( "wlan[0-9]" ) - { } + RuntimeInfo( NNI ), + Pat( "wlan[0-9]" ) { + } - virtual AsDevice * device( void ) - { return (AsDevice *)this; } - virtual AsDevice * asDevice( void ) - { return (AsDevice *)this; } + virtual RuntimeInfo * device( void ) + { return this; } -protected : - - void detectState( NodeCollection * ); - bool setState( NodeCollection *, Action_t, bool ); - bool canSetState( State_t, Action_t ); bool handlesInterface( const QString & I ); bool handlesInterface( const InterfaceInfo & II ); + State_t detectState( void ); + +protected : + + QString setMyState( NodeCollection * , Action_t, bool ); + private : InterfaceInfo * getInterface( void ); QRegExp Pat; WLanData * Data; }; |