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,9 +1,9 @@ | |||
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 |
8 | Description: Network settings wlan plugin. | 8 | Description: Network settings wlan plugin. |
9 | Version: $QPE_VERSION$EXTRAVERSION | 9 | 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 @@ | |||
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 | */ |
18 | WLanNetNode::~WLanNetNode(){ | 26 | WLanNetNode::~WLanNetNode(){ |
19 | } | 27 | } |
20 | 28 | ||
21 | const QString WLanNetNode::nodeDescription(){ | 29 | const QString WLanNetNode::nodeDescription(){ |
22 | return tr("\ | 30 | return tr("\ |
23 | <p>Configure Wi/Fi or WLan network cards.</p>\ | 31 | <p>Configure Wi/Fi or WLan network cards.</p>\ |
24 | <p>Defines Wireless options for those cards</p>\ | 32 | <p>Defines Wireless options for those cards</p>\ |
25 | " | 33 | " |
26 | ); | 34 | ); |
27 | } | 35 | } |
28 | 36 | ||
29 | ANetNodeInstance * WLanNetNode::createInstance( void ) { | 37 | ANetNodeInstance * WLanNetNode::createInstance( void ) { |
30 | return new AWLan( this ); | 38 | return new AWLan( this ); |
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 | } |
45 | 53 | ||
46 | void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) { | 54 | void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) { |
47 | if( A == "interfacecount" ) { | 55 | if( A == "interfacecount" ) { |
48 | InstanceCount = V.toLong(); | 56 | InstanceCount = V.toLong(); |
49 | } | 57 | } |
50 | } | 58 | } |
51 | 59 | ||
52 | void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) { | 60 | void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) { |
53 | TS << "interfacecount=" | 61 | TS << "interfacecount=" |
54 | << InstanceCount | 62 | << InstanceCount |
55 | << endl; | 63 | << endl; |
56 | } | 64 | } |
57 | 65 | ||
58 | extern "C" { | 66 | extern "C" { |
59 | void create_plugin( QList<ANetNode> & PNN ) { | 67 | void create_plugin( QList<ANetNode> & PNN ) { |
60 | PNN.append( new WLanNetNode() ); | 68 | PNN.append( new WLanNetNode() ); |
61 | } | 69 | } |
62 | } | 70 | } |
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 @@ | |||
1 | #ifndef WLAN_NETNODE_H | 1 | #ifndef WLAN_NETNODE_H |
2 | #define WLAN_NETNODE_H | 2 | #define WLAN_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AWLan; | 6 | class AWLan; |
7 | 7 | ||
8 | class WLanNetNode : public ANetNode{ | 8 | class WLanNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | WLanNetNode(); | 14 | WLanNetNode(); |
15 | virtual ~WLanNetNode(); | 15 | virtual ~WLanNetNode(); |
16 | 16 | ||
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: |
30 | 30 | ||
31 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 31 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
32 | virtual void saveSpecificAttribute( QTextStream & TS ); | 32 | virtual void saveSpecificAttribute( QTextStream & TS ); |
33 | 33 | ||
34 | // number of interfaces for this device | 34 | // number of interfaces for this device |
35 | long InstanceCount; | 35 | long InstanceCount; |
36 | 36 | ||
37 | }; | 37 | }; |
38 | 38 | ||
39 | extern "C" | 39 | extern "C" |
40 | { | 40 | { |
41 | void create_plugin( QList<ANetNode> & PNN ); | 41 | void create_plugin( QList<ANetNode> & PNN ); |
42 | }; | 42 | }; |
43 | 43 | ||
44 | #endif | 44 | #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 ) { | |||
34 | Data.Encrypted = (V=="yes"); | 34 | Data.Encrypted = (V=="yes"); |
35 | } else if( A == "acceptnonencrypted" ) { | 35 | } else if( A == "acceptnonencrypted" ) { |
36 | Data.AcceptNonEncrypted = (V=="yes"); | 36 | Data.AcceptNonEncrypted = (V=="yes"); |
37 | } else if( A == "key0" ) { | 37 | } else if( A == "key0" ) { |
38 | Data.Key[0] = V; | 38 | Data.Key[0] = V; |
39 | } else if( A == "key1" ) { | 39 | } else if( A == "key1" ) { |
40 | Data.Key[1] = V; | 40 | Data.Key[1] = V; |
41 | } else if( A == "key2" ) { | 41 | } else if( A == "key2" ) { |
42 | Data.Key[2] = V; | 42 | Data.Key[2] = V; |
43 | } else if( A == "key3" ) { | 43 | } else if( A == "key3" ) { |
44 | Data.Key[3] = V; | 44 | Data.Key[3] = V; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | void AWLan::saveSpecificAttribute( QTextStream & S ) { | 48 | void AWLan::saveSpecificAttribute( QTextStream & S ) { |
49 | S << "essid=" << quote( Data.ESSID ) << endl; | 49 | S << "essid=" << quote( Data.ESSID ) << endl; |
50 | S << "nodename=" << quote( Data.NodeName ) << endl; | 50 | S << "nodename=" << quote( Data.NodeName ) << endl; |
51 | S << "mode=" << Data.Mode << endl; | 51 | S << "mode=" << Data.Mode << endl; |
52 | S << "specificap=" | 52 | S << "specificap=" |
53 | << ((Data.SpecificAP) ? "yes" : "no") | 53 | << ((Data.SpecificAP) ? "yes" : "no") |
54 | << endl; | 54 | << endl; |
55 | S << "apmac=" << Data.APMac << endl; | 55 | S << "apmac=" << Data.APMac << endl; |
56 | S << "encrypted=" | 56 | S << "encrypted=" |
57 | << ((Data.Encrypted) ? "yes" : "no") | 57 | << ((Data.Encrypted) ? "yes" : "no") |
58 | << endl; | 58 | << endl; |
59 | S << "acceptnonencrypted=" | 59 | S << "acceptnonencrypted=" |
60 | << ((Data.AcceptNonEncrypted) ? "yes" : "no") | 60 | << ((Data.AcceptNonEncrypted) ? "yes" : "no") |
61 | << endl; | 61 | << endl; |
62 | for( int i = 0 ;i < 4 ; i ++ ) { | 62 | for( int i = 0 ;i < 4 ; i ++ ) { |
63 | S << "key" << i << "=" << Data.Key[i] << endl; | 63 | S << "key" << i << "=" << Data.Key[i] << endl; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | QWidget * AWLan::edit( QWidget * parent ) { | 67 | QWidget * AWLan::edit( QWidget * parent ) { |
68 | GUI = new WLanEdit( parent, this ); | 68 | GUI = new WLanEdit( parent, this ); |
69 | GUI->showData( Data ); | 69 | GUI->showData( Data ); |
70 | return GUI; | 70 | return GUI; |
71 | } | 71 | } |
72 | 72 | ||
73 | QString AWLan::acceptable( void ) { | 73 | QString AWLan::acceptable( void ) { |
74 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 74 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
75 | } | 75 | } |
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 | ||
115 | char * M = "Auto"; | 113 | char * M = "Auto"; |
116 | switch ( Data.Mode ) { | 114 | switch ( Data.Mode ) { |
117 | case 0 : | 115 | case 0 : |
118 | break; | 116 | break; |
119 | case 1 : | 117 | case 1 : |
120 | M = "Managed"; | 118 | M = "Managed"; |
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 | |||
@@ -1,47 +1,45 @@ | |||
1 | #ifndef WLAN_H | 1 | #ifndef WLAN_H |
2 | #define WLAN_H | 2 | #define WLAN_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "wlandata.h" | 5 | #include "wlandata.h" |
6 | #include "wlanrun.h" | 6 | #include "wlanrun.h" |
7 | 7 | ||
8 | class WLanNetNode; | 8 | class WLanNetNode; |
9 | class WLanEdit; | 9 | class WLanEdit; |
10 | 10 | ||
11 | class AWLan : public ANetNodeInstance { | 11 | class AWLan : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | AWLan( WLanNetNode * PNN ); | 15 | AWLan( WLanNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | 17 | RuntimeInfo * runtime( void ) |
18 | { return | 18 | { return |
19 | ( RT ) ? RT : ( RT = new WLanRun( this, Data ) ); | 19 | ( RT ) ? RT : ( RT = new WLanRun( this, Data ) ); |
20 | } | 20 | } |
21 | 21 | ||
22 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
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 ); |
38 | 36 | ||
39 | private : | 37 | private : |
40 | 38 | ||
41 | WLanEdit * GUI; | 39 | WLanEdit * GUI; |
42 | WLanData Data; | 40 | WLanData Data; |
43 | WLanRun * RT; | 41 | WLanRun * RT; |
44 | 42 | ||
45 | }; | 43 | }; |
46 | 44 | ||
47 | #endif | 45 | #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 @@ | |||
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 | |||
@@ -1,115 +1,115 @@ | |||
1 | #include <qlineedit.h> | 1 | #include <qlineedit.h> |
2 | #include <qprogressbar.h> | 2 | #include <qprogressbar.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qregexp.h> | 5 | #include <qregexp.h> |
6 | #include <qcheckbox.h> | 6 | #include <qcheckbox.h> |
7 | #include <GUIUtils.h> | 7 | #include <GUIUtils.h> |
8 | #include <resources.h> | 8 | #include <resources.h> |
9 | #include <wextensions.h> | 9 | #include <wextensions.h> |
10 | 10 | ||
11 | #include "wlanedit.h" | 11 | #include "wlanedit.h" |
12 | #include "wlan_NN.h" | 12 | #include "wlan_NN.h" |
13 | #include "wlan_NNI.h" | 13 | #include "wlan_NNI.h" |
14 | 14 | ||
15 | WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : | 15 | WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : |
16 | WLanGUI( Parent ), RefreshTimer(this){ | 16 | WLanGUI( Parent ), RefreshTimer(this){ |
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() ); |
30 | ESSID_LBL->setText( WE->essid() ); | 30 | ESSID_LBL->setText( WE->essid() ); |
31 | Mode_LBL->setText( WE->mode() ); | 31 | Mode_LBL->setText( WE->mode() ); |
32 | S.setNum( WE->frequency() ); | 32 | S.setNum( WE->frequency() ); |
33 | Frequency_LBL->setText( S ); | 33 | Frequency_LBL->setText( S ); |
34 | S.setNum( WE->channel() ); | 34 | S.setNum( WE->channel() ); |
35 | Channel_LBL->setText( S ); | 35 | Channel_LBL->setText( S ); |
36 | S.setNum( WE->rate() ); | 36 | S.setNum( WE->rate() ); |
37 | Rate_LBL->setText( S ); | 37 | Rate_LBL->setText( S ); |
38 | AP_LBL->setText( WE->ap() ); | 38 | AP_LBL->setText( WE->ap() ); |
39 | 39 | ||
40 | SLOT_Refresh(); | 40 | SLOT_Refresh(); |
41 | 41 | ||
42 | connect( &RefreshTimer, SIGNAL( timeout() ), | 42 | connect( &RefreshTimer, SIGNAL( timeout() ), |
43 | this, SLOT( SLOT_Refresh() ) ); | 43 | this, SLOT( SLOT_Refresh() ) ); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | WLanEdit::~WLanEdit( void ) { | 48 | WLanEdit::~WLanEdit( void ) { |
49 | if( WE ) | 49 | if( WE ) |
50 | delete WE; | 50 | delete WE; |
51 | } | 51 | } |
52 | 52 | ||
53 | QString WLanEdit::acceptable( void ) { | 53 | QString WLanEdit::acceptable( void ) { |
54 | if( ESSID_LE->text().isEmpty() ) { | 54 | if( ESSID_LE->text().isEmpty() ) { |
55 | return QString("ESSID is mandatory"); | 55 | return QString("ESSID is mandatory"); |
56 | } | 56 | } |
57 | if( SpecifyAP_CB->isChecked() && | 57 | if( SpecifyAP_CB->isChecked() && |
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 | ||
71 | EnableWEP_CB->setChecked( Data.Encrypted ); | 71 | EnableWEP_CB->setChecked( Data.Encrypted ); |
72 | AcceptNonEncrypted_CB->setChecked( Data.AcceptNonEncrypted ); | 72 | AcceptNonEncrypted_CB->setChecked( Data.AcceptNonEncrypted ); |
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 ); |
86 | TXTM( Data.Key[1], Key2_LE, SM ); | 86 | TXTM( Data.Key[1], Key2_LE, SM ); |
87 | TXTM( Data.Key[2], Key3_LE, SM ); | 87 | TXTM( Data.Key[2], Key3_LE, SM ); |
88 | TXTM( Data.Key[3], Key4_LE, SM ); | 88 | TXTM( Data.Key[3], Key4_LE, SM ); |
89 | CBM( Data.SpecificAP, SpecifyAP_CB, SM ); | 89 | CBM( Data.SpecificAP, SpecifyAP_CB, SM ); |
90 | CBM( Data.Encrypted, EnableWEP_CB, SM ); | 90 | CBM( Data.Encrypted, EnableWEP_CB, SM ); |
91 | CBM( Data.AcceptNonEncrypted, AcceptNonEncrypted_CB, SM ); | 91 | CBM( Data.AcceptNonEncrypted, AcceptNonEncrypted_CB, SM ); |
92 | CIM( Data.Mode, Mode_CB, SM ); | 92 | CIM( Data.Mode, Mode_CB, SM ); |
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | void WLanEdit::SLOT_Refresh( void ) { | 96 | void WLanEdit::SLOT_Refresh( void ) { |
97 | if( WE ) { | 97 | if( WE ) { |
98 | int signal, noise, quality; | 98 | int signal, noise, quality; |
99 | WE->stats( signal, noise, quality); | 99 | WE->stats( signal, noise, quality); |
100 | 100 | ||
101 | Signal_PB->setProgress( signal ); | 101 | Signal_PB->setProgress( signal ); |
102 | Noise_PB->setProgress( noise ); | 102 | Noise_PB->setProgress( noise ); |
103 | Quality_PB->setProgress( quality ); | 103 | Quality_PB->setProgress( quality ); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | void WLanEdit::SLOT_AutoRefresh( bool ar ) { | 107 | void WLanEdit::SLOT_AutoRefresh( bool ar ) { |
108 | if( ar ) { | 108 | if( ar ) { |
109 | RefreshTimer.start( 1000 ); | 109 | RefreshTimer.start( 1000 ); |
110 | SLOT_Refresh(); | 110 | SLOT_Refresh(); |
111 | } else { | 111 | } else { |
112 | RefreshTimer.stop(); | 112 | RefreshTimer.stop(); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
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 | |||
@@ -1,185 +1,120 @@ | |||
1 | 1 | ||
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 | ||
20 | if( F.open( IO_ReadOnly ) ) { | 21 | if( F.open( IO_ReadOnly ) ) { |
21 | // could open file -> read interface and assign | 22 | // could open file -> read interface and assign |
22 | QString X; | 23 | QString X; |
23 | QTextStream TS(&F); | 24 | QTextStream TS(&F); |
24 | X = TS.readLine(); | 25 | X = TS.readLine(); |
25 | // find interface | 26 | // find interface |
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(); |
58 | if( handlesInterface( *Run ) && | 56 | if( handlesInterface( *Run ) && |
59 | ( Run->CardType == ARPHRD_ETHER | 57 | ( Run->CardType == ARPHRD_ETHER |
60 | #ifdef ARPHRD_IEEE1394 | 58 | #ifdef ARPHRD_IEEE1394 |
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(); |
148 | InterfaceInfo * best = 0, * Run; | 83 | InterfaceInfo * best = 0, * Run; |
149 | 84 | ||
150 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 85 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
151 | It.current(); | 86 | It.current(); |
152 | ++It ) { | 87 | ++It ) { |
153 | Run = It.current(); | 88 | Run = It.current(); |
154 | if( handlesInterface( *Run ) && | 89 | if( handlesInterface( *Run ) && |
155 | ( Run->CardType == ARPHRD_ETHER | 90 | ( Run->CardType == ARPHRD_ETHER |
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 |
172 | } | 107 | } |
173 | 108 | ||
174 | bool WLanRun::handlesInterface( const QString & S ) { | 109 | bool WLanRun::handlesInterface( const QString & S ) { |
175 | InterfaceInfo * II; | 110 | InterfaceInfo * II; |
176 | II = NSResources->system().interface( S ); | 111 | II = NSResources->system().interface( S ); |
177 | if( ( II = NSResources->system().interface( S ) ) ) { | 112 | if( ( II = NSResources->system().interface( S ) ) ) { |
178 | return handlesInterface( *II ); | 113 | return handlesInterface( *II ); |
179 | } | 114 | } |
180 | return Pat.match( S ) >= 0; | 115 | return Pat.match( S ) >= 0; |
181 | } | 116 | } |
182 | 117 | ||
183 | bool WLanRun::handlesInterface( const InterfaceInfo & II ) { | 118 | bool WLanRun::handlesInterface( const InterfaceInfo & II ) { |
184 | return ( Pat.match( II.Name ) < 0 ); | 119 | return ( Pat.match( II.Name ) < 0 ); |
185 | } | 120 | } |
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 @@ | |||
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 | }; |
36 | 35 | ||
37 | #endif | 36 | #endif |