summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2002-08-31 10:43:26 (UTC)
committer mickeyl <mickeyl>2002-08-31 10:43:26 (UTC)
commitcd33eed8d5eccebdc37dcd0e30d7917b91765222 (patch) (unidiff)
treecec3d088b58501bcc660686f468c4a968dc2d729
parent3b720187b21a3b9b3d17fc2b26489723febdaec2 (diff)
downloadopie-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 (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/advancedconfig.cpp55
-rw-r--r--noncore/applets/wirelessapplet/advancedconfig.h36
-rw-r--r--noncore/applets/wirelessapplet/advancedconfigbase.ui159
-rw-r--r--noncore/applets/wirelessapplet/networkinfo.cpp30
-rw-r--r--noncore/applets/wirelessapplet/networkinfo.h4
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp149
-rw-r--r--noncore/applets/wirelessapplet/wireless.h18
-rw-r--r--noncore/applets/wirelessapplet/wirelessapplet.pro7
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
22AdvancedConfig::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
39AdvancedConfig::~AdvancedConfig()
40{
41}
42
43void 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
23class AdvancedConfig: public AdvancedConfigBase
24{
25 Q_OBJECT
26
27public:
28 AdvancedConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
29 ~AdvancedConfig();
30
31protected:
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
@@ -51,6 +51,8 @@
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//
@@ -69,8 +71,9 @@ MNetworkInterface::~MNetworkInterface()
69 close( fd ); 71 close( fd );
70} 72}
71 73
72void MNetworkInterface::updateStatistics() 74bool MNetworkInterface::updateStatistics()
73{ 75{
76 return true;
74} 77}
75 78
76//--------------------------------------------------------------------------- 79//---------------------------------------------------------------------------
@@ -104,9 +107,11 @@ int MWirelessNetworkInterface::noisePercent()
104 return ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; 107 return ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER;
105} 108}
106 109
107void MWirelessNetworkInterface::updateStatistics() 110bool 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
@@ -181,21 +186,32 @@ void MWirelessNetworkInterface::updateStatistics()
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//---------------------------------------------------------------------------
@@ -204,13 +220,11 @@ void MWirelessNetworkInterface::updateStatistics()
204 220
205MNetwork::MNetwork() 221MNetwork::MNetwork()
206{ 222{
207 //qDebug( "MNetwork::MNetwork()" );
208 procfile = PROCNETDEV; 223 procfile = PROCNETDEV;
209} 224}
210 225
211MNetwork::~MNetwork() 226MNetwork::~MNetwork()
212{ 227{
213 //qDebug( "MNetwork::~MNetwork()" );
214} 228}
215 229
216//--------------------------------------------------------------------------- 230//---------------------------------------------------------------------------
@@ -219,13 +233,11 @@ MNetwork::~MNetwork()
219 233
220MWirelessNetwork::MWirelessNetwork() 234MWirelessNetwork::MWirelessNetwork()
221{ 235{
222 //qDebug( "MWirelessNetwork::MWirelessNetwork()" );
223 procfile = PROCNETWIRELESS; 236 procfile = PROCNETWIRELESS;
224} 237}
225 238
226MWirelessNetwork::~MWirelessNetwork() 239MWirelessNetwork::~MWirelessNetwork()
227{ 240{
228 //qDebug( "MWirelessNetwork::~MWirelessNetwork()" );
229} 241}
230 242
231MNetworkInterface* MWirelessNetwork::createInterface( const char* n ) const 243MNetworkInterface* MWirelessNetwork::createInterface( const char* n ) const
@@ -259,7 +271,9 @@ void MNetwork::enumerateInterfaces()
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 }
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
@@ -37,7 +37,7 @@ public:
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
42protected: 42protected:
43 43
@@ -70,7 +70,7 @@ public:
70 double freq; 70 double freq;
71 int channel; 71 int channel;
72 72
73 virtual void updateStatistics(); 73 virtual bool updateStatistics();
74 74
75private: 75private:
76 int quality; 76 int quality;
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
@@ -21,7 +21,7 @@
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>
@@ -31,10 +31,16 @@
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"
@@ -46,6 +52,8 @@
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
49WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) 57WirelessControl::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{
@@ -94,12 +102,13 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const
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
@@ -128,7 +137,22 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const
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
145void 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
134void WirelessControl::updateDelayChange( int delay ) 158void WirelessControl::updateDelayChange( int delay )
@@ -166,7 +190,11 @@ void WirelessControl::readConfig()
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
172void WirelessControl::writeConfigEntry( const char *entry, int val ) 200void WirelessControl::writeConfigEntry( const char *entry, int val )
@@ -180,7 +208,8 @@ void WirelessControl::writeConfigEntry( const char *entry, int val )
180 208
181WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) 209WirelessApplet::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 );
@@ -193,15 +222,55 @@ void WirelessApplet::checkInterface()
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
239void 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
266void 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
205void WirelessApplet::updateDelayChange( int delay ) 274void WirelessApplet::updateDelayChange( int delay )
206{ 275{
207 if ( timer ) 276 if ( timer )
@@ -228,7 +297,13 @@ void WirelessApplet::timerEvent( QTimerEvent* )
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." );
@@ -258,8 +333,22 @@ bool WirelessApplet::mustRepaint()
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();
@@ -283,6 +372,40 @@ bool WirelessApplet::mustRepaint()
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}
@@ -334,7 +457,7 @@ void WirelessApplet::paintEvent( QPaintEvent* )
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
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
@@ -45,6 +45,7 @@ public:
45public slots: 45public slots:
46 void updateDelayChange( int ); 46 void updateDelayChange( int );
47 void displayStyleChange( int ); 47 void displayStyleChange( int );
48 void advancedConfigClicked();
48 49
49private: 50private:
50 WirelessApplet* applet; 51 WirelessApplet* applet;
@@ -52,6 +53,10 @@ private:
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
57class WirelessApplet : public QWidget 62class WirelessApplet : public QWidget
@@ -65,11 +70,14 @@ public:
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
69private: 76private:
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();
@@ -89,6 +97,16 @@ private:
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__
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,13 +1,14 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3HEADERS = wireless.h wirelessappletimpl.h networkinfo.h mgraph.h 3HEADERS = wireless.h wirelessappletimpl.h networkinfo.h mgraph.h advancedconfig.h
4SOURCES = wireless.cpp wirelessappletimpl.cpp networkinfo.cpp mgraph.cpp 4SOURCES = wireless.cpp wirelessappletimpl.cpp networkinfo.cpp mgraph.cpp advancedconfig.cpp
5INTERFACES = advancedconfigbase.ui
5TARGET = wirelessapplet 6TARGET = wirelessapplet
6DESTDIR = $(OPIEDIR)/plugins/applets 7DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 8INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../$(OPIEDIR)/include 9DEPENDPATH += ../$(OPIEDIR)/include
9LIBS += -lqpe 10LIBS += -lqpe
10VERSION = 0.0.3 11VERSION = 0.1.0
11 12
12TRANSLATIONS = ../../../i18n/de/libwirelessapplet.ts \ 13TRANSLATIONS = ../../../i18n/de/libwirelessapplet.ts \
13 ../../../i18n/en/libwirelessapplet.ts \ 14 ../../../i18n/en/libwirelessapplet.ts \