summaryrefslogtreecommitdiff
path: root/libopie
authorgroucho <groucho>2003-03-19 11:36:34 (UTC)
committer groucho <groucho>2003-03-19 11:36:34 (UTC)
commit28be0fcc9bda71175c3ee17e79fce2ac24340ff2 (patch) (unidiff)
treef09c80460e4f0219eb308d612a2e67df57f2c254 /libopie
parent18c6c51705de3b1897f671e54b25929e74d11f23 (diff)
downloadopie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.zip
opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.tar.gz
opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.tar.bz2
Fixed bug #744 where non mapped buttons in buttonsettings were not saved by introducing the "
ignore" statement. Also removed unsed debug code
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp15
-rw-r--r--libopie/odevicebutton.cpp3
2 files changed, 12 insertions, 6 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9e97c56..d5e3c5c 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -187,193 +187,192 @@ struct z_button {
187 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 187 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
188 "devicebuttons/z_contact", 188 "devicebuttons/z_contact",
189 "addressbook", "raise()", 189 "addressbook", "raise()",
190 "addressbook", "beamBusinessCard()" }, 190 "addressbook", "beamBusinessCard()" },
191 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 191 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
192 "devicebuttons/z_home", 192 "devicebuttons/z_home",
193 "QPE/Launcher", "home()", 193 "QPE/Launcher", "home()",
194 "buttonsettings", "raise()" }, 194 "buttonsettings", "raise()" },
195 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 195 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
196 "devicebuttons/z_menu", 196 "devicebuttons/z_menu",
197 "QPE/TaskBar", "toggleMenu()", 197 "QPE/TaskBar", "toggleMenu()",
198 "QPE/TaskBar", "toggleStartMenu()" }, 198 "QPE/TaskBar", "toggleStartMenu()" },
199 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 199 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
200 "devicebuttons/z_mail", 200 "devicebuttons/z_mail",
201 "mail", "raise()", 201 "mail", "raise()",
202 "mail", "newMail()" }, 202 "mail", "newMail()" },
203}; 203};
204 204
205static QCString makeChannel ( const char *str ) 205static QCString makeChannel ( const char *str )
206{ 206{
207 if ( str && !::strchr ( str, '/' )) 207 if ( str && !::strchr ( str, '/' ))
208 return QCString ( "QPE/Application/" ) + str; 208 return QCString ( "QPE/Application/" ) + str;
209 else 209 else
210 return str; 210 return str;
211} 211}
212 212
213 213
214 214
215 215
216ODevice *ODevice::inst ( ) 216ODevice *ODevice::inst ( )
217{ 217{
218 static ODevice *dev = 0; 218 static ODevice *dev = 0;
219 219
220 if ( !dev ) { 220 if ( !dev ) {
221 if ( QFile::exists ( "/proc/hal/model" )) 221 if ( QFile::exists ( "/proc/hal/model" ))
222 dev = new iPAQ ( ); 222 dev = new iPAQ ( );
223 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 223 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
224 dev = new Zaurus ( ); 224 dev = new Zaurus ( );
225 else 225 else
226 dev = new ODevice ( ); 226 dev = new ODevice ( );
227 227
228 dev-> init ( ); 228 dev-> init ( );
229 } 229 }
230 return dev; 230 return dev;
231} 231}
232 232
233 233
234/************************************************** 234/**************************************************
235 * 235 *
236 * common 236 * common
237 * 237 *
238 **************************************************/ 238 **************************************************/
239 239
240 240
241ODevice::ODevice ( ) 241ODevice::ODevice ( )
242{ 242{
243 d = new ODeviceData; 243 d = new ODeviceData;
244 244
245 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 245 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
246 246
247 d-> m_modelstr = "Unknown"; 247 d-> m_modelstr = "Unknown";
248 d-> m_model = Model_Unknown; 248 d-> m_model = Model_Unknown;
249 d-> m_vendorstr = "Unknown"; 249 d-> m_vendorstr = "Unknown";
250 d-> m_vendor = Vendor_Unknown; 250 d-> m_vendor = Vendor_Unknown;
251 d-> m_systemstr = "Unknown"; 251 d-> m_systemstr = "Unknown";
252 d-> m_system = System_Unknown; 252 d-> m_system = System_Unknown;
253 d-> m_sysverstr = "0.0"; 253 d-> m_sysverstr = "0.0";
254 d-> m_rotation = Rot0; 254 d-> m_rotation = Rot0;
255 255
256 d-> m_holdtime = 1000; // 1000ms 256 d-> m_holdtime = 1000; // 1000ms
257 257
258 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 258 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
259 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 259 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
260} 260}
261 261
262void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 262void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
263{ 263{
264 if ( msg == "deviceButtonMappingChanged()" ) { 264 if ( msg == "deviceButtonMappingChanged()" ) {
265 reloadButtonMapping ( ); 265 reloadButtonMapping ( );
266 } 266 }
267} 267}
268 268
269void ODevice::init ( ) 269void ODevice::init ( )
270{ 270{
271 // Simulation uses iPAQ 3660 device buttons 271 // Simulation uses iPAQ 3660 device buttons
272 272
273 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 273 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
274 i_button *ib = ipaq_buttons + i; 274 i_button *ib = ipaq_buttons + i;
275 ODeviceButton b; 275 ODeviceButton b;
276 276
277 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 277 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
278 b. setKeycode ( ib-> code ); 278 b. setKeycode ( ib-> code );
279 b. setUserText ( qApp-> translate ( "Button", ib-> utext )); 279 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
280 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 280 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
283
284 d-> m_buttons. append ( b ); 283 d-> m_buttons. append ( b );
285 } 284 }
286 } 285 }
287 reloadButtonMapping ( ); 286 reloadButtonMapping ( );
288} 287}
289 288
290ODevice::~ODevice ( ) 289ODevice::~ODevice ( )
291{ 290{
292 delete d; 291 delete d;
293} 292}
294 293
295bool ODevice::setSoftSuspend ( bool /*soft*/ ) 294bool ODevice::setSoftSuspend ( bool /*soft*/ )
296{ 295{
297 return false; 296 return false;
298} 297}
299 298
300//#include <linux/apm_bios.h> 299//#include <linux/apm_bios.h>
301 300
302#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 301#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
303 302
304 303
305bool ODevice::suspend ( ) 304bool ODevice::suspend ( )
306{ 305{
307 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 306 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
308 return false; 307 return false;
309 308
310 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 309 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
311 return false; 310 return false;
312 311
313 bool res = false; 312 bool res = false;
314 313
315 struct timeval tvs, tvn; 314 struct timeval tvs, tvn;
316 ::gettimeofday ( &tvs, 0 ); 315 ::gettimeofday ( &tvs, 0 );
317 316
318 ::sync ( ); // flush fs caches 317 ::sync ( ); // flush fs caches
319 res = ( ::system ( "apm --suspend" ) == 0 ); 318 res = ( ::system ( "apm --suspend" ) == 0 );
320 319
321 // This is needed because the iPAQ apm implementation is asynchronous and we 320 // This is needed because the iPAQ apm implementation is asynchronous and we
322 // can not be sure when exactly the device is really suspended 321 // can not be sure when exactly the device is really suspended
323 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 322 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
324 323
325 if ( res ) { 324 if ( res ) {
326 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 325 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
327 ::usleep ( 200 * 1000 ); 326 ::usleep ( 200 * 1000 );
328 ::gettimeofday ( &tvn, 0 ); 327 ::gettimeofday ( &tvn, 0 );
329 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 328 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
330 } 329 }
331 330
332 return res; 331 return res;
333} 332}
334 333
335//#include <linux/fb.h> better not rely on kernel headers in userspace ... 334//#include <linux/fb.h> better not rely on kernel headers in userspace ...
336 335
337#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 336#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
338 337
339/* VESA Blanking Levels */ 338/* VESA Blanking Levels */
340#define VESA_NO_BLANKING 0 339#define VESA_NO_BLANKING 0
341#define VESA_VSYNC_SUSPEND 1 340#define VESA_VSYNC_SUSPEND 1
342#define VESA_HSYNC_SUSPEND 2 341#define VESA_HSYNC_SUSPEND 2
343#define VESA_POWERDOWN 3 342#define VESA_POWERDOWN 3
344 343
345 344
346bool ODevice::setDisplayStatus ( bool on ) 345bool ODevice::setDisplayStatus ( bool on )
347{ 346{
348 if ( d-> m_model == Model_Unknown ) 347 if ( d-> m_model == Model_Unknown )
349 return false; 348 return false;
350 349
351 bool res = false; 350 bool res = false;
352 int fd; 351 int fd;
353 352
354 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 353 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
355 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 354 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
356 ::close ( fd ); 355 ::close ( fd );
357 } 356 }
358 return res; 357 return res;
359} 358}
360 359
361bool ODevice::setDisplayBrightness ( int ) 360bool ODevice::setDisplayBrightness ( int )
362{ 361{
363 return false; 362 return false;
364} 363}
365 364
366int ODevice::displayBrightnessResolution ( ) const 365int ODevice::displayBrightnessResolution ( ) const
367{ 366{
368 return 16; 367 return 16;
369} 368}
370 369
371QString ODevice::vendorString ( ) const 370QString ODevice::vendorString ( ) const
372{ 371{
373 return d-> m_vendorstr; 372 return d-> m_vendorstr;
374} 373}
375 374
376OVendor ODevice::vendor ( ) const 375OVendor ODevice::vendor ( ) const
377{ 376{
378 return d-> m_vendor; 377 return d-> m_vendor;
379} 378}
@@ -423,223 +422,229 @@ void ODevice::keySound ( )
423#ifndef QT_NO_SOUND 422#ifndef QT_NO_SOUND
424 static Sound snd ( "keysound" ); 423 static Sound snd ( "keysound" );
425 424
426 if ( snd. isFinished ( )) 425 if ( snd. isFinished ( ))
427 snd. play ( ); 426 snd. play ( );
428#endif 427#endif
429} 428}
430 429
431void ODevice::touchSound ( ) 430void ODevice::touchSound ( )
432{ 431{
433 432
434#ifndef QT_NO_SOUND 433#ifndef QT_NO_SOUND
435 static Sound snd ( "touchsound" ); 434 static Sound snd ( "touchsound" );
436 435
437 if ( snd. isFinished ( )) 436 if ( snd. isFinished ( ))
438 snd. play ( ); 437 snd. play ( );
439#endif 438#endif
440} 439}
441 440
442 441
443QValueList <OLed> ODevice::ledList ( ) const 442QValueList <OLed> ODevice::ledList ( ) const
444{ 443{
445 return QValueList <OLed> ( ); 444 return QValueList <OLed> ( );
446} 445}
447 446
448QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 447QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
449{ 448{
450 return QValueList <OLedState> ( ); 449 return QValueList <OLedState> ( );
451} 450}
452 451
453OLedState ODevice::ledState ( OLed /*which*/ ) const 452OLedState ODevice::ledState ( OLed /*which*/ ) const
454{ 453{
455 return Led_Off; 454 return Led_Off;
456} 455}
457 456
458bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 457bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
459{ 458{
460 return false; 459 return false;
461} 460}
462 461
463bool ODevice::hasLightSensor ( ) const 462bool ODevice::hasLightSensor ( ) const
464{ 463{
465 return false; 464 return false;
466} 465}
467 466
468int ODevice::readLightSensor ( ) 467int ODevice::readLightSensor ( )
469{ 468{
470 return -1; 469 return -1;
471} 470}
472 471
473int ODevice::lightSensorResolution ( ) const 472int ODevice::lightSensorResolution ( ) const
474{ 473{
475 return 0; 474 return 0;
476} 475}
477 476
478const QValueList <ODeviceButton> &ODevice::buttons ( ) const 477const QValueList <ODeviceButton> &ODevice::buttons ( ) const
479{ 478{
480 return d-> m_buttons; 479 return d-> m_buttons;
481} 480}
482 481
483uint ODevice::buttonHoldTime ( ) const 482uint ODevice::buttonHoldTime ( ) const
484{ 483{
485 return d-> m_holdtime; 484 return d-> m_holdtime;
486} 485}
487 486
488const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 487const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
489{ 488{
490 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { 489 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) {
491 if ( (*it). keycode ( ) == code ) 490 if ( (*it). keycode ( ) == code )
492 return &(*it); 491 return &(*it);
493 } 492 }
494 return 0; 493 return 0;
495} 494}
496 495
497void ODevice::reloadButtonMapping ( ) 496void ODevice::reloadButtonMapping ( )
498{ 497{
499 Config cfg ( "ButtonSettings" ); 498 Config cfg ( "ButtonSettings" );
500 499
501 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { 500 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) {
502 ODeviceButton &b = d-> m_buttons [i]; 501 ODeviceButton &b = d-> m_buttons [i];
503 QString group = "Button" + QString::number ( i ); 502 QString group = "Button" + QString::number ( i );
504 503
505 QCString pch, hch; 504 QCString pch, hch;
506 QCString pm, hm; 505 QCString pm, hm;
507 QByteArray pdata, hdata; 506 QByteArray pdata, hdata;
508 507
509 if ( cfg. hasGroup ( group )) { 508 if ( cfg. hasGroup ( group )) {
510 cfg. setGroup ( group ); 509 cfg. setGroup ( group );
511 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 510 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
512 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 511 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
513 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 512 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
514 513
515 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 514 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
516 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 515 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
517 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 516 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
518 } 517 }
519 518
520 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 519 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
520
521 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 521 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
522 } 522 }
523} 523}
524 524
525void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 525void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
526{ 526{
527 QString mb_chan;
528
527 if ( button >= (int) d-> m_buttons. count ( )) 529 if ( button >= (int) d-> m_buttons. count ( ))
528 return; 530 return;
531
529 532
530 ODeviceButton &b = d-> m_buttons [button]; 533 ODeviceButton &b = d-> m_buttons [button];
531 b. setPressedAction ( action ); 534 b. setPressedAction ( action );
535
536 mb_chan=b. pressedAction ( ). channel ( );
532 537
533 Config buttonFile ( "ButtonSettings" ); 538 Config buttonFile ( "ButtonSettings" );
534 buttonFile. setGroup ( "Button" + QString::number ( button )); 539 buttonFile. setGroup ( "Button" + QString::number ( button ));
535 buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( )); 540 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
536 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 541 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
537 542
538 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 543 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
539 544
540 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 545 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
541} 546}
542 547
543void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 548void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
544{ 549{
545 if ( button >= (int) d-> m_buttons. count ( )) 550 if ( button >= (int) d-> m_buttons. count ( ))
546 return; 551 return;
547 552
548 ODeviceButton &b = d-> m_buttons [button]; 553 ODeviceButton &b = d-> m_buttons [button];
549 b. setHeldAction ( action ); 554 b. setHeldAction ( action );
550 555
551 Config buttonFile ( "ButtonSettings" ); 556 Config buttonFile ( "ButtonSettings" );
552 buttonFile. setGroup ( "Button" + QString::number ( button )); 557 buttonFile. setGroup ( "Button" + QString::number ( button ));
553 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 558 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
554 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 559 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
555 560
556 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 561 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
557 562
558 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 563 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
559} 564}
560 565
561 566
562 567
563 568
564/************************************************** 569/**************************************************
565 * 570 *
566 * iPAQ 571 * iPAQ
567 * 572 *
568 **************************************************/ 573 **************************************************/
569 574
570void iPAQ::init ( ) 575void iPAQ::init ( )
571{ 576{
572 d-> m_vendorstr = "HP"; 577 d-> m_vendorstr = "HP";
573 d-> m_vendor = Vendor_HP; 578 d-> m_vendor = Vendor_HP;
574 579
575 QFile f ( "/proc/hal/model" ); 580 QFile f ( "/proc/hal/model" );
576 581
577 if ( f. open ( IO_ReadOnly )) { 582 if ( f. open ( IO_ReadOnly )) {
578 QTextStream ts ( &f ); 583 QTextStream ts ( &f );
579 584
580 d-> m_modelstr = "H" + ts. readLine ( ); 585 d-> m_modelstr = "H" + ts. readLine ( );
581 586
582 if ( d-> m_modelstr == "H3100" ) 587 if ( d-> m_modelstr == "H3100" )
583 d-> m_model = Model_iPAQ_H31xx; 588 d-> m_model = Model_iPAQ_H31xx;
584 else if ( d-> m_modelstr == "H3600" ) 589 else if ( d-> m_modelstr == "H3600" )
585 d-> m_model = Model_iPAQ_H36xx; 590 d-> m_model = Model_iPAQ_H36xx;
586 else if ( d-> m_modelstr == "H3700" ) 591 else if ( d-> m_modelstr == "H3700" )
587 d-> m_model = Model_iPAQ_H37xx; 592 d-> m_model = Model_iPAQ_H37xx;
588 else if ( d-> m_modelstr == "H3800" ) 593 else if ( d-> m_modelstr == "H3800" )
589 d-> m_model = Model_iPAQ_H38xx; 594 d-> m_model = Model_iPAQ_H38xx;
590 else if ( d-> m_modelstr == "H3900" ) 595 else if ( d-> m_modelstr == "H3900" )
591 d-> m_model = Model_iPAQ_H39xx; 596 d-> m_model = Model_iPAQ_H39xx;
592 else 597 else
593 d-> m_model = Model_Unknown; 598 d-> m_model = Model_Unknown;
594 599
595 f. close ( ); 600 f. close ( );
596 } 601 }
597 602
598 switch ( d-> m_model ) { 603 switch ( d-> m_model ) {
599 case Model_iPAQ_H31xx: 604 case Model_iPAQ_H31xx:
600 case Model_iPAQ_H38xx: 605 case Model_iPAQ_H38xx:
601 d-> m_rotation = Rot90; 606 d-> m_rotation = Rot90;
602 break; 607 break;
603 case Model_iPAQ_H36xx: 608 case Model_iPAQ_H36xx:
604 case Model_iPAQ_H37xx: 609 case Model_iPAQ_H37xx:
605 case Model_iPAQ_H39xx: 610 case Model_iPAQ_H39xx:
606 default: 611 default:
607 d-> m_rotation = Rot270; 612 d-> m_rotation = Rot270;
608 break; 613 break;
609 } 614 }
610 615
611 f. setName ( "/etc/familiar-version" ); 616 f. setName ( "/etc/familiar-version" );
612 if ( f. open ( IO_ReadOnly )) { 617 if ( f. open ( IO_ReadOnly )) {
613 d-> m_systemstr = "Familiar"; 618 d-> m_systemstr = "Familiar";
614 d-> m_system = System_Familiar; 619 d-> m_system = System_Familiar;
615 620
616 QTextStream ts ( &f ); 621 QTextStream ts ( &f );
617 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 622 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
618 623
619 f. close ( ); 624 f. close ( );
620 } 625 }
621 626
622 m_leds [0] = m_leds [1] = Led_Off; 627 m_leds [0] = m_leds [1] = Led_Off;
623 628
624 m_power_timer = 0; 629 m_power_timer = 0;
625 630
626 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 631 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
627 i_button *ib = ipaq_buttons + i; 632 i_button *ib = ipaq_buttons + i;
628 ODeviceButton b; 633 ODeviceButton b;
629 634
630 if (( ib-> model & d-> m_model ) == d-> m_model ) { 635 if (( ib-> model & d-> m_model ) == d-> m_model ) {
631 b. setKeycode ( ib-> code ); 636 b. setKeycode ( ib-> code );
632 b. setUserText ( qApp-> translate ( "Button", ib-> utext )); 637 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
633 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 638 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
634 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 639 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
635 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 640 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
636 641
637 d-> m_buttons. append ( b ); 642 d-> m_buttons. append ( b );
638 } 643 }
639 } 644 }
640 reloadButtonMapping ( ); 645 reloadButtonMapping ( );
641 646
642 if ( d-> m_qwsserver ) 647 if ( d-> m_qwsserver )
643 QWSServer::setKeyboardFilter ( this ); 648 QWSServer::setKeyboardFilter ( this );
644} 649}
645 650
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp
index 2270343..4b22358 100644
--- a/libopie/odevicebutton.cpp
+++ b/libopie/odevicebutton.cpp
@@ -1,234 +1,235 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qpixmap.h> 21#include <qpixmap.h>
22#include <qstring.h> 22#include <qstring.h>
23 23
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <opie/odevicebutton.h> 25#include <opie/odevicebutton.h>
26 26
27using namespace Opie; 27using namespace Opie;
28 28
29 29
30class OQCopMessageData { 30class OQCopMessageData {
31 public: 31 public:
32 QCString m_channel; 32 QCString m_channel;
33 QCString m_message; 33 QCString m_message;
34 QByteArray m_data; 34 QByteArray m_data;
35}; 35};
36 36
37 37
38OQCopMessage::OQCopMessage ( ) 38OQCopMessage::OQCopMessage ( )
39 : d ( 0 ) 39 : d ( 0 )
40{ 40{
41 init ( QCString ( ), QCString ( ), QByteArray ( )); 41 init ( QCString ( ), QCString ( ), QByteArray ( ));
42} 42}
43 43
44OQCopMessage::OQCopMessage ( const OQCopMessage &copy ) 44OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
45 : d ( 0 ) 45 : d ( 0 )
46{ 46{
47 init ( copy. channel ( ), copy. message ( ), copy. data ( )); 47 init ( copy. channel ( ), copy. message ( ), copy. data ( ));
48} 48}
49 49
50OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) 50OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
51{ 51{
52 init ( assign. channel ( ), assign. message ( ), assign. data ( )); 52 init ( assign. channel ( ), assign. message ( ), assign. data ( ));
53 return *this; 53 return *this;
54} 54}
55 55
56OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) 56OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
57 : d ( 0 ) 57 : d ( 0 )
58{ 58{
59 init ( ch, m, arg ); 59 init ( ch, m, arg );
60} 60}
61 61
62void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) 62void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
63{ 63{
64 if ( !d ) 64 if ( !d )
65 d = new OQCopMessageData ( ); 65 d = new OQCopMessageData ( );
66 d-> m_channel = ch; 66 d-> m_channel = ch;
67 d-> m_message = m; 67 d-> m_message = m;
68 d-> m_data = arg; 68 d-> m_data = arg;
69} 69}
70 70
71bool OQCopMessage::send ( ) 71bool OQCopMessage::send ( )
72{ 72{
73 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( )) 73 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) )
74 return false; 74 return false;
75 75
76 QCopEnvelope e ( d-> m_channel, d-> m_message ); 76 QCopEnvelope e ( d-> m_channel, d-> m_message );
77 77
78 if ( d-> m_data. size ( )) 78 if ( d-> m_data. size ( ))
79 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( )); 79 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
80 80
81 return true; 81 return true;
82} 82}
83 83
84QCString OQCopMessage::channel ( ) const 84QCString OQCopMessage::channel ( ) const
85{ 85{
86 return d-> m_channel; 86 return d-> m_channel;
87} 87}
88 88
89QCString OQCopMessage::message ( ) const 89QCString OQCopMessage::message ( ) const
90{ 90{
91 return d-> m_message; 91 return d-> m_message;
92} 92}
93 93
94QByteArray OQCopMessage::data ( ) const 94QByteArray OQCopMessage::data ( ) const
95{ 95{
96 return d-> m_data; 96 return d-> m_data;
97} 97}
98 98
99void OQCopMessage::setChannel ( const QCString &ch ) 99void OQCopMessage::setChannel ( const QCString &ch )
100{ 100{
101 d-> m_channel = ch; 101 d-> m_channel = ch;
102} 102}
103 103
104void OQCopMessage::setMessage ( const QCString &m ) 104void OQCopMessage::setMessage ( const QCString &m )
105{ 105{
106 d-> m_message = m; 106 d-> m_message = m;
107} 107}
108 108
109void OQCopMessage::setData ( const QByteArray &data ) 109void OQCopMessage::setData ( const QByteArray &data )
110{ 110{
111 d-> m_data = data; 111 d-> m_data = data;
112} 112}
113 113
114/*! \class ODeviceButton 114/*! \class ODeviceButton
115 \brief The ODeviceButton class represents a physical user mappable button on a Qtopia device. 115 \brief The ODeviceButton class represents a physical user mappable button on a Qtopia device.
116 116
117 This class represents a physical button on a Qtopia device. A 117 This class represents a physical button on a Qtopia device. A
118 device may have "user programmable" buttons. 118 device may have "user programmable" buttons.
119 The location and number of buttons will vary from device to 119 The location and number of buttons will vary from device to
120 device. userText() and pixmap() may be used to describe this button 120 device. userText() and pixmap() may be used to describe this button
121 to the user in help documentation. 121 to the user in help documentation.
122 122
123 \ingroup qtopiaemb 123 \ingroup qtopiaemb
124 \internal 124 \internal
125*/ 125*/
126 126
127ODeviceButton::ODeviceButton() 127ODeviceButton::ODeviceButton()
128{ 128{
129} 129}
130 130
131ODeviceButton::~ODeviceButton() 131ODeviceButton::~ODeviceButton()
132{ 132{
133} 133}
134 134
135/*! 135/*!
136 Returns the button's keycode. 136 Returns the button's keycode.
137 */ 137 */
138ushort ODeviceButton::keycode() const 138ushort ODeviceButton::keycode() const
139{ 139{
140 return m_Keycode; 140 return m_Keycode;
141} 141}
142 142
143 143
144/*! 144/*!
145 This function returns a human readable, translated description of the button. 145 This function returns a human readable, translated description of the button.
146 */ 146 */
147QString ODeviceButton::userText() const 147QString ODeviceButton::userText() const
148{ 148{
149 return m_UserText; 149 return m_UserText;
150} 150}
151 151
152/*! 152/*!
153 This function returns the pixmap for this button. If there isn't one 153 This function returns the pixmap for this button. If there isn't one
154 it will return an empty (null) pixmap. 154 it will return an empty (null) pixmap.
155 */ 155 */
156QPixmap ODeviceButton::pixmap() const 156QPixmap ODeviceButton::pixmap() const
157{ 157{
158 return m_Pixmap; 158 return m_Pixmap;
159} 159}
160 160
161/*! 161/*!
162 This function returns the factory preset (default) action for when this button 162 This function returns the factory preset (default) action for when this button
163 is pressed. The return value is a legal QCop message. 163 is pressed. The return value is a legal QCop message.
164 */ 164 */
165OQCopMessage ODeviceButton::factoryPresetPressedAction() const 165OQCopMessage ODeviceButton::factoryPresetPressedAction() const
166{ 166{
167 return m_FactoryPresetPressedAction; 167 return m_FactoryPresetPressedAction;
168} 168}
169 169
170/*! 170/*!
171 This function returns the user assigned action for when this button is pressed. 171 This function returns the user assigned action for when this button is pressed.
172 If no action is assigned, factoryPresetAction() is returned. 172 If no action is assigned, factoryPresetAction() is returned.
173 */ 173 */
174OQCopMessage ODeviceButton::pressedAction() const 174OQCopMessage ODeviceButton::pressedAction() const
175{ 175{
176 if (m_PressedAction.channel().isEmpty()) 176 if (m_PressedAction.channel().isEmpty())
177 return factoryPresetPressedAction(); 177 return factoryPresetPressedAction();
178 return m_PressedAction; 178 return m_PressedAction;
179} 179}
180 180
181/*! 181/*!
182 This function returns the factory preset (default) action for when this button 182 This function returns the factory preset (default) action for when this button
183 is pressed and held. The return value is a legal QCop message. 183 is pressed and held. The return value is a legal QCop message.
184 */ 184 */
185OQCopMessage ODeviceButton::factoryPresetHeldAction() const 185OQCopMessage ODeviceButton::factoryPresetHeldAction() const
186{ 186{
187 return m_FactoryPresetHeldAction; 187 return m_FactoryPresetHeldAction;
188} 188}
189 189
190/*! 190/*!
191 This function returns the user assigned action for when this button is pressed 191 This function returns the user assigned action for when this button is pressed
192 and held. If no action is assigned, factoryPresetAction() is returned. 192 and held. If no action is assigned, factoryPresetAction() is returned.
193 */ 193 */
194OQCopMessage ODeviceButton::heldAction() const 194OQCopMessage ODeviceButton::heldAction() const
195{ 195{
196 if (m_HeldAction.channel().isEmpty()) 196 if (m_HeldAction.channel().isEmpty())
197 return factoryPresetHeldAction(); 197 return factoryPresetHeldAction();
198 return m_HeldAction; 198 return m_HeldAction;
199} 199}
200 200
201void ODeviceButton::setKeycode(ushort keycode) 201void ODeviceButton::setKeycode(ushort keycode)
202{ 202{
203 m_Keycode = keycode; 203 m_Keycode = keycode;
204} 204}
205 205
206void ODeviceButton::setUserText(const QString& text) 206void ODeviceButton::setUserText(const QString& text)
207{ 207{
208 m_UserText = text; 208 m_UserText = text;
209} 209}
210 210
211void ODeviceButton::setPixmap(const QPixmap& picture) 211void ODeviceButton::setPixmap(const QPixmap& picture)
212{ 212{
213 m_Pixmap = picture; 213 m_Pixmap = picture;
214} 214}
215 215
216void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) 216void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
217{ 217{
218 m_FactoryPresetPressedAction = action; 218 m_FactoryPresetPressedAction = action;
219} 219}
220 220
221
221void ODeviceButton::setPressedAction(const OQCopMessage& action) 222void ODeviceButton::setPressedAction(const OQCopMessage& action)
222{ 223{
223 m_PressedAction = action; 224 m_PressedAction = action;
224} 225}
225 226
226void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) 227void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
227{ 228{
228 m_FactoryPresetHeldAction = action; 229 m_FactoryPresetHeldAction = action;
229} 230}
230 231
231void ODeviceButton::setHeldAction(const OQCopMessage& action) 232void ODeviceButton::setHeldAction(const OQCopMessage& action)
232{ 233{
233 m_HeldAction = action; 234 m_HeldAction = action;
234} 235}