summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/wlan
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/wlan') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control2
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.cpp12
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.h2
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.cpp22
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.h4
-rw-r--r--noncore/settings/networksettings2/wlan/wlandata.h5
-rw-r--r--noncore/settings/networksettings2/wlan/wlanedit.cpp6
-rw-r--r--noncore/settings/networksettings2/wlan/wlanedit.h8
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.cpp91
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.h27
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,9 +1,9 @@
-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
Description: Network settings wlan plugin.
Version: $QPE_VERSION$EXTRAVERSION
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,62 +1,70 @@
+#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.
*/
WLanNetNode::~WLanNetNode(){
}
const QString WLanNetNode::nodeDescription(){
return tr("\
<p>Configure Wi/Fi or WLan network cards.</p>\
<p>Defines Wireless options for those cards</p>\
"
);
}
ANetNodeInstance * WLanNetNode::createInstance( void ) {
return new AWLan( this );
}
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 );
}
void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) {
if( A == "interfacecount" ) {
InstanceCount = V.toLong();
}
}
void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) {
TS << "interfacecount="
<< InstanceCount
<< endl;
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new WLanNetNode() );
}
}
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
@@ -1,44 +1,44 @@
#ifndef WLAN_NETNODE_H
#define WLAN_NETNODE_H
#include "netnode.h"
class AWLan;
class WLanNetNode : public ANetNode{
Q_OBJECT
public:
WLanNetNode();
virtual ~WLanNetNode();
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:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
// number of interfaces for this device
long InstanceCount;
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
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
@@ -34,118 +34,116 @@ void AWLan::setSpecificAttribute( QString & A, QString & V ) {
Data.Encrypted = (V=="yes");
} else if( A == "acceptnonencrypted" ) {
Data.AcceptNonEncrypted = (V=="yes");
} else if( A == "key0" ) {
Data.Key[0] = V;
} else if( A == "key1" ) {
Data.Key[1] = V;
} else if( A == "key2" ) {
Data.Key[2] = V;
} else if( A == "key3" ) {
Data.Key[3] = V;
}
}
void AWLan::saveSpecificAttribute( QTextStream & S ) {
S << "essid=" << quote( Data.ESSID ) << endl;
S << "nodename=" << quote( Data.NodeName ) << endl;
S << "mode=" << Data.Mode << endl;
S << "specificap="
<< ((Data.SpecificAP) ? "yes" : "no")
<< endl;
S << "apmac=" << Data.APMac << endl;
S << "encrypted="
<< ((Data.Encrypted) ? "yes" : "no")
<< endl;
S << "acceptnonencrypted="
<< ((Data.AcceptNonEncrypted) ? "yes" : "no")
<< endl;
for( int i = 0 ;i < 4 ; i ++ ) {
S << "key" << i << "=" << Data.Key[i] << endl;
}
}
QWidget * AWLan::edit( QWidget * parent ) {
GUI = new WLanEdit( parent, this );
GUI->showData( Data );
return GUI;
}
QString AWLan::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
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;
}
}
char * M = "Auto";
switch ( Data.Mode ) {
case 0 :
break;
case 1 :
M = "Managed";
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
@@ -1,47 +1,45 @@
#ifndef WLAN_H
#define WLAN_H
#include <netnode.h>
#include "wlandata.h"
#include "wlanrun.h"
class WLanNetNode;
class WLanEdit;
class AWLan : public ANetNodeInstance {
public :
AWLan( WLanNetNode * PNN );
RuntimeInfo * runtime( void )
{ return
( RT ) ? RT : ( RT = new WLanRun( this, Data ) );
}
QWidget * edit( QWidget * parent );
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 );
private :
WLanEdit * GUI;
WLanData Data;
WLanRun * RT;
};
#endif
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
@@ -1,115 +1,115 @@
#include <qlineedit.h>
#include <qprogressbar.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qregexp.h>
#include <qcheckbox.h>
#include <GUIUtils.h>
#include <resources.h>
#include <wextensions.h>
#include "wlanedit.h"
#include "wlan_NN.h"
#include "wlan_NNI.h"
WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
WLanGUI( Parent ), RefreshTimer(this){
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() );
ESSID_LBL->setText( WE->essid() );
Mode_LBL->setText( WE->mode() );
S.setNum( WE->frequency() );
Frequency_LBL->setText( S );
S.setNum( WE->channel() );
Channel_LBL->setText( S );
S.setNum( WE->rate() );
Rate_LBL->setText( S );
AP_LBL->setText( WE->ap() );
SLOT_Refresh();
connect( &RefreshTimer, SIGNAL( timeout() ),
this, SLOT( SLOT_Refresh() ) );
}
}
}
WLanEdit::~WLanEdit( void ) {
if( WE )
delete WE;
}
QString WLanEdit::acceptable( void ) {
if( ESSID_LE->text().isEmpty() ) {
return QString("ESSID is mandatory");
}
if( SpecifyAP_CB->isChecked() &&
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 );
EnableWEP_CB->setChecked( Data.Encrypted );
AcceptNonEncrypted_CB->setChecked( Data.AcceptNonEncrypted );
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 );
TXTM( Data.Key[1], Key2_LE, SM );
TXTM( Data.Key[2], Key3_LE, SM );
TXTM( Data.Key[3], Key4_LE, SM );
CBM( Data.SpecificAP, SpecifyAP_CB, SM );
CBM( Data.Encrypted, EnableWEP_CB, SM );
CBM( Data.AcceptNonEncrypted, AcceptNonEncrypted_CB, SM );
CIM( Data.Mode, Mode_CB, SM );
return 0;
}
void WLanEdit::SLOT_Refresh( void ) {
if( WE ) {
int signal, noise, quality;
WE->stats( signal, noise, quality);
Signal_PB->setProgress( signal );
Noise_PB->setProgress( noise );
Quality_PB->setProgress( quality );
}
}
void WLanEdit::SLOT_AutoRefresh( bool ar ) {
if( ar ) {
RefreshTimer.start( 1000 );
SLOT_Refresh();
} else {
RefreshTimer.stop();
}
}
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
@@ -1,185 +1,120 @@
#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 );
if( F.open( IO_ReadOnly ) ) {
// could open file -> read interface and assign
QString X;
QTextStream TS(&F);
X = TS.readLine();
// find interface
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();
if( handlesInterface( *Run ) &&
( Run->CardType == ARPHRD_ETHER
#ifdef ARPHRD_IEEE1394
|| 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();
InterfaceInfo * best = 0, * Run;
for( QDictIterator<InterfaceInfo> It(S.interfaces());
It.current();
++It ) {
Run = It.current();
if( handlesInterface( *Run ) &&
( Run->CardType == ARPHRD_ETHER
#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
}
bool WLanRun::handlesInterface( const QString & S ) {
InterfaceInfo * II;
II = NSResources->system().interface( S );
if( ( II = NSResources->system().interface( S ) ) ) {
return handlesInterface( *II );
}
return Pat.match( S ) >= 0;
}
bool WLanRun::handlesInterface( const InterfaceInfo & II ) {
return ( Pat.match( II.Name ) < 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,37 +1,36 @@
#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;
};
#endif