summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index e57cdef..39b37cd 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -136,724 +136,725 @@ ODevice *ODevice::inst()
136 qDebug( "ODevice() - found '%s'", (const char*) line ); 136 qDebug( "ODevice() - found '%s'", (const char*) line );
137 cpu_info = line; 137 cpu_info = line;
138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
144 else qWarning( "ODevice() - unknown hardware - using default." ); 144 else qWarning( "ODevice() - unknown hardware - using default." );
145 break; 145 break;
146 } 146 }
147 } 147 }
148 } 148 }
149 else 149 else
150 { 150 {
151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
152 } 152 }
153 if ( !dev ) dev = new ODevice(); 153 if ( !dev ) dev = new ODevice();
154 dev->init(cpu_info); 154 dev->init(cpu_info);
155 } 155 }
156 return dev; 156 return dev;
157} 157}
158 158
159ODevice::ODevice() 159ODevice::ODevice()
160{ 160{
161 d = new ODeviceData; 161 d = new ODeviceData;
162 162
163 d->m_modelstr = "Unknown"; 163 d->m_modelstr = "Unknown";
164 d->m_model = Model_Unknown; 164 d->m_model = Model_Unknown;
165 d->m_vendorstr = "Unknown"; 165 d->m_vendorstr = "Unknown";
166 d->m_vendor = Vendor_Unknown; 166 d->m_vendor = Vendor_Unknown;
167 d->m_systemstr = "Unknown"; 167 d->m_systemstr = "Unknown";
168 d->m_system = System_Unknown; 168 d->m_system = System_Unknown;
169 d->m_sysverstr = "0.0"; 169 d->m_sysverstr = "0.0";
170 d->m_rotation = Rot0; 170 d->m_rotation = Rot0;
171 d->m_direction = CW; 171 d->m_direction = CW;
172 172
173 d->m_holdtime = 1000; // 1000ms 173 d->m_holdtime = 1000; // 1000ms
174 d->m_buttons = 0; 174 d->m_buttons = 0;
175 d->m_cpu_frequencies = new QStrList; 175 d->m_cpu_frequencies = new QStrList;
176 176
177 177
178 /* mixer */ 178 /* mixer */
179 d->m_sound = d->m_vol = d->m_mixer = -1; 179 d->m_sound = d->m_vol = d->m_mixer = -1;
180 180
181 /* System QCopChannel created */ 181 /* System QCopChannel created */
182 d->m_initializedButtonQcop = false; 182 d->m_initializedButtonQcop = false;
183 183
184 // New distribution detection code first checks for legacy distributions, 184 // New distribution detection code first checks for legacy distributions,
185 // identified by /etc/familiar-version or /etc/oz_version. 185 // identified by /etc/familiar-version or /etc/oz_version.
186 // Then check for OpenEmbedded and lastly, read /etc/issue 186 // Then check for OpenEmbedded and lastly, read /etc/issue
187 187
188 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 188 for ( unsigned int i = 0; i < sizeof distributions; ++i )
189 { 189 {
190 if ( QFile::exists( distributions[i].sysvfile ) ) 190 if ( QFile::exists( distributions[i].sysvfile ) )
191 { 191 {
192 d->m_systemstr = distributions[i].sysstr; 192 d->m_systemstr = distributions[i].sysstr;
193 d->m_system = distributions[i].system; 193 d->m_system = distributions[i].system;
194 d->m_sysverstr = "<Unknown>"; 194 d->m_sysverstr = "<Unknown>";
195 QFile f( distributions[i].sysvfile ); 195 QFile f( distributions[i].sysvfile );
196 if ( f.open( IO_ReadOnly ) ) 196 if ( f.open( IO_ReadOnly ) )
197 { 197 {
198 QTextStream ts( &f ); 198 QTextStream ts( &f );
199 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 199 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
200 } 200 }
201 break; 201 break;
202 } 202 }
203 } 203 }
204} 204}
205 205
206void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 206void ODevice::systemMessage( const QCString &msg, const QByteArray & )
207{ 207{
208 if ( msg == "deviceButtonMappingChanged()" ) { 208 if ( msg == "deviceButtonMappingChanged()" ) {
209 reloadButtonMapping(); 209 reloadButtonMapping();
210 } 210 }
211} 211}
212 212
213void ODevice::init(const QString&) 213void ODevice::init(const QString&)
214{ 214{
215} 215}
216 216
217/** 217/**
218* This method initialises the button mapping 218* This method initialises the button mapping
219*/ 219*/
220void ODevice::initButtons() 220void ODevice::initButtons()
221{ 221{
222 if ( d->m_buttons ) 222 if ( d->m_buttons )
223 return; 223 return;
224 224
225 qDebug ( "init Buttons" ); 225 qDebug ( "init Buttons" );
226 d->m_buttons = new QValueList <ODeviceButton>; 226 d->m_buttons = new QValueList <ODeviceButton>;
227 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 227 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
228 default_button *db = default_buttons + i; 228 default_button *db = default_buttons + i;
229 ODeviceButton b; 229 ODeviceButton b;
230 b. setKeycode ( db->code ); 230 b. setKeycode ( db->code );
231 b. setUserText ( QObject::tr ( "Button", db->utext )); 231 b. setUserText ( QObject::tr ( "Button", db->utext ));
232 b. setPixmap ( Resource::loadPixmap ( db->pix )); 232 b. setPixmap ( Resource::loadPixmap ( db->pix ));
233 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 233 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
235 d->m_buttons->append ( b ); 235 d->m_buttons->append ( b );
236 } 236 }
237 237
238 reloadButtonMapping(); 238 reloadButtonMapping();
239} 239}
240 240
241ODevice::~ODevice() 241ODevice::~ODevice()
242{ 242{
243// we leak m_devicebuttons and m_cpu_frequency 243// we leak m_devicebuttons and m_cpu_frequency
244// but it's a singleton and it is not so importantant 244// but it's a singleton and it is not so importantant
245// -zecke 245// -zecke
246 delete d; 246 delete d;
247} 247}
248 248
249bool ODevice::setSoftSuspend ( bool /*soft*/ ) 249bool ODevice::setSoftSuspend ( bool /*soft*/ )
250{ 250{
251 return false; 251 return false;
252} 252}
253 253
254//#include <linux/apm_bios.h> 254//#include <linux/apm_bios.h>
255 255
256#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 256#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
257 257
258/** 258/**
259* This method will try to suspend the device 259* This method will try to suspend the device
260* It only works if the user is the QWS Server and the apm application 260* It only works if the user is the QWS Server and the apm application
261* is installed. 261* is installed.
262* It tries to suspend and then waits some time cause some distributions 262* It tries to suspend and then waits some time cause some distributions
263* do have asynchronus apm implementations. 263* do have asynchronus apm implementations.
264* This method will either fail and return false or it'll suspend the 264* This method will either fail and return false or it'll suspend the
265* device and return once the device got woken up 265* device and return once the device got woken up
266* 266*
267* @return if the device got suspended 267* @return if the device got suspended
268*/ 268*/
269bool ODevice::suspend() 269bool ODevice::suspend()
270{ 270{
271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
272 return false; 272 return false;
273 273
274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
275 return false; 275 return false;
276 276
277 bool res = false; 277 bool res = false;
278 ODevice::sendSuspendmsg(); 278 ODevice::sendSuspendmsg();
279 279
280 struct timeval tvs, tvn; 280 struct timeval tvs, tvn;
281 ::gettimeofday ( &tvs, 0 ); 281 ::gettimeofday ( &tvs, 0 );
282 282
283 ::sync(); // flush fs caches 283 ::sync(); // flush fs caches
284 res = ( ::system ( "apm --suspend" ) == 0 ); 284 res = ( ::system ( "apm --suspend" ) == 0 );
285 285
286 // This is needed because the iPAQ apm implementation is asynchronous and we 286 // This is needed because the iPAQ apm implementation is asynchronous and we
287 // can not be sure when exactly the device is really suspended 287 // can not be sure when exactly the device is really suspended
288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
289 289
290 if ( res ) { 290 if ( res ) {
291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
292 ::usleep ( 200 * 1000 ); 292 ::usleep ( 200 * 1000 );
293 ::gettimeofday ( &tvn, 0 ); 293 ::gettimeofday ( &tvn, 0 );
294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
295 } 295 }
296 296
297 return res; 297 return res;
298} 298}
299 299
300//#include <linux/fb.h> better not rely on kernel headers in userspace ... 300//#include <linux/fb.h> better not rely on kernel headers in userspace ...
301 301
302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
303 303
304/* VESA Blanking Levels */ 304/* VESA Blanking Levels */
305#define VESA_NO_BLANKING 0 305#define VESA_NO_BLANKING 0
306#define VESA_VSYNC_SUSPEND 1 306#define VESA_VSYNC_SUSPEND 1
307#define VESA_HSYNC_SUSPEND 2 307#define VESA_HSYNC_SUSPEND 2
308#define VESA_POWERDOWN 3 308#define VESA_POWERDOWN 3
309 309
310/** 310/**
311* This sets the display on or off 311* This sets the display on or off
312*/ 312*/
313bool ODevice::setDisplayStatus ( bool on ) 313bool ODevice::setDisplayStatus ( bool on )
314{ 314{
315 qDebug("ODevice::setDisplayStatus(%d)", on); 315 qDebug("ODevice::setDisplayStatus(%d)", on);
316 316
317 if ( d->m_model == Model_Unknown ) 317 if ( d->m_model == Model_Unknown )
318 return false; 318 return false;
319 319
320 bool res = false; 320 bool res = false;
321 int fd; 321 int fd;
322 322
323#ifdef QT_QWS_DEVFS 323#ifdef QT_QWS_DEVFS
324 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { 324 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
325#else 325#else
326 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 326 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
327#endif 327#endif
328 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 328 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
329 ::close ( fd ); 329 ::close ( fd );
330 } 330 }
331 return res; 331 return res;
332} 332}
333 333
334/** 334/**
335* This sets the display brightness 335* This sets the display brightness
336* 336*
337* @param b The brightness to be set on a scale from 0 to 255 337* @param b The brightness to be set on a scale from 0 to 255
338* @return success or failure 338* @return success or failure
339*/ 339*/
340bool ODevice::setDisplayBrightness ( int b) 340bool ODevice::setDisplayBrightness ( int b)
341{ 341{
342 Q_UNUSED( b ) 342 Q_UNUSED( b )
343 return false; 343 return false;
344} 344}
345 345
346/** 346/**
347 * 347 *
348 * @return Returns the number of steppings on the brightness slider 348 * @return Returns the number of steppings on the brightness slider
349 * in the Light-'n-Power settings. Values smaller zero and bigger 349 * in the Light-'n-Power settings. Values smaller zero and bigger
350 * than 255 do not make sense. 350 * than 255 do not make sense.
351 * 351 *
352 * \sa QSlider::setLineStep 352 * \sa QSlider::setLineStep
353 * \sa QSlider::setPageStep 353 * \sa QSlider::setPageStep
354 */ 354 */
355int ODevice::displayBrightnessResolution() const 355int ODevice::displayBrightnessResolution() const
356{ 356{
357 return 16; 357 return 16;
358} 358}
359 359
360/** 360/**
361* This sets the display contrast 361* This sets the display contrast
362* @param p The contrast to be set on a scale from 0 to 255 362* @param p The contrast to be set on a scale from 0 to 255
363* @return success or failure 363* @return success or failure
364*/ 364*/
365bool ODevice::setDisplayContrast ( int p) 365bool ODevice::setDisplayContrast ( int p)
366{ 366{
367 Q_UNUSED( p ) 367 Q_UNUSED( p )
368 return false; 368 return false;
369} 369}
370 370
371/** 371/**
372* @return return the max value for the brightness settings slider 372* @return return the max value for the brightness settings slider
373* or 0 if the device doesn't support setting of a contrast 373* or 0 if the device doesn't support setting of a contrast
374*/ 374*/
375int ODevice::displayContrastResolution() const 375int ODevice::displayContrastResolution() const
376{ 376{
377 return 0; 377 return 0;
378} 378}
379 379
380/** 380/**
381* This returns the vendor as string 381* This returns the vendor as string
382* @return Vendor as QString 382* @return Vendor as QString
383*/ 383*/
384QString ODevice::vendorString() const 384QString ODevice::vendorString() const
385{ 385{
386 return d->m_vendorstr; 386 return d->m_vendorstr;
387} 387}
388 388
389/** 389/**
390* This returns the vendor as one of the values of OVendor 390* This returns the vendor as one of the values of OVendor
391* @return OVendor 391* @return OVendor
392*/ 392*/
393OVendor ODevice::vendor() const 393OVendor ODevice::vendor() const
394{ 394{
395 return d->m_vendor; 395 return d->m_vendor;
396} 396}
397 397
398/** 398/**
399* This returns the model as a string 399* This returns the model as a string
400* @return A string representing the model 400* @return A string representing the model
401*/ 401*/
402QString ODevice::modelString() const 402QString ODevice::modelString() const
403{ 403{
404 return d->m_modelstr; 404 return d->m_modelstr;
405} 405}
406 406
407/** 407/**
408* This does return the OModel used 408* This does return the OModel used
409*/ 409*/
410OModel ODevice::model() const 410OModel ODevice::model() const
411{ 411{
412 return d->m_model; 412 return d->m_model;
413} 413}
414 414
415/** 415/**
416* This does return the systen name 416* This does return the systen name
417*/ 417*/
418QString ODevice::systemString() const 418QString ODevice::systemString() const
419{ 419{
420 return d->m_systemstr; 420 return d->m_systemstr;
421} 421}
422 422
423/** 423/**
424* Return System as OSystem value 424* Return System as OSystem value
425*/ 425*/
426OSystem ODevice::system() const 426OSystem ODevice::system() const
427{ 427{
428 return d->m_system; 428 return d->m_system;
429} 429}
430 430
431/** 431/**
432* @return the version string of the base system 432* @return the version string of the base system
433*/ 433*/
434QString ODevice::systemVersionString() const 434QString ODevice::systemVersionString() const
435{ 435{
436 return d->m_sysverstr; 436 return d->m_sysverstr;
437} 437}
438 438
439/** 439/**
440* @return the current Transformation 440* @return the current Transformation
441*/ 441*/
442Transformation ODevice::rotation() const 442Transformation ODevice::rotation() const
443{ 443{
444 return d->m_rotation; 444 return d->m_rotation;
445} 445}
446 446
447/** 447/**
448* @return the current rotation direction 448* @return the current rotation direction
449*/ 449*/
450ODirection ODevice::direction() const 450ODirection ODevice::direction() const
451{ 451{
452 return d->m_direction; 452 return d->m_direction;
453} 453}
454 454
455/** 455/**
456* This plays an alarm sound 456* This plays an alarm sound
457*/ 457*/
458void ODevice::playAlarmSound() 458void ODevice::playAlarmSound()
459{ 459{
460#ifndef QT_NO_SOUND 460#ifndef QT_NO_SOUND
461 static Sound snd ( "alarm" ); 461 static Sound snd ( "alarm" );
462 462
463 if ( snd. isFinished()) 463 if ( snd. isFinished())
464 snd. play(); 464 snd. play();
465#endif 465#endif
466} 466}
467 467
468/** 468/**
469* This plays a key sound 469* This plays a key sound
470*/ 470*/
471void ODevice::playKeySound() 471void ODevice::playKeySound()
472{ 472{
473#ifndef QT_NO_SOUND 473#ifndef QT_NO_SOUND
474 static Sound snd ( "keysound" ); 474 static Sound snd ( "keysound" );
475 475
476 if ( snd. isFinished()) 476 if ( snd. isFinished())
477 snd. play(); 477 snd. play();
478#endif 478#endif
479} 479}
480 480
481/** 481/**
482* This plays a touch sound 482* This plays a touch sound
483*/ 483*/
484void ODevice::playTouchSound() 484void ODevice::playTouchSound()
485{ 485{
486#ifndef QT_NO_SOUND 486#ifndef QT_NO_SOUND
487 static Sound snd ( "touchsound" ); 487 static Sound snd ( "touchsound" );
488 488
489 if ( snd. isFinished()) 489 if ( snd. isFinished())
490 snd. play(); 490 snd. play();
491#endif 491#endif
492} 492}
493 493
494/** 494/**
495* This method will return a list of leds 495* This method will return a list of leds
496* available on this device 496* available on this device
497* @return a list of LEDs. 497* @return a list of LEDs.
498*/ 498*/
499QValueList <OLed> ODevice::ledList() const 499QValueList <OLed> ODevice::ledList() const
500{ 500{
501 return QValueList <OLed>(); 501 return QValueList <OLed>();
502} 502}
503 503
504/** 504/**
505* This does return the state of the LEDs 505* This does return the state of the LEDs
506*/ 506*/
507QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 507QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
508{ 508{
509 return QValueList <OLedState>(); 509 return QValueList <OLedState>();
510} 510}
511 511
512/** 512/**
513* @return the state for a given OLed 513* @return the state for a given OLed
514*/ 514*/
515OLedState ODevice::ledState ( OLed /*which*/ ) const 515OLedState ODevice::ledState ( OLed /*which*/ ) const
516{ 516{
517 return Led_Off; 517 return Led_Off;
518} 518}
519 519
520/** 520/**
521* Set the state for a LED 521* Set the state for a LED
522* @param which Which OLed to use 522* @param which Which OLed to use
523* @param st The state to set 523* @param st The state to set
524* @return success or failure 524* @return success or failure
525*/ 525*/
526bool ODevice::setLedState ( OLed which, OLedState st ) 526bool ODevice::setLedState ( OLed which, OLedState st )
527{ 527{
528 Q_UNUSED( which ) 528 Q_UNUSED( which )
529 Q_UNUSED( st ) 529 Q_UNUSED( st )
530 return false; 530 return false;
531} 531}
532 532
533/** 533/**
534* @return if the device has a light sensor 534* @return if the device has a light sensor
535*/ 535*/
536bool ODevice::hasLightSensor() const 536bool ODevice::hasLightSensor() const
537{ 537{
538 return false; 538 return false;
539} 539}
540 540
541/** 541/**
542* @return a value from the light sensor 542* @return a value from the light sensor
543*/ 543*/
544int ODevice::readLightSensor() 544int ODevice::readLightSensor()
545{ 545{
546 return -1; 546 return -1;
547} 547}
548 548
549/** 549/**
550* @return the light sensor resolution 550* @return the light sensor resolution
551*/ 551*/
552int ODevice::lightSensorResolution() const 552int ODevice::lightSensorResolution() const
553{ 553{
554 return 0; 554 return 0;
555} 555}
556 556
557/** 557/**
558* @return if the device has a hinge sensor 558* @return if the device has a hinge sensor
559*/ 559*/
560bool ODevice::hasHingeSensor() const 560bool ODevice::hasHingeSensor() const
561{ 561{
562 return false; 562 return false;
563} 563}
564 564
565/** 565/**
566* @return a value from the hinge sensor 566* @return a value from the hinge sensor
567*/ 567*/
568OHingeStatus ODevice::readHingeSensor() 568OHingeStatus ODevice::readHingeSensor()
569{ 569{
570 return CASE_UNKNOWN; 570 return CASE_UNKNOWN;
571} 571}
572 572
573/** 573/**
574* @return a list with CPU frequencies supported by the hardware 574* @return a list with CPU frequencies supported by the hardware
575*/ 575*/
576const QStrList &ODevice::allowedCpuFrequencies() const 576const QStrList &ODevice::allowedCpuFrequencies() const
577{ 577{
578 return *d->m_cpu_frequencies; 578 return *d->m_cpu_frequencies;
579} 579}
580 580
581 581
582/** 582/**
583* Set desired CPU frequency 583* Set desired CPU frequency
584* 584*
585* @param index index into d->m_cpu_frequencies of the frequency to be set 585* @param index index into d->m_cpu_frequencies of the frequency to be set
586*/ 586*/
587bool ODevice::setCurrentCpuFrequency(uint index) 587bool ODevice::setCurrentCpuFrequency(uint index)
588{ 588{
589 if (index >= d->m_cpu_frequencies->count()) 589 if (index >= d->m_cpu_frequencies->count())
590 return false; 590 return false;
591 591
592 char *freq = d->m_cpu_frequencies->at(index); 592 char *freq = d->m_cpu_frequencies->at(index);
593 qWarning("set freq to %s", freq); 593 qWarning("set freq to %s", freq);
594 594
595 int fd; 595 int fd;
596 596
597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
598 char writeCommand[50]; 598 char writeCommand[50];
599 const int count = sprintf(writeCommand, "%s\n", freq); 599 const int count = sprintf(writeCommand, "%s\n", freq);
600 int res = (::write(fd, writeCommand, count) != -1); 600 int res = (::write(fd, writeCommand, count) != -1);
601 ::close(fd); 601 ::close(fd);
602 return res; 602 return res;
603 } 603 }
604 604
605 return false; 605 return false;
606} 606}
607 607
608 608
609/** 609/**
610* @return a list of hardware buttons 610* @return a list of hardware buttons
611*/ 611*/
612const QValueList <ODeviceButton> &ODevice::buttons() 612const QValueList <ODeviceButton> &ODevice::buttons()
613{ 613{
614 initButtons(); 614 initButtons();
615 615
616 return *d->m_buttons; 616 return *d->m_buttons;
617} 617}
618 618
619/** 619/**
620* @return The amount of time that would count as a hold 620* @return The amount of time that would count as a hold
621*/ 621*/
622uint ODevice::buttonHoldTime() const 622uint ODevice::buttonHoldTime() const
623{ 623{
624 return d->m_holdtime; 624 return d->m_holdtime;
625} 625}
626 626
627/** 627/**
628* This method return a ODeviceButton for a key code 628* This method return a ODeviceButton for a key code
629* or 0 if no special hardware button is available for the device 629* or 0 if no special hardware button is available for the device
630* 630*
631* @return The devicebutton or 0l 631* @return The devicebutton or 0l
632* @see ODeviceButton 632* @see ODeviceButton
633*/ 633*/
634const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 634const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
635{ 635{
636 initButtons(); 636 initButtons();
637 637
638 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 638 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
639 if ( (*it). keycode() == code ) 639 if ( (*it). keycode() == code )
640 return &(*it); 640 return &(*it);
641 } 641 }
642 return 0; 642 return 0;
643} 643}
644 644
645void ODevice::reloadButtonMapping() 645void ODevice::reloadButtonMapping()
646{ 646{
647 if(!d->m_buttons) 647 if(!d->m_buttons)
648 initButtons(); 648 initButtons();
649 649
650 if(!d->m_initializedButtonQcop) { 650 if(!d->m_initializedButtonQcop) {
651 connect(qApp,SIGNAL(systemMessageSignal(const QCString&,const QByteArray&)), 651 QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel");
652 connect(chan,SIGNAL(received(const QCString&,const QByteArray&)),
652 this,SLOT(systemMessage(const QCString&,const QByteArray&))); 653 this,SLOT(systemMessage(const QCString&,const QByteArray&)));
653 d->m_initializedButtonQcop = true; 654 d->m_initializedButtonQcop = true;
654 } 655 }
655 656
656 Config cfg ( "ButtonSettings" ); 657 Config cfg ( "ButtonSettings" );
657 658
658 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 659 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
659 ODeviceButton &b = ( *d->m_buttons ) [i]; 660 ODeviceButton &b = ( *d->m_buttons ) [i];
660 QString group = "Button" + QString::number ( i ); 661 QString group = "Button" + QString::number ( i );
661 662
662 QCString pch, hch; 663 QCString pch, hch;
663 QCString pm, hm; 664 QCString pm, hm;
664 QByteArray pdata, hdata; 665 QByteArray pdata, hdata;
665 666
666 if ( cfg. hasGroup ( group )) { 667 if ( cfg. hasGroup ( group )) {
667 cfg. setGroup ( group ); 668 cfg. setGroup ( group );
668 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 669 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
669 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 670 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
670 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 671 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
671 672
672 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 673 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
673 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 674 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
674 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 675 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
675 } 676 }
676 677
677 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 678 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
678 679
679 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 680 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
680 } 681 }
681} 682}
682 683
683void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 684void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
684{ 685{
685 initButtons(); 686 initButtons();
686 687
687 QString mb_chan; 688 QString mb_chan;
688 689
689 if ( button >= (int) d->m_buttons->count()) 690 if ( button >= (int) d->m_buttons->count())
690 return; 691 return;
691 692
692 ODeviceButton &b = ( *d->m_buttons ) [button]; 693 ODeviceButton &b = ( *d->m_buttons ) [button];
693 b. setPressedAction ( action ); 694 b. setPressedAction ( action );
694 695
695 mb_chan=b. pressedAction(). channel(); 696 mb_chan=b. pressedAction(). channel();
696 697
697 Config buttonFile ( "ButtonSettings" ); 698 Config buttonFile ( "ButtonSettings" );
698 buttonFile. setGroup ( "Button" + QString::number ( button )); 699 buttonFile. setGroup ( "Button" + QString::number ( button ));
699 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 700 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
700 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 701 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
701 702
702// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 703// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
703 704
704 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 705 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
705} 706}
706 707
707void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 708void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
708{ 709{
709 initButtons(); 710 initButtons();
710 711
711 if ( button >= (int) d->m_buttons->count()) 712 if ( button >= (int) d->m_buttons->count())
712 return; 713 return;
713 714
714 ODeviceButton &b = ( *d->m_buttons ) [button]; 715 ODeviceButton &b = ( *d->m_buttons ) [button];
715 b. setHeldAction ( action ); 716 b. setHeldAction ( action );
716 717
717 Config buttonFile ( "ButtonSettings" ); 718 Config buttonFile ( "ButtonSettings" );
718 buttonFile. setGroup ( "Button" + QString::number ( button )); 719 buttonFile. setGroup ( "Button" + QString::number ( button ));
719 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 720 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
720 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 721 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
721 722
722// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 723// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
723 724
724 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 725 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
725} 726}
726 727
727/** 728/**
728 * @internal 729 * @internal
729 */ 730 */
730void ODevice::virtual_hook(int, void* ){ 731void ODevice::virtual_hook(int, void* ){
731 732
732} 733}
733 734
734/** 735/**
735 * \brief Send a QCOP Message before suspending 736 * \brief Send a QCOP Message before suspending
736 * 737 *
737 * Sends a QCOP message to channel QPE/System 738 * Sends a QCOP message to channel QPE/System
738 * with the message "aboutToSuspend()" if this 739 * with the message "aboutToSuspend()" if this
739 * is the windowing server. 740 * is the windowing server.
740 * 741 *
741 * Call this in your custom \sa suspend() Method 742 * Call this in your custom \sa suspend() Method
742 * before going to suspend. 743 * before going to suspend.
743 * 744 *
744 */ 745 */
745void ODevice::sendSuspendmsg() 746void ODevice::sendSuspendmsg()
746{ 747{
747 if ( isQWS() ) 748 if ( isQWS() )
748 return; 749 return;
749 750
750 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 751 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
751} 752}
752 753
753/** 754/**
754 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters 755 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
755 * 756 *
756 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard 757 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
757 * Filters. This function is the only way to prepend a KeyFilter. 758 * Filters. This function is the only way to prepend a KeyFilter.
758 * 759 *
759 * @param aFilter The KeyFilter to be prepended to the list of filters 760 * @param aFilter The KeyFilter to be prepended to the list of filters
760 * 761 *
761 * @see Opie::Core::OKeyFilter 762 * @see Opie::Core::OKeyFilter
762 * @see Opie::Core::OKeyFilter::inst() 763 * @see Opie::Core::OKeyFilter::inst()
763 */ 764 */
764void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 765void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
765{ 766{
766 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 767 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
767} 768}
768 769
769/** 770/**
770 * \brief Remove the QWSServer::KeyboardFilter in the param from the list 771 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
771 * 772 *
772 * Remove the QWSServer::KeyboardFilter \par aFilter from the List 773 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
773 * of Keyfilters. Call this when you delete the KeyFilter! 774 * of Keyfilters. Call this when you delete the KeyFilter!
774 * 775 *
775 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter 776 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
776 * @see Opie::Core::ODevice::addPreHandler 777 * @see Opie::Core::ODevice::addPreHandler
777 */ 778 */
778void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 779void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
779{ 780{
780 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 781 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
781} 782}
782 783
783 784
784/** 785/**
785 * @internal 786 * @internal
786 * 787 *
787 * @see changeMixerForAlarm 788 * @see changeMixerForAlarm
788 */ 789 */
789void ODevice::playingStopped() { 790void ODevice::playingStopped() {
790 if ( sender() ) 791 if ( sender() )
791 const_cast<QObject*>(sender())->disconnect( this ); 792 const_cast<QObject*>(sender())->disconnect( this );
792 793
793#ifndef QT_NO_SOUND 794#ifndef QT_NO_SOUND
794 if ( d->m_sound >= 0 ) { 795 if ( d->m_sound >= 0 ) {
795 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); 796 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
796 ::close ( d->m_sound ); 797 ::close ( d->m_sound );
797 } 798 }
798#endif 799#endif
799} 800}
800 801
801 802
802/** 803/**
803 * \brief Change the Volume for the Alarm and set it back after playing is finished 804 * \brief Change the Volume for the Alarm and set it back after playing is finished
804 * 805 *
805 * If you play an Alarm Sound you might want to change the Mixer to 806 * If you play an Alarm Sound you might want to change the Mixer to
806 * full volume and ignore the user setting. After it \sa Sound::isFinished 807 * full volume and ignore the user setting. After it \sa Sound::isFinished
807 * you would turn the volume back to the user preference. 808 * you would turn the volume back to the user preference.
808 * The problem is that we used to enter the event loop while waiting 809 * The problem is that we used to enter the event loop while waiting
809 * for the sound to be finished triggering all kind of reentrance 810 * for the sound to be finished triggering all kind of reentrance
810 * problems what a library shouldn't introduce. 811 * problems what a library shouldn't introduce.
811 * Instead of manually waiting for the sound to be finished use 812 * Instead of manually waiting for the sound to be finished use
812 * this Method and it will automatically restore the Mixer to 813 * this Method and it will automatically restore the Mixer to
813 * the user configuration after the sound finished playing. 814 * the user configuration after the sound finished playing.
814 * 815 *
815 * Note: The onwership of \param snd is not transfered and playing 816 * Note: The onwership of \param snd is not transfered and playing
816 * is not started in this method. If 'snd' gets deleted before 817 * is not started in this method. If 'snd' gets deleted before
817 * playing is finished the volume doesn't get set back to 818 * playing is finished the volume doesn't get set back to
818 * the user preference! 819 * the user preference!
819 * 820 *
820 * \code 821 * \code
821 * static Sound snd("alarm"); 822 * static Sound snd("alarm");
822 * if(!snd.isFinished()) 823 * if(!snd.isFinished())
823 * return; 824 * return;
824 * 825 *
825 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); 826 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd );
826 * snd.play() 827 * snd.play()
827 * \endcode 828 * \endcode
828 * 829 *
829 * 830 *
830 * 831 *
831 * @param mixer The mixer number/channel to use 832 * @param mixer The mixer number/channel to use
832 * @param file The file name. If you convert from QString use QFile::encodeName 833 * @param file The file name. If you convert from QString use QFile::encodeName
833 * @param snd The sound to wait for finishing 834 * @param snd The sound to wait for finishing
834 * 835 *
835 */ 836 */
836void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { 837void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
837#ifndef QT_NO_SOUND 838#ifndef QT_NO_SOUND
838 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { 839 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
839 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { 840 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
840 Config cfg ( "qpe" ); 841 Config cfg ( "qpe" );
841 cfg. setGroup ( "Volume" ); 842 cfg. setGroup ( "Volume" );
842 843
843 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 844 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
844 if ( volalarm < 0 ) 845 if ( volalarm < 0 )
845 volalarm = 0; 846 volalarm = 0;
846 else if ( volalarm > 100 ) 847 else if ( volalarm > 100 )
847 volalarm = 100; 848 volalarm = 100;
848 volalarm |= ( volalarm << 8 ); 849 volalarm |= ( volalarm << 8 );
849 850
850 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) 851 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
851 register_qpe_sound_finished(snd, this, SLOT(playingStopped())); 852 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
852 } 853 }
853 d->m_mixer = mixer; 854 d->m_mixer = mixer;
854 } 855 }
855#endif 856#endif
856} 857}
857 858
858} 859}
859} 860}