-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 280b0c5..2355621 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -226,193 +226,197 @@ void ODevice::initButtons() | |||
226 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 226 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
227 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 227 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
228 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 228 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
229 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 229 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
230 | d->m_buttons->append ( b ); | 230 | d->m_buttons->append ( b ); |
231 | } | 231 | } |
232 | 232 | ||
233 | reloadButtonMapping(); | 233 | reloadButtonMapping(); |
234 | 234 | ||
235 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 235 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
236 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 236 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
237 | } | 237 | } |
238 | 238 | ||
239 | ODevice::~ODevice() | 239 | ODevice::~ODevice() |
240 | { | 240 | { |
241 | // we leak m_devicebuttons and m_cpu_frequency | 241 | // we leak m_devicebuttons and m_cpu_frequency |
242 | // but it's a singleton and it is not so importantant | 242 | // but it's a singleton and it is not so importantant |
243 | // -zecke | 243 | // -zecke |
244 | delete d; | 244 | delete d; |
245 | } | 245 | } |
246 | 246 | ||
247 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 247 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
248 | { | 248 | { |
249 | return false; | 249 | return false; |
250 | } | 250 | } |
251 | 251 | ||
252 | //#include <linux/apm_bios.h> | 252 | //#include <linux/apm_bios.h> |
253 | 253 | ||
254 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 254 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * This method will try to suspend the device | 257 | * This method will try to suspend the device |
258 | * It only works if the user is the QWS Server and the apm application | 258 | * It only works if the user is the QWS Server and the apm application |
259 | * is installed. | 259 | * is installed. |
260 | * It tries to suspend and then waits some time cause some distributions | 260 | * It tries to suspend and then waits some time cause some distributions |
261 | * do have asynchronus apm implementations. | 261 | * do have asynchronus apm implementations. |
262 | * This method will either fail and return false or it'll suspend the | 262 | * This method will either fail and return false or it'll suspend the |
263 | * device and return once the device got woken up | 263 | * device and return once the device got woken up |
264 | * | 264 | * |
265 | * @return if the device got suspended | 265 | * @return if the device got suspended |
266 | */ | 266 | */ |
267 | bool ODevice::suspend() | 267 | bool ODevice::suspend() |
268 | { | 268 | { |
269 | qDebug("ODevice::suspend"); | 269 | qDebug("ODevice::suspend"); |
270 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 270 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
271 | return false; | 271 | return false; |
272 | 272 | ||
273 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 273 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
274 | return false; | 274 | return false; |
275 | 275 | ||
276 | bool res = false; | 276 | bool res = false; |
277 | ODevice::sendSuspendmsg(); | 277 | ODevice::sendSuspendmsg(); |
278 | 278 | ||
279 | struct timeval tvs, tvn; | 279 | struct timeval tvs, tvn; |
280 | ::gettimeofday ( &tvs, 0 ); | 280 | ::gettimeofday ( &tvs, 0 ); |
281 | 281 | ||
282 | ::sync(); // flush fs caches | 282 | ::sync(); // flush fs caches |
283 | res = ( ::system ( "apm --suspend" ) == 0 ); | 283 | res = ( ::system ( "apm --suspend" ) == 0 ); |
284 | 284 | ||
285 | // This is needed because the iPAQ apm implementation is asynchronous and we | 285 | // This is needed because the iPAQ apm implementation is asynchronous and we |
286 | // can not be sure when exactly the device is really suspended | 286 | // can not be sure when exactly the device is really suspended |
287 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 287 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
288 | 288 | ||
289 | if ( res ) { | 289 | if ( res ) { |
290 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 290 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
291 | ::usleep ( 200 * 1000 ); | 291 | ::usleep ( 200 * 1000 ); |
292 | ::gettimeofday ( &tvn, 0 ); | 292 | ::gettimeofday ( &tvn, 0 ); |
293 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 293 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
294 | } | 294 | } |
295 | 295 | ||
296 | return res; | 296 | return res; |
297 | } | 297 | } |
298 | 298 | ||
299 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 299 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
300 | 300 | ||
301 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 301 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
302 | 302 | ||
303 | /* VESA Blanking Levels */ | 303 | /* VESA Blanking Levels */ |
304 | #define VESA_NO_BLANKING 0 | 304 | #define VESA_NO_BLANKING 0 |
305 | #define VESA_VSYNC_SUSPEND 1 | 305 | #define VESA_VSYNC_SUSPEND 1 |
306 | #define VESA_HSYNC_SUSPEND 2 | 306 | #define VESA_HSYNC_SUSPEND 2 |
307 | #define VESA_POWERDOWN 3 | 307 | #define VESA_POWERDOWN 3 |
308 | 308 | ||
309 | /** | 309 | /** |
310 | * This sets the display on or off | 310 | * This sets the display on or off |
311 | */ | 311 | */ |
312 | bool ODevice::setDisplayStatus ( bool on ) | 312 | bool ODevice::setDisplayStatus ( bool on ) |
313 | { | 313 | { |
314 | qDebug("ODevice::setDisplayStatus(%d)", on); | 314 | qDebug("ODevice::setDisplayStatus(%d)", on); |
315 | 315 | ||
316 | if ( d->m_model == Model_Unknown ) | 316 | if ( d->m_model == Model_Unknown ) |
317 | return false; | 317 | return false; |
318 | 318 | ||
319 | bool res = false; | 319 | bool res = false; |
320 | int fd; | 320 | int fd; |
321 | 321 | ||
322 | #ifdef QT_QWS_DEVFS | ||
323 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | ||
324 | #else | ||
322 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 325 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
326 | #endif | ||
323 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 327 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
324 | ::close ( fd ); | 328 | ::close ( fd ); |
325 | } | 329 | } |
326 | return res; | 330 | return res; |
327 | } | 331 | } |
328 | 332 | ||
329 | /** | 333 | /** |
330 | * This sets the display brightness | 334 | * This sets the display brightness |
331 | * | 335 | * |
332 | * @param p The brightness to be set on a scale from 0 to 255 | 336 | * @param p The brightness to be set on a scale from 0 to 255 |
333 | * @return success or failure | 337 | * @return success or failure |
334 | */ | 338 | */ |
335 | bool ODevice::setDisplayBrightness ( int p) | 339 | bool ODevice::setDisplayBrightness ( int p) |
336 | { | 340 | { |
337 | Q_UNUSED( p ) | 341 | Q_UNUSED( p ) |
338 | return false; | 342 | return false; |
339 | } | 343 | } |
340 | 344 | ||
341 | /** | 345 | /** |
342 | * @return returns the number of steppings on the brightness slider | 346 | * @return returns the number of steppings on the brightness slider |
343 | * in the Light-'n-Power settings. | 347 | * in the Light-'n-Power settings. |
344 | */ | 348 | */ |
345 | int ODevice::displayBrightnessResolution() const | 349 | int ODevice::displayBrightnessResolution() const |
346 | { | 350 | { |
347 | return 16; | 351 | return 16; |
348 | } | 352 | } |
349 | 353 | ||
350 | /** | 354 | /** |
351 | * This sets the display contrast | 355 | * This sets the display contrast |
352 | * @param p The contrast to be set on a scale from 0 to 255 | 356 | * @param p The contrast to be set on a scale from 0 to 255 |
353 | * @return success or failure | 357 | * @return success or failure |
354 | */ | 358 | */ |
355 | bool ODevice::setDisplayContrast ( int p) | 359 | bool ODevice::setDisplayContrast ( int p) |
356 | { | 360 | { |
357 | Q_UNUSED( p ) | 361 | Q_UNUSED( p ) |
358 | return false; | 362 | return false; |
359 | } | 363 | } |
360 | 364 | ||
361 | /** | 365 | /** |
362 | * @return return the max value for the brightness settings slider | 366 | * @return return the max value for the brightness settings slider |
363 | * or 0 if the device doesn't support setting of a contrast | 367 | * or 0 if the device doesn't support setting of a contrast |
364 | */ | 368 | */ |
365 | int ODevice::displayContrastResolution() const | 369 | int ODevice::displayContrastResolution() const |
366 | { | 370 | { |
367 | return 0; | 371 | return 0; |
368 | } | 372 | } |
369 | 373 | ||
370 | /** | 374 | /** |
371 | * This returns the vendor as string | 375 | * This returns the vendor as string |
372 | * @return Vendor as QString | 376 | * @return Vendor as QString |
373 | */ | 377 | */ |
374 | QString ODevice::vendorString() const | 378 | QString ODevice::vendorString() const |
375 | { | 379 | { |
376 | return d->m_vendorstr; | 380 | return d->m_vendorstr; |
377 | } | 381 | } |
378 | 382 | ||
379 | /** | 383 | /** |
380 | * This returns the vendor as one of the values of OVendor | 384 | * This returns the vendor as one of the values of OVendor |
381 | * @return OVendor | 385 | * @return OVendor |
382 | */ | 386 | */ |
383 | OVendor ODevice::vendor() const | 387 | OVendor ODevice::vendor() const |
384 | { | 388 | { |
385 | return d->m_vendor; | 389 | return d->m_vendor; |
386 | } | 390 | } |
387 | 391 | ||
388 | /** | 392 | /** |
389 | * This returns the model as a string | 393 | * This returns the model as a string |
390 | * @return A string representing the model | 394 | * @return A string representing the model |
391 | */ | 395 | */ |
392 | QString ODevice::modelString() const | 396 | QString ODevice::modelString() const |
393 | { | 397 | { |
394 | return d->m_modelstr; | 398 | return d->m_modelstr; |
395 | } | 399 | } |
396 | 400 | ||
397 | /** | 401 | /** |
398 | * This does return the OModel used | 402 | * This does return the OModel used |
399 | */ | 403 | */ |
400 | OModel ODevice::model() const | 404 | OModel ODevice::model() const |
401 | { | 405 | { |
402 | return d->m_model; | 406 | return d->m_model; |
403 | } | 407 | } |
404 | 408 | ||
405 | /** | 409 | /** |
406 | * This does return the systen name | 410 | * This does return the systen name |
407 | */ | 411 | */ |
408 | QString ODevice::systemString() const | 412 | QString ODevice::systemString() const |
409 | { | 413 | { |
410 | return d->m_systemstr; | 414 | return d->m_systemstr; |
411 | } | 415 | } |
412 | 416 | ||
413 | /** | 417 | /** |
414 | * Return System as OSystem value | 418 | * Return System as OSystem value |
415 | */ | 419 | */ |
416 | OSystem ODevice::system() const | 420 | OSystem ODevice::system() const |
417 | { | 421 | { |
418 | return d->m_system; | 422 | return d->m_system; |