-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 2 | ||||
-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 3f07b41..48146ab 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -312,69 +312,69 @@ bool CardMonitor::getStatusSd( int showPopUp ) { | |||
312 | #endif | 312 | #endif |
313 | 313 | ||
314 | popUp( text, "cardmon/ide" ); // XX add SD pic | 314 | popUp( text, "cardmon/ide" ); // XX add SD pic |
315 | } | 315 | } |
316 | #else | 316 | #else |
317 | #error "Not on Linux" | 317 | #error "Not on Linux" |
318 | #endif | 318 | #endif |
319 | repaint( FALSE ); | 319 | repaint( FALSE ); |
320 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); | 320 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); |
321 | } | 321 | } |
322 | 322 | ||
323 | void CardMonitor::paintEvent( QPaintEvent * ) { | 323 | void CardMonitor::paintEvent( QPaintEvent * ) { |
324 | 324 | ||
325 | QPainter p( this ); | 325 | QPainter p( this ); |
326 | 326 | ||
327 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 327 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { |
328 | p.drawPixmap( 0, 0, pm ); | 328 | p.drawPixmap( 0, 0, pm ); |
329 | show(); | 329 | show(); |
330 | } else { | 330 | } else { |
331 | //p.eraseRect(rect()); | 331 | //p.eraseRect(rect()); |
332 | hide(); | 332 | hide(); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | int CardMonitor::position() { | 336 | int CardMonitor::position() { |
337 | return 7; | 337 | return 7; |
338 | } | 338 | } |
339 | 339 | ||
340 | void CardMonitor::execCommand( const QString &command ) { | 340 | void CardMonitor::execCommand( const QString &command ) { |
341 | 341 | ||
342 | if ( m_process == 0 ) { | 342 | if ( m_process == 0 ) { |
343 | m_process = new OProcess(); | 343 | m_process = new OProcess(); |
344 | QStringList strList = QStringList::split( " ", command ); | 344 | QStringList strList = QStringList::split( " ", command ); |
345 | 345 | ||
346 | for ( QStringList::Iterator it = strList.begin(); it != strList.end(); ++it ) { | 346 | for ( QStringList::Iterator it = strList.begin(); it != strList.end(); ++it ) { |
347 | *m_process << *it; | 347 | *m_process << *it; |
348 | } | 348 | } |
349 | 349 | ||
350 | connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), | 350 | connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), |
351 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); | 351 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); |
352 | 352 | ||
353 | if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ) { | 353 | if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ) { |
354 | delete m_process; | 354 | delete m_process; |
355 | m_process = 0; | 355 | m_process = 0; |
356 | } | 356 | } |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | void CardMonitor::slotExited( OProcess* proc ) { | 360 | void CardMonitor::slotExited( OProcess* ) { |
361 | 361 | ||
362 | if( m_process->normalExit() ) { | 362 | if( m_process->normalExit() ) { |
363 | int ret = m_process->exitStatus(); | 363 | int ret = m_process->exitStatus(); |
364 | if( ret != 0 ) { | 364 | if( ret != 0 ) { |
365 | if ( m_commandOrig == 1 ) { | 365 | if ( m_commandOrig == 1 ) { |
366 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 366 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
367 | } else if ( m_commandOrig == 2 ) { | 367 | } else if ( m_commandOrig == 2 ) { |
368 | popUp( tr( "SD/MMC card eject failed!" ) ); | 368 | popUp( tr( "SD/MMC card eject failed!" ) ); |
369 | } else if ( m_commandOrig == 3 ) { | 369 | } else if ( m_commandOrig == 3 ) { |
370 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 370 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | delete m_process; | 375 | delete m_process; |
376 | m_process = 0; | 376 | m_process = 0; |
377 | } | 377 | } |
378 | 378 | ||
379 | EXPORT_OPIE_APPLET_v1( CardMonitor ) | 379 | EXPORT_OPIE_APPLET_v1( CardMonitor ) |
380 | 380 | ||
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index 7122b40..267714e 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp | |||
@@ -162,109 +162,109 @@ bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) | |||
162 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { | 162 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { |
163 | discovery.putch ( d ? '1' : '0' ); | 163 | discovery.putch ( d ? '1' : '0' ); |
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | return false; | 166 | return false; |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) | 170 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) |
171 | { | 171 | { |
172 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); | 172 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); |
173 | e << ( d ? 1 : 0 ); | 173 | e << ( d ? 1 : 0 ); |
174 | 174 | ||
175 | m_receive_active = d; | 175 | m_receive_active = d; |
176 | m_receive_state_changed = true; | 176 | m_receive_state_changed = true; |
177 | 177 | ||
178 | return true; | 178 | return true; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | void IrdaApplet::showDiscovered ( ) | 182 | void IrdaApplet::showDiscovered ( ) |
183 | { | 183 | { |
184 | //static Sound snd_found ( "irdaapplet/irdaon" ); | 184 | //static Sound snd_found ( "irdaapplet/irdaon" ); |
185 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); | 185 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); |
186 | 186 | ||
187 | QFile discovery ( "/proc/net/irda/discovery" ); | 187 | QFile discovery ( "/proc/net/irda/discovery" ); |
188 | 188 | ||
189 | if ( discovery. open ( IO_ReadOnly )) { | 189 | if ( discovery. open ( IO_ReadOnly )) { |
190 | bool qcopsend = false; | 190 | bool qcopsend = false; |
191 | 191 | ||
192 | QString discoveredDevice; | 192 | QString discoveredDevice; |
193 | QString deviceAddr; | 193 | QString deviceAddr; |
194 | 194 | ||
195 | // since it is /proc we _must_ use QTextStream | 195 | // since it is /proc we _must_ use QTextStream |
196 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); | 196 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); |
197 | 197 | ||
198 | QMap <QString, QString>::Iterator it; | 198 | QMap <QString, QString>::Iterator it; |
199 | 199 | ||
200 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 200 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
201 | it. data ( ). prepend ( "+++" ); | 201 | it. data ( ). prepend ( "+++" ); |
202 | 202 | ||
203 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { | 203 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { |
204 | const QString &line = *lit; | 204 | const QString &line = *lit; |
205 | 205 | ||
206 | if ( line. startsWith ( "nickname:" )) { | 206 | if ( line. startsWith ( "nickname:" )) { |
207 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); | 207 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); |
208 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); | 208 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); |
209 | 209 | ||
210 | // odebug << discoveredDevice + "(" + deviceAddr + ")" << oendl; | 210 | // odebug << discoveredDevice + "(" + deviceAddr + ")" << oendl; |
211 | 211 | ||
212 | if ( !m_devices. contains ( deviceAddr )) { | 212 | if ( !m_devices. contains ( deviceAddr )) { |
213 | popup ( tr( "Found:" ) + " " + discoveredDevice ); | 213 | popup ( tr( "Found:" ) + " " + discoveredDevice ); |
214 | //snd_found. play ( ); | 214 | //snd_found. play ( ); |
215 | qcopsend = true; | 215 | qcopsend = true; |
216 | } | 216 | } |
217 | m_devices. replace ( deviceAddr, discoveredDevice ); | 217 | m_devices. replace ( deviceAddr, discoveredDevice ); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { | 221 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { |
222 | // odebug << "IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?" << oendl; | 222 | // odebug << "IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?" << oendl; |
223 | 223 | ||
224 | if ( it. data ( ). left ( 3 ) == "+++" ) { | 224 | if ( it. data ( ). left ( 3 ) == "+++" ) { |
225 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); | 225 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); |
226 | //snd_lost. play ( ); | 226 | //snd_lost. play ( ); |
227 | 227 | ||
228 | QMap <QString, QString>::Iterator tmp = it; | 228 | QMap <QString, QString>::Iterator tmp = it; |
229 | tmp++; | 229 | tmp++; |
230 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator | 230 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator |
231 | it = tmp; | 231 | it = tmp; |
232 | 232 | ||
233 | qcopsend = true; | 233 | qcopsend = true; |
234 | } | 234 | } |
235 | else | 235 | else |
236 | it++; | 236 | it++; |
237 | } | 237 | } |
238 | // XXX if( qcopsend ) { | 238 | // XXX if( qcopsend ) { |
239 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); | 239 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); |
240 | e << ( m_devices. count ( ) > 0 ); | 240 | e << ( m_devices. count ( ) > 0 ); |
241 | // } | 241 | // } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) | 245 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) |
246 | { | 246 | { |
247 | QPopupMenu *menu = new QPopupMenu ( this ); | 247 | QPopupMenu *menu = new QPopupMenu ( this ); |
248 | QString cmd; | 248 | QString cmd; |
249 | 249 | ||
250 | /* Refresh active state */ | 250 | /* Refresh active state */ |
251 | timerEvent ( 0 ); | 251 | timerEvent ( 0 ); |
252 | 252 | ||
253 | //menu->insertItem( tr("More..."), 4 ); | 253 | //menu->insertItem( tr("More..."), 4 ); |
254 | 254 | ||
255 | if ( m_irda_active && !m_devices. isEmpty ( )) { | 255 | if ( m_irda_active && !m_devices. isEmpty ( )) { |
256 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); | 256 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); |
257 | 257 | ||
258 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 258 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
259 | menu-> insertItem ( *it ); | 259 | menu-> insertItem ( *it ); |
260 | 260 | ||
261 | menu-> insertSeparator ( ); | 261 | menu-> insertSeparator ( ); |
262 | } | 262 | } |
263 | 263 | ||
264 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); | 264 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); |
265 | 265 | ||
266 | if ( m_irda_active ) { | 266 | if ( m_irda_active ) { |
267 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); | 267 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); |
268 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); | 268 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); |
269 | } | 269 | } |
270 | 270 | ||
@@ -286,78 +286,78 @@ void IrdaApplet::mousePressEvent ( QMouseEvent * ) | |||
286 | setIrdaReceiveStatus ( !m_receive_active ); | 286 | setIrdaReceiveStatus ( !m_receive_active ); |
287 | timerEvent( 0 ); | 287 | timerEvent( 0 ); |
288 | break; | 288 | break; |
289 | } | 289 | } |
290 | 290 | ||
291 | delete menu; | 291 | delete menu; |
292 | } | 292 | } |
293 | 293 | ||
294 | void IrdaApplet::timerEvent ( QTimerEvent * ) | 294 | void IrdaApplet::timerEvent ( QTimerEvent * ) |
295 | { | 295 | { |
296 | bool oldactive = m_irda_active; | 296 | bool oldactive = m_irda_active; |
297 | bool olddiscovery = m_irda_discovery_active; | 297 | bool olddiscovery = m_irda_discovery_active; |
298 | bool receiveUpdate = false; | 298 | bool receiveUpdate = false; |
299 | 299 | ||
300 | if ( m_receive_state_changed ) { | 300 | if ( m_receive_state_changed ) { |
301 | receiveUpdate = true; | 301 | receiveUpdate = true; |
302 | m_receive_state_changed = false; | 302 | m_receive_state_changed = false; |
303 | } | 303 | } |
304 | 304 | ||
305 | m_irda_active = checkIrdaStatus ( ); | 305 | m_irda_active = checkIrdaStatus ( ); |
306 | m_irda_discovery_active = checkIrdaDiscoveryStatus ( ); | 306 | m_irda_discovery_active = checkIrdaDiscoveryStatus ( ); |
307 | 307 | ||
308 | if ( m_irda_discovery_active ) | 308 | if ( m_irda_discovery_active ) |
309 | showDiscovered ( ); | 309 | showDiscovered ( ); |
310 | 310 | ||
311 | if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) | 311 | if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) |
312 | update ( ); | 312 | update ( ); |
313 | } | 313 | } |
314 | 314 | ||
315 | void IrdaApplet::paintEvent ( QPaintEvent * ) | 315 | void IrdaApplet::paintEvent ( QPaintEvent * ) |
316 | { | 316 | { |
317 | QPainter p ( this ); | 317 | QPainter p ( this ); |
318 | 318 | ||
319 | p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap ); | 319 | p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap ); |
320 | 320 | ||
321 | if ( m_irda_discovery_active ) | 321 | if ( m_irda_discovery_active ) |
322 | p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap ); | 322 | p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap ); |
323 | 323 | ||
324 | if ( m_receive_active ) | 324 | if ( m_receive_active ) |
325 | p. drawPixmap( 0, 1, m_receiveActivePixmap ); | 325 | p. drawPixmap( 0, 1, m_receiveActivePixmap ); |
326 | } | 326 | } |
327 | /* | 327 | /* |
328 | * We know 3 calls | 328 | * We know 3 calls |
329 | * a) enable | 329 | * a) enable |
330 | * b) disable | 330 | * b) disable |
331 | * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on | 331 | * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on |
332 | * c) listDevices: We will return a list of known devices | 332 | * c) listDevices: We will return a list of known devices |
333 | */ | 333 | */ |
334 | void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) { | 334 | void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ) { |
335 | if ( str == "enableIrda()") { | 335 | if ( str == "enableIrda()") { |
336 | m_wasOn = checkIrdaStatus(); | 336 | m_wasOn = checkIrdaStatus(); |
337 | m_wasDiscover = checkIrdaDiscoveryStatus(); | 337 | m_wasDiscover = checkIrdaDiscoveryStatus(); |
338 | if (!m_wasOn) { | 338 | if (!m_wasOn) { |
339 | setIrdaStatus( true ); | 339 | setIrdaStatus( true ); |
340 | } | 340 | } |
341 | if ( !m_wasDiscover ) { | 341 | if ( !m_wasDiscover ) { |
342 | setIrdaDiscoveryStatus ( true ); | 342 | setIrdaDiscoveryStatus ( true ); |
343 | } | 343 | } |
344 | } else if ( str == "disableIrda()") { | 344 | } else if ( str == "disableIrda()") { |
345 | if (!m_wasOn) { | 345 | if (!m_wasOn) { |
346 | setIrdaStatus( false ); | 346 | setIrdaStatus( false ); |
347 | } | 347 | } |
348 | if ( !m_wasDiscover ) { | 348 | if ( !m_wasDiscover ) { |
349 | setIrdaDiscoveryStatus ( false ); | 349 | setIrdaDiscoveryStatus ( false ); |
350 | } | 350 | } |
351 | } else if ( str == "listDevices()") { | 351 | } else if ( str == "listDevices()") { |
352 | QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)"); | 352 | QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)"); |
353 | 353 | ||
354 | QStringList list; | 354 | QStringList list; |
355 | QMap<QString, QString>::Iterator it; | 355 | QMap<QString, QString>::Iterator it; |
356 | for (it = m_devices.begin(); it != m_devices.end(); ++it ) | 356 | for (it = m_devices.begin(); it != m_devices.end(); ++it ) |
357 | list << (*it); | 357 | list << (*it); |
358 | 358 | ||
359 | e << list; | 359 | e << list; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | EXPORT_OPIE_APPLET_v1( IrdaApplet ) | 363 | EXPORT_OPIE_APPLET_v1( IrdaApplet ) |