Diffstat (limited to 'noncore/applets/wirelessapplet/wireless.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index 9ce6618..6ef2e44 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp | |||
@@ -28,203 +28,203 @@ | |||
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | #include <qradiobutton.h> | 31 | #include <qradiobutton.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qpainter.h> | 33 | #include <qpainter.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qslider.h> | 35 | #include <qslider.h> |
36 | #include <qbuttongroup.h> | 36 | #include <qbuttongroup.h> |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | 40 | ||
41 | /* STD */ | 41 | /* STD */ |
42 | #include <sys/types.h> | 42 | #include <sys/types.h> |
43 | #include <signal.h> | 43 | #include <signal.h> |
44 | 44 | ||
45 | #define STYLE_BARS 0 | 45 | #define STYLE_BARS 0 |
46 | #define STYLE_ANTENNA 1 | 46 | #define STYLE_ANTENNA 1 |
47 | 47 | ||
48 | //#define MDEBUG | 48 | //#define MDEBUG |
49 | #undef MDEBUG | 49 | #undef MDEBUG |
50 | 50 | ||
51 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) | 51 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) |
52 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) | 52 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) |
53 | { | 53 | { |
54 | 54 | ||
55 | readConfig(); | 55 | readConfig(); |
56 | writeConfigEntry( "UpdateFrequency", updateFrequency ); | 56 | writeConfigEntry( "UpdateFrequency", updateFrequency ); |
57 | writeConfigEntry( "DisplayStyle", displayStyle ); | 57 | writeConfigEntry( "DisplayStyle", displayStyle ); |
58 | 58 | ||
59 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 59 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
60 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); | 60 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); |
61 | 61 | ||
62 | /* status label */ | 62 | /* status label */ |
63 | 63 | ||
64 | statusLabel = new QLabel( this, "statuslabel" ); | 64 | statusLabel = new QLabel( this, "statuslabel" ); |
65 | QString text( "Wireless Status:<br>" | 65 | QString text( "Wireless Status:<br>" |
66 | "*** Unknown ***<br>" | 66 | "*** Unknown ***<br>" |
67 | "Card not inserted ?<br>" | 67 | "Card not inserted ?<br>" |
68 | "Or Sharp ROM ?<br>" | 68 | "Or Sharp ROM ?<br>" |
69 | "CELL: 00:00:00:00:00:00" ); | 69 | "CELL: 00:00:00:00:00:00" ); |
70 | /* QString text( "Station: Unknown<br>" | 70 | /* QString text( "Station: Unknown<br>" |
71 | "ESSID: Unknown<br>" | 71 | "ESSID: Unknown<br>" |
72 | "MODE: Unknown<br>" | 72 | "MODE: Unknown<br>" |
73 | "FREQ: Unknown<br>" | 73 | "FREQ: Unknown<br>" |
74 | "CELL: AA:BB:CC:DD:EE:FF" ); */ | 74 | "CELL: AA:BB:CC:DD:EE:FF" ); */ |
75 | statusLabel->setText( text ); | 75 | statusLabel->setText( text ); |
76 | statusLabel->setFixedSize( statusLabel->sizeHint() ); | 76 | statusLabel->setFixedSize( statusLabel->sizeHint() ); |
77 | grid->addWidget( statusLabel, 0, 0 ); | 77 | grid->addWidget( statusLabel, 0, 0 ); |
78 | 78 | ||
79 | /* visualization group box */ | 79 | /* visualization group box */ |
80 | 80 | ||
81 | QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this ); | 81 | QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this ); |
82 | QRadioButton* r1 = new QRadioButton( "Color Bars", group ); | 82 | QRadioButton* r1 = new QRadioButton( "Color Bars", group ); |
83 | QRadioButton* r2 = new QRadioButton( "Antenna", group ); | 83 | QRadioButton* r2 = new QRadioButton( "Antenna", group ); |
84 | r1->setFocusPolicy( QWidget::NoFocus ); | 84 | r1->setFocusPolicy( QWidget::NoFocus ); |
85 | r2->setFocusPolicy( QWidget::NoFocus ); | 85 | r2->setFocusPolicy( QWidget::NoFocus ); |
86 | group->setFocusPolicy( QWidget::NoFocus ); | 86 | group->setFocusPolicy( QWidget::NoFocus ); |
87 | group->setButton( displayStyle ); | 87 | group->setButton( displayStyle ); |
88 | grid->addWidget( group, 0, 1 ); | 88 | grid->addWidget( group, 0, 1 ); |
89 | 89 | ||
90 | /* quality graph */ | 90 | /* quality graph */ |
91 | 91 | ||
92 | mgraph = new MGraph( this ); | 92 | mgraph = new MGraph( this ); |
93 | mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 93 | mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
94 | mgraph->setMin( 0 ); | 94 | mgraph->setMin( 0 ); |
95 | mgraph->setMax( 92 ); | 95 | mgraph->setMax( 92 ); |
96 | grid->addWidget( mgraph, 1, 0 ); | 96 | grid->addWidget( mgraph, 1, 0 ); |
97 | mgraph->setFocusPolicy( QWidget::NoFocus ); | 97 | mgraph->setFocusPolicy( QWidget::NoFocus ); |
98 | 98 | ||
99 | /* advanced configuration Button */ | 99 | /* advanced configuration Button */ |
100 | 100 | ||
101 | QPushButton* advanced = new QPushButton( "Advanced...", this ); | 101 | QPushButton* advanced = new QPushButton( "Advanced...", this ); |
102 | advanced->setFocusPolicy( QWidget::NoFocus ); | 102 | advanced->setFocusPolicy( QWidget::NoFocus ); |
103 | grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); | 103 | grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); |
104 | connect( advanced, SIGNAL( clicked() ), | 104 | connect( advanced, SIGNAL( clicked() ), |
105 | this, SLOT( advancedConfigClicked() ) ); | 105 | this, SLOT( advancedConfigClicked() ) ); |
106 | 106 | ||
107 | /* update Frequency Label */ | 107 | /* update Frequency Label */ |
108 | 108 | ||
109 | updateLabel = new QLabel( this ); | 109 | updateLabel = new QLabel( this ); |
110 | text.sprintf( "Update every %d s", updateFrequency ); | 110 | text.sprintf( "Update every %d s", updateFrequency ); |
111 | updateLabel->setText( text ); | 111 | updateLabel->setText( text ); |
112 | grid->addWidget( updateLabel, 2, 1 ); | 112 | grid->addWidget( updateLabel, 2, 1 ); |
113 | 113 | ||
114 | /* update Frequency Slider */ | 114 | /* update Frequency Slider */ |
115 | 115 | ||
116 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); | 116 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); |
117 | updateSlider->setRange( 0, 9 ); | 117 | updateSlider->setRange( 0, 9 ); |
118 | updateSlider->setValue( updateFrequency ); | 118 | updateSlider->setValue( updateFrequency ); |
119 | updateSlider->setTickmarks( QSlider::Both ); | 119 | updateSlider->setTickmarks( QSlider::Both ); |
120 | updateSlider->setTickInterval( 1 ); | 120 | updateSlider->setTickInterval( 1 ); |
121 | updateSlider->setSteps( 1, 1 ); | 121 | updateSlider->setSteps( 1, 1 ); |
122 | updateSlider->setFocusPolicy( QWidget::NoFocus ); | 122 | updateSlider->setFocusPolicy( QWidget::NoFocus ); |
123 | grid->addWidget( updateSlider, 1, 1 ); | 123 | grid->addWidget( updateSlider, 1, 1 ); |
124 | connect( updateSlider, SIGNAL( valueChanged( int ) ), | 124 | connect( updateSlider, SIGNAL( valueChanged(int) ), |
125 | this, SLOT( updateDelayChange( int ) ) ); | 125 | this, SLOT( updateDelayChange(int) ) ); |
126 | 126 | ||
127 | setFixedSize( sizeHint() ); | 127 | setFixedSize( sizeHint() ); |
128 | setFocusPolicy( QWidget::NoFocus ); | 128 | setFocusPolicy( QWidget::NoFocus ); |
129 | 129 | ||
130 | applet->displayStyleChange( displayStyle ); | 130 | applet->displayStyleChange( displayStyle ); |
131 | applet->updateDelayChange( updateFrequency ); | 131 | applet->updateDelayChange( updateFrequency ); |
132 | 132 | ||
133 | connect( group, SIGNAL( clicked( int ) ), | 133 | connect( group, SIGNAL( clicked(int) ), |
134 | this, SLOT( displayStyleChange( int ) ) ); | 134 | this, SLOT( displayStyleChange(int) ) ); |
135 | 135 | ||
136 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | 136 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); |
137 | } | 137 | } |
138 | 138 | ||
139 | void WirelessControl::advancedConfigClicked() | 139 | void WirelessControl::advancedConfigClicked() |
140 | { | 140 | { |
141 | AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE ); | 141 | AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE ); |
142 | int result = a->exec(); | 142 | int result = a->exec(); |
143 | a->hide(); | 143 | a->hide(); |
144 | delete a; | 144 | delete a; |
145 | if ( result == QDialog::Accepted ) | 145 | if ( result == QDialog::Accepted ) |
146 | { | 146 | { |
147 | readConfig(); | 147 | readConfig(); |
148 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | 148 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | void WirelessControl::updateDelayChange( int delay ) | 152 | void WirelessControl::updateDelayChange( int delay ) |
153 | { | 153 | { |
154 | QString text; | 154 | QString text; |
155 | text.sprintf( "Update every %d s", delay ); | 155 | text.sprintf( "Update every %d s", delay ); |
156 | updateLabel->setText( text ); | 156 | updateLabel->setText( text ); |
157 | applet->updateDelayChange( delay ); | 157 | applet->updateDelayChange( delay ); |
158 | writeConfigEntry( "UpdateFrequency", delay ); | 158 | writeConfigEntry( "UpdateFrequency", delay ); |
159 | } | 159 | } |
160 | 160 | ||
161 | void WirelessControl::displayStyleChange( int style ) | 161 | void WirelessControl::displayStyleChange( int style ) |
162 | { | 162 | { |
163 | applet->displayStyleChange( style ); | 163 | applet->displayStyleChange( style ); |
164 | writeConfigEntry( "DisplayStyle", style ); | 164 | writeConfigEntry( "DisplayStyle", style ); |
165 | } | 165 | } |
166 | 166 | ||
167 | void WirelessControl::show ( bool ) | 167 | void WirelessControl::show ( bool ) |
168 | { | 168 | { |
169 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); | 169 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); |
170 | 170 | ||
171 | int w = sizeHint().width(); | 171 | int w = sizeHint().width(); |
172 | int x = curPos.x() - ( w / 2 ); | 172 | int x = curPos.x() - ( w / 2 ); |
173 | 173 | ||
174 | if ( ( x + w ) > QPEApplication::desktop() ->width() ) | 174 | if ( ( x + w ) > QPEApplication::desktop() ->width() ) |
175 | x = QPEApplication::desktop ( ) -> width ( ) - w; | 175 | x = QPEApplication::desktop ( ) -> width ( ) - w; |
176 | 176 | ||
177 | move( x, curPos.y () - sizeHint().height () ); | 177 | move( x, curPos.y () - sizeHint().height () ); |
178 | QFrame::show(); | 178 | QFrame::show(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void WirelessControl::readConfig() | 181 | void WirelessControl::readConfig() |
182 | { | 182 | { |
183 | Config cfg( "qpe" ); | 183 | Config cfg( "qpe" ); |
184 | cfg.setGroup( "Wireless" ); | 184 | cfg.setGroup( "Wireless" ); |
185 | 185 | ||
186 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); | 186 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); |
187 | displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); | 187 | displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); |
188 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); | 188 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); |
189 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); | 189 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); |
190 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); | 190 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); |
191 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); | 191 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); |
192 | } | 192 | } |
193 | 193 | ||
194 | void WirelessControl::writeConfigEntry( const char *entry, int val ) | 194 | void WirelessControl::writeConfigEntry( const char *entry, int val ) |
195 | { | 195 | { |
196 | Config cfg( "qpe" ); | 196 | Config cfg( "qpe" ); |
197 | cfg.setGroup( "Wireless" ); | 197 | cfg.setGroup( "Wireless" ); |
198 | cfg.writeEntry( entry, val ); | 198 | cfg.writeEntry( entry, val ); |
199 | } | 199 | } |
200 | 200 | ||
201 | //=========================================================================== | 201 | //=========================================================================== |
202 | 202 | ||
203 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) | 203 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) |
204 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), | 204 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), |
205 | timer( 0 ), interface( 0 ), oldiface( 0 ), | 205 | timer( 0 ), interface( 0 ), oldiface( 0 ), |
206 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) | 206 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) |
207 | { | 207 | { |
208 | setFixedHeight( 18 ); | 208 | setFixedHeight( 18 ); |
209 | setFixedWidth( 14 ); | 209 | setFixedWidth( 14 ); |
210 | status = new WirelessControl( this, this, "wireless status" ); | 210 | status = new WirelessControl( this, this, "wireless status" ); |
211 | } | 211 | } |
212 | 212 | ||
213 | void WirelessApplet::checkInterface() | 213 | void WirelessApplet::checkInterface() |
214 | { | 214 | { |
215 | interface = 0L; | 215 | interface = 0L; |
216 | ONetwork* net = ONetwork::instance(); | 216 | ONetwork* net = ONetwork::instance(); |
217 | net->synchronize(); | 217 | net->synchronize(); |
218 | ONetwork::InterfaceIterator it = net->iterator(); | 218 | ONetwork::InterfaceIterator it = net->iterator(); |
219 | 219 | ||
220 | while ( it.current() && !it.current()->isWireless() ) ++it; | 220 | while ( it.current() && !it.current()->isWireless() ) ++it; |
221 | 221 | ||
222 | if ( it.current() && it.current()->isWireless() ) | 222 | if ( it.current() && it.current()->isWireless() ) |
223 | interface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 223 | interface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
224 | 224 | ||
225 | if ( interface ) | 225 | if ( interface ) |
226 | { | 226 | { |
227 | #ifdef MDEBUG | 227 | #ifdef MDEBUG |
228 | qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() ); | 228 | qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() ); |
229 | #endif | 229 | #endif |
230 | 230 | ||