-rw-r--r-- | noncore/applets/wirelessapplet/advancedconfig.cpp | 55 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/advancedconfig.h | 36 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/advancedconfigbase.ui | 159 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/networkinfo.cpp | 30 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/networkinfo.h | 4 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 149 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.h | 18 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wirelessapplet.pro | 7 |
8 files changed, 432 insertions, 26 deletions
diff --git a/noncore/applets/wirelessapplet/advancedconfig.cpp b/noncore/applets/wirelessapplet/advancedconfig.cpp new file mode 100644 index 0000000..97b008d --- a/dev/null +++ b/noncore/applets/wirelessapplet/advancedconfig.cpp | |||
@@ -0,0 +1,55 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer | ||
3 | ** <mickey@tm.informatik.uni-frankfurt.de> | ||
4 | ** http://www.Vanille.de | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "advancedconfig.h" | ||
17 | |||
18 | #include <qpe/config.h> | ||
19 | #include <qwidget.h> | ||
20 | #include <qcheckbox.h> | ||
21 | |||
22 | AdvancedConfig::AdvancedConfig( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
23 | : AdvancedConfigBase( parent, name, modal, fl ) | ||
24 | { | ||
25 | Config cfg( "qpe" ); | ||
26 | cfg.setGroup( "Wireless" ); | ||
27 | |||
28 | bool rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); | ||
29 | bool rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); | ||
30 | bool rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); | ||
31 | bool rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); | ||
32 | |||
33 | cbESSID->setChecked( rocESSID ); | ||
34 | cbFrequency->setChecked( rocFREQ ); | ||
35 | cbAccessPoint->setChecked( rocAP ); | ||
36 | cbMODE->setChecked( rocMODE ); | ||
37 | } | ||
38 | |||
39 | AdvancedConfig::~AdvancedConfig() | ||
40 | { | ||
41 | } | ||
42 | |||
43 | void AdvancedConfig::accept() | ||
44 | { | ||
45 | |||
46 | Config cfg( "qpe" ); | ||
47 | cfg.setGroup( "Wireless" ); | ||
48 | cfg.writeEntry( "renew_dhcp_on_essid_change", cbESSID->isChecked() ); | ||
49 | cfg.writeEntry( "renew_dhcp_on_freq_change", cbFrequency->isChecked() ); | ||
50 | cfg.writeEntry( "renew_dhcp_on_ap_change", cbAccessPoint->isChecked() ); | ||
51 | cfg.writeEntry( "renew_dhcp_on_mode_change", cbMODE->isChecked() ); | ||
52 | |||
53 | AdvancedConfigBase::accept(); | ||
54 | } | ||
55 | |||
diff --git a/noncore/applets/wirelessapplet/advancedconfig.h b/noncore/applets/wirelessapplet/advancedconfig.h new file mode 100644 index 0000000..17ba3c5 --- a/dev/null +++ b/noncore/applets/wirelessapplet/advancedconfig.h | |||
@@ -0,0 +1,36 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer | ||
3 | ** <mickey@tm.informatik.uni-frankfurt.de> | ||
4 | ** http://www.Vanille.de | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #ifndef ADVANCED_CONFIG_H | ||
17 | #define ADVANCED_CONFIG_H | ||
18 | |||
19 | #include "advancedconfigbase.h" | ||
20 | |||
21 | #include <qnamespace.h> | ||
22 | |||
23 | class AdvancedConfig: public AdvancedConfigBase | ||
24 | { | ||
25 | Q_OBJECT | ||
26 | |||
27 | public: | ||
28 | AdvancedConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | ||
29 | ~AdvancedConfig(); | ||
30 | |||
31 | protected: | ||
32 | virtual void accept(); | ||
33 | |||
34 | }; | ||
35 | |||
36 | #endif | ||
diff --git a/noncore/applets/wirelessapplet/advancedconfigbase.ui b/noncore/applets/wirelessapplet/advancedconfigbase.ui new file mode 100644 index 0000000..c7c4a10 --- a/dev/null +++ b/noncore/applets/wirelessapplet/advancedconfigbase.ui | |||
@@ -0,0 +1,159 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>AdvancedConfigBase</class> | ||
3 | <comment>/********************************************************************** | ||
4 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | ||
5 | ** | ||
6 | ** This file is part of Qt Palmtop Environment. | ||
7 | ** | ||
8 | ** This file may be distributed and/or modified under the terms of the | ||
9 | ** GNU General Public License version 2 as published by the Free Software | ||
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
11 | ** packaging of this file. | ||
12 | ** | ||
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
15 | ** | ||
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
17 | ** | ||
18 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
19 | ** not clear to you. | ||
20 | ** | ||
21 | ** $Id$ | ||
22 | ** | ||
23 | **********************************************************************/</comment> | ||
24 | <widget> | ||
25 | <class>QDialog</class> | ||
26 | <property stdset="1"> | ||
27 | <name>name</name> | ||
28 | <cstring>AdvancedConfigBase</cstring> | ||
29 | </property> | ||
30 | <property stdset="1"> | ||
31 | <name>geometry</name> | ||
32 | <rect> | ||
33 | <x>0</x> | ||
34 | <y>0</y> | ||
35 | <width>197</width> | ||
36 | <height>158</height> | ||
37 | </rect> | ||
38 | </property> | ||
39 | <property stdset="1"> | ||
40 | <name>sizePolicy</name> | ||
41 | <sizepolicy> | ||
42 | <hsizetype>1</hsizetype> | ||
43 | <vsizetype>1</vsizetype> | ||
44 | </sizepolicy> | ||
45 | </property> | ||
46 | <property stdset="1"> | ||
47 | <name>caption</name> | ||
48 | <string>Advanced Config</string> | ||
49 | </property> | ||
50 | <property> | ||
51 | <name>layoutMargin</name> | ||
52 | </property> | ||
53 | <property> | ||
54 | <name>layoutSpacing</name> | ||
55 | </property> | ||
56 | <widget> | ||
57 | <class>QGroupBox</class> | ||
58 | <property stdset="1"> | ||
59 | <name>name</name> | ||
60 | <cstring>fraStart</cstring> | ||
61 | </property> | ||
62 | <property stdset="1"> | ||
63 | <name>geometry</name> | ||
64 | <rect> | ||
65 | <x>11</x> | ||
66 | <y>11</y> | ||
67 | <width>175</width> | ||
68 | <height>136</height> | ||
69 | </rect> | ||
70 | </property> | ||
71 | <property stdset="1"> | ||
72 | <name>frameShape</name> | ||
73 | <enum>Box</enum> | ||
74 | </property> | ||
75 | <property stdset="1"> | ||
76 | <name>frameShadow</name> | ||
77 | <enum>Sunken</enum> | ||
78 | </property> | ||
79 | <property stdset="1"> | ||
80 | <name>title</name> | ||
81 | <string>Renew DHCP on changing</string> | ||
82 | </property> | ||
83 | <widget> | ||
84 | <class>QLayoutWidget</class> | ||
85 | <property stdset="1"> | ||
86 | <name>name</name> | ||
87 | <cstring>Layout5</cstring> | ||
88 | </property> | ||
89 | <property stdset="1"> | ||
90 | <name>geometry</name> | ||
91 | <rect> | ||
92 | <x>10</x> | ||
93 | <y>21</y> | ||
94 | <width>98</width> | ||
95 | <height>96</height> | ||
96 | </rect> | ||
97 | </property> | ||
98 | <grid> | ||
99 | <property stdset="1"> | ||
100 | <name>margin</name> | ||
101 | <number>0</number> | ||
102 | </property> | ||
103 | <property stdset="1"> | ||
104 | <name>spacing</name> | ||
105 | <number>6</number> | ||
106 | </property> | ||
107 | <widget row="1" column="0" > | ||
108 | <class>QCheckBox</class> | ||
109 | <property stdset="1"> | ||
110 | <name>name</name> | ||
111 | <cstring>cbFrequency</cstring> | ||
112 | </property> | ||
113 | <property stdset="1"> | ||
114 | <name>text</name> | ||
115 | <string>Frequency</string> | ||
116 | </property> | ||
117 | </widget> | ||
118 | <widget row="3" column="0" > | ||
119 | <class>QCheckBox</class> | ||
120 | <property stdset="1"> | ||
121 | <name>name</name> | ||
122 | <cstring>cbMODE</cstring> | ||
123 | </property> | ||
124 | <property stdset="1"> | ||
125 | <name>text</name> | ||
126 | <string>MODE</string> | ||
127 | </property> | ||
128 | </widget> | ||
129 | <widget row="0" column="0" > | ||
130 | <class>QCheckBox</class> | ||
131 | <property stdset="1"> | ||
132 | <name>name</name> | ||
133 | <cstring>cbESSID</cstring> | ||
134 | </property> | ||
135 | <property stdset="1"> | ||
136 | <name>text</name> | ||
137 | <string>ESSID</string> | ||
138 | </property> | ||
139 | </widget> | ||
140 | <widget row="2" column="0" > | ||
141 | <class>QCheckBox</class> | ||
142 | <property stdset="1"> | ||
143 | <name>name</name> | ||
144 | <cstring>cbAccessPoint</cstring> | ||
145 | </property> | ||
146 | <property stdset="1"> | ||
147 | <name>text</name> | ||
148 | <string>AccessPoint</string> | ||
149 | </property> | ||
150 | </widget> | ||
151 | </grid> | ||
152 | </widget> | ||
153 | </widget> | ||
154 | </widget> | ||
155 | <connections> | ||
156 | <slot access="protected">itemUp()</slot> | ||
157 | <slot access="protected">itemDown()</slot> | ||
158 | </connections> | ||
159 | </UI> | ||
diff --git a/noncore/applets/wirelessapplet/networkinfo.cpp b/noncore/applets/wirelessapplet/networkinfo.cpp index 22d7d83..8531fd5 100644 --- a/noncore/applets/wirelessapplet/networkinfo.cpp +++ b/noncore/applets/wirelessapplet/networkinfo.cpp | |||
@@ -42,44 +42,47 @@ | |||
42 | 42 | ||
43 | /* estimated wireless signal strength and noise level values | 43 | /* estimated wireless signal strength and noise level values |
44 | based on experimentation with Orinoco and Prism2 cards. | 44 | based on experimentation with Orinoco and Prism2 cards. |
45 | Seem to be correct, but please inform me, if you got values | 45 | Seem to be correct, but please inform me, if you got values |
46 | outside these boundaries. :Mickey: */ | 46 | outside these boundaries. :Mickey: */ |
47 | 47 | ||
48 | #define IW_UPPER 220 | 48 | #define IW_UPPER 220 |
49 | #define IW_LOWER 140 | 49 | #define IW_LOWER 140 |
50 | 50 | ||
51 | #define PROCNETDEV "/proc/net/dev" | 51 | #define PROCNETDEV "/proc/net/dev" |
52 | #define PROCNETWIRELESS "/proc/net/wireless" | 52 | #define PROCNETWIRELESS "/proc/net/wireless" |
53 | 53 | ||
54 | #define MDEBUG 0 | ||
55 | |||
54 | //--------------------------------------------------------------------------- | 56 | //--------------------------------------------------------------------------- |
55 | // class MNetworkInterface | 57 | // class MNetworkInterface |
56 | // | 58 | // |
57 | 59 | ||
58 | MNetworkInterface::MNetworkInterface( const char* name ) | 60 | MNetworkInterface::MNetworkInterface( const char* name ) |
59 | :name( name ) | 61 | :name( name ) |
60 | { | 62 | { |
61 | struct ifreq ifr; | 63 | struct ifreq ifr; |
62 | struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; | 64 | struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; |
63 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); | 65 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); |
64 | } | 66 | } |
65 | 67 | ||
66 | MNetworkInterface::~MNetworkInterface() | 68 | MNetworkInterface::~MNetworkInterface() |
67 | { | 69 | { |
68 | if ( fd != -1 ) | 70 | if ( fd != -1 ) |
69 | close( fd ); | 71 | close( fd ); |
70 | } | 72 | } |
71 | 73 | ||
72 | void MNetworkInterface::updateStatistics() | 74 | bool MNetworkInterface::updateStatistics() |
73 | { | 75 | { |
76 | return true; | ||
74 | } | 77 | } |
75 | 78 | ||
76 | //--------------------------------------------------------------------------- | 79 | //--------------------------------------------------------------------------- |
77 | // class MWirelessNetworkInterface | 80 | // class MWirelessNetworkInterface |
78 | // | 81 | // |
79 | 82 | ||
80 | MWirelessNetworkInterface::MWirelessNetworkInterface( const char* n ) | 83 | MWirelessNetworkInterface::MWirelessNetworkInterface( const char* n ) |
81 | :MNetworkInterface( n ) | 84 | :MNetworkInterface( n ) |
82 | { | 85 | { |
83 | signal = 0; | 86 | signal = 0; |
84 | noise = 0; | 87 | noise = 0; |
85 | quality = 0; | 88 | quality = 0; |
@@ -95,27 +98,29 @@ int MWirelessNetworkInterface::qualityPercent() | |||
95 | } | 98 | } |
96 | 99 | ||
97 | int MWirelessNetworkInterface::signalPercent() | 100 | int MWirelessNetworkInterface::signalPercent() |
98 | { | 101 | { |
99 | return ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | 102 | return ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; |
100 | } | 103 | } |
101 | 104 | ||
102 | int MWirelessNetworkInterface::noisePercent() | 105 | int MWirelessNetworkInterface::noisePercent() |
103 | { | 106 | { |
104 | return ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | 107 | return ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; |
105 | } | 108 | } |
106 | 109 | ||
107 | void MWirelessNetworkInterface::updateStatistics() | 110 | bool MWirelessNetworkInterface::updateStatistics() |
108 | { | 111 | { |
109 | MNetworkInterface::updateStatistics(); | 112 | bool base = MNetworkInterface::updateStatistics(); |
113 | if ( !base ) | ||
114 | return false; | ||
110 | 115 | ||
111 | const char* buffer[200]; | 116 | const char* buffer[200]; |
112 | 117 | ||
113 | struct iwreq iwr; | 118 | struct iwreq iwr; |
114 | memset( &iwr, 0, sizeof( iwr ) ); | 119 | memset( &iwr, 0, sizeof( iwr ) ); |
115 | iwr.u.essid.pointer = (caddr_t) buffer; | 120 | iwr.u.essid.pointer = (caddr_t) buffer; |
116 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 121 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
117 | iwr.u.essid.flags = 0; | 122 | iwr.u.essid.flags = 0; |
118 | 123 | ||
119 | // check if it is an IEEE 802.11 standard conform | 124 | // check if it is an IEEE 802.11 standard conform |
120 | // wireless device by sending SIOCGIWESSID | 125 | // wireless device by sending SIOCGIWESSID |
121 | // which also gives back the Extended Service Set ID | 126 | // which also gives back the Extended Service Set ID |
@@ -172,69 +177,76 @@ void MWirelessNetworkInterface::updateStatistics() | |||
172 | QString status; | 177 | QString status; |
173 | QString name; | 178 | QString name; |
174 | QFile wfile( PROCNETWIRELESS ); | 179 | QFile wfile( PROCNETWIRELESS ); |
175 | bool hasFile = wfile.open( IO_ReadOnly ); | 180 | bool hasFile = wfile.open( IO_ReadOnly ); |
176 | QTextStream wstream( &wfile ); | 181 | QTextStream wstream( &wfile ); |
177 | if ( hasFile ) | 182 | if ( hasFile ) |
178 | { | 183 | { |
179 | wstream.readLine(); // skip the first two lines | 184 | wstream.readLine(); // skip the first two lines |
180 | wstream.readLine(); // because they only contain headers | 185 | wstream.readLine(); // because they only contain headers |
181 | } | 186 | } |
182 | if ( ( !hasFile ) || ( wstream.atEnd() ) ) | 187 | if ( ( !hasFile ) || ( wstream.atEnd() ) ) |
183 | { | 188 | { |
189 | #ifdef MDEBUG | ||
184 | qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); | 190 | qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); |
191 | #endif | ||
185 | quality = -1; | 192 | quality = -1; |
186 | signal = IW_LOWER; | 193 | signal = IW_LOWER; |
187 | noise = IW_LOWER; | 194 | noise = IW_LOWER; |
188 | return; | 195 | return false; |
189 | } | 196 | } |
190 | 197 | ||
191 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 198 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
192 | 199 | ||
193 | if ( quality > 92 ) | 200 | if ( quality > 92 ) |
201 | #ifdef MDEBUG | ||
194 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 202 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
203 | #endif | ||
195 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 204 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
205 | #ifdef MDEBUG | ||
196 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 206 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
207 | #endif | ||
197 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 208 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
209 | #ifdef MDEBUG | ||
198 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 210 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
211 | #endif | ||
212 | |||
213 | return true; | ||
214 | |||
199 | } | 215 | } |
200 | 216 | ||
201 | //--------------------------------------------------------------------------- | 217 | //--------------------------------------------------------------------------- |
202 | // class Network | 218 | // class Network |
203 | // | 219 | // |
204 | 220 | ||
205 | MNetwork::MNetwork() | 221 | MNetwork::MNetwork() |
206 | { | 222 | { |
207 | //qDebug( "MNetwork::MNetwork()" ); | ||
208 | procfile = PROCNETDEV; | 223 | procfile = PROCNETDEV; |
209 | } | 224 | } |
210 | 225 | ||
211 | MNetwork::~MNetwork() | 226 | MNetwork::~MNetwork() |
212 | { | 227 | { |
213 | //qDebug( "MNetwork::~MNetwork()" ); | ||
214 | } | 228 | } |
215 | 229 | ||
216 | //--------------------------------------------------------------------------- | 230 | //--------------------------------------------------------------------------- |
217 | // class WirelessNetwork | 231 | // class WirelessNetwork |
218 | // | 232 | // |
219 | 233 | ||
220 | MWirelessNetwork::MWirelessNetwork() | 234 | MWirelessNetwork::MWirelessNetwork() |
221 | { | 235 | { |
222 | //qDebug( "MWirelessNetwork::MWirelessNetwork()" ); | ||
223 | procfile = PROCNETWIRELESS; | 236 | procfile = PROCNETWIRELESS; |
224 | } | 237 | } |
225 | 238 | ||
226 | MWirelessNetwork::~MWirelessNetwork() | 239 | MWirelessNetwork::~MWirelessNetwork() |
227 | { | 240 | { |
228 | //qDebug( "MWirelessNetwork::~MWirelessNetwork()" ); | ||
229 | } | 241 | } |
230 | 242 | ||
231 | MNetworkInterface* MWirelessNetwork::createInterface( const char* n ) const | 243 | MNetworkInterface* MWirelessNetwork::createInterface( const char* n ) const |
232 | { | 244 | { |
233 | return new MWirelessNetworkInterface( n ); | 245 | return new MWirelessNetworkInterface( n ); |
234 | } | 246 | } |
235 | 247 | ||
236 | //--------------------------------------------------------------------------- | 248 | //--------------------------------------------------------------------------- |
237 | // class NetworkInterface | 249 | // class NetworkInterface |
238 | // | 250 | // |
239 | 251 | ||
240 | MNetworkInterface* MNetwork::getFirstInterface() | 252 | MNetworkInterface* MNetwork::getFirstInterface() |
@@ -250,22 +262,24 @@ void MNetwork::enumerateInterfaces() | |||
250 | QString str; | 262 | QString str; |
251 | QFile f( procfile ); | 263 | QFile f( procfile ); |
252 | bool hasFile = f.open( IO_ReadOnly ); | 264 | bool hasFile = f.open( IO_ReadOnly ); |
253 | if ( !hasFile ) | 265 | if ( !hasFile ) |
254 | return; | 266 | return; |
255 | QTextStream s( &f ); | 267 | QTextStream s( &f ); |
256 | s.readLine(); | 268 | s.readLine(); |
257 | s.readLine(); | 269 | s.readLine(); |
258 | while ( !s.atEnd() ) | 270 | while ( !s.atEnd() ) |
259 | { | 271 | { |
260 | s >> str; | 272 | s >> str; |
261 | str.truncate( str.find( ':' ) ); | 273 | str.truncate( str.find( ':' ) ); |
274 | #ifdef MDEBUG | ||
262 | qDebug( "WIFIAPPLET: found interface '%s'", (const char*) str ); | 275 | qDebug( "WIFIAPPLET: found interface '%s'", (const char*) str ); |
276 | #endif | ||
263 | interfaces.insert( str, createInterface( str ) ); | 277 | interfaces.insert( str, createInterface( str ) ); |
264 | s.readLine(); | 278 | s.readLine(); |
265 | } | 279 | } |
266 | } | 280 | } |
267 | 281 | ||
268 | MNetworkInterface* MNetwork::createInterface( const char* n ) const | 282 | MNetworkInterface* MNetwork::createInterface( const char* n ) const |
269 | { | 283 | { |
270 | return new MNetworkInterface( n ); | 284 | return new MNetworkInterface( n ); |
271 | } | 285 | } |
diff --git a/noncore/applets/wirelessapplet/networkinfo.h b/noncore/applets/wirelessapplet/networkinfo.h index c5eb743..7e50bc4 100644 --- a/noncore/applets/wirelessapplet/networkinfo.h +++ b/noncore/applets/wirelessapplet/networkinfo.h | |||
@@ -28,25 +28,25 @@ | |||
28 | // | 28 | // |
29 | 29 | ||
30 | class MNetworkInterface | 30 | class MNetworkInterface |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | 33 | ||
34 | MNetworkInterface( const char* name = "eth0" ); | 34 | MNetworkInterface( const char* name = "eth0" ); |
35 | virtual ~MNetworkInterface(); | 35 | virtual ~MNetworkInterface(); |
36 | 36 | ||
37 | bool isLoopback() { return isLoopbackInterface; }; | 37 | bool isLoopback() { return isLoopbackInterface; }; |
38 | const QString& getName() { return name; }; | 38 | const QString& getName() { return name; }; |
39 | 39 | ||
40 | virtual void updateStatistics(); | 40 | virtual bool updateStatistics(); |
41 | 41 | ||
42 | protected: | 42 | protected: |
43 | 43 | ||
44 | int fd; | 44 | int fd; |
45 | const QString name; | 45 | const QString name; |
46 | bool isLoopbackInterface; | 46 | bool isLoopbackInterface; |
47 | bool isIrda; | 47 | bool isIrda; |
48 | bool isTunnel; | 48 | bool isTunnel; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | //--------------------------------------------------------------------------- | 51 | //--------------------------------------------------------------------------- |
52 | // class MWirelessNetworkInterface | 52 | // class MWirelessNetworkInterface |
@@ -61,25 +61,25 @@ public: | |||
61 | int noisePercent(); | 61 | int noisePercent(); |
62 | int qualityPercent(); | 62 | int qualityPercent(); |
63 | int signalPercent(); | 63 | int signalPercent(); |
64 | 64 | ||
65 | QString APAddr; | 65 | QString APAddr; |
66 | QString essid; | 66 | QString essid; |
67 | QString mode; | 67 | QString mode; |
68 | QString nick; | 68 | QString nick; |
69 | QString rate; | 69 | QString rate; |
70 | double freq; | 70 | double freq; |
71 | int channel; | 71 | int channel; |
72 | 72 | ||
73 | virtual void updateStatistics(); | 73 | virtual bool updateStatistics(); |
74 | 74 | ||
75 | private: | 75 | private: |
76 | int quality; | 76 | int quality; |
77 | int signal; | 77 | int signal; |
78 | int noise; | 78 | int noise; |
79 | 79 | ||
80 | bool hasWirelessExtensions; | 80 | bool hasWirelessExtensions; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | //--------------------------------------------------------------------------- | 83 | //--------------------------------------------------------------------------- |
84 | // class MNetwork | 84 | // class MNetwork |
85 | // | 85 | // |
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index 183aab8..a5aabb0 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp | |||
@@ -12,49 +12,57 @@ | |||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "wireless.h" | 16 | #include "wireless.h" |
17 | 17 | ||
18 | #include <qapplication.h> | 18 | #include <qapplication.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | 21 | ||
22 | #include <qpoint.h> | 22 | #include <qpoint.h> |
23 | #include <qradiobutton.h> | 23 | #include <qradiobutton.h> |
24 | #include <qcheckbox.h> | 24 | #include <qpushbutton.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qslider.h> | 27 | #include <qslider.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qframe.h> | 30 | #include <qframe.h> |
31 | #include <qpixmap.h> | 31 | #include <qpixmap.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qtextstream.h> | ||
35 | |||
36 | #include <sys/types.h> | ||
37 | #include <signal.h> | ||
34 | 38 | ||
35 | #include "networkinfo.h" | 39 | #include "networkinfo.h" |
36 | #include "mgraph.h" | 40 | #include "mgraph.h" |
37 | 41 | ||
42 | #include "advancedconfig.h" | ||
43 | |||
38 | #include "connect0.xpm" | 44 | #include "connect0.xpm" |
39 | #include "connect1.xpm" | 45 | #include "connect1.xpm" |
40 | #include "connect2.xpm" | 46 | #include "connect2.xpm" |
41 | #include "connect3.xpm" | 47 | #include "connect3.xpm" |
42 | #include "connect4.xpm" | 48 | #include "connect4.xpm" |
43 | #include "connect5.xpm" | 49 | #include "connect5.xpm" |
44 | #include "nowireless.xpm" | 50 | #include "nowireless.xpm" |
45 | 51 | ||
46 | #define STYLE_BARS 0 | 52 | #define STYLE_BARS 0 |
47 | #define STYLE_ANTENNA 1 | 53 | #define STYLE_ANTENNA 1 |
48 | 54 | ||
55 | #define MDEBUG 0 | ||
56 | |||
49 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) | 57 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) |
50 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) | 58 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) |
51 | { | 59 | { |
52 | 60 | ||
53 | readConfig(); | 61 | readConfig(); |
54 | writeConfigEntry( "UpdateFrequency", updateFrequency ); | 62 | writeConfigEntry( "UpdateFrequency", updateFrequency ); |
55 | writeConfigEntry( "DisplayStyle", displayStyle ); | 63 | writeConfigEntry( "DisplayStyle", displayStyle ); |
56 | 64 | ||
57 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 65 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
58 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); | 66 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); |
59 | 67 | ||
60 | /* status label */ | 68 | /* status label */ |
@@ -85,30 +93,31 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const | |||
85 | group->setButton( displayStyle ); | 93 | group->setButton( displayStyle ); |
86 | grid->addWidget( group, 0, 1 ); | 94 | grid->addWidget( group, 0, 1 ); |
87 | 95 | ||
88 | /* quality graph */ | 96 | /* quality graph */ |
89 | 97 | ||
90 | mgraph = new MGraph( this ); | 98 | mgraph = new MGraph( this ); |
91 | mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 99 | mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
92 | mgraph->setMin( 0 ); | 100 | mgraph->setMin( 0 ); |
93 | mgraph->setMax( 92 ); | 101 | mgraph->setMax( 92 ); |
94 | grid->addWidget( mgraph, 1, 0 ); | 102 | grid->addWidget( mgraph, 1, 0 ); |
95 | mgraph->setFocusPolicy( QWidget::NoFocus ); | 103 | mgraph->setFocusPolicy( QWidget::NoFocus ); |
96 | 104 | ||
97 | /* dhcp renew CheckBox */ | 105 | /* advanced configuration Button */ |
98 | 106 | ||
99 | //FIXME: under construction | 107 | QPushButton* advanced = new QPushButton( "Advanced...", this ); |
100 | //QCheckBox* dhcpCheckBox = new QCheckBox( "DHCP renew", this ); | 108 | advanced->setFocusPolicy( QWidget::NoFocus ); |
101 | //dhcpCheckBox->setFocusPolicy( QWidget::NoFocus ); | 109 | grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); |
102 | //grid->addWidget( dhcpCheckBox, 2, 0, Qt::AlignCenter ); | 110 | connect( advanced, SIGNAL( clicked() ), |
111 | this, SLOT( advancedConfigClicked() ) ); | ||
103 | 112 | ||
104 | /* update Frequency Label */ | 113 | /* update Frequency Label */ |
105 | 114 | ||
106 | updateLabel = new QLabel( this ); | 115 | updateLabel = new QLabel( this ); |
107 | text.sprintf( "Update every %d s", updateFrequency ); | 116 | text.sprintf( "Update every %d s", updateFrequency ); |
108 | updateLabel->setText( text ); | 117 | updateLabel->setText( text ); |
109 | grid->addWidget( updateLabel, 2, 1 ); | 118 | grid->addWidget( updateLabel, 2, 1 ); |
110 | 119 | ||
111 | /* update Frequency Slider */ | 120 | /* update Frequency Slider */ |
112 | 121 | ||
113 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); | 122 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); |
114 | updateSlider->setRange( 0, 9 ); | 123 | updateSlider->setRange( 0, 9 ); |
@@ -119,25 +128,40 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const | |||
119 | updateSlider->setFocusPolicy( QWidget::NoFocus ); | 128 | updateSlider->setFocusPolicy( QWidget::NoFocus ); |
120 | grid->addWidget( updateSlider, 1, 1 ); | 129 | grid->addWidget( updateSlider, 1, 1 ); |
121 | connect( updateSlider, SIGNAL( valueChanged( int ) ), | 130 | connect( updateSlider, SIGNAL( valueChanged( int ) ), |
122 | this, SLOT( updateDelayChange( int ) ) ); | 131 | this, SLOT( updateDelayChange( int ) ) ); |
123 | 132 | ||
124 | setFixedSize( sizeHint() ); | 133 | setFixedSize( sizeHint() ); |
125 | setFocusPolicy( QWidget::NoFocus ); | 134 | setFocusPolicy( QWidget::NoFocus ); |
126 | 135 | ||
127 | applet->displayStyleChange( displayStyle ); | 136 | applet->displayStyleChange( displayStyle ); |
128 | applet->updateDelayChange( updateFrequency ); | 137 | applet->updateDelayChange( updateFrequency ); |
129 | 138 | ||
130 | connect( group, SIGNAL( clicked( int ) ), | 139 | connect( group, SIGNAL( clicked( int ) ), |
131 | this, SLOT( displayStyleChange( int ) ) ); | 140 | this, SLOT( displayStyleChange( int ) ) ); |
141 | |||
142 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | ||
143 | } | ||
144 | |||
145 | void WirelessControl::advancedConfigClicked() | ||
146 | { | ||
147 | AdvancedConfig* a = new AdvancedConfig( this, "dialog", TRUE ); | ||
148 | int result = a->exec(); | ||
149 | a->hide(); | ||
150 | delete a; | ||
151 | if ( result == QDialog::Accepted ) | ||
152 | { | ||
153 | readConfig(); | ||
154 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | ||
155 | } | ||
132 | } | 156 | } |
133 | 157 | ||
134 | void WirelessControl::updateDelayChange( int delay ) | 158 | void WirelessControl::updateDelayChange( int delay ) |
135 | { | 159 | { |
136 | QString text; | 160 | QString text; |
137 | text.sprintf( "Update every %d s", delay ); | 161 | text.sprintf( "Update every %d s", delay ); |
138 | updateLabel->setText( text ); | 162 | updateLabel->setText( text ); |
139 | applet->updateDelayChange( delay ); | 163 | applet->updateDelayChange( delay ); |
140 | writeConfigEntry( "UpdateFrequency", delay ); | 164 | writeConfigEntry( "UpdateFrequency", delay ); |
141 | } | 165 | } |
142 | 166 | ||
143 | void WirelessControl::displayStyleChange( int style ) | 167 | void WirelessControl::displayStyleChange( int style ) |
@@ -157,60 +181,105 @@ void WirelessControl::show ( bool ) | |||
157 | x = QPEApplication::desktop ( )-> width ( ) - w; | 181 | x = QPEApplication::desktop ( )-> width ( ) - w; |
158 | 182 | ||
159 | move( x, curPos.y () - sizeHint().height () ); | 183 | move( x, curPos.y () - sizeHint().height () ); |
160 | QFrame::show(); | 184 | QFrame::show(); |
161 | } | 185 | } |
162 | 186 | ||
163 | void WirelessControl::readConfig() | 187 | void WirelessControl::readConfig() |
164 | { | 188 | { |
165 | Config cfg( "qpe" ); | 189 | Config cfg( "qpe" ); |
166 | cfg.setGroup( "Wireless" ); | 190 | cfg.setGroup( "Wireless" ); |
167 | 191 | ||
168 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); | 192 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); |
169 | displayStyle = cfg. readNumEntry( "DisplayStyle", STYLE_ANTENNA ); | 193 | displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); |
194 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); | ||
195 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); | ||
196 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); | ||
197 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); | ||
170 | } | 198 | } |
171 | 199 | ||
172 | void WirelessControl::writeConfigEntry( const char *entry, int val ) | 200 | void WirelessControl::writeConfigEntry( const char *entry, int val ) |
173 | { | 201 | { |
174 | Config cfg( "qpe" ); | 202 | Config cfg( "qpe" ); |
175 | cfg.setGroup( "Wireless" ); | 203 | cfg.setGroup( "Wireless" ); |
176 | cfg.writeEntry( entry, val ); | 204 | cfg.writeEntry( entry, val ); |
177 | } | 205 | } |
178 | 206 | ||
179 | //=========================================================================== | 207 | //=========================================================================== |
180 | 208 | ||
181 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) | 209 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) |
182 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), | 210 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), |
183 | timer( 0 ), interface( 0 ) | 211 | timer( 0 ), interface( 0 ), |
212 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) | ||
184 | { | 213 | { |
185 | setFixedHeight( 18 ); | 214 | setFixedHeight( 18 ); |
186 | setFixedWidth( 14 ); | 215 | setFixedWidth( 14 ); |
187 | network = new MWirelessNetwork(); | 216 | network = new MWirelessNetwork(); |
188 | status = new WirelessControl( this, 0, "wireless status" ); | 217 | status = new WirelessControl( this, 0, "wireless status" ); |
189 | } | 218 | } |
190 | 219 | ||
191 | void WirelessApplet::checkInterface() | 220 | void WirelessApplet::checkInterface() |
192 | { | 221 | { |
193 | interface = network->getFirstInterface(); | 222 | interface = network->getFirstInterface(); |
194 | if ( interface ) | 223 | if ( interface ) |
195 | { | 224 | { |
225 | #ifdef MDEBUG | ||
196 | qDebug( "WIFIAPPLET: using interface '%s'", (const char*) | 226 | qDebug( "WIFIAPPLET: using interface '%s'", (const char*) |
227 | #endif | ||
197 | interface->getName() ); | 228 | interface->getName() ); |
198 | } | 229 | } |
199 | else | 230 | else |
200 | { | 231 | { |
232 | #ifdef MDEBUG | ||
201 | qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); | 233 | qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); |
234 | hide(); | ||
235 | #endif | ||
202 | } | 236 | } |
203 | } | 237 | } |
204 | 238 | ||
239 | void WirelessApplet::renewDHCP() | ||
240 | { | ||
241 | #ifdef MDEBUG | ||
242 | qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); | ||
243 | #endif | ||
244 | |||
245 | QString pidfile; | ||
246 | if ( !interface ) | ||
247 | return; | ||
248 | QString ifacename( interface->getName() ); | ||
249 | pidfile.sprintf( "/var/run/dhcpcd-%s.pid", (const char* ) ifacename ); | ||
250 | #ifdef MDEBUG | ||
251 | qDebug( "WIFIAPPLET: pidfile is '%s'", (const char*) pidfile ); | ||
252 | #endif | ||
253 | int pid; | ||
254 | QFile pfile( pidfile ); | ||
255 | bool hasFile = pfile.open( IO_ReadOnly ); | ||
256 | QTextStream s( &pfile ); | ||
257 | if ( hasFile ) | ||
258 | s >> pid; | ||
259 | #ifdef MDEBUG | ||
260 | qDebug( "WIFIAPPLET: sent -14 to pid %d", pid ); | ||
261 | #endif | ||
262 | kill( pid, -14 ); | ||
263 | |||
264 | } | ||
265 | |||
266 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) | ||
267 | { | ||
268 | rocESSID = ESSID; | ||
269 | rocFREQ = FREQ; | ||
270 | rocAP = AP; | ||
271 | rocMODE = MODE; | ||
272 | } | ||
273 | |||
205 | void WirelessApplet::updateDelayChange( int delay ) | 274 | void WirelessApplet::updateDelayChange( int delay ) |
206 | { | 275 | { |
207 | if ( timer ) | 276 | if ( timer ) |
208 | killTimer( timer ); | 277 | killTimer( timer ); |
209 | delay *= 1000; | 278 | delay *= 1000; |
210 | if ( delay == 0 ) | 279 | if ( delay == 0 ) |
211 | delay = 50; | 280 | delay = 50; |
212 | timer = startTimer( delay ); | 281 | timer = startTimer( delay ); |
213 | } | 282 | } |
214 | 283 | ||
215 | void WirelessApplet::displayStyleChange( int style ) | 284 | void WirelessApplet::displayStyleChange( int style ) |
216 | { | 285 | { |
@@ -219,25 +288,31 @@ void WirelessApplet::displayStyleChange( int style ) | |||
219 | } | 288 | } |
220 | 289 | ||
221 | WirelessApplet::~WirelessApplet() | 290 | WirelessApplet::~WirelessApplet() |
222 | { | 291 | { |
223 | } | 292 | } |
224 | 293 | ||
225 | void WirelessApplet::timerEvent( QTimerEvent* ) | 294 | void WirelessApplet::timerEvent( QTimerEvent* ) |
226 | { | 295 | { |
227 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 296 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; |
228 | 297 | ||
229 | if ( iface ) | 298 | if ( iface ) |
230 | { | 299 | { |
231 | iface->updateStatistics(); | 300 | bool statResult = iface->updateStatistics(); |
301 | if ( !statResult ) | ||
302 | { | ||
303 | interface = 0; | ||
304 | mustRepaint(); | ||
305 | return; | ||
306 | } else | ||
232 | if ( mustRepaint() ) | 307 | if ( mustRepaint() ) |
233 | { | 308 | { |
234 | //qDebug( "WIFIAPPLET: A value has changed -> repainting." ); | 309 | //qDebug( "WIFIAPPLET: A value has changed -> repainting." ); |
235 | repaint(); | 310 | repaint(); |
236 | } | 311 | } |
237 | 312 | ||
238 | if ( status->isVisible() ) | 313 | if ( status->isVisible() ) |
239 | updatePopupWindow(); | 314 | updatePopupWindow(); |
240 | } else checkInterface(); | 315 | } else checkInterface(); |
241 | } | 316 | } |
242 | 317 | ||
243 | void WirelessApplet::mousePressEvent( QMouseEvent *) | 318 | void WirelessApplet::mousePressEvent( QMouseEvent *) |
@@ -249,49 +324,97 @@ void WirelessApplet::mousePressEvent( QMouseEvent *) | |||
249 | } | 324 | } |
250 | 325 | ||
251 | bool WirelessApplet::mustRepaint() | 326 | bool WirelessApplet::mustRepaint() |
252 | { | 327 | { |
253 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 328 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; |
254 | 329 | ||
255 | // check if there are enough changes to justify a (flickering) repaint | 330 | // check if there are enough changes to justify a (flickering) repaint |
256 | 331 | ||
257 | // has the interface changed? | 332 | // has the interface changed? |
258 | 333 | ||
259 | if ( iface != oldiface ) | 334 | if ( iface != oldiface ) |
260 | { | 335 | { |
261 | oldiface = iface; | 336 | oldiface = iface; |
262 | return true; | 337 | if ( iface ) |
338 | { | ||
339 | #ifdef MDEBUG | ||
340 | qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" ); | ||
341 | #endif | ||
342 | show(); | ||
343 | } | ||
344 | else | ||
345 | { | ||
346 | #ifdef MDEBUG | ||
347 | qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" ); | ||
348 | #endif | ||
349 | hide(); | ||
350 | return true; | ||
351 | } | ||
263 | } | 352 | } |
264 | 353 | ||
265 | const char** pixmap = getQualityPixmap(); | 354 | const char** pixmap = getQualityPixmap(); |
266 | 355 | ||
267 | if ( pixmap && ( pixmap != oldpixmap ) ) | 356 | if ( pixmap && ( pixmap != oldpixmap ) ) |
268 | { | 357 | { |
269 | oldpixmap = pixmap; | 358 | oldpixmap = pixmap; |
270 | return true; | 359 | return true; |
271 | } | 360 | } |
272 | 361 | ||
273 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; | 362 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; |
274 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; | 363 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; |
275 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; | 364 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; |
276 | 365 | ||
277 | if ( ( noiseH != oldnoiseH ) | 366 | if ( ( noiseH != oldnoiseH ) |
278 | || ( signalH != oldsignalH ) | 367 | || ( signalH != oldsignalH ) |
279 | || ( qualityH != oldqualityH ) ) | 368 | || ( qualityH != oldqualityH ) ) |
280 | { | 369 | { |
281 | oldnoiseH = noiseH; | 370 | oldnoiseH = noiseH; |
282 | oldsignalH = signalH; | 371 | oldsignalH = signalH; |
283 | oldqualityH = qualityH; | 372 | oldqualityH = qualityH; |
284 | return true; | 373 | return true; |
285 | } | 374 | } |
375 | |||
376 | if ( rocESSID && ( oldESSID != iface->essid ) ) | ||
377 | { | ||
378 | #ifdef MDEBUG | ||
379 | qDebug( "WIFIAPPLET: ESSID has changed."); | ||
380 | #endif | ||
381 | renewDHCP(); | ||
382 | } | ||
383 | else if ( rocFREQ && ( oldFREQ != iface->freq ) ) | ||
384 | { | ||
385 | #ifdef MDEBUG | ||
386 | qDebug( "WIFIAPPLET: FREQ has changed."); | ||
387 | #endif | ||
388 | renewDHCP(); | ||
389 | } | ||
390 | else if ( rocAP && ( oldAP != iface->APAddr ) ) | ||
391 | { | ||
392 | #ifdef MDEBUG | ||
393 | qDebug( "WIFIAPPLET: AP has changed."); | ||
394 | #endif | ||
395 | renewDHCP(); | ||
396 | } | ||
397 | else if ( rocMODE && ( oldMODE != iface->mode ) ) | ||
398 | { | ||
399 | #ifdef MDEBUG | ||
400 | qDebug( "WIFIAPPLET: MODE has changed."); | ||
401 | #endif | ||
402 | renewDHCP(); | ||
403 | } | ||
404 | |||
405 | oldESSID = iface->essid; | ||
406 | oldMODE = iface->mode; | ||
407 | oldFREQ = iface->freq; | ||
408 | oldAP = iface->APAddr; | ||
286 | 409 | ||
287 | return false; | 410 | return false; |
288 | } | 411 | } |
289 | 412 | ||
290 | void WirelessApplet::updatePopupWindow() | 413 | void WirelessApplet::updatePopupWindow() |
291 | { | 414 | { |
292 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 415 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; |
293 | int qualityH = iface->qualityPercent(); | 416 | int qualityH = iface->qualityPercent(); |
294 | 417 | ||
295 | if ( status->mgraph ) | 418 | if ( status->mgraph ) |
296 | status->mgraph->addValue( qualityH, false ); | 419 | status->mgraph->addValue( qualityH, false ); |
297 | 420 | ||
@@ -325,25 +448,25 @@ const char** WirelessApplet::getQualityPixmap() | |||
325 | 448 | ||
326 | return 0; // please draw your bars | 449 | return 0; // please draw your bars |
327 | } | 450 | } |
328 | 451 | ||
329 | void WirelessApplet::paintEvent( QPaintEvent* ) | 452 | void WirelessApplet::paintEvent( QPaintEvent* ) |
330 | { | 453 | { |
331 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 454 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; |
332 | 455 | ||
333 | QPainter p(this); | 456 | QPainter p(this); |
334 | QColor color; | 457 | QColor color; |
335 | 458 | ||
336 | const char** pixmap = getQualityPixmap(); | 459 | const char** pixmap = getQualityPixmap(); |
337 | 460 | ||
338 | if ( pixmap ) | 461 | if ( pixmap ) |
339 | p.drawPixmap( 0, 1, pixmap ); | 462 | p.drawPixmap( 0, 1, pixmap ); |
340 | else | 463 | else |
341 | { | 464 | { |
342 | 465 | ||
343 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; | 466 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; |
344 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; | 467 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; |
345 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; | 468 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; |
346 | 469 | ||
347 | double intensity; | 470 | double intensity; |
348 | int pixelHeight; | 471 | int pixelHeight; |
349 | int pixelWidth = 2; | 472 | int pixelWidth = 2; |
diff --git a/noncore/applets/wirelessapplet/wireless.h b/noncore/applets/wirelessapplet/wireless.h index 45c519d..51a3fab 100644 --- a/noncore/applets/wirelessapplet/wireless.h +++ b/noncore/applets/wirelessapplet/wireless.h | |||
@@ -36,60 +36,78 @@ public: | |||
36 | void show( bool ); | 36 | void show( bool ); |
37 | 37 | ||
38 | void readConfig(); | 38 | void readConfig(); |
39 | void writeConfigEntry( const char* entry, int val ); | 39 | void writeConfigEntry( const char* entry, int val ); |
40 | 40 | ||
41 | MGraph* mgraph; | 41 | MGraph* mgraph; |
42 | QLabel* statusLabel; | 42 | QLabel* statusLabel; |
43 | QLabel* updateLabel; | 43 | QLabel* updateLabel; |
44 | 44 | ||
45 | public slots: | 45 | public slots: |
46 | void updateDelayChange( int ); | 46 | void updateDelayChange( int ); |
47 | void displayStyleChange( int ); | 47 | void displayStyleChange( int ); |
48 | void advancedConfigClicked(); | ||
48 | 49 | ||
49 | private: | 50 | private: |
50 | WirelessApplet* applet; | 51 | WirelessApplet* applet; |
51 | 52 | ||
52 | int displayStyle; | 53 | int displayStyle; |
53 | int updateFrequency; | 54 | int updateFrequency; |
54 | 55 | ||
56 | bool rocESSID; | ||
57 | bool rocFREQ; | ||
58 | bool rocAP; | ||
59 | bool rocMODE; | ||
55 | }; | 60 | }; |
56 | 61 | ||
57 | class WirelessApplet : public QWidget | 62 | class WirelessApplet : public QWidget |
58 | { | 63 | { |
59 | Q_OBJECT | 64 | Q_OBJECT |
60 | public: | 65 | public: |
61 | WirelessApplet( QWidget *parent = 0, const char *name=0 ); | 66 | WirelessApplet( QWidget *parent = 0, const char *name=0 ); |
62 | ~WirelessApplet(); | 67 | ~WirelessApplet(); |
63 | WirelessControl* status; | 68 | WirelessControl* status; |
64 | 69 | ||
65 | virtual void timerEvent( QTimerEvent* ); | 70 | virtual void timerEvent( QTimerEvent* ); |
66 | void updateDelayChange( int delay ); | 71 | void updateDelayChange( int delay ); |
67 | void displayStyleChange( int style ); | 72 | void displayStyleChange( int style ); |
73 | |||
74 | void updateDHCPConfig( bool, bool, bool, bool ); | ||
68 | 75 | ||
69 | private: | 76 | private: |
70 | void mousePressEvent( QMouseEvent * ); | 77 | void mousePressEvent( QMouseEvent * ); |
71 | void paintEvent( QPaintEvent* ); | 78 | void paintEvent( QPaintEvent* ); |
72 | void checkInterface(); | 79 | void checkInterface(); |
80 | void renewDHCP(); | ||
73 | 81 | ||
74 | bool mustRepaint(); | 82 | bool mustRepaint(); |
75 | void updatePopupWindow(); | 83 | void updatePopupWindow(); |
76 | const char** getQualityPixmap(); | 84 | const char** getQualityPixmap(); |
77 | 85 | ||
78 | private: | 86 | private: |
79 | QPixmap snapshotPixmap; | 87 | QPixmap snapshotPixmap; |
80 | int visualStyle; | 88 | int visualStyle; |
81 | int timer; | 89 | int timer; |
82 | 90 | ||
83 | MWirelessNetwork* network; | 91 | MWirelessNetwork* network; |
84 | MNetworkInterface* interface; | 92 | MNetworkInterface* interface; |
85 | 93 | ||
86 | private: | 94 | private: |
87 | const char** oldpixmap; | 95 | const char** oldpixmap; |
88 | MWirelessNetworkInterface* oldiface; | 96 | MWirelessNetworkInterface* oldiface; |
89 | int oldqualityH; | 97 | int oldqualityH; |
90 | int oldsignalH; | 98 | int oldsignalH; |
91 | int oldnoiseH; | 99 | int oldnoiseH; |
100 | |||
101 | QString oldESSID; | ||
102 | QString oldAP; | ||
103 | QString oldMODE; | ||
104 | double oldFREQ; | ||
105 | |||
106 | bool rocESSID; | ||
107 | bool rocFREQ; | ||
108 | bool rocAP; | ||
109 | bool rocMODE; | ||
92 | }; | 110 | }; |
93 | 111 | ||
94 | #endif // __WIRELESS_APPLET_H__ | 112 | #endif // __WIRELESS_APPLET_H__ |
95 | 113 | ||
diff --git a/noncore/applets/wirelessapplet/wirelessapplet.pro b/noncore/applets/wirelessapplet/wirelessapplet.pro index b758d4f..390b271 100644 --- a/noncore/applets/wirelessapplet/wirelessapplet.pro +++ b/noncore/applets/wirelessapplet/wirelessapplet.pro | |||
@@ -1,22 +1,23 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS = wireless.h wirelessappletimpl.h networkinfo.h mgraph.h | 3 | HEADERS = wireless.h wirelessappletimpl.h networkinfo.h mgraph.h advancedconfig.h |
4 | SOURCES = wireless.cpp wirelessappletimpl.cpp networkinfo.cpp mgraph.cpp | 4 | SOURCES = wireless.cpp wirelessappletimpl.cpp networkinfo.cpp mgraph.cpp advancedconfig.cpp |
5 | INTERFACES = advancedconfigbase.ui | ||
5 | TARGET = wirelessapplet | 6 | TARGET = wirelessapplet |
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 7 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 8 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include | 9 | DEPENDPATH += ../$(OPIEDIR)/include |
9 | LIBS += -lqpe | 10 | LIBS += -lqpe |
10 | VERSION = 0.0.3 | 11 | VERSION = 0.1.0 |
11 | 12 | ||
12 | TRANSLATIONS = ../../../i18n/de/libwirelessapplet.ts \ | 13 | TRANSLATIONS = ../../../i18n/de/libwirelessapplet.ts \ |
13 | ../../../i18n/en/libwirelessapplet.ts \ | 14 | ../../../i18n/en/libwirelessapplet.ts \ |
14 | ../../../i18n/es/libwirelessapplet.ts \ | 15 | ../../../i18n/es/libwirelessapplet.ts \ |
15 | ../../../i18n/fr/libwirelessapplet.ts \ | 16 | ../../../i18n/fr/libwirelessapplet.ts \ |
16 | ../../../i18n/hu/libwirelessapplet.ts \ | 17 | ../../../i18n/hu/libwirelessapplet.ts \ |
17 | ../../../i18n/ja/libwirelessapplet.ts \ | 18 | ../../../i18n/ja/libwirelessapplet.ts \ |
18 | ../../../i18n/ko/libwirelessapplet.ts \ | 19 | ../../../i18n/ko/libwirelessapplet.ts \ |
19 | ../../../i18n/no/libwirelessapplet.ts \ | 20 | ../../../i18n/no/libwirelessapplet.ts \ |
20 | ../../../i18n/pl/libwirelessapplet.ts \ | 21 | ../../../i18n/pl/libwirelessapplet.ts \ |
21 | ../../../i18n/pt/libwirelessapplet.ts \ | 22 | ../../../i18n/pt/libwirelessapplet.ts \ |
22 | ../../../i18n/pt_BR/libwirelessapplet.ts \ | 23 | ../../../i18n/pt_BR/libwirelessapplet.ts \ |