summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 27b0e53..f3e2cfb 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -39,74 +39,74 @@ _;:, .> :=|. This program is free software; you can
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
62 62
63using namespace Opie; 63using namespace Opie::Core;
64 64
65ODevice *ODevice::inst() 65ODevice *ODevice::inst()
66{ 66{
67 static ODevice *dev = 0; 67 static ODevice *dev = 0;
68 68
69 // rewrite this to only use /proc/cpuinfo or so 69 // rewrite this to only use /proc/cpuinfo or so
70 70
71 if ( !dev ) 71 if ( !dev )
72 { 72 {
73 QFile f( PATH_PROC_CPUINFO ); 73 QFile f( PATH_PROC_CPUINFO );
74 if ( f.open( IO_ReadOnly ) ) 74 if ( f.open( IO_ReadOnly ) )
75 { 75 {
76 QTextStream s( &f ); 76 QTextStream s( &f );
77 while ( !s.atEnd() ) 77 while ( !s.atEnd() )
78 { 78 {
79 QString line; 79 QString line;
80 line = s.readLine(); 80 line = s.readLine();
81 if ( line.startsWith( "Hardware" ) ) 81 if ( line.startsWith( "Hardware" ) )
82 { 82 {
83 qDebug( "ODevice() - found '%s'", (const char*) line ); 83 qDebug( "ODevice() - found '%s'", (const char*) line );
84 if ( line.contains( "sharp", false ) ) dev = new Zaurus(); 84 if ( line.contains( "sharp", false ) ) dev = new Private::Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new iPAQ(); 85 else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new SIMpad(); 86 else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Jornada(); 87 else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Ramses(); 88 else if ( line.contains( "ramses", false ) ) dev = new Private::Ramses();
89 else qWarning( "ODevice() - unknown hardware - using default." ); 89 else qWarning( "ODevice() - unknown hardware - using default." );
90 break; 90 break;
91 } 91 }
92 } 92 }
93 } 93 }
94 else 94 else
95 { 95 {
96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." ); 96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." );
97 } 97 }
98 if ( !dev ) dev = new ODevice(); 98 if ( !dev ) dev = new ODevice();
99 dev->init(); 99 dev->init();
100 } 100 }
101 return dev; 101 return dev;
102} 102}
103 103
104ODevice::ODevice() 104ODevice::ODevice()
105{ 105{
106 d = new ODeviceData; 106 d = new ODeviceData;
107 107
108 d->m_modelstr = "Unknown"; 108 d->m_modelstr = "Unknown";
109 d->m_model = Model_Unknown; 109 d->m_model = Model_Unknown;
110 d->m_vendorstr = "Unknown"; 110 d->m_vendorstr = "Unknown";
111 d->m_vendor = Vendor_Unknown; 111 d->m_vendor = Vendor_Unknown;
112 d->m_systemstr = "Unknown"; 112 d->m_systemstr = "Unknown";
@@ -166,49 +166,49 @@ bool ODevice::setSoftSuspend ( bool /*soft*/ )
166#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 166#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
167 167
168/** 168/**
169* This method will try to suspend the device 169* This method will try to suspend the device
170* It only works if the user is the QWS Server and the apm application 170* It only works if the user is the QWS Server and the apm application
171* is installed. 171* is installed.
172* It tries to suspend and then waits some time cause some distributions 172* It tries to suspend and then waits some time cause some distributions
173* do have asynchronus apm implementations. 173* do have asynchronus apm implementations.
174* This method will either fail and return false or it'll suspend the 174* This method will either fail and return false or it'll suspend the
175* device and return once the device got woken up 175* device and return once the device got woken up
176* 176*
177* @return if the device got suspended 177* @return if the device got suspended
178*/ 178*/
179bool ODevice::suspend() 179bool ODevice::suspend()
180{ 180{
181 qDebug("ODevice::suspend"); 181 qDebug("ODevice::suspend");
182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
183 return false; 183 return false;
184 184
185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
186 return false; 186 return false;
187 187
188 bool res = false; 188 bool res = false;
189 ODevice::sendSuspendmsg(); 189 ODevice::sendSuspendmsg();
190 190
191 struct timeval tvs, tvn; 191 struct timeval tvs, tvn;
192 ::gettimeofday ( &tvs, 0 ); 192 ::gettimeofday ( &tvs, 0 );
193 193
194 ::sync(); // flush fs caches 194 ::sync(); // flush fs caches
195 res = ( ::system ( "apm --suspend" ) == 0 ); 195 res = ( ::system ( "apm --suspend" ) == 0 );
196 196
197 // This is needed because the iPAQ apm implementation is asynchronous and we 197 // This is needed because the iPAQ apm implementation is asynchronous and we
198 // can not be sure when exactly the device is really suspended 198 // can not be sure when exactly the device is really suspended
199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
200 200
201 if ( res ) { 201 if ( res ) {
202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
203 ::usleep ( 200 * 1000 ); 203 ::usleep ( 200 * 1000 );
204 ::gettimeofday ( &tvn, 0 ); 204 ::gettimeofday ( &tvn, 0 );
205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
206 } 206 }
207 207
208 return res; 208 return res;
209} 209}
210 210
211//#include <linux/fb.h> better not rely on kernel headers in userspace ... 211//#include <linux/fb.h> better not rely on kernel headers in userspace ...
212 212
213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
214 214
@@ -603,26 +603,29 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
603{ 603{
604 initButtons(); 604 initButtons();
605 605
606 if ( button >= (int) d->m_buttons->count()) 606 if ( button >= (int) d->m_buttons->count())
607 return; 607 return;
608 608
609 ODeviceButton &b = ( *d->m_buttons ) [button]; 609 ODeviceButton &b = ( *d->m_buttons ) [button];
610 b. setHeldAction ( action ); 610 b. setHeldAction ( action );
611 611
612 Config buttonFile ( "ButtonSettings" ); 612 Config buttonFile ( "ButtonSettings" );
613 buttonFile. setGroup ( "Button" + QString::number ( button )); 613 buttonFile. setGroup ( "Button" + QString::number ( button ));
614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
616 616
617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
618 618
619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
620} 620}
621void ODevice::virtual_hook(int, void* ){ 621void ODevice::virtual_hook(int, void* ){
622 622
623} 623}
624 624
625void ODevice::sendSuspendmsg() 625void ODevice::sendSuspendmsg()
626{ 626{
627 if ( isQWS() )
628 return;
629
627 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 630 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
628} 631}