summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/wlan
authorwimpie <wimpie>2005-01-04 01:35:26 (UTC)
committer wimpie <wimpie>2005-01-04 01:35:26 (UTC)
commita9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (unidiff)
tree13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/wlan
parent48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff)
downloadopie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip
opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz
opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2
CONTROL files : changed version string
NS2 many changes and first release of OT2
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,4 +1,4 @@
1Package: opie-networksettingsplugin2-wlan 1Package: opie-networksettings2plugin-wlan
2Files: plugins/networksettings2/libwlan.so* 2Files: plugins/networksettings2/libwlan.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
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,3 +1,4 @@
1#include <resources.h>
1#include "wlan_NN.h" 2#include "wlan_NN.h"
2#include "wlan_NNI.h" 3#include "wlan_NNI.h"
3 4
@@ -5,10 +6,17 @@ static const char * WLanNeeds[] =
5 { 0 6 { 0
6 }; 7 };
7 8
9static const char * WLanProvides[] =
10 { "device",
11 0
12 };
13
8/** 14/**
9 * Constructor, find all of the possible interfaces 15 * Constructor, find all of the possible interfaces
10 */ 16 */
11WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) { 17WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) {
18 NSResources->addSystemFile(
19 "interfaces", "/etc/network/interfaces", 1 );
12 InstanceCount = 2; 20 InstanceCount = 2;
13} 21}
14 22
@@ -34,8 +42,8 @@ const char ** WLanNetNode::needs( void ) {
34 return WLanNeeds; 42 return WLanNeeds;
35} 43}
36 44
37const char * WLanNetNode::provides( void ) { 45const char ** WLanNetNode::provides( void ) {
38 return "device"; 46 return WLanProvides;
39} 47}
40 48
41QString WLanNetNode::genNic( long nr ) { 49QString WLanNetNode::genNic( long 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
@@ -20,7 +20,7 @@ public:
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25 virtual long instanceCount( void ) 25 virtual long instanceCount( void )
26 { return InstanceCount; } 26 { return InstanceCount; }
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
@@ -79,18 +79,16 @@ void AWLan::commit( void ) {
79 setModified( 1 ); 79 setModified( 1 );
80} 80}
81 81
82short AWLan::generateFileEmbedded( const QString & ID, 82short AWLan::generateFileEmbedded( SystemFile & SF,
83 const QString & Path,
84 QTextStream & TS,
85 long DevNr ) { 83 long DevNr ) {
86 84
87 short rvl, rvd; 85 short rvl, rvd;
88 86
89 rvl = 1; 87 rvl = 1;
90 88
91 if( ID == "interfaces" ) { 89 if( SF.name() == "interfaces" ) {
92 Log(("Generate WLanNNI for %s\n", ID.latin1() )); 90 Log(("Generate WLanNNI for %s\n", SF.name().latin1() ));
93 TS << " wireless_essid \"" 91 SF << " wireless_essid \""
94 << Data.ESSID 92 << Data.ESSID
95 << "\"" 93 << "\""
96 << endl; 94 << endl;
@@ -100,12 +98,12 @@ short AWLan::generateFileEmbedded( const QString & ID,
100 char Buf[100]; 98 char Buf[100];
101 if( gethostname(Buf, sizeof(Buf) ) == 0 ) { 99 if( gethostname(Buf, sizeof(Buf) ) == 0 ) {
102 Buf[99] = '\0'; // just to make sure 100 Buf[99] = '\0'; // just to make sure
103 TS << " wireless_nick " 101 SF << " wireless_nick "
104 << Buf 102 << Buf
105 << endl; 103 << endl;
106 } 104 }
107 } else { 105 } else {
108 TS << " wireless_nick \"" 106 SF << " wireless_nick \""
109 << Data.NodeName 107 << Data.NodeName
110 << "\"" 108 << "\""
111 << endl; 109 << endl;
@@ -124,26 +122,26 @@ short AWLan::generateFileEmbedded( const QString & ID,
124 break; 122 break;
125 } 123 }
126 124
127 TS << " wireless_mode " 125 SF << " wireless_mode "
128 << M 126 << M
129 << endl; 127 << endl;
130 if( Data.Encrypted ) { 128 if( Data.Encrypted ) {
131 for( int i = 0; i < 4; i ++ ) { 129 for( int i = 0; i < 4; i ++ ) {
132 if( ! Data.Key[i].isEmpty() ) { 130 if( ! Data.Key[i].isEmpty() ) {
133 TS << " wireless_key" 131 SF << " wireless_key"
134 << i 132 << i
135 << " " 133 << " "
136 << Data.Key[i] 134 << Data.Key[i]
137 << endl; 135 << endl;
138 } 136 }
139 } 137 }
140 TS << " wireless_keymode " 138 SF << " wireless_keymode "
141 << ((Data.AcceptNonEncrypted) ? "open" : "restricted") 139 << ((Data.AcceptNonEncrypted) ? "open" : "restricted")
142 << endl; 140 << endl;
143 } 141 }
144 rvl = 0; 142 rvl = 0;
145 } 143 }
146 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr); 144 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr);
147 145
148 return (rvd == 2 || rvl == 2 ) ? 2 : 146 return (rvd == 2 || rvl == 2 ) ? 2 :
149 (rvd == 0 || rvl == 0 ) ? 0 : 1; 147 (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
@@ -26,9 +26,7 @@ public :
26 virtual void * data( void ) 26 virtual void * data( void )
27 { return (void *)&Data; } 27 { return (void *)&Data; }
28 28
29 virtual short generateFileEmbedded( const QString & ID, 29 virtual short generateFileEmbedded( SystemFile & Sf,
30 const QString & Path,
31 QTextStream & TS,
32 long DevNr ); 30 long DevNr );
33 31
34protected : 32protected :
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
@@ -2,7 +2,8 @@
2#define WLAN_DATA_H 2#define WLAN_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5typedef struct WLanData { 5class WLanData {
6public :
6 QString ESSID; 7 QString ESSID;
7 QString NodeName; 8 QString NodeName;
8 short Mode; 9 short Mode;
@@ -11,6 +12,6 @@ typedef struct WLanData {
11 bool Encrypted; 12 bool Encrypted;
12 QString Key[4]; 13 QString Key[4];
13 bool AcceptNonEncrypted; 14 bool AcceptNonEncrypted;
14} WLanData_t; 15} ;
15 16
16#endif 17#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
@@ -20,7 +20,7 @@ WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
20 NNI = TNNI; 20 NNI = TNNI;
21 Dev = NNI->runtime()->device(); 21 Dev = NNI->runtime()->device();
22 WE = 0; 22 WE = 0;
23 if( ( II = Dev->assignedInterface() ) ) { 23 if( ( II = NNI->connection()->assignedInterface() ) ) {
24 // show data 24 // show data
25 WE = new WExtensions( II->Name ); 25 WE = new WExtensions( II->Name );
26 26
@@ -61,7 +61,7 @@ QString WLanEdit::acceptable( void ) {
61 return QString(); 61 return QString();
62} 62}
63 63
64void WLanEdit::showData( WLanData_t & Data ) { 64void WLanEdit::showData( WLanData & Data ) {
65 Mode_CB->setCurrentItem( Data.Mode ); 65 Mode_CB->setCurrentItem( Data.Mode );
66 ESSID_LE->setText( Data.ESSID ); 66 ESSID_LE->setText( Data.ESSID );
67 NodeName_LE->setText( Data.NodeName ); 67 NodeName_LE->setText( Data.NodeName );
@@ -76,7 +76,7 @@ void WLanEdit::showData( WLanData_t & Data ) {
76 Key4_LE->setText( Data.Key[3] ); 76 Key4_LE->setText( Data.Key[3] );
77} 77}
78 78
79bool WLanEdit::commit( WLanData_t & Data ) { 79bool WLanEdit::commit( WLanData & Data ) {
80 bool SM = 0; 80 bool SM = 0;
81 81
82 TXTM( Data.ESSID, ESSID_LE, SM ); 82 TXTM( Data.ESSID, ESSID_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
@@ -4,7 +4,7 @@
4#include "wlanGUI.h" 4#include "wlanGUI.h"
5 5
6class ANetNodeInstance; 6class ANetNodeInstance;
7class AsDevice; 7class RuntimeInfo;
8class WExtensions; 8class WExtensions;
9 9
10class WLanEdit : public WLanGUI { 10class WLanEdit : public WLanGUI {
@@ -14,8 +14,8 @@ public :
14 WLanEdit( QWidget * parent, ANetNodeInstance * NNI ); 14 WLanEdit( QWidget * parent, ANetNodeInstance * NNI );
15 ~WLanEdit( void ); 15 ~WLanEdit( void );
16 QString acceptable( void ); 16 QString acceptable( void );
17 void showData( WLanData_t & Data ); 17 void showData( WLanData & Data );
18 bool commit( WLanData_t & Data ); 18 bool commit( WLanData & Data );
19 19
20public slots : 20public slots :
21 21
@@ -25,7 +25,7 @@ public slots :
25private : 25private :
26 26
27 ANetNodeInstance * NNI; 27 ANetNodeInstance * NNI;
28 AsDevice * Dev; 28 RuntimeInfo * Dev;
29 QTimer RefreshTimer; 29 QTimer RefreshTimer;
30 WExtensions * WE; 30 WExtensions * WE;
31 31
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
@@ -5,12 +5,13 @@
5#include <resources.h> 5#include <resources.h>
6#include "wlanrun.h" 6#include "wlanrun.h"
7 7
8void WLanRun::detectState( NodeCollection * NC ) { 8State_t WLanRun::detectState( void ) {
9 9
10 // unavailable : no card found 10 // unavailable : no card found
11 // available : card found and assigned to us or free 11 // available : card found and assigned to us or free
12 // up : card found and assigned to us and up 12 // up : card found and assigned to us and up
13 13
14 NodeCollection * NC = nodeCollection();
14 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); 15 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
15 System & Sys = NSResources->system(); 16 System & Sys = NSResources->system();
16 InterfaceInfo * Run; 17 InterfaceInfo * Run;
@@ -29,26 +30,23 @@ void WLanRun::detectState( NodeCollection * NC ) {
29 ++It ) { 30 ++It ) {
30 Run = It.current(); 31 Run = It.current();
31 if( X == Run->Name ) { 32 if( X == Run->Name ) {
32 Run->assignNode( netNode() ); 33 NC->assignInterface( Run );
33 assignInterface( Run ); 34 return IsUp;
34 NC->setCurrentState( IsUp );
35 return;
36 } 35 }
37 } 36 }
38 } 37 }
39 } 38 }
40 39
41 if( ( Run = assignedInterface() ) ) { 40 if( ( Run = NC->assignedInterface() ) ) {
42 // we already have an interface assigned -> still present ? 41 // we already have an interface assigned -> still present ?
43 if( ! Run->IsUp ) { 42 if( ! Run->IsUp ) {
44 // usb is still free -> keep assignment 43 // usb is still free -> keep assignment
45 NC->setCurrentState( Available ); 44 return Available;
46 return;
47 } // else interface is up but NOT us -> some other profile 45 } // else interface is up but NOT us -> some other profile
48 } 46 }
49 47
50 // nothing (valid) assigned to us 48 // nothing (valid) assigned to us
51 assignInterface( 0 ); 49 NC->assignInterface( 0 );
52 50
53 // find possible interface 51 // find possible interface
54 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
@@ -64,81 +62,18 @@ void WLanRun::detectState( NodeCollection * NC ) {
64 ! Run->IsUp 62 ! Run->IsUp
65 ) { 63 ) {
66 // proper type, and Not UP -> free 64 // proper type, and Not UP -> free
67 NC->setCurrentState( Off ); 65 return Off;
68 return;
69 } 66 }
70 } 67 }
71 // no free found
72 68
73 NC->setCurrentState( Unavailable ); 69 return Unavailable;
74 70
75} 71}
76 72
77bool WLanRun::setState( NodeCollection * NC, Action_t A, bool ) { 73QString WLanRun::setMyState( NodeCollection * , Action_t , bool ) {
78 74
79 // we only handle activate and deactivate 75 // we only handle activate and deactivate
80 switch( A ) { 76 return QString();
81 case Activate :
82 {
83 if( NC->currentState() != Off ) {
84 return 0;
85 }
86 InterfaceInfo * N = getInterface();
87 if( ! N ) {
88 // no interface available
89 NC->setCurrentState( Unavailable );
90 return 0;
91 }
92 // because we were OFF the interface
93 // we get back is NOT assigned
94 N->assignNode( netNode() );
95 assignInterface( N );
96 NC->setCurrentState( Available );
97 return 1;
98 }
99 case Deactivate :
100 if( NC->currentState() == IsUp ) {
101 // bring down first
102 if( ! connection()->setState( Down ) )
103 // could not ...
104 return 0;
105 } else if( NC->currentState() != Available ) {
106 return 1;
107 }
108 assignedInterface()->assignNode( 0 ); // release
109 assignInterface( 0 );
110 NC->setCurrentState( Off );
111 return 1;
112 default :
113 // FT
114 break;
115 }
116 return 0;
117}
118
119bool WLanRun::canSetState( State_t Curr, Action_t A ) {
120 // we only handle up down activate and deactivate
121 switch( A ) {
122 case Activate :
123 { // at least available
124 if( Curr == Available ) {
125 return 1;
126 }
127 // or we can make one available
128 InterfaceInfo * N = getInterface();
129 if( ! N || N->assignedNode() != 0 ) {
130 // non available or assigned
131 return 0;
132 }
133 return 1;
134 }
135 case Deactivate :
136 return ( Curr >= Available );
137 default :
138 // FT
139 break;
140 }
141 return 0;
142} 77}
143 78
144// get interface that is free or assigned to us 79// get interface that is free or assigned to us
@@ -159,10 +94,10 @@ InterfaceInfo * WLanRun::getInterface( void ) {
159 ) 94 )
160 ) { 95 ) {
161 // this is a LAN card 96 // this is a LAN card
162 if( Run->assignedNode() == netNode() ) { 97 if( Run->assignedConnection() == netNode()->connection() ) {
163 // assigned to us 98 // assigned to us
164 return Run; 99 return Run;
165 } else if( Run->assignedNode() == 0 ) { 100 } else if( Run->assignedConnection() == 0 ) {
166 // free 101 // free
167 best = Run; 102 best = Run;
168 } 103 }
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
@@ -2,31 +2,30 @@
2#define WLANRUN_H 2#define WLANRUN_H
3 3
4#include <qregexp.h> 4#include <qregexp.h>
5#include <asdevice.h> 5#include <netnode.h>
6#include "wlandata.h" 6#include "wlandata.h"
7 7
8class WLanRun : public AsDevice { 8class WLanRun : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 WLanRun( ANetNodeInstance * NNI, WLanData & Data ) : 12 WLanRun( ANetNodeInstance * NNI, WLanData & Data ) :
13 AsDevice( NNI ), 13 RuntimeInfo( NNI ),
14 Pat( "wlan[0-9]" ) 14 Pat( "wlan[0-9]" ) {
15 { } 15 }
16 16
17 virtual AsDevice * device( void ) 17 virtual RuntimeInfo * device( void )
18 { return (AsDevice *)this; } 18 { return this; }
19 virtual AsDevice * asDevice( void )
20 { return (AsDevice *)this; }
21 19
22protected :
23
24 void detectState( NodeCollection * );
25 bool setState( NodeCollection *, Action_t, bool );
26 bool canSetState( State_t, Action_t );
27 bool handlesInterface( const QString & I ); 20 bool handlesInterface( const QString & I );
28 bool handlesInterface( const InterfaceInfo & II ); 21 bool handlesInterface( const InterfaceInfo & II );
29 22
23 State_t detectState( void );
24
25protected :
26
27 QString setMyState( NodeCollection * , Action_t, bool );
28
30private : 29private :
31 30
32 InterfaceInfo * getInterface( void ); 31 InterfaceInfo * getInterface( void );