summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice.cpp
authormickeyl <mickeyl>2005-01-23 21:35:29 (UTC)
committer mickeyl <mickeyl>2005-01-23 21:35:29 (UTC)
commitdd410f1eb69e68f04cf26b6d3e6bca88f0987f71 (patch) (side-by-side diff)
tree0f2b59bae4c326011783e9cdea0754e180ae0e27 /libopie2/opiecore/device/odevice.cpp
parent78e658cecc7521cf3932f5eb44d3f551d73f3181 (diff)
downloadopie-dd410f1eb69e68f04cf26b6d3e6bca88f0987f71.zip
opie-dd410f1eb69e68f04cf26b6d3e6bca88f0987f71.tar.gz
opie-dd410f1eb69e68f04cf26b6d3e6bca88f0987f71.tar.bz2
remove setSoftSuspend() from ODevice. this is a left-over from the old days
Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp5
1 files changed, 0 insertions, 5 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index a824392..3d69614 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -161,197 +161,192 @@ ODevice *ODevice::inst()
if ( !dev ) dev = new ODevice();
dev->init(cpu_info);
}
return dev;
}
ODevice::ODevice()
{
d = new ODeviceData;
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;
d->m_cpu_frequencies = new QStrList;
/* mixer */
d->m_sound = d->m_vol = d->m_mixer = -1;
/* System QCopChannel created */
d->m_initializedButtonQcop = false;
// New distribution detection code first checks for legacy distributions,
// identified by /etc/familiar-version or /etc/oz_version.
// Then check for OpenEmbedded and lastly, read /etc/issue
for ( unsigned int i = 0; i < sizeof distributions; ++i )
{
if ( QFile::exists( distributions[i].sysvfile ) )
{
d->m_systemstr = distributions[i].sysstr;
d->m_system = distributions[i].system;
d->m_sysverstr = "<Unknown>";
QFile f( distributions[i].sysvfile );
if ( f.open( IO_ReadOnly ) )
{
QTextStream ts( &f );
d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
}
break;
}
}
}
void ODevice::systemMessage( const QCString &msg, const QByteArray & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping();
}
}
void ODevice::init(const QString&)
{
}
/**
* This method initialises the button mapping
*/
void ODevice::initButtons()
{
if ( d->m_buttons )
return;
qDebug ( "init Buttons" );
d->m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
default_button *db = default_buttons + i;
ODeviceButton b;
b. setKeycode ( db->code );
b. setUserText ( QObject::tr ( "Button", db->utext ));
b. setPixmap ( Resource::loadPixmap ( db->pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
d->m_buttons->append ( b );
}
reloadButtonMapping();
}
ODevice::~ODevice()
{
// we leak m_devicebuttons and m_cpu_frequency
// but it's a singleton and it is not so importantant
// -zecke
delete d;
}
-bool ODevice::setSoftSuspend ( bool /*soft*/ )
-{
- return false;
-}
-
//#include <linux/apm_bios.h>
#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
/**
* 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 ( !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;
ODevice::sendSuspendmsg();
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 );
}
return res;
}
//#include <linux/fb.h> better not rely on kernel headers in userspace ...
#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
/* VESA Blanking Levels */
#define VESA_NO_BLANKING 0
#define VESA_VSYNC_SUSPEND 1
#define VESA_HSYNC_SUSPEND 2
#define VESA_POWERDOWN 3
/**
* This sets the display on or off
*/
bool ODevice::setDisplayStatus ( bool on )
{
qDebug("ODevice::setDisplayStatus(%d)", on);
if ( d->m_model == Model_Unknown )
return false;
bool res = false;
int fd;
#ifdef QT_QWS_DEVFS
if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
#else
if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
#endif
res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
::close ( fd );
}
return res;
}
/**
* This sets the display brightness
*
* @param b The brightness to be set on a scale from 0 to 255
* @return success or failure
*/
bool ODevice::setDisplayBrightness ( int b)
{
Q_UNUSED( b )
return false;
}
/**
*
* @return Returns the number of steppings on the brightness slider
* in the Light-'n-Power settings. Values smaller zero and bigger