summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 501b601..62e3569 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -47,26 +47,24 @@
#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
#define OD_IO(type,number) OD_IOC(0,type,number,0)
#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
using namespace Opie;
class ODeviceData {
public:
- bool m_qwsserver : 1;
-
QString m_vendorstr;
OVendor m_vendor;
QString m_modelstr;
OModel m_model;
QString m_systemstr;
OSystem m_system;
QString m_sysverstr;
Transformation m_rotation;
@@ -230,26 +228,28 @@ struct z_button z_buttons_c700 [] = {
"QPE/Rotation", "flip()",
"QPE/Rotation", "flip()" },
};
static QCString makeChannel ( const char *str )
{
if ( str && !::strchr ( str, '/' ))
return QCString ( "QPE/Application/" ) + str;
else
return str;
}
-
-
+static inline bool isQWS()
+{
+ return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
+}
ODevice *ODevice::inst ( )
{
static ODevice *dev = 0;
if ( !dev ) {
if ( QFile::exists ( "/proc/hal/model" ))
dev = new iPAQ ( );
else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
dev = new Zaurus ( );
else
dev = new ODevice ( );
@@ -262,26 +262,24 @@ ODevice *ODevice::inst ( )
/**************************************************
*
* common
*
**************************************************/
ODevice::ODevice ( )
{
d = new ODeviceData;
- d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
-
d-> m_modelstr = "Unknown";
d-> m_model = Model_Unknown;
d-> m_vendorstr = "Unknown";
d-> m_vendor = Vendor_Unknown;
d-> m_systemstr = "Unknown";
d-> m_system = System_Unknown;
d-> m_sysverstr = "0.0";
d-> m_rotation = Rot0;
d-> m_direction = CW;
d-> m_holdtime = 1000; // 1000ms
d-> m_buttons = 0;
@@ -297,26 +295,24 @@ void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
void ODevice::init ( )
{
}
/**
* This method initialises the button mapping
*/
void ODevice::initButtons ( )
{
if ( d-> m_buttons )
return;
- d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
-
// Simulation uses iPAQ 3660 device buttons
qDebug ( "init Buttons" );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
i_button *ib = ipaq_buttons + i;
ODeviceButton b;
if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
@@ -350,25 +346,25 @@ bool ODevice::setSoftSuspend ( bool /*soft*/ )
* This method will try to suspend the device
* It only works if the user is the QWS Server and the apm application
* is installed.
* It tries to suspend and then waits some time cause some distributions
* do have asynchronus apm implementations.
* This method will either fail and return false or it'll suspend the
* device and return once the device got woken up
*
* @return if the device got suspended
*/
bool ODevice::suspend ( )
{
- if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
+ if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync ( ); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );
@@ -798,27 +794,25 @@ void iPAQ::init ( )
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
}
void iPAQ::initButtons ( )
{
if ( d-> m_buttons )
return;
- d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
-
- if ( d-> m_qwsserver )
+ if ( isQWS( ) )
QWSServer::setKeyboardFilter ( this );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
i_button *ib = ipaq_buttons + i;
ODeviceButton b;
if (( ib-> model & d-> m_model ) == d-> m_model ) {
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
@@ -1198,26 +1192,24 @@ void Zaurus::init ( )
default:
d-> m_rotation = Rot270;
break;
}
m_leds [0] = Led_Off;
}
void Zaurus::initButtons ( )
{
if ( d-> m_buttons )
return;
- d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
-
d-> m_buttons = new QValueList <ODeviceButton>;
struct z_button * pz_buttons;
int buttoncount;
switch ( d-> m_model ) {
case Model_Zaurus_SLC700:
pz_buttons = z_buttons_c700;
buttoncount = ARRAY_SIZE(z_buttons_c700);
break;
default:
pz_buttons = z_buttons;
buttoncount = ARRAY_SIZE(z_buttons);