summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/wlan
Unidiff
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,3 +1,3 @@
1Package: opie-networksettingsplugin2-wlan 1Package: opie-networksettings2plugin-wlan
2Files: plugins/networksettings2/libwlan.so* 2Files: plugins/networksettings2/libwlan.so*
3Priority: optional 3Priority: optional
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,2 +1,3 @@
1#include <resources.h>
1#include "wlan_NN.h" 2#include "wlan_NN.h"
2#include "wlan_NNI.h" 3#include "wlan_NNI.h"
@@ -6,8 +7,15 @@ static const char * WLanNeeds[] =
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}
@@ -35,6 +43,6 @@ const char ** WLanNetNode::needs( void ) {
35} 43}
36 44
37const char * WLanNetNode::provides( void ) { 45const char ** WLanNetNode::provides( void ) {
38 return "device"; 46 return WLanProvides;
39} 47}
40 48
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
@@ -21,5 +21,5 @@ public:
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 )
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
@@ -80,7 +80,5 @@ void AWLan::commit( void ) {
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
@@ -89,7 +87,7 @@ short AWLan::generateFileEmbedded( const QString & ID,
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 << "\""
@@ -101,10 +99,10 @@ short AWLan::generateFileEmbedded( const QString & ID,
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 << "\""
@@ -125,5 +123,5 @@ short AWLan::generateFileEmbedded( const QString & ID,
125 } 123 }
126 124
127 TS << " wireless_mode " 125 SF << " wireless_mode "
128 << M 126 << M
129 << endl; 127 << endl;
@@ -131,5 +129,5 @@ short AWLan::generateFileEmbedded( const QString & ID,
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 << " "
@@ -138,5 +136,5 @@ short AWLan::generateFileEmbedded( const QString & ID,
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;
@@ -144,5 +142,5 @@ short AWLan::generateFileEmbedded( const QString & ID,
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 :
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
@@ -27,7 +27,5 @@ public :
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
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
@@ -3,5 +3,6 @@
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;
@@ -12,5 +13,5 @@ typedef struct WLanData {
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
@@ -21,5 +21,5 @@ WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * 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 );
@@ -62,5 +62,5 @@ QString WLanEdit::acceptable( void ) {
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 );
@@ -77,5 +77,5 @@ void WLanEdit::showData( WLanData_t & Data ) {
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
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
@@ -5,5 +5,5 @@
5 5
6class ANetNodeInstance; 6class ANetNodeInstance;
7class AsDevice; 7class RuntimeInfo;
8class WExtensions; 8class WExtensions;
9 9
@@ -15,6 +15,6 @@ public :
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 :
@@ -26,5 +26,5 @@ private :
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;
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
@@ -6,5 +6,5 @@
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
@@ -12,4 +12,5 @@ void WLanRun::detectState( NodeCollection * NC ) {
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();
@@ -30,8 +31,6 @@ void WLanRun::detectState( NodeCollection * NC ) {
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 }
@@ -39,15 +38,14 @@ void WLanRun::detectState( NodeCollection * NC ) {
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
@@ -65,79 +63,16 @@ void WLanRun::detectState( NodeCollection * NC ) {
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
@@ -160,8 +95,8 @@ InterfaceInfo * WLanRun::getInterface( void ) {
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;
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
@@ -3,29 +3,28 @@
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