summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Side-by-side diff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9e97c56..d5e3c5c 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -235,97 +235,96 @@ 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_holdtime = 1000; // 1000ms
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
}
void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping ( );
}
}
void ODevice::init ( )
{
// Simulation uses iPAQ 3660 device buttons
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 ( qApp-> translate ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
-
d-> m_buttons. append ( b );
}
}
reloadButtonMapping ( );
}
ODevice::~ODevice ( )
{
delete d;
}
bool ODevice::setSoftSuspend ( bool /*soft*/ )
{
return false;
}
//#include <linux/apm_bios.h>
#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
bool ODevice::suspend ( )
{
if ( !d-> m_qwsserver ) // 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 );
// This is needed because the iPAQ apm implementation is asynchronous and we
// can not be sure when exactly the device is really suspended
// This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
if ( res ) {
do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
::usleep ( 200 * 1000 );
::gettimeofday ( &tvn, 0 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
}
@@ -471,127 +470,133 @@ int ODevice::readLightSensor ( )
}
int ODevice::lightSensorResolution ( ) const
{
return 0;
}
const QValueList <ODeviceButton> &ODevice::buttons ( ) const
{
return d-> m_buttons;
}
uint ODevice::buttonHoldTime ( ) const
{
return d-> m_holdtime;
}
const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
{
for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) {
if ( (*it). keycode ( ) == code )
return &(*it);
}
return 0;
}
void ODevice::reloadButtonMapping ( )
{
Config cfg ( "ButtonSettings" );
for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) {
ODeviceButton &b = d-> m_buttons [i];
QString group = "Button" + QString::number ( i );
QCString pch, hch;
QCString pm, hm;
QByteArray pdata, hdata;
if ( cfg. hasGroup ( group )) {
cfg. setGroup ( group );
pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
// pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
// hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
}
-
+
b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
+
b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
}
}
void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
{
+ QString mb_chan;
+
if ( button >= (int) d-> m_buttons. count ( ))
return;
+
ODeviceButton &b = d-> m_buttons [button];
- b. setPressedAction ( action );
+ b. setPressedAction ( action );
+
+ mb_chan=b. pressedAction ( ). channel ( );
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
- buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( ));
+ buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
{
if ( button >= (int) d-> m_buttons. count ( ))
return;
ODeviceButton &b = d-> m_buttons [button];
- b. setHeldAction ( action );
+ b. setHeldAction ( action );
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
/**************************************************
*
* iPAQ
*
**************************************************/
void iPAQ::init ( )
{
d-> m_vendorstr = "HP";
d-> m_vendor = Vendor_HP;
QFile f ( "/proc/hal/model" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d-> m_modelstr = "H" + ts. readLine ( );
if ( d-> m_modelstr == "H3100" )
d-> m_model = Model_iPAQ_H31xx;
else if ( d-> m_modelstr == "H3600" )
d-> m_model = Model_iPAQ_H36xx;
else if ( d-> m_modelstr == "H3700" )
d-> m_model = Model_iPAQ_H37xx;
else if ( d-> m_modelstr == "H3800" )
d-> m_model = Model_iPAQ_H38xx;
else if ( d-> m_modelstr == "H3900" )
d-> m_model = Model_iPAQ_H39xx;
else
d-> m_model = Model_Unknown;
f. close ( );
}