author | mickeyl <mickeyl> | 2002-08-31 10:43:26 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2002-08-31 10:43:26 (UTC) |
commit | cd33eed8d5eccebdc37dcd0e30d7917b91765222 (patch) (unidiff) | |
tree | cec3d088b58501bcc660686f468c4a968dc2d729 /noncore/applets/wirelessapplet/networkinfo.cpp | |
parent | 3b720187b21a3b9b3d17fc2b26489723febdaec2 (diff) | |
download | opie-cd33eed8d5eccebdc37dcd0e30d7917b91765222.zip opie-cd33eed8d5eccebdc37dcd0e30d7917b91765222.tar.gz opie-cd33eed8d5eccebdc37dcd0e30d7917b91765222.tar.bz2 |
- debug output is now #ifdef'd
- wireless applet icon shows on demand (like cardmon
- applet has an advanced configuration dialog
- applet features experimental dhcp renew on change of essid/freq/ap/mode
Diffstat (limited to 'noncore/applets/wirelessapplet/networkinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/wirelessapplet/networkinfo.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
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 | |||
@@ -48,12 +48,14 @@ | |||
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 ) |
@@ -66,14 +68,15 @@ MNetworkInterface::MNetworkInterface( const char* name ) | |||
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 | ||
@@ -101,15 +104,17 @@ int MWirelessNetworkInterface::signalPercent() | |||
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; |
@@ -178,57 +183,64 @@ void MWirelessNetworkInterface::updateStatistics() | |||
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 | } |
@@ -256,13 +268,15 @@ void MNetwork::enumerateInterfaces() | |||
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 |