-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 211 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.h | 33 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wirelessapplet.pro | 8 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wirelessappletimpl.cpp | 66 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wirelessappletimpl.h | 43 |
5 files changed, 133 insertions, 228 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index 763aab8..cbaf5d6 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp | |||
@@ -1,539 +1,552 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de> |
3 | ** <mickey@tm.informatik.uni-frankfurt.de> | ||
4 | ** http://www.Vanille.de | ||
5 | ** | 3 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 4 | ** 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 | 5 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 7 | ** packaging of this file. |
10 | ** | 8 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** 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. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 11 | ** |
14 | **********************************************************************/ | 12 | **********************************************************************/ |
15 | 13 | ||
16 | #include "wireless.h" | 14 | #include "wireless.h" |
15 | #include "networkinfo.h" | ||
16 | #include "mgraph.h" | ||
17 | #include "advancedconfig.h" | ||
18 | #include "connect0.xpm" | ||
19 | #include "connect1.xpm" | ||
20 | #include "connect2.xpm" | ||
21 | #include "connect3.xpm" | ||
22 | #include "connect4.xpm" | ||
23 | #include "connect5.xpm" | ||
24 | #include "nowireless.xpm" | ||
17 | 25 | ||
18 | #include <qapplication.h> | 26 | /* OPIE */ |
27 | #include <opie2/otaskbarapplet.h> | ||
19 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
21 | 30 | ||
31 | /* QT */ | ||
22 | #include <qpoint.h> | 32 | #include <qpoint.h> |
23 | #include <qradiobutton.h> | 33 | #include <qradiobutton.h> |
24 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
25 | #include <qpainter.h> | 35 | #include <qpainter.h> |
26 | #include <qlabel.h> | 36 | #include <qlabel.h> |
27 | #include <qslider.h> | 37 | #include <qslider.h> |
28 | #include <qbuttongroup.h> | 38 | #include <qbuttongroup.h> |
29 | #include <qlayout.h> | 39 | #include <qlayout.h> |
30 | #include <qframe.h> | 40 | #include <qframe.h> |
31 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
32 | #include <qstring.h> | 42 | #include <qstring.h> |
33 | #include <qfile.h> | 43 | #include <qfile.h> |
34 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
35 | 45 | ||
46 | /* STD */ | ||
36 | #include <sys/types.h> | 47 | #include <sys/types.h> |
37 | #include <signal.h> | 48 | #include <signal.h> |
38 | 49 | ||
39 | #include "networkinfo.h" | ||
40 | #include "mgraph.h" | ||
41 | |||
42 | #include "advancedconfig.h" | ||
43 | |||
44 | #include "connect0.xpm" | ||
45 | #include "connect1.xpm" | ||
46 | #include "connect2.xpm" | ||
47 | #include "connect3.xpm" | ||
48 | #include "connect4.xpm" | ||
49 | #include "connect5.xpm" | ||
50 | #include "nowireless.xpm" | ||
51 | |||
52 | #define STYLE_BARS 0 | 50 | #define STYLE_BARS 0 |
53 | #define STYLE_ANTENNA 1 | 51 | #define STYLE_ANTENNA 1 |
54 | 52 | ||
55 | //#define MDEBUG | 53 | //#define MDEBUG |
56 | #undef MDEBUG | 54 | #undef MDEBUG |
57 | 55 | ||
58 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) | 56 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) |
59 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) | 57 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) |
60 | { | 58 | { |
61 | 59 | ||
62 | readConfig(); | 60 | readConfig(); |
63 | writeConfigEntry( "UpdateFrequency", updateFrequency ); | 61 | writeConfigEntry( "UpdateFrequency", updateFrequency ); |
64 | writeConfigEntry( "DisplayStyle", displayStyle ); | 62 | writeConfigEntry( "DisplayStyle", displayStyle ); |
65 | 63 | ||
66 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 64 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
67 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); | 65 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); |
68 | 66 | ||
69 | /* status label */ | 67 | /* status label */ |
70 | 68 | ||
71 | statusLabel = new QLabel( this, "statuslabel" ); | 69 | statusLabel = new QLabel( this, "statuslabel" ); |
72 | QString text( "Wireless Status:<br>" | 70 | QString text( "Wireless Status:<br>" |
73 | "*** Unknown ***<br>" | 71 | "*** Unknown ***<br>" |
74 | "Card not inserted ?<br>" | 72 | "Card not inserted ?<br>" |
75 | "Or Sharp ROM ?<br>" | 73 | "Or Sharp ROM ?<br>" |
76 | "CELL: 00:00:00:00:00:00" ); | 74 | "CELL: 00:00:00:00:00:00" ); |
77 | /* QString text( "Station: Unknown<br>" | 75 | /* QString text( "Station: Unknown<br>" |
78 | "ESSID: Unknown<br>" | 76 | "ESSID: Unknown<br>" |
79 | "MODE: Unknown<br>" | 77 | "MODE: Unknown<br>" |
80 | "FREQ: Unknown<br>" | 78 | "FREQ: Unknown<br>" |
81 | "CELL: AA:BB:CC:DD:EE:FF" ); */ | 79 | "CELL: AA:BB:CC:DD:EE:FF" ); */ |
82 | statusLabel->setText( text ); | 80 | statusLabel->setText( text ); |
83 | statusLabel->setFixedSize( statusLabel->sizeHint() ); | 81 | statusLabel->setFixedSize( statusLabel->sizeHint() ); |
84 | grid->addWidget( statusLabel, 0, 0 ); | 82 | grid->addWidget( statusLabel, 0, 0 ); |
85 | 83 | ||
86 | /* visualization group box */ | 84 | /* visualization group box */ |
87 | 85 | ||
88 | QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this ); | 86 | QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this ); |
89 | QRadioButton* r1 = new QRadioButton( "Color Bars", group ); | 87 | QRadioButton* r1 = new QRadioButton( "Color Bars", group ); |
90 | QRadioButton* r2 = new QRadioButton( "Antenna", group ); | 88 | QRadioButton* r2 = new QRadioButton( "Antenna", group ); |
91 | r1->setFocusPolicy( QWidget::NoFocus ); | 89 | r1->setFocusPolicy( QWidget::NoFocus ); |
92 | r2->setFocusPolicy( QWidget::NoFocus ); | 90 | r2->setFocusPolicy( QWidget::NoFocus ); |
93 | group->setFocusPolicy( QWidget::NoFocus ); | 91 | group->setFocusPolicy( QWidget::NoFocus ); |
94 | group->setButton( displayStyle ); | 92 | group->setButton( displayStyle ); |
95 | grid->addWidget( group, 0, 1 ); | 93 | grid->addWidget( group, 0, 1 ); |
96 | 94 | ||
97 | /* quality graph */ | 95 | /* quality graph */ |
98 | 96 | ||
99 | mgraph = new MGraph( this ); | 97 | mgraph = new MGraph( this ); |
100 | mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 98 | mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
101 | mgraph->setMin( 0 ); | 99 | mgraph->setMin( 0 ); |
102 | mgraph->setMax( 92 ); | 100 | mgraph->setMax( 92 ); |
103 | grid->addWidget( mgraph, 1, 0 ); | 101 | grid->addWidget( mgraph, 1, 0 ); |
104 | mgraph->setFocusPolicy( QWidget::NoFocus ); | 102 | mgraph->setFocusPolicy( QWidget::NoFocus ); |
105 | 103 | ||
106 | /* advanced configuration Button */ | 104 | /* advanced configuration Button */ |
107 | 105 | ||
108 | QPushButton* advanced = new QPushButton( "Advanced...", this ); | 106 | QPushButton* advanced = new QPushButton( "Advanced...", this ); |
109 | advanced->setFocusPolicy( QWidget::NoFocus ); | 107 | advanced->setFocusPolicy( QWidget::NoFocus ); |
110 | grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); | 108 | grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); |
111 | connect( advanced, SIGNAL( clicked() ), | 109 | connect( advanced, SIGNAL( clicked() ), |
112 | this, SLOT( advancedConfigClicked() ) ); | 110 | this, SLOT( advancedConfigClicked() ) ); |
113 | 111 | ||
114 | /* update Frequency Label */ | 112 | /* update Frequency Label */ |
115 | 113 | ||
116 | updateLabel = new QLabel( this ); | 114 | updateLabel = new QLabel( this ); |
117 | text.sprintf( "Update every %d s", updateFrequency ); | 115 | text.sprintf( "Update every %d s", updateFrequency ); |
118 | updateLabel->setText( text ); | 116 | updateLabel->setText( text ); |
119 | grid->addWidget( updateLabel, 2, 1 ); | 117 | grid->addWidget( updateLabel, 2, 1 ); |
120 | 118 | ||
121 | /* update Frequency Slider */ | 119 | /* update Frequency Slider */ |
122 | 120 | ||
123 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); | 121 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); |
124 | updateSlider->setRange( 0, 9 ); | 122 | updateSlider->setRange( 0, 9 ); |
125 | updateSlider->setValue( updateFrequency ); | 123 | updateSlider->setValue( updateFrequency ); |
126 | updateSlider->setTickmarks( QSlider::Both ); | 124 | updateSlider->setTickmarks( QSlider::Both ); |
127 | updateSlider->setTickInterval( 1 ); | 125 | updateSlider->setTickInterval( 1 ); |
128 | updateSlider->setSteps( 1, 1 ); | 126 | updateSlider->setSteps( 1, 1 ); |
129 | updateSlider->setFocusPolicy( QWidget::NoFocus ); | 127 | updateSlider->setFocusPolicy( QWidget::NoFocus ); |
130 | grid->addWidget( updateSlider, 1, 1 ); | 128 | grid->addWidget( updateSlider, 1, 1 ); |
131 | connect( updateSlider, SIGNAL( valueChanged( int ) ), | 129 | connect( updateSlider, SIGNAL( valueChanged( int ) ), |
132 | this, SLOT( updateDelayChange( int ) ) ); | 130 | this, SLOT( updateDelayChange( int ) ) ); |
133 | 131 | ||
134 | setFixedSize( sizeHint() ); | 132 | setFixedSize( sizeHint() ); |
135 | setFocusPolicy( QWidget::NoFocus ); | 133 | setFocusPolicy( QWidget::NoFocus ); |
136 | 134 | ||
137 | applet->displayStyleChange( displayStyle ); | 135 | applet->displayStyleChange( displayStyle ); |
138 | applet->updateDelayChange( updateFrequency ); | 136 | applet->updateDelayChange( updateFrequency ); |
139 | 137 | ||
140 | connect( group, SIGNAL( clicked( int ) ), | 138 | connect( group, SIGNAL( clicked( int ) ), |
141 | this, SLOT( displayStyleChange( int ) ) ); | 139 | this, SLOT( displayStyleChange( int ) ) ); |
142 | 140 | ||
143 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | 141 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); |
144 | } | 142 | } |
145 | 143 | ||
146 | void WirelessControl::advancedConfigClicked() | 144 | void WirelessControl::advancedConfigClicked() |
147 | { | 145 | { |
148 | AdvancedConfig* a = new AdvancedConfig( this, "dialog", TRUE ); | 146 | AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE ); |
149 | int result = a->exec(); | 147 | int result = a->exec(); |
150 | a->hide(); | 148 | a->hide(); |
151 | delete a; | 149 | delete a; |
152 | if ( result == QDialog::Accepted ) | 150 | if ( result == QDialog::Accepted ) |
153 | { | 151 | { |
154 | readConfig(); | 152 | readConfig(); |
155 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | 153 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); |
156 | } | 154 | } |
157 | } | 155 | } |
158 | 156 | ||
159 | void WirelessControl::updateDelayChange( int delay ) | 157 | void WirelessControl::updateDelayChange( int delay ) |
160 | { | 158 | { |
161 | QString text; | 159 | QString text; |
162 | text.sprintf( "Update every %d s", delay ); | 160 | text.sprintf( "Update every %d s", delay ); |
163 | updateLabel->setText( text ); | 161 | updateLabel->setText( text ); |
164 | applet->updateDelayChange( delay ); | 162 | applet->updateDelayChange( delay ); |
165 | writeConfigEntry( "UpdateFrequency", delay ); | 163 | writeConfigEntry( "UpdateFrequency", delay ); |
166 | } | 164 | } |
167 | 165 | ||
168 | void WirelessControl::displayStyleChange( int style ) | 166 | void WirelessControl::displayStyleChange( int style ) |
169 | { | 167 | { |
170 | applet->displayStyleChange( style ); | 168 | applet->displayStyleChange( style ); |
171 | writeConfigEntry( "DisplayStyle", style ); | 169 | writeConfigEntry( "DisplayStyle", style ); |
172 | } | 170 | } |
173 | 171 | ||
174 | void WirelessControl::show ( bool ) | 172 | void WirelessControl::show ( bool ) |
175 | { | 173 | { |
176 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); | 174 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); |
177 | 175 | ||
178 | int w = sizeHint().width(); | 176 | int w = sizeHint().width(); |
179 | int x = curPos.x() - ( w / 2 ); | 177 | int x = curPos.x() - ( w / 2 ); |
180 | 178 | ||
181 | if ( ( x + w ) > QPEApplication::desktop()->width() ) | 179 | if ( ( x + w ) > QPEApplication::desktop() ->width() ) |
182 | x = QPEApplication::desktop ( )-> width ( ) - w; | 180 | x = QPEApplication::desktop ( ) -> width ( ) - w; |
183 | 181 | ||
184 | move( x, curPos.y () - sizeHint().height () ); | 182 | move( x, curPos.y () - sizeHint().height () ); |
185 | QFrame::show(); | 183 | QFrame::show(); |
186 | } | 184 | } |
187 | 185 | ||
188 | void WirelessControl::readConfig() | 186 | void WirelessControl::readConfig() |
189 | { | 187 | { |
190 | Config cfg( "qpe" ); | 188 | Config cfg( "qpe" ); |
191 | cfg.setGroup( "Wireless" ); | 189 | cfg.setGroup( "Wireless" ); |
192 | 190 | ||
193 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); | 191 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); |
194 | displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); | 192 | displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); |
195 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); | 193 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); |
196 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); | 194 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); |
197 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); | 195 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); |
198 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); | 196 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); |
199 | } | 197 | } |
200 | 198 | ||
201 | void WirelessControl::writeConfigEntry( const char *entry, int val ) | 199 | void WirelessControl::writeConfigEntry( const char *entry, int val ) |
202 | { | 200 | { |
203 | Config cfg( "qpe" ); | 201 | Config cfg( "qpe" ); |
204 | cfg.setGroup( "Wireless" ); | 202 | cfg.setGroup( "Wireless" ); |
205 | cfg.writeEntry( entry, val ); | 203 | cfg.writeEntry( entry, val ); |
206 | } | 204 | } |
207 | 205 | ||
208 | //=========================================================================== | 206 | //=========================================================================== |
209 | 207 | ||
210 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) | 208 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), | 209 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), |
212 | timer( 0 ), interface( 0 ), | 210 | timer( 0 ), interface( 0 ), |
213 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) | 211 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) |
214 | { | 212 | { |
215 | setFixedHeight( 18 ); | 213 | setFixedHeight( 18 ); |
216 | setFixedWidth( 14 ); | 214 | setFixedWidth( 14 ); |
217 | network = new MWirelessNetwork(); | 215 | network = new MWirelessNetwork(); |
218 | status = new WirelessControl( this, this, "wireless status" ); | 216 | status = new WirelessControl( this, this, "wireless status" ); |
219 | } | 217 | } |
220 | 218 | ||
221 | void WirelessApplet::checkInterface() | 219 | void WirelessApplet::checkInterface() |
222 | { | 220 | { |
223 | interface = network->getFirstInterface(); | 221 | interface = network->getFirstInterface(); |
224 | if ( interface ) | 222 | if ( interface ) |
225 | { | 223 | { |
226 | #ifdef MDEBUG | 224 | #ifdef MDEBUG |
227 | qDebug( "WIFIAPPLET: using interface '%s'", (const char*) interface->getName() ); | 225 | qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->getName() ); |
228 | #endif | 226 | #endif |
227 | |||
229 | } | 228 | } |
230 | else | 229 | else |
231 | { | 230 | { |
232 | #ifdef MDEBUG | 231 | #ifdef MDEBUG |
233 | qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); | 232 | qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); |
234 | #endif | 233 | #endif |
235 | hide(); | 234 | hide(); |
236 | } | 235 | } |
237 | } | 236 | } |
238 | 237 | ||
239 | void WirelessApplet::renewDHCP() | 238 | void WirelessApplet::renewDHCP() |
240 | { | 239 | { |
241 | #ifdef MDEBUG | 240 | #ifdef MDEBUG |
242 | qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); | 241 | qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); |
243 | #endif | 242 | #endif |
244 | 243 | ||
245 | QString pidfile; | 244 | QString pidfile; |
246 | if ( !interface ) | 245 | if ( !interface ) |
247 | return; | 246 | return ; |
248 | QString ifacename( interface->getName() ); | 247 | QString ifacename( interface->getName() ); |
249 | 248 | ||
250 | // At first we are trying dhcpcd | 249 | // At first we are trying dhcpcd |
251 | 250 | ||
252 | pidfile.sprintf( "/var/run/dhcpcd-%s.pid", (const char* ) ifacename ); | 251 | pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); |
253 | #ifdef MDEBUG | 252 | #ifdef MDEBUG |
254 | qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", (const char*) pidfile ); | 253 | qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", ( const char* ) pidfile ); |
255 | #endif | 254 | #endif |
256 | int pid; | 255 | int pid; |
257 | QFile pfile( pidfile ); | 256 | QFile pfile( pidfile ); |
258 | bool hasFile = pfile.open( IO_ReadOnly ); | 257 | bool hasFile = pfile.open( IO_ReadOnly ); |
259 | QTextStream s( &pfile ); | 258 | QTextStream s( &pfile ); |
260 | if ( hasFile ) | 259 | if ( hasFile ) |
261 | { | 260 | { |
262 | s >> pid; | 261 | s >> pid; |
263 | #ifdef MDEBUG | 262 | #ifdef MDEBUG |
264 | qDebug( "WIFIAPPLET: sent SIGALARM to pid %d", pid ); | 263 | qDebug( "WIFIAPPLET: sent SIGALARM to pid %d", pid ); |
265 | #endif | 264 | #endif |
266 | kill( pid, SIGALRM ); | 265 | kill( pid, SIGALRM ); |
267 | return; | 266 | return ; |
268 | } | 267 | } |
269 | 268 | ||
270 | // No dhcpcd, so we are trying udhcpc | 269 | // No dhcpcd, so we are trying udhcpc |
271 | #ifdef MDEBUG | 270 | #ifdef MDEBUG |
272 | qDebug( "WIFIAPPLET: dhcpcd not available." ); | 271 | qDebug( "WIFIAPPLET: dhcpcd not available." ); |
273 | #endif | 272 | #endif |
274 | pidfile.sprintf( "/var/run/udhcpc.%s.pid", (const char*) ifacename ); | 273 | pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename ); |
275 | #ifdef MDEBUG | 274 | #ifdef MDEBUG |
276 | qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", (const char*) pidfile ); | 275 | qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", ( const char* ) pidfile ); |
277 | #endif | 276 | #endif |
278 | QFile pfile2( pidfile ); | 277 | QFile pfile2( pidfile ); |
279 | hasFile = pfile2.open( IO_ReadOnly ); | 278 | hasFile = pfile2.open( IO_ReadOnly ); |
280 | QTextStream s2( &pfile2 ); | 279 | QTextStream s2( &pfile2 ); |
281 | if ( hasFile ) | 280 | if ( hasFile ) |
282 | { | 281 | { |
283 | s2 >> pid; | 282 | s2 >> pid; |
284 | #ifdef MDEBUG | 283 | #ifdef MDEBUG |
285 | qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid ); | 284 | qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid ); |
286 | #endif | 285 | #endif |
287 | kill( pid, SIGUSR1 ); | 286 | kill( pid, SIGUSR1 ); |
288 | return; | 287 | return ; |
289 | } | 288 | } |
290 | } | 289 | } |
291 | 290 | ||
292 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) | 291 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) |
293 | { | 292 | { |
294 | rocESSID = ESSID; | 293 | rocESSID = ESSID; |
295 | rocFREQ = FREQ; | 294 | rocFREQ = FREQ; |
296 | rocAP = AP; | 295 | rocAP = AP; |
297 | rocMODE = MODE; | 296 | rocMODE = MODE; |
298 | } | 297 | } |
299 | 298 | ||
300 | void WirelessApplet::updateDelayChange( int delay ) | 299 | void WirelessApplet::updateDelayChange( int delay ) |
301 | { | 300 | { |
302 | if ( timer ) | 301 | if ( timer ) |
303 | killTimer( timer ); | 302 | killTimer( timer ); |
304 | delay *= 1000; | 303 | delay *= 1000; |
305 | if ( delay == 0 ) | 304 | if ( delay == 0 ) |
306 | delay = 50; | 305 | delay = 50; |
307 | timer = startTimer( delay ); | 306 | timer = startTimer( delay ); |
308 | } | 307 | } |
309 | 308 | ||
310 | void WirelessApplet::displayStyleChange( int style ) | 309 | void WirelessApplet::displayStyleChange( int style ) |
311 | { | 310 | { |
312 | visualStyle = style; | 311 | visualStyle = style; |
313 | repaint(); | 312 | repaint(); |
314 | } | 313 | } |
315 | 314 | ||
316 | WirelessApplet::~WirelessApplet() | 315 | WirelessApplet::~WirelessApplet() |
317 | { | 316 | {} |
318 | } | ||
319 | 317 | ||
320 | void WirelessApplet::timerEvent( QTimerEvent* ) | 318 | void WirelessApplet::timerEvent( QTimerEvent* ) |
321 | { | 319 | { |
322 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 320 | MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; |
323 | 321 | ||
324 | if ( iface ) | 322 | if ( iface ) |
325 | { | 323 | { |
326 | bool statResult = iface->updateStatistics(); | 324 | bool statResult = iface->updateStatistics(); |
327 | if ( !statResult ) | 325 | if ( !statResult ) |
328 | { | 326 | { |
329 | interface = 0; | 327 | interface = 0; |
330 | mustRepaint(); | 328 | mustRepaint(); |
331 | return; | 329 | return ; |
332 | } else | ||
333 | if ( mustRepaint() ) | ||
334 | { | ||
335 | //qDebug( "WIFIAPPLET: A value has changed -> repainting." ); | ||
336 | repaint(); | ||
337 | } | 330 | } |
338 | 331 | else | |
332 | if ( mustRepaint() ) | ||
333 | { | ||
334 | //qDebug( "WIFIAPPLET: A value has changed -> repainting." ); | ||
335 | repaint(); | ||
336 | } | ||
337 | |||
339 | if ( status->isVisible() ) | 338 | if ( status->isVisible() ) |
340 | updatePopupWindow(); | 339 | updatePopupWindow(); |
341 | } else checkInterface(); | 340 | } |
341 | else checkInterface(); | ||
342 | } | 342 | } |
343 | 343 | ||
344 | void WirelessApplet::mousePressEvent( QMouseEvent *) | 344 | void WirelessApplet::mousePressEvent( QMouseEvent * ) |
345 | { | 345 | { |
346 | if ( status->isVisible() ) | 346 | if ( status->isVisible() ) |
347 | status->hide(); | 347 | status->hide(); |
348 | else | 348 | else |
349 | status->show( true ); | 349 | status->show( true ); |
350 | } | 350 | } |
351 | 351 | ||
352 | bool WirelessApplet::mustRepaint() | 352 | bool WirelessApplet::mustRepaint() |
353 | { | 353 | { |
354 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 354 | MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; |
355 | 355 | ||
356 | // check if there are enough changes to justify a (flickering) repaint | 356 | // check if there are enough changes to justify a (flickering) repaint |
357 | 357 | ||
358 | // has the interface changed? | 358 | // has the interface changed? |
359 | 359 | ||
360 | if ( iface != oldiface ) | 360 | if ( iface != oldiface ) |
361 | { | 361 | { |
362 | oldiface = iface; | 362 | oldiface = iface; |
363 | if ( iface ) | 363 | if ( iface ) |
364 | { | 364 | { |
365 | #ifdef MDEBUG | 365 | #ifdef MDEBUG |
366 | qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" ); | 366 | qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" ); |
367 | #endif | 367 | #endif |
368 | show(); | 368 | show(); |
369 | } | 369 | } |
370 | else | 370 | else |
371 | { | 371 | { |
372 | #ifdef MDEBUG | 372 | #ifdef MDEBUG |
373 | qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" ); | 373 | qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" ); |
374 | #endif | 374 | #endif |
375 | hide(); | 375 | hide(); |
376 | return true; | 376 | return true; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | const char** pixmap = getQualityPixmap(); | 380 | const char** pixmap = getQualityPixmap(); |
381 | 381 | ||
382 | if ( pixmap && ( pixmap != oldpixmap ) ) | 382 | if ( pixmap && ( pixmap != oldpixmap ) ) |
383 | { | 383 | { |
384 | oldpixmap = pixmap; | 384 | oldpixmap = pixmap; |
385 | return true; | 385 | return true; |
386 | } | 386 | } |
387 | 387 | ||
388 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; | 388 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; |
389 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; | 389 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; |
390 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; | 390 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; |
391 | 391 | ||
392 | if ( ( noiseH != oldnoiseH ) | 392 | if ( ( noiseH != oldnoiseH ) |
393 | || ( signalH != oldsignalH ) | 393 | || ( signalH != oldsignalH ) |
394 | || ( qualityH != oldqualityH ) ) | 394 | || ( qualityH != oldqualityH ) ) |
395 | { | 395 | { |
396 | oldnoiseH = noiseH; | 396 | oldnoiseH = noiseH; |
397 | oldsignalH = signalH; | 397 | oldsignalH = signalH; |
398 | oldqualityH = qualityH; | 398 | oldqualityH = qualityH; |
399 | return true; | 399 | return true; |
400 | } | 400 | } |
401 | 401 | ||
402 | if ( rocESSID && ( oldESSID != iface->essid ) ) | 402 | if ( rocESSID && ( oldESSID != iface->essid ) ) |
403 | { | 403 | { |
404 | #ifdef MDEBUG | 404 | #ifdef MDEBUG |
405 | qDebug( "WIFIAPPLET: ESSID has changed."); | 405 | qDebug( "WIFIAPPLET: ESSID has changed." ); |
406 | #endif | 406 | #endif |
407 | renewDHCP(); | 407 | renewDHCP(); |
408 | } | 408 | } |
409 | else if ( rocFREQ && ( oldFREQ != iface->freq ) ) | 409 | else if ( rocFREQ && ( oldFREQ != iface->freq ) ) |
410 | { | 410 | { |
411 | #ifdef MDEBUG | 411 | #ifdef MDEBUG |
412 | qDebug( "WIFIAPPLET: FREQ has changed."); | 412 | qDebug( "WIFIAPPLET: FREQ has changed." ); |
413 | #endif | 413 | #endif |
414 | renewDHCP(); | 414 | renewDHCP(); |
415 | } | 415 | } |
416 | else if ( rocAP && ( oldAP != iface->APAddr ) ) | 416 | else if ( rocAP && ( oldAP != iface->APAddr ) ) |
417 | { | 417 | { |
418 | #ifdef MDEBUG | 418 | #ifdef MDEBUG |
419 | qDebug( "WIFIAPPLET: AP has changed."); | 419 | qDebug( "WIFIAPPLET: AP has changed." ); |
420 | #endif | 420 | #endif |
421 | renewDHCP(); | 421 | renewDHCP(); |
422 | } | 422 | } |
423 | else if ( rocMODE && ( oldMODE != iface->mode ) ) | 423 | else if ( rocMODE && ( oldMODE != iface->mode ) ) |
424 | { | 424 | { |
425 | #ifdef MDEBUG | 425 | #ifdef MDEBUG |
426 | qDebug( "WIFIAPPLET: MODE has changed."); | 426 | qDebug( "WIFIAPPLET: MODE has changed." ); |
427 | #endif | 427 | #endif |
428 | renewDHCP(); | 428 | renewDHCP(); |
429 | } | 429 | } |
430 | 430 | ||
431 | oldESSID = iface->essid; | 431 | oldESSID = iface->essid; |
432 | oldMODE = iface->mode; | 432 | oldMODE = iface->mode; |
433 | oldFREQ = iface->freq; | 433 | oldFREQ = iface->freq; |
434 | oldAP = iface->APAddr; | 434 | oldAP = iface->APAddr; |
435 | 435 | ||
436 | return false; | 436 | return false; |
437 | } | 437 | } |
438 | 438 | ||
439 | void WirelessApplet::updatePopupWindow() | 439 | void WirelessApplet::updatePopupWindow() |
440 | { | 440 | { |
441 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 441 | MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; |
442 | int qualityH = iface->qualityPercent(); | 442 | int qualityH = iface->qualityPercent(); |
443 | 443 | ||
444 | if ( status->mgraph ) | 444 | if ( status->mgraph ) |
445 | status->mgraph->addValue( qualityH, false ); | 445 | status->mgraph->addValue( qualityH, false ); |
446 | 446 | ||
447 | QString freqString; | 447 | QString freqString; |
448 | QString cell = ( iface->mode == "Managed" ) ? "AP: " : "Cell: "; | 448 | QString cell = ( iface->mode == "Managed" ) ? "AP: " : "Cell: "; |
449 | freqString.sprintf( "%.3f GHz", iface->freq ); | 449 | freqString.sprintf( "%.3f GHz", iface->freq ); |
450 | status->statusLabel->setText( "Station: " + iface->nick + "<br>" + | 450 | status->statusLabel->setText( "Station: " + iface->nick + "<br>" + |
451 | "ESSID: " + iface->essid + "<br>" + | 451 | "ESSID: " + iface->essid + "<br>" + |
452 | "MODE: " + iface->mode + "<br>" + | 452 | "MODE: " + iface->mode + "<br>" + |
453 | "FREQ: " + freqString + "<br>" + | 453 | "FREQ: " + freqString + "<br>" + |
454 | cell + " " + iface->APAddr ); | 454 | cell + " " + iface->APAddr ); |
455 | } | 455 | } |
456 | 456 | ||
457 | const char** WirelessApplet::getQualityPixmap() | 457 | const char** WirelessApplet::getQualityPixmap() |
458 | { | 458 | { |
459 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 459 | MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; |
460 | 460 | ||
461 | if ( !iface ) return ( const char** ) nowireless_xpm; | 461 | if ( !iface ) return ( const char** ) nowireless_xpm; |
462 | int qualityH = iface->qualityPercent(); | 462 | int qualityH = iface->qualityPercent(); |
463 | if ( qualityH < 0 ) return ( const char** ) nowireless_xpm; | 463 | if ( qualityH < 0 ) return ( const char** ) nowireless_xpm; |
464 | 464 | ||
465 | if ( visualStyle == STYLE_ANTENNA ) | 465 | if ( visualStyle == STYLE_ANTENNA ) |
466 | { | 466 | { |
467 | if ( qualityH < 1 ) return ( const char** ) connect0_xpm; | 467 | if ( qualityH < 1 ) return ( const char** ) connect0_xpm; |
468 | if ( qualityH < 17 ) return ( const char** ) connect1_xpm; | 468 | if ( qualityH < 17 ) return ( const char** ) connect1_xpm; |
469 | if ( qualityH < 34 ) return ( const char** ) connect2_xpm; | 469 | if ( qualityH < 34 ) return ( const char** ) connect2_xpm; |
470 | if ( qualityH < 50 ) return ( const char** ) connect3_xpm; | 470 | if ( qualityH < 50 ) return ( const char** ) connect3_xpm; |
471 | if ( qualityH < 65 ) return ( const char** ) connect4_xpm; | 471 | if ( qualityH < 65 ) return ( const char** ) connect4_xpm; |
472 | return ( const char** ) connect5_xpm; | 472 | return ( const char** ) connect5_xpm; |
473 | } | 473 | } |
474 | 474 | ||
475 | return 0; // please draw your bars | 475 | return 0; // please draw your bars |
476 | } | 476 | } |
477 | 477 | ||
478 | void WirelessApplet::paintEvent( QPaintEvent* ) | 478 | void WirelessApplet::paintEvent( QPaintEvent* ) |
479 | { | 479 | { |
480 | MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; | 480 | MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; |
481 | 481 | ||
482 | QPainter p(this); | 482 | QPainter p( this ); |
483 | QColor color; | 483 | QColor color; |
484 | 484 | ||
485 | const char** pixmap = getQualityPixmap(); | 485 | const char** pixmap = getQualityPixmap(); |
486 | 486 | ||
487 | if ( pixmap ) | 487 | if ( pixmap ) |
488 | p.drawPixmap( 0, 1, pixmap ); | 488 | p.drawPixmap( 0, 1, pixmap ); |
489 | else | 489 | else |
490 | { | 490 | { |
491 | 491 | ||
492 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; | 492 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; |
493 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; | 493 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; |
494 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; | 494 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; |
495 | 495 | ||
496 | double intensity; | 496 | double intensity; |
497 | int pixelHeight; | 497 | int pixelHeight; |
498 | int pixelWidth = 2; | 498 | int pixelWidth = 2; |
499 | int Hue; | 499 | int Hue; |
500 | int barSpace = 3; | 500 | int barSpace = 3; |
501 | int leftoffset = 0; | 501 | int leftoffset = 0; |
502 | int bottomoffset = 2; | 502 | int bottomoffset = 2; |
503 | 503 | ||
504 | // draw noise indicator | 504 | // draw noise indicator |
505 | pixelHeight = noiseH; | 505 | pixelHeight = noiseH; |
506 | Hue = 50; | 506 | Hue = 50; |
507 | for ( int i = 0; i < pixelHeight; ++i ) | 507 | for ( int i = 0; i < pixelHeight; ++i ) |
508 | { | 508 | { |
509 | intensity = 50 + ( (double) i / (double) pixelHeight ) * 205; | 509 | intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; |
510 | color.setHsv( Hue, 255, intensity ); | 510 | color.setHsv( Hue, 255, intensity ); |
511 | p.setPen ( color ); | 511 | p.setPen ( color ); |
512 | p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i ); | 512 | p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); |
513 | } | 513 | } |
514 | 514 | ||
515 | // draw signal indicator | 515 | // draw signal indicator |
516 | pixelHeight = signalH; | 516 | pixelHeight = signalH; |
517 | Hue = 100; | 517 | Hue = 100; |
518 | leftoffset += pixelWidth + barSpace; | 518 | leftoffset += pixelWidth + barSpace; |
519 | for ( int i = 0; i < pixelHeight; ++i ) | 519 | for ( int i = 0; i < pixelHeight; ++i ) |
520 | { | 520 | { |
521 | intensity = 50 + ( (double) i / (double) pixelHeight ) * 205; | 521 | intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; |
522 | color.setHsv( Hue, 255, intensity ); | 522 | color.setHsv( Hue, 255, intensity ); |
523 | p.setPen ( color ); | 523 | p.setPen ( color ); |
524 | p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i ); | 524 | p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); |
525 | } | 525 | } |
526 | 526 | ||
527 | // draw quality indicator | 527 | // draw quality indicator |
528 | pixelHeight = qualityH; | 528 | pixelHeight = qualityH; |
529 | Hue = 250; | 529 | Hue = 250; |
530 | leftoffset += pixelWidth + barSpace; | 530 | leftoffset += pixelWidth + barSpace; |
531 | for ( int i = 0; i < pixelHeight; ++i ) | 531 | for ( int i = 0; i < pixelHeight; ++i ) |
532 | { | 532 | { |
533 | intensity = 50 + ( (double) i / (double) pixelHeight ) * 205; | 533 | intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; |
534 | color.setHsv( Hue, 255, intensity ); | 534 | color.setHsv( Hue, 255, intensity ); |
535 | p.setPen ( color ); | 535 | p.setPen ( color ); |
536 | p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i ); | 536 | p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); |
537 | } | 537 | } |
538 | } | 538 | } |
539 | } | 539 | } |
540 | |||
541 | |||
542 | int WirelessApplet::position() | ||
543 | { | ||
544 | return 6; | ||
545 | } | ||
546 | |||
547 | |||
548 | Q_EXPORT_INTERFACE() | ||
549 | { | ||
550 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<WirelessApplet> ); | ||
551 | } | ||
552 | |||
diff --git a/noncore/applets/wirelessapplet/wireless.h b/noncore/applets/wirelessapplet/wireless.h index 51a3fab..644be26 100644 --- a/noncore/applets/wirelessapplet/wireless.h +++ b/noncore/applets/wirelessapplet/wireless.h | |||
@@ -1,113 +1,114 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #ifndef __WIRELESS_APPLET_H__ | 15 | #ifndef __WIRELESS_APPLET_H__ |
16 | #define __WIRELESS_APPLET_H__ | 16 | #define __WIRELESS_APPLET_H__ |
17 | 17 | ||
18 | #include <qwidget.h> | 18 | #include <qwidget.h> |
19 | #include <qframe.h> | 19 | #include <qframe.h> |
20 | #include <qpixmap.h> | 20 | #include <qpixmap.h> |
21 | 21 | ||
22 | class MNetwork; | 22 | class MNetwork; |
23 | class MWirelessNetwork; | 23 | class MWirelessNetwork; |
24 | class MNetworkInterface; | 24 | class MNetworkInterface; |
25 | class MWirelessNetworkInterface; | 25 | class MWirelessNetworkInterface; |
26 | class Y; | 26 | class Y; |
27 | class QLabel; | 27 | class QLabel; |
28 | class WirelessApplet; | 28 | class WirelessApplet; |
29 | class MGraph; | 29 | class MGraph; |
30 | 30 | ||
31 | class WirelessControl : public QFrame | 31 | class WirelessControl : public QFrame |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | public: | 34 | public: |
35 | WirelessControl( WirelessApplet* icon, QWidget *parent=0, const char *name=0 ); | 35 | WirelessControl( WirelessApplet* icon, QWidget *parent=0, const char *name=0 ); |
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 | void advancedConfigClicked(); |
49 | 49 | ||
50 | private: | 50 | private: |
51 | WirelessApplet* applet; | 51 | WirelessApplet* applet; |
52 | 52 | ||
53 | int displayStyle; | 53 | int displayStyle; |
54 | int updateFrequency; | 54 | int updateFrequency; |
55 | 55 | ||
56 | bool rocESSID; | 56 | bool rocESSID; |
57 | bool rocFREQ; | 57 | bool rocFREQ; |
58 | bool rocAP; | 58 | bool rocAP; |
59 | bool rocMODE; | 59 | bool rocMODE; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | class WirelessApplet : public QWidget | 62 | class WirelessApplet : public QWidget |
63 | { | 63 | { |
64 | Q_OBJECT | 64 | Q_OBJECT |
65 | public: | 65 | public: |
66 | WirelessApplet( QWidget *parent = 0, const char *name=0 ); | 66 | WirelessApplet( QWidget *parent = 0, const char *name=0 ); |
67 | ~WirelessApplet(); | 67 | ~WirelessApplet(); |
68 | static int position(); | ||
68 | WirelessControl* status; | 69 | WirelessControl* status; |
69 | 70 | ||
70 | virtual void timerEvent( QTimerEvent* ); | 71 | virtual void timerEvent( QTimerEvent* ); |
71 | void updateDelayChange( int delay ); | 72 | void updateDelayChange( int delay ); |
72 | void displayStyleChange( int style ); | 73 | void displayStyleChange( int style ); |
73 | 74 | ||
74 | void updateDHCPConfig( bool, bool, bool, bool ); | 75 | void updateDHCPConfig( bool, bool, bool, bool ); |
75 | 76 | ||
76 | private: | 77 | private: |
77 | void mousePressEvent( QMouseEvent * ); | 78 | void mousePressEvent( QMouseEvent * ); |
78 | void paintEvent( QPaintEvent* ); | 79 | void paintEvent( QPaintEvent* ); |
79 | void checkInterface(); | 80 | void checkInterface(); |
80 | void renewDHCP(); | 81 | void renewDHCP(); |
81 | 82 | ||
82 | bool mustRepaint(); | 83 | bool mustRepaint(); |
83 | void updatePopupWindow(); | 84 | void updatePopupWindow(); |
84 | const char** getQualityPixmap(); | 85 | const char** getQualityPixmap(); |
85 | 86 | ||
86 | private: | 87 | private: |
87 | QPixmap snapshotPixmap; | 88 | QPixmap snapshotPixmap; |
88 | int visualStyle; | 89 | int visualStyle; |
89 | int timer; | 90 | int timer; |
90 | 91 | ||
91 | MWirelessNetwork* network; | 92 | MWirelessNetwork* network; |
92 | MNetworkInterface* interface; | 93 | MNetworkInterface* interface; |
93 | 94 | ||
94 | private: | 95 | private: |
95 | const char** oldpixmap; | 96 | const char** oldpixmap; |
96 | MWirelessNetworkInterface* oldiface; | 97 | MWirelessNetworkInterface* oldiface; |
97 | int oldqualityH; | 98 | int oldqualityH; |
98 | int oldsignalH; | 99 | int oldsignalH; |
99 | int oldnoiseH; | 100 | int oldnoiseH; |
100 | 101 | ||
101 | QString oldESSID; | 102 | QString oldESSID; |
102 | QString oldAP; | 103 | QString oldAP; |
103 | QString oldMODE; | 104 | QString oldMODE; |
104 | double oldFREQ; | 105 | double oldFREQ; |
105 | 106 | ||
106 | bool rocESSID; | 107 | bool rocESSID; |
107 | bool rocFREQ; | 108 | bool rocFREQ; |
108 | bool rocAP; | 109 | bool rocAP; |
109 | bool rocMODE; | 110 | bool rocMODE; |
110 | }; | 111 | }; |
111 | 112 | ||
112 | #endif // __WIRELESS_APPLET_H__ | 113 | #endif // __WIRELESS_APPLET_H__ |
113 | 114 | ||
diff --git a/noncore/applets/wirelessapplet/wirelessapplet.pro b/noncore/applets/wirelessapplet/wirelessapplet.pro index 411a039..38cb475 100644 --- a/noncore/applets/wirelessapplet/wirelessapplet.pro +++ b/noncore/applets/wirelessapplet/wirelessapplet.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt plugin warn_on release | 2 | CONFIG += qt plugin warn_on release |
3 | HEADERS = wireless.h wirelessappletimpl.h networkinfo.h mgraph.h advancedconfig.h | 3 | HEADERS = wireless.h networkinfo.h mgraph.h advancedconfig.h |
4 | SOURCES = wireless.cpp wirelessappletimpl.cpp networkinfo.cpp mgraph.cpp advancedconfig.cpp | 4 | SOURCES = wireless.cpp networkinfo.cpp mgraph.cpp advancedconfig.cpp |
5 | INTERFACES = advancedconfigbase.ui | 5 | INTERFACES = advancedconfigbase.ui |
6 | TARGET = wirelessapplet | 6 | TARGET = wirelessapplet |
7 | DESTDIR = $(OPIEDIR)/plugins/applets | 7 | DESTDIR = $(OPIEDIR)/plugins/applets |
8 | INCLUDEPATH += $(OPIEDIR)/include | 8 | INCLUDEPATH += $(OPIEDIR)/include |
9 | DEPENDPATH += ../$(OPIEDIR)/include | 9 | DEPENDPATH += $(OPIEDIR)/include |
10 | LIBS += -lqpe | 10 | LIBS += -lqpe |
11 | VERSION = 0.1.0 | 11 | VERSION = 0.1.1 |
12 | 12 | ||
13 | include ( $(OPIEDIR)/include.pro ) | 13 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/applets/wirelessapplet/wirelessappletimpl.cpp b/noncore/applets/wirelessapplet/wirelessappletimpl.cpp deleted file mode 100644 index de70714..0000000 --- a/noncore/applets/wirelessapplet/wirelessappletimpl.cpp +++ b/dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
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 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include "wireless.h" | ||
21 | #include "wirelessappletimpl.h" | ||
22 | |||
23 | |||
24 | WirelessAppletImpl::WirelessAppletImpl() | ||
25 | : wireless(0) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | WirelessAppletImpl::~WirelessAppletImpl() | ||
30 | { | ||
31 | delete wireless; | ||
32 | } | ||
33 | |||
34 | QWidget *WirelessAppletImpl::applet( QWidget *parent ) | ||
35 | { | ||
36 | if ( !wireless ) | ||
37 | wireless = new WirelessApplet( parent ); | ||
38 | return wireless; | ||
39 | } | ||
40 | |||
41 | int WirelessAppletImpl::position() const | ||
42 | { | ||
43 | return 6; | ||
44 | } | ||
45 | |||
46 | QRESULT WirelessAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
47 | { | ||
48 | *iface = 0; | ||
49 | if ( uuid == IID_QUnknown ) | ||
50 | *iface = this; | ||
51 | else if ( uuid == IID_TaskbarApplet ) | ||
52 | *iface = this; | ||
53 | else | ||
54 | return QS_FALSE; | ||
55 | |||
56 | if ( *iface ) | ||
57 | (*iface)->addRef(); | ||
58 | return QS_OK; | ||
59 | } | ||
60 | |||
61 | Q_EXPORT_INTERFACE() | ||
62 | { | ||
63 | Q_CREATE_INSTANCE( WirelessAppletImpl ) | ||
64 | } | ||
65 | |||
66 | |||
diff --git a/noncore/applets/wirelessapplet/wirelessappletimpl.h b/noncore/applets/wirelessapplet/wirelessappletimpl.h deleted file mode 100644 index 1bf4507..0000000 --- a/noncore/applets/wirelessapplet/wirelessappletimpl.h +++ b/dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
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 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef WIRELESSAPPLETIMPL_H | ||
21 | #define WIRELESSAPPLETIMPL_H | ||
22 | |||
23 | #include <qpe/taskbarappletinterface.h> | ||
24 | |||
25 | class WirelessApplet; | ||
26 | |||
27 | class WirelessAppletImpl : public TaskbarAppletInterface | ||
28 | { | ||
29 | public: | ||
30 | WirelessAppletImpl(); | ||
31 | virtual ~WirelessAppletImpl(); | ||
32 | |||
33 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
34 | Q_REFCOUNT | ||
35 | |||
36 | virtual QWidget *applet( QWidget *parent ); | ||
37 | virtual int position() const; | ||
38 | |||
39 | private: | ||
40 | WirelessApplet *wireless; | ||
41 | }; | ||
42 | |||
43 | #endif | ||