author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (unidiff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/wlan | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-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)
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 @@ | |||
1 | Package: opie-networksettingsplugin2-wlan | 1 | Package: opie-networksettings2plugin-wlan |
2 | Files: plugins/networksettings2/libwlan.so* | 2 | Files: plugins/networksettings2/libwlan.so* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/settings | 4 | Section: opie/settings |
5 | Maintainer: Wim Delvaux <wimpie@handhelds.org> | 5 | Maintainer: Wim Delvaux <wimpie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: opie-networksettings2, libopiecore2, libopienet2 | 7 | 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 @@ | |||
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 | ||
4 | static const char * WLanNeeds[] = | 5 | static const char * WLanNeeds[] = |
5 | { 0 | 6 | { 0 |
6 | }; | 7 | }; |
7 | 8 | ||
9 | static 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 | */ |
11 | WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) { | 17 | WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) { |
18 | NSResources->addSystemFile( | ||
19 | "interfaces", "/etc/network/interfaces", 1 ); | ||
12 | InstanceCount = 2; | 20 | InstanceCount = 2; |
13 | } | 21 | } |
14 | 22 | ||
15 | /** | 23 | /** |
16 | * Delete any interfaces that we own. | 24 | * Delete any interfaces that we own. |
17 | */ | 25 | */ |
@@ -31,14 +39,14 @@ ANetNodeInstance * WLanNetNode::createInstance( void ) { | |||
31 | } | 39 | } |
32 | 40 | ||
33 | const char ** WLanNetNode::needs( void ) { | 41 | const char ** WLanNetNode::needs( void ) { |
34 | return WLanNeeds; | 42 | return WLanNeeds; |
35 | } | 43 | } |
36 | 44 | ||
37 | const char * WLanNetNode::provides( void ) { | 45 | const char ** WLanNetNode::provides( void ) { |
38 | return "device"; | 46 | return WLanProvides; |
39 | } | 47 | } |
40 | 48 | ||
41 | QString WLanNetNode::genNic( long nr ) { | 49 | QString WLanNetNode::genNic( long nr ) { |
42 | QString S; | 50 | QString S; |
43 | return S.sprintf( "wlan%ld", nr ); | 51 | return S.sprintf( "wlan%ld", nr ); |
44 | } | 52 | } |
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: | |||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/wlan"; } | 18 | { return "Devices/wlan"; } |
19 | 19 | ||
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; } |
27 | virtual QString genNic( long ); | 27 | virtual QString genNic( long ); |
28 | 28 | ||
29 | private: | 29 | 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 ) { | |||
76 | 76 | ||
77 | void AWLan::commit( void ) { | 77 | void AWLan::commit( void ) { |
78 | if( GUI && GUI->commit( Data ) ) | 78 | if( GUI && GUI->commit( Data ) ) |
79 | setModified( 1 ); | 79 | setModified( 1 ); |
80 | } | 80 | } |
81 | 81 | ||
82 | short AWLan::generateFileEmbedded( const QString & ID, | 82 | short 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; |
97 | 95 | ||
98 | if( ! Data.NodeName.isEmpty() ) { | 96 | if( ! Data.NodeName.isEmpty() ) { |
99 | if( Data.NodeName == tr("<UseHostName>") ) { | 97 | if( Data.NodeName == tr("<UseHostName>") ) { |
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; |
112 | } | 110 | } |
113 | } | 111 | } |
114 | 112 | ||
@@ -121,31 +119,31 @@ short AWLan::generateFileEmbedded( const QString & ID, | |||
121 | break; | 119 | break; |
122 | case 2 : | 120 | case 2 : |
123 | M = "Ad-Hoc"; | 121 | M = "Ad-Hoc"; |
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; |
150 | } | 148 | } |
151 | 149 | ||
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 : | |||
23 | QString acceptable( void ); | 23 | QString acceptable( void ); |
24 | void commit( void ); | 24 | void commit( void ); |
25 | 25 | ||
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 | ||
34 | protected : | 32 | protected : |
35 | 33 | ||
36 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
37 | virtual void saveSpecificAttribute( QTextStream & TS ); | 35 | 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 @@ | |||
1 | #ifndef WLAN_DATA_H | 1 | #ifndef WLAN_DATA_H |
2 | #define WLAN_DATA_H | 2 | #define WLAN_DATA_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | typedef struct WLanData { | 5 | class WLanData { |
6 | public : | ||
6 | QString ESSID; | 7 | QString ESSID; |
7 | QString NodeName; | 8 | QString NodeName; |
8 | short Mode; | 9 | short Mode; |
9 | bool SpecificAP; | 10 | bool SpecificAP; |
10 | QString APMac; | 11 | QString APMac; |
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 | |||
@@ -17,13 +17,13 @@ WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : | |||
17 | 17 | ||
18 | InterfaceInfo * II; | 18 | InterfaceInfo * II; |
19 | 19 | ||
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 | ||
27 | if( WE->doesHaveWirelessExtensions() ) { | 27 | if( WE->doesHaveWirelessExtensions() ) { |
28 | QString S; | 28 | QString S; |
29 | Station_LBL->setText( WE->station() ); | 29 | Station_LBL->setText( WE->station() ); |
@@ -58,13 +58,13 @@ QString WLanEdit::acceptable( void ) { | |||
58 | APMac_LE->text().isEmpty() ) { | 58 | APMac_LE->text().isEmpty() ) { |
59 | return QString("APMac must have value"); | 59 | return QString("APMac must have value"); |
60 | } | 60 | } |
61 | return QString(); | 61 | return QString(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void WLanEdit::showData( WLanData_t & Data ) { | 64 | void 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 ); |
68 | SpecifyAP_CB->setChecked( Data.SpecificAP ); | 68 | SpecifyAP_CB->setChecked( Data.SpecificAP ); |
69 | APMac_LE->setText( Data.APMac ); | 69 | APMac_LE->setText( Data.APMac ); |
70 | 70 | ||
@@ -73,13 +73,13 @@ void WLanEdit::showData( WLanData_t & Data ) { | |||
73 | Key1_LE->setText( Data.Key[0] ); | 73 | Key1_LE->setText( Data.Key[0] ); |
74 | Key2_LE->setText( Data.Key[1] ); | 74 | Key2_LE->setText( Data.Key[1] ); |
75 | Key3_LE->setText( Data.Key[2] ); | 75 | Key3_LE->setText( Data.Key[2] ); |
76 | Key4_LE->setText( Data.Key[3] ); | 76 | Key4_LE->setText( Data.Key[3] ); |
77 | } | 77 | } |
78 | 78 | ||
79 | bool WLanEdit::commit( WLanData_t & Data ) { | 79 | bool 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 ); |
83 | TXTM( Data.NodeName, NodeName_LE, SM ); | 83 | TXTM( Data.NodeName, NodeName_LE, SM ); |
84 | TXTM( Data.APMac, APMac_LE, SM ); | 84 | TXTM( Data.APMac, APMac_LE, SM ); |
85 | TXTM( Data.Key[0], Key1_LE, SM ); | 85 | 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 @@ | |||
1 | #include <qtimer.h> | 1 | #include <qtimer.h> |
2 | #include <wextensions.h> | 2 | #include <wextensions.h> |
3 | #include "wlandata.h" | 3 | #include "wlandata.h" |
4 | #include "wlanGUI.h" | 4 | #include "wlanGUI.h" |
5 | 5 | ||
6 | class ANetNodeInstance; | 6 | class ANetNodeInstance; |
7 | class AsDevice; | 7 | class RuntimeInfo; |
8 | class WExtensions; | 8 | class WExtensions; |
9 | 9 | ||
10 | class WLanEdit : public WLanGUI { | 10 | class WLanEdit : public WLanGUI { |
11 | 11 | ||
12 | public : | 12 | public : |
13 | 13 | ||
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 | ||
20 | public slots : | 20 | public slots : |
21 | 21 | ||
22 | void SLOT_AutoRefresh( bool ); | 22 | void SLOT_AutoRefresh( bool ); |
23 | void SLOT_Refresh( void ); | 23 | void SLOT_Refresh( void ); |
24 | 24 | ||
25 | private : | 25 | 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; |
31 | 31 | ||
32 | }; | 32 | }; |
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 @@ | |||
2 | #include <qfile.h> | 2 | #include <qfile.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
5 | #include <resources.h> | 5 | #include <resources.h> |
6 | #include "wlanrun.h" | 6 | #include "wlanrun.h" |
7 | 7 | ||
8 | void WLanRun::detectState( NodeCollection * NC ) { | 8 | State_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; |
17 | 18 | ||
18 | QFile F( S ); | 19 | QFile F( S ); |
19 | 20 | ||
@@ -26,32 +27,29 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
26 | if( handlesInterface( X ) ) { | 27 | if( handlesInterface( X ) ) { |
27 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 28 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
28 | It.current(); | 29 | It.current(); |
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()); |
55 | It.current(); | 53 | It.current(); |
56 | ++It ) { | 54 | ++It ) { |
57 | Run = It.current(); | 55 | Run = It.current(); |
@@ -61,87 +59,24 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
61 | || Run->CardType == ARPHRD_IEEE1394 | 59 | || Run->CardType == ARPHRD_IEEE1394 |
62 | #endif | 60 | #endif |
63 | ) && | 61 | ) && |
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 | ||
77 | bool WLanRun::setState( NodeCollection * NC, Action_t A, bool ) { | 73 | QString 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 | |||
119 | bool 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 |
145 | InterfaceInfo * WLanRun::getInterface( void ) { | 80 | InterfaceInfo * WLanRun::getInterface( void ) { |
146 | 81 | ||
147 | System & S = NSResources->system(); | 82 | System & S = NSResources->system(); |
@@ -156,16 +91,16 @@ InterfaceInfo * WLanRun::getInterface( void ) { | |||
156 | #ifdef ARPHRD_IEEE1394 | 91 | #ifdef ARPHRD_IEEE1394 |
157 | || Run->CardType == ARPHRD_IEEE1394 | 92 | || Run->CardType == ARPHRD_IEEE1394 |
158 | #endif | 93 | #endif |
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 | } |
169 | } | 104 | } |
170 | } | 105 | } |
171 | return best; // can be 0 | 106 | 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 @@ | |||
1 | #ifndef WLANRUN_H | 1 | #ifndef WLANRUN_H |
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 | ||
8 | class WLanRun : public AsDevice { | 8 | class WLanRun : public RuntimeInfo { |
9 | 9 | ||
10 | public : | 10 | public : |
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 | ||
22 | protected : | ||
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 | |||
25 | protected : | ||
26 | |||
27 | QString setMyState( NodeCollection * , Action_t, bool ); | ||
28 | |||
30 | private : | 29 | private : |
31 | 30 | ||
32 | InterfaceInfo * getInterface( void ); | 31 | InterfaceInfo * getInterface( void ); |
33 | QRegExp Pat; | 32 | QRegExp Pat; |
34 | WLanData * Data; | 33 | WLanData * Data; |
35 | }; | 34 | }; |