summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 21070bf..9d0bbbf 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -214,769 +214,773 @@ struct i_button {
214 char *utext; 214 char *utext;
215 char *pix; 215 char *pix;
216 char *fpressedservice; 216 char *fpressedservice;
217 char *fpressedaction; 217 char *fpressedaction;
218 char *fheldservice; 218 char *fheldservice;
219 char *fheldaction; 219 char *fheldaction;
220} ipaq_buttons [] = { 220} ipaq_buttons [] = {
221 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 221 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
222 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 222 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
223 "devicebuttons/ipaq_calendar", 223 "devicebuttons/ipaq_calendar",
224 "datebook", "nextView()", 224 "datebook", "nextView()",
225 "today", "raise()" }, 225 "today", "raise()" },
226 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 226 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
227 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 227 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
228 "devicebuttons/ipaq_contact", 228 "devicebuttons/ipaq_contact",
229 "addressbook", "raise()", 229 "addressbook", "raise()",
230 "addressbook", "beamBusinessCard()" }, 230 "addressbook", "beamBusinessCard()" },
231 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 231 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
232 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 232 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
233 "devicebuttons/ipaq_menu", 233 "devicebuttons/ipaq_menu",
234 "QPE/TaskBar", "toggleMenu()", 234 "QPE/TaskBar", "toggleMenu()",
235 "QPE/TaskBar", "toggleStartMenu()" }, 235 "QPE/TaskBar", "toggleStartMenu()" },
236 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 236 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
237 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 237 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
238 "devicebuttons/ipaq_mail", 238 "devicebuttons/ipaq_mail",
239 "mail", "raise()", 239 "mail", "raise()",
240 "mail", "newMail()" }, 240 "mail", "newMail()" },
241 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 241 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
242 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 242 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
243 "devicebuttons/ipaq_home", 243 "devicebuttons/ipaq_home",
244 "QPE/Launcher", "home()", 244 "QPE/Launcher", "home()",
245 "buttonsettings", "raise()" }, 245 "buttonsettings", "raise()" },
246 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 246 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
247 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 247 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
248 "devicebuttons/ipaq_record", 248 "devicebuttons/ipaq_record",
249 "QPE/VMemo", "toggleRecord()", 249 "QPE/VMemo", "toggleRecord()",
250 "sound", "raise()" }, 250 "sound", "raise()" },
251}; 251};
252 252
253struct z_button { 253struct z_button {
254 Qt::Key code; 254 Qt::Key code;
255 char *utext; 255 char *utext;
256 char *pix; 256 char *pix;
257 char *fpressedservice; 257 char *fpressedservice;
258 char *fpressedaction; 258 char *fpressedaction;
259 char *fheldservice; 259 char *fheldservice;
260 char *fheldaction; 260 char *fheldaction;
261} z_buttons [] = { 261} z_buttons [] = {
262 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 262 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
263 "devicebuttons/z_calendar", 263 "devicebuttons/z_calendar",
264 "datebook", "nextView()", 264 "datebook", "nextView()",
265 "today", "raise()" }, 265 "today", "raise()" },
266 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 266 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
267 "devicebuttons/z_contact", 267 "devicebuttons/z_contact",
268 "addressbook", "raise()", 268 "addressbook", "raise()",
269 "addressbook", "beamBusinessCard()" }, 269 "addressbook", "beamBusinessCard()" },
270 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 270 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
271 "devicebuttons/z_home", 271 "devicebuttons/z_home",
272 "QPE/Launcher", "home()", 272 "QPE/Launcher", "home()",
273 "buttonsettings", "raise()" }, 273 "buttonsettings", "raise()" },
274 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 274 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
275 "devicebuttons/z_menu", 275 "devicebuttons/z_menu",
276 "QPE/TaskBar", "toggleMenu()", 276 "QPE/TaskBar", "toggleMenu()",
277 "QPE/TaskBar", "toggleStartMenu()" }, 277 "QPE/TaskBar", "toggleStartMenu()" },
278 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 278 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
279 "devicebuttons/z_mail", 279 "devicebuttons/z_mail",
280 "mail", "raise()", 280 "mail", "raise()",
281 "mail", "newMail()" }, 281 "mail", "newMail()" },
282}; 282};
283 283
284struct z_button z_buttons_c700 [] = { 284struct z_button z_buttons_c700 [] = {
285 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 285 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
286 "devicebuttons/z_calendar", 286 "devicebuttons/z_calendar",
287 "datebook", "nextView()", 287 "datebook", "nextView()",
288 "today", "raise()" }, 288 "today", "raise()" },
289 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 289 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
290 "devicebuttons/z_contact", 290 "devicebuttons/z_contact",
291 "addressbook", "raise()", 291 "addressbook", "raise()",
292 "addressbook", "beamBusinessCard()" }, 292 "addressbook", "beamBusinessCard()" },
293 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 293 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
294 "devicebuttons/z_home", 294 "devicebuttons/z_home",
295 "QPE/Launcher", "home()", 295 "QPE/Launcher", "home()",
296 "buttonsettings", "raise()" }, 296 "buttonsettings", "raise()" },
297 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 297 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
298 "devicebuttons/z_menu", 298 "devicebuttons/z_menu",
299 "QPE/TaskBar", "toggleMenu()", 299 "QPE/TaskBar", "toggleMenu()",
300 "QPE/TaskBar", "toggleStartMenu()" }, 300 "QPE/TaskBar", "toggleStartMenu()" },
301 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 301 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
302 "devicebuttons/z_hinge", 302 "devicebuttons/z_hinge",
303 "QPE/Rotation", "rotateDefault()", 303 "QPE/Rotation", "rotateDefault()",
304 "QPE/Dummy", "doNothing()" }, 304 "QPE/Dummy", "doNothing()" },
305}; 305};
306 306
307struct s_button { 307struct s_button {
308 uint model; 308 uint model;
309 Qt::Key code; 309 Qt::Key code;
310 char *utext; 310 char *utext;
311 char *pix; 311 char *pix;
312 char *fpressedservice; 312 char *fpressedservice;
313 char *fpressedaction; 313 char *fpressedaction;
314 char *fheldservice; 314 char *fheldservice;
315 char *fheldaction; 315 char *fheldaction;
316} simpad_buttons [] = { 316} simpad_buttons [] = {
317 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 317 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
318 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 318 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
319 "devicebuttons/simpad_lower_up", 319 "devicebuttons/simpad_lower_up",
320 "datebook", "nextView()", 320 "datebook", "nextView()",
321 "today", "raise()" }, 321 "today", "raise()" },
322 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 322 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
323 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 323 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
324 "devicebuttons/simpad_lower_down", 324 "devicebuttons/simpad_lower_down",
325 "addressbook", "raise()", 325 "addressbook", "raise()",
326 "addressbook", "beamBusinessCard()" }, 326 "addressbook", "beamBusinessCard()" },
327 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 327 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
328 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 328 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
329 "devicebuttons/simpad_lower_right", 329 "devicebuttons/simpad_lower_right",
330 "QPE/TaskBar", "toggleMenu()", 330 "QPE/TaskBar", "toggleMenu()",
331 "QPE/TaskBar", "toggleStartMenu()" }, 331 "QPE/TaskBar", "toggleStartMenu()" },
332 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 332 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
333 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 333 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
334 "devicebuttons/simpad_lower_left", 334 "devicebuttons/simpad_lower_left",
335 "mail", "raise()", 335 "mail", "raise()",
336 "mail", "newMail()" }, 336 "mail", "newMail()" },
337 337
338 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 338 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
339 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 339 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
340 "devicebuttons/simpad_upper_up", 340 "devicebuttons/simpad_upper_up",
341 "QPE/Launcher", "home()", 341 "QPE/Launcher", "home()",
342 "buttonsettings", "raise()" }, 342 "buttonsettings", "raise()" },
343 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 343 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
344 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 344 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
345 "devicebuttons/simpad_upper_down", 345 "devicebuttons/simpad_upper_down",
346 "addressbook", "raise()", 346 "addressbook", "raise()",
347 "addressbook", "beamBusinessCard()" }, 347 "addressbook", "beamBusinessCard()" },
348 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 348 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
349 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 349 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
350 "devicebuttons/simpad_upper_right", 350 "devicebuttons/simpad_upper_right",
351 "QPE/TaskBar", "toggleMenu()", 351 "QPE/TaskBar", "toggleMenu()",
352 "QPE/TaskBar", "toggleStartMenu()" }, 352 "QPE/TaskBar", "toggleStartMenu()" },
353 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 353 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
354 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 354 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
355 "devicebuttons/simpad_upper_left", 355 "devicebuttons/simpad_upper_left",
356 "QPE/Rotation", "flip()", 356 "QPE/Rotation", "flip()",
357 "QPE/Rotation", "flip()" }, 357 "QPE/Rotation", "flip()" },
358 /* 358 /*
359 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 359 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
360 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 360 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
361 "devicebuttons/simpad_lower_upper", 361 "devicebuttons/simpad_lower_upper",
362 "QPE/Launcher", "home()", 362 "QPE/Launcher", "home()",
363 "buttonsettings", "raise()" }, 363 "buttonsettings", "raise()" },
364 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 364 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
365 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 365 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
366 "devicebuttons/simpad_upper_lower", 366 "devicebuttons/simpad_upper_lower",
367 "QPE/Launcher", "home()", 367 "QPE/Launcher", "home()",
368 "buttonsettings", "raise()" }, 368 "buttonsettings", "raise()" },
369 */ 369 */
370}; 370};
371 371
372class Yopy : public ODevice { 372class Yopy : public ODevice {
373protected: 373protected:
374 virtual void init ( ); 374 virtual void init ( );
375 virtual void initButtons ( ); 375 virtual void initButtons ( );
376 376
377public: 377public:
378 virtual bool suspend ( ); 378 virtual bool suspend ( );
379 379
380 virtual bool setDisplayBrightness ( int b ); 380 virtual bool setDisplayBrightness ( int b );
381 virtual int displayBrightnessResolution ( ) const; 381 virtual int displayBrightnessResolution ( ) const;
382 382
383 static bool isYopy ( ); 383 static bool isYopy ( );
384}; 384};
385 385
386struct yopy_button { 386struct yopy_button {
387 Qt::Key code; 387 Qt::Key code;
388 char *utext; 388 char *utext;
389 char *pix; 389 char *pix;
390 char *fpressedservice; 390 char *fpressedservice;
391 char *fpressedaction; 391 char *fpressedaction;
392 char *fheldservice; 392 char *fheldservice;
393 char *fheldaction; 393 char *fheldaction;
394} yopy_buttons [] = { 394} yopy_buttons [] = {
395 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), 395 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
396 "devicebuttons/yopy_action", 396 "devicebuttons/yopy_action",
397 "datebook", "nextView()", 397 "datebook", "nextView()",
398 "today", "raise()" }, 398 "today", "raise()" },
399 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), 399 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
400 "devicebuttons/yopy_ok", 400 "devicebuttons/yopy_ok",
401 "addressbook", "raise()", 401 "addressbook", "raise()",
402 "addressbook", "beamBusinessCard()" }, 402 "addressbook", "beamBusinessCard()" },
403 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), 403 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
404 "devicebuttons/yopy_end", 404 "devicebuttons/yopy_end",
405 "QPE/Launcher", "home()", 405 "QPE/Launcher", "home()",
406 "buttonsettings", "raise()" }, 406 "buttonsettings", "raise()" },
407}; 407};
408 408
409static QCString makeChannel ( const char *str ) 409static QCString makeChannel ( const char *str )
410{ 410{
411 if ( str && !::strchr ( str, '/' )) 411 if ( str && !::strchr ( str, '/' ))
412 return QCString ( "QPE/Application/" ) + str; 412 return QCString ( "QPE/Application/" ) + str;
413 else 413 else
414 return str; 414 return str;
415} 415}
416 416
417static inline bool isQWS() 417static inline bool isQWS()
418{ 418{
419 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 419 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
420} 420}
421 421
422ODevice *ODevice::inst ( ) 422ODevice *ODevice::inst ( )
423{ 423{
424 static ODevice *dev = 0; 424 static ODevice *dev = 0;
425 425
426 if ( !dev ) { 426 if ( !dev ) {
427 if ( QFile::exists ( "/proc/hal/model" )) 427 if ( QFile::exists ( "/proc/hal/model" ))
428 dev = new iPAQ ( ); 428 dev = new iPAQ ( );
429 else if ( Zaurus::isZaurus() ) 429 else if ( Zaurus::isZaurus() )
430 dev = new Zaurus ( ); 430 dev = new Zaurus ( );
431 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 431 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
432 dev = new SIMpad ( ); 432 dev = new SIMpad ( );
433 else if ( Yopy::isYopy() ) 433 else if ( Yopy::isYopy() )
434 dev = new Yopy ( ); 434 dev = new Yopy ( );
435 else if ( Jornada::isJornada() ) 435 else if ( Jornada::isJornada() )
436 dev = new Jornada ( ); 436 dev = new Jornada ( );
437 else if ( QFile::exists ( "/proc/sys/board/sys_name" )) 437 else if ( QFile::exists ( "/proc/sys/board/sys_name" ))
438 dev = new Ramses ( ); 438 dev = new Ramses ( );
439 else 439 else
440 dev = new ODevice ( ); 440 dev = new ODevice ( );
441 dev-> init ( ); 441 dev-> init ( );
442 } 442 }
443 return dev; 443 return dev;
444} 444}
445 445
446 446
447/************************************************** 447/**************************************************
448 * 448 *
449 * common 449 * common
450 * 450 *
451 **************************************************/ 451 **************************************************/
452 452
453 453
454ODevice::ODevice ( ) 454ODevice::ODevice ( )
455{ 455{
456 d = new ODeviceData; 456 d = new ODeviceData;
457 457
458 d-> m_modelstr = "Unknown"; 458 d-> m_modelstr = "Unknown";
459 d-> m_model = Model_Unknown; 459 d-> m_model = Model_Unknown;
460 d-> m_vendorstr = "Unknown"; 460 d-> m_vendorstr = "Unknown";
461 d-> m_vendor = Vendor_Unknown; 461 d-> m_vendor = Vendor_Unknown;
462 d-> m_systemstr = "Unknown"; 462 d-> m_systemstr = "Unknown";
463 d-> m_system = System_Unknown; 463 d-> m_system = System_Unknown;
464 d-> m_sysverstr = "0.0"; 464 d-> m_sysverstr = "0.0";
465 d-> m_rotation = Rot0; 465 d-> m_rotation = Rot0;
466 d-> m_direction = CW; 466 d-> m_direction = CW;
467 467
468 d-> m_holdtime = 1000; // 1000ms 468 d-> m_holdtime = 1000; // 1000ms
469 d-> m_buttons = 0; 469 d-> m_buttons = 0;
470 d-> m_cpu_frequencies = new QStrList; 470 d-> m_cpu_frequencies = new QStrList;
471} 471}
472 472
473void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 473void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
474{ 474{
475 if ( msg == "deviceButtonMappingChanged()" ) { 475 if ( msg == "deviceButtonMappingChanged()" ) {
476 reloadButtonMapping ( ); 476 reloadButtonMapping ( );
477 } 477 }
478} 478}
479 479
480void ODevice::init ( ) 480void ODevice::init ( )
481{ 481{
482} 482}
483 483
484/** 484/**
485 * This method initialises the button mapping 485 * This method initialises the button mapping
486 */ 486 */
487void ODevice::initButtons ( ) 487void ODevice::initButtons ( )
488{ 488{
489 if ( d-> m_buttons ) 489 if ( d-> m_buttons )
490 return; 490 return;
491 491
492 // Simulation uses iPAQ 3660 device buttons 492 // Simulation uses iPAQ 3660 device buttons
493 493
494 qDebug ( "init Buttons" ); 494 qDebug ( "init Buttons" );
495 d-> m_buttons = new QValueList <ODeviceButton>; 495 d-> m_buttons = new QValueList <ODeviceButton>;
496 496
497 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 497 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
498 i_button *ib = ipaq_buttons + i; 498 i_button *ib = ipaq_buttons + i;
499 ODeviceButton b; 499 ODeviceButton b;
500 500
501 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 501 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
502 b. setKeycode ( ib-> code ); 502 b. setKeycode ( ib-> code );
503 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 503 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
504 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 504 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
505 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 505 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
506 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 506 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
507 d-> m_buttons-> append ( b ); 507 d-> m_buttons-> append ( b );
508 } 508 }
509 } 509 }
510 reloadButtonMapping ( ); 510 reloadButtonMapping ( );
511 511
512 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 512 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
513 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 513 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
514} 514}
515 515
516ODevice::~ODevice ( ) 516ODevice::~ODevice ( )
517{ 517{
518// we leak m_devicebuttons and m_cpu_frequency 518// we leak m_devicebuttons and m_cpu_frequency
519// but it's a singleton and it is not so importantant 519// but it's a singleton and it is not so importantant
520// -zecke 520// -zecke
521 delete d; 521 delete d;
522} 522}
523 523
524bool ODevice::setSoftSuspend ( bool /*soft*/ ) 524bool ODevice::setSoftSuspend ( bool /*soft*/ )
525{ 525{
526 return false; 526 return false;
527} 527}
528 528
529//#include <linux/apm_bios.h> 529//#include <linux/apm_bios.h>
530 530
531#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 531#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
532 532
533/** 533/**
534 * This method will try to suspend the device 534 * This method will try to suspend the device
535 * It only works if the user is the QWS Server and the apm application 535 * It only works if the user is the QWS Server and the apm application
536 * is installed. 536 * is installed.
537 * It tries to suspend and then waits some time cause some distributions 537 * It tries to suspend and then waits some time cause some distributions
538 * do have asynchronus apm implementations. 538 * do have asynchronus apm implementations.
539 * This method will either fail and return false or it'll suspend the 539 * This method will either fail and return false or it'll suspend the
540 * device and return once the device got woken up 540 * device and return once the device got woken up
541 * 541 *
542 * @return if the device got suspended 542 * @return if the device got suspended
543 */ 543 */
544bool ODevice::suspend ( ) 544bool ODevice::suspend ( )
545{ 545{
546 qDebug("ODevice::suspend"); 546 qDebug("ODevice::suspend");
547 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 547 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
548 return false; 548 return false;
549 549
550 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 550 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
551 return false; 551 return false;
552 552
553 bool res = false; 553 bool res = false;
554 554
555 struct timeval tvs, tvn; 555 struct timeval tvs, tvn;
556 ::gettimeofday ( &tvs, 0 ); 556 ::gettimeofday ( &tvs, 0 );
557 557
558 ::sync ( ); // flush fs caches 558 ::sync ( ); // flush fs caches
559 res = ( ::system ( "apm --suspend" ) == 0 ); 559 res = ( ::system ( "apm --suspend" ) == 0 );
560 560
561 // This is needed because the iPAQ apm implementation is asynchronous and we 561 // This is needed because the iPAQ apm implementation is asynchronous and we
562 // can not be sure when exactly the device is really suspended 562 // can not be sure when exactly the device is really suspended
563 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 563 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
564 564
565 if ( res ) { 565 if ( res ) {
566 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 566 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
567 ::usleep ( 200 * 1000 ); 567 ::usleep ( 200 * 1000 );
568 ::gettimeofday ( &tvn, 0 ); 568 ::gettimeofday ( &tvn, 0 );
569 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 569 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
570 } 570 }
571 571
572 return res; 572 return res;
573} 573}
574 574
575//#include <linux/fb.h> better not rely on kernel headers in userspace ... 575//#include <linux/fb.h> better not rely on kernel headers in userspace ...
576 576
577#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 577#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
578 578
579/* VESA Blanking Levels */ 579/* VESA Blanking Levels */
580#define VESA_NO_BLANKING 0 580#define VESA_NO_BLANKING 0
581#define VESA_VSYNC_SUSPEND 1 581#define VESA_VSYNC_SUSPEND 1
582#define VESA_HSYNC_SUSPEND 2 582#define VESA_HSYNC_SUSPEND 2
583#define VESA_POWERDOWN 3 583#define VESA_POWERDOWN 3
584 584
585/** 585/**
586 * This sets the display on or off 586 * This sets the display on or off
587 */ 587 */
588bool ODevice::setDisplayStatus ( bool on ) 588bool ODevice::setDisplayStatus ( bool on )
589{ 589{
590 qDebug("ODevice::setDisplayStatus(%d)", on); 590 qDebug("ODevice::setDisplayStatus(%d)", on);
591 591
592 if ( d-> m_model == Model_Unknown ) 592 if ( d-> m_model == Model_Unknown )
593 return false; 593 return false;
594 594
595 bool res = false; 595 bool res = false;
596 int fd; 596 int fd;
597 597
598#ifdef QT_QWS_DEVFS
599 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
600#else
598 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 601 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
602#endif
599 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 603 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
600 ::close ( fd ); 604 ::close ( fd );
601 } 605 }
602 return res; 606 return res;
603} 607}
604 608
605/** 609/**
606 * This sets the display brightness 610 * This sets the display brightness
607 * 611 *
608 * @param p The brightness to be set on a scale from 0 to 255 612 * @param p The brightness to be set on a scale from 0 to 255
609 * @return success or failure 613 * @return success or failure
610 */ 614 */
611bool ODevice::setDisplayBrightness ( int p) 615bool ODevice::setDisplayBrightness ( int p)
612{ 616{
613 Q_UNUSED( p ) 617 Q_UNUSED( p )
614 return false; 618 return false;
615} 619}
616 620
617/** 621/**
618 * @return returns the number of steppings on the brightness slider 622 * @return returns the number of steppings on the brightness slider
619 * in the Light-'n-Power settings. 623 * in the Light-'n-Power settings.
620 */ 624 */
621int ODevice::displayBrightnessResolution ( ) const 625int ODevice::displayBrightnessResolution ( ) const
622{ 626{
623 return 16; 627 return 16;
624} 628}
625 629
626/** 630/**
627 * This sets the display contrast 631 * This sets the display contrast
628 * @param p The contrast to be set on a scale from 0 to 255 632 * @param p The contrast to be set on a scale from 0 to 255
629 * @return success or failure 633 * @return success or failure
630 */ 634 */
631bool ODevice::setDisplayContrast ( int p) 635bool ODevice::setDisplayContrast ( int p)
632{ 636{
633 Q_UNUSED( p ) 637 Q_UNUSED( p )
634 return false; 638 return false;
635} 639}
636 640
637/** 641/**
638 * @return return the max value for the brightness settings slider 642 * @return return the max value for the brightness settings slider
639 * or 0 if the device doesn't support setting of a contrast 643 * or 0 if the device doesn't support setting of a contrast
640 */ 644 */
641int ODevice::displayContrastResolution ( ) const 645int ODevice::displayContrastResolution ( ) const
642{ 646{
643 return 0; 647 return 0;
644} 648}
645 649
646/** 650/**
647 * This returns the vendor as string 651 * This returns the vendor as string
648 * @return Vendor as QString 652 * @return Vendor as QString
649 */ 653 */
650QString ODevice::vendorString ( ) const 654QString ODevice::vendorString ( ) const
651{ 655{
652 return d-> m_vendorstr; 656 return d-> m_vendorstr;
653} 657}
654 658
655/** 659/**
656 * This returns the vendor as one of the values of OVendor 660 * This returns the vendor as one of the values of OVendor
657 * @return OVendor 661 * @return OVendor
658 */ 662 */
659OVendor ODevice::vendor ( ) const 663OVendor ODevice::vendor ( ) const
660{ 664{
661 return d-> m_vendor; 665 return d-> m_vendor;
662} 666}
663 667
664/** 668/**
665 * This returns the model as a string 669 * This returns the model as a string
666 * @return A string representing the model 670 * @return A string representing the model
667 */ 671 */
668QString ODevice::modelString ( ) const 672QString ODevice::modelString ( ) const
669{ 673{
670 return d-> m_modelstr; 674 return d-> m_modelstr;
671} 675}
672 676
673/** 677/**
674 * This does return the OModel used 678 * This does return the OModel used
675 */ 679 */
676OModel ODevice::model ( ) const 680OModel ODevice::model ( ) const
677{ 681{
678 return d-> m_model; 682 return d-> m_model;
679} 683}
680 684
681/** 685/**
682 * This does return the systen name 686 * This does return the systen name
683 */ 687 */
684QString ODevice::systemString ( ) const 688QString ODevice::systemString ( ) const
685{ 689{
686 return d-> m_systemstr; 690 return d-> m_systemstr;
687} 691}
688 692
689/** 693/**
690 * Return System as OSystem value 694 * Return System as OSystem value
691 */ 695 */
692OSystem ODevice::system ( ) const 696OSystem ODevice::system ( ) const
693{ 697{
694 return d-> m_system; 698 return d-> m_system;
695} 699}
696 700
697/** 701/**
698 * @return the version string of the base system 702 * @return the version string of the base system
699 */ 703 */
700QString ODevice::systemVersionString ( ) const 704QString ODevice::systemVersionString ( ) const
701{ 705{
702 return d-> m_sysverstr; 706 return d-> m_sysverstr;
703} 707}
704 708
705/** 709/**
706 * @return the current Transformation 710 * @return the current Transformation
707 */ 711 */
708Transformation ODevice::rotation ( ) const 712Transformation ODevice::rotation ( ) const
709{ 713{
710 VirtRotation rot; 714 VirtRotation rot;
711 ODevice* that =(ODevice* )this; 715 ODevice* that =(ODevice* )this;
712 that->virtual_hook( VIRTUAL_ROTATION, &rot ); 716 that->virtual_hook( VIRTUAL_ROTATION, &rot );
713 return rot.trans; 717 return rot.trans;
714} 718}
715 719
716/** 720/**
717 * @return the current rotation direction 721 * @return the current rotation direction
718 */ 722 */
719ODirection ODevice::direction ( ) const 723ODirection ODevice::direction ( ) const
720{ 724{
721 VirtDirection dir; 725 VirtDirection dir;
722 ODevice* that =(ODevice* )this; 726 ODevice* that =(ODevice* )this;
723 that->virtual_hook( VIRTUAL_DIRECTION, &dir ); 727 that->virtual_hook( VIRTUAL_DIRECTION, &dir );
724 return dir.direct; 728 return dir.direct;
725} 729}
726 730
727/** 731/**
728 * This plays an alarmSound 732 * This plays an alarmSound
729 */ 733 */
730void ODevice::alarmSound ( ) 734void ODevice::alarmSound ( )
731{ 735{
732#ifndef QT_NO_SOUND 736#ifndef QT_NO_SOUND
733 static Sound snd ( "alarm" ); 737 static Sound snd ( "alarm" );
734 738
735 if ( snd. isFinished ( )) 739 if ( snd. isFinished ( ))
736 snd. play ( ); 740 snd. play ( );
737#endif 741#endif
738} 742}
739 743
740/** 744/**
741 * This plays a key sound 745 * This plays a key sound
742 */ 746 */
743void ODevice::keySound ( ) 747void ODevice::keySound ( )
744{ 748{
745#ifndef QT_NO_SOUND 749#ifndef QT_NO_SOUND
746 static Sound snd ( "keysound" ); 750 static Sound snd ( "keysound" );
747 751
748 if ( snd. isFinished ( )) 752 if ( snd. isFinished ( ))
749 snd. play ( ); 753 snd. play ( );
750#endif 754#endif
751} 755}
752 756
753/** 757/**
754 * This plays a touch sound 758 * This plays a touch sound
755 */ 759 */
756void ODevice::touchSound ( ) 760void ODevice::touchSound ( )
757{ 761{
758#ifndef QT_NO_SOUND 762#ifndef QT_NO_SOUND
759 static Sound snd ( "touchsound" ); 763 static Sound snd ( "touchsound" );
760 764
761 if ( snd. isFinished ( )) 765 if ( snd. isFinished ( ))
762 snd. play ( ); 766 snd. play ( );
763#endif 767#endif
764} 768}
765 769
766/** 770/**
767 * This method will return a list of leds 771 * This method will return a list of leds
768 * available on this device 772 * available on this device
769 * @return a list of LEDs. 773 * @return a list of LEDs.
770 */ 774 */
771QValueList <OLed> ODevice::ledList ( ) const 775QValueList <OLed> ODevice::ledList ( ) const
772{ 776{
773 return QValueList <OLed> ( ); 777 return QValueList <OLed> ( );
774} 778}
775 779
776/** 780/**
777 * This does return the state of the LEDs 781 * This does return the state of the LEDs
778 */ 782 */
779QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 783QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
780{ 784{
781 return QValueList <OLedState> ( ); 785 return QValueList <OLedState> ( );
782} 786}
783 787
784/** 788/**
785 * @return the state for a given OLed 789 * @return the state for a given OLed
786 */ 790 */
787OLedState ODevice::ledState ( OLed /*which*/ ) const 791OLedState ODevice::ledState ( OLed /*which*/ ) const
788{ 792{
789 return Led_Off; 793 return Led_Off;
790} 794}
791 795
792/** 796/**
793 * Set the state for a LED 797 * Set the state for a LED
794 * @param which Which OLed to use 798 * @param which Which OLed to use
795 * @param st The state to set 799 * @param st The state to set
796 * @return success or failure 800 * @return success or failure
797 */ 801 */
798bool ODevice::setLedState ( OLed which, OLedState st ) 802bool ODevice::setLedState ( OLed which, OLedState st )
799{ 803{
800 Q_UNUSED( which ) 804 Q_UNUSED( which )
801 Q_UNUSED( st ) 805 Q_UNUSED( st )
802 return false; 806 return false;
803} 807}
804 808
805/** 809/**
806 * @return if the device has a light sensor 810 * @return if the device has a light sensor
807 */ 811 */
808bool ODevice::hasLightSensor ( ) const 812bool ODevice::hasLightSensor ( ) const
809{ 813{
810 return false; 814 return false;
811} 815}
812 816
813/** 817/**
814 * @return a value from the light sensor 818 * @return a value from the light sensor
815 */ 819 */
816int ODevice::readLightSensor ( ) 820int ODevice::readLightSensor ( )
817{ 821{
818 return -1; 822 return -1;
819} 823}
820 824
821/** 825/**
822 * @return the light sensor resolution 826 * @return the light sensor resolution
823 */ 827 */
824int ODevice::lightSensorResolution ( ) const 828int ODevice::lightSensorResolution ( ) const
825{ 829{
826 return 0; 830 return 0;
827} 831}
828 832
829/** 833/**
830 * @return if the device has a hinge sensor 834 * @return if the device has a hinge sensor
831 */ 835 */
832bool ODevice::hasHingeSensor ( ) const 836bool ODevice::hasHingeSensor ( ) const
833{ 837{
834 VirtHasHinge hing; 838 VirtHasHinge hing;
835 ODevice* that =(ODevice* )this; 839 ODevice* that =(ODevice* )this;
836 that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); 840 that->virtual_hook( VIRTUAL_HAS_HINGE, &hing );
837 return hing.hasHinge; 841 return hing.hasHinge;
838} 842}
839 843
840/** 844/**
841 * @return a value from the hinge sensor 845 * @return a value from the hinge sensor
842 */ 846 */
843OHingeStatus ODevice::readHingeSensor ( ) 847OHingeStatus ODevice::readHingeSensor ( )
844{ 848{
845 VirtHingeStatus hing; 849 VirtHingeStatus hing;
846 virtual_hook( VIRTUAL_HINGE, &hing ); 850 virtual_hook( VIRTUAL_HINGE, &hing );
847 return hing.hingeStat; 851 return hing.hingeStat;
848} 852}
849 853
850/** 854/**
851 * @return a list with CPU frequencies supported by the hardware 855 * @return a list with CPU frequencies supported by the hardware
852 */ 856 */
853const QStrList &ODevice::allowedCpuFrequencies ( ) const 857const QStrList &ODevice::allowedCpuFrequencies ( ) const
854{ 858{
855 return *d->m_cpu_frequencies; 859 return *d->m_cpu_frequencies;
856} 860}
857 861
858 862
859/** 863/**
860 * Set desired CPU frequency 864 * Set desired CPU frequency
861 * 865 *
862 * @param index index into d->m_cpu_frequencies of the frequency to be set 866 * @param index index into d->m_cpu_frequencies of the frequency to be set
863 */ 867 */
864bool ODevice::setCurrentCpuFrequency(uint index) 868bool ODevice::setCurrentCpuFrequency(uint index)
865{ 869{
866 if (index >= d->m_cpu_frequencies->count()) 870 if (index >= d->m_cpu_frequencies->count())
867 return false; 871 return false;
868 872
869 char *freq = d->m_cpu_frequencies->at(index); 873 char *freq = d->m_cpu_frequencies->at(index);
870 qWarning("set freq to %s", freq); 874 qWarning("set freq to %s", freq);
871 875
872 int fd; 876 int fd;
873 877
874 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 878 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
875 char writeCommand[50]; 879 char writeCommand[50];
876 const int count = sprintf(writeCommand, "%s\n", freq); 880 const int count = sprintf(writeCommand, "%s\n", freq);
877 int res = (::write(fd, writeCommand, count) != -1); 881 int res = (::write(fd, writeCommand, count) != -1);
878 ::close(fd); 882 ::close(fd);
879 return res; 883 return res;
880 } 884 }
881 885
882 return false; 886 return false;
883} 887}
884 888
885 889
886/** 890/**
887 * @return a list of hardware buttons 891 * @return a list of hardware buttons
888 */ 892 */
889const QValueList <ODeviceButton> &ODevice::buttons ( ) 893const QValueList <ODeviceButton> &ODevice::buttons ( )
890{ 894{
891 initButtons ( ); 895 initButtons ( );
892 896
893 return *d-> m_buttons; 897 return *d-> m_buttons;
894} 898}
895 899
896/** 900/**
897 * @return The amount of time that would count as a hold 901 * @return The amount of time that would count as a hold
898 */ 902 */
899uint ODevice::buttonHoldTime ( ) const 903uint ODevice::buttonHoldTime ( ) const
900{ 904{
901 return d-> m_holdtime; 905 return d-> m_holdtime;
902} 906}
903 907
904/** 908/**
905 * This method return a ODeviceButton for a key code 909 * This method return a ODeviceButton for a key code
906 * or 0 if no special hardware button is available for the device 910 * or 0 if no special hardware button is available for the device
907 * 911 *
908 * @return The devicebutton or 0l 912 * @return The devicebutton or 0l
909 * @see ODeviceButton 913 * @see ODeviceButton
910 */ 914 */
911const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 915const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
912{ 916{
913 initButtons ( ); 917 initButtons ( );
914 918
915 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 919 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
916 if ( (*it). keycode ( ) == code ) 920 if ( (*it). keycode ( ) == code )
917 return &(*it); 921 return &(*it);
918 } 922 }
919 return 0; 923 return 0;
920} 924}
921 925
922void ODevice::reloadButtonMapping ( ) 926void ODevice::reloadButtonMapping ( )
923{ 927{
924 initButtons ( ); 928 initButtons ( );
925 929
926 Config cfg ( "ButtonSettings" ); 930 Config cfg ( "ButtonSettings" );
927 931
928 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 932 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
929 ODeviceButton &b = ( *d-> m_buttons ) [i]; 933 ODeviceButton &b = ( *d-> m_buttons ) [i];
930 QString group = "Button" + QString::number ( i ); 934 QString group = "Button" + QString::number ( i );
931 935
932 QCString pch, hch; 936 QCString pch, hch;
933 QCString pm, hm; 937 QCString pm, hm;
934 QByteArray pdata, hdata; 938 QByteArray pdata, hdata;
935 939
936 if ( cfg. hasGroup ( group )) { 940 if ( cfg. hasGroup ( group )) {
937 cfg. setGroup ( group ); 941 cfg. setGroup ( group );
938 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 942 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
939 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 943 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
940 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 944 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
941 945
942 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 946 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
943 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 947 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
944 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 948 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
945 } 949 }
946 950
947 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 951 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
948 952
949 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 953 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
950 } 954 }
951} 955}
952 956
953void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 957void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
954{ 958{
955 initButtons ( ); 959 initButtons ( );
956 960
957 QString mb_chan; 961 QString mb_chan;
958 962
959 if ( button >= (int) d-> m_buttons-> count ( )) 963 if ( button >= (int) d-> m_buttons-> count ( ))
960 return; 964 return;
961 965
962 ODeviceButton &b = ( *d-> m_buttons ) [button]; 966 ODeviceButton &b = ( *d-> m_buttons ) [button];
963 b. setPressedAction ( action ); 967 b. setPressedAction ( action );
964 968
965 mb_chan=b. pressedAction ( ). channel ( ); 969 mb_chan=b. pressedAction ( ). channel ( );
966 970
967 Config buttonFile ( "ButtonSettings" ); 971 Config buttonFile ( "ButtonSettings" );
968 buttonFile. setGroup ( "Button" + QString::number ( button )); 972 buttonFile. setGroup ( "Button" + QString::number ( button ));
969 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 973 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
970 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 974 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
971 975
972 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 976 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
973 977
974 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 978 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
975} 979}
976 980
977void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 981void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
978{ 982{
979 initButtons ( ); 983 initButtons ( );
980 984
981 if ( button >= (int) d-> m_buttons-> count ( )) 985 if ( button >= (int) d-> m_buttons-> count ( ))
982 return; 986 return;