summaryrefslogtreecommitdiff
authorzecke <zecke>2004-11-04 22:03:38 (UTC)
committer zecke <zecke>2004-11-04 22:03:38 (UTC)
commit586ba5bb2842d80911ea22bf47eaa2f1b39362e1 (patch) (side-by-side diff)
treee8ee53bea0563e16d8bd2649a5846b8377f53be3
parent2df2234beb066097c1c3bd899c21eff30abf4323 (diff)
downloadopie-586ba5bb2842d80911ea22bf47eaa2f1b39362e1.zip
opie-586ba5bb2842d80911ea22bf47eaa2f1b39362e1.tar.gz
opie-586ba5bb2842d80911ea22bf47eaa2f1b39362e1.tar.bz2
Revert last commit and create a QCOP Channel for QPE/System in
ODevice again, as OApplication doesn't expose the signal anymore
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index e57cdef..39b37cd 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -552,196 +552,197 @@ int ODevice::readLightSensor()
int ODevice::lightSensorResolution() const
{
return 0;
}
/**
* @return if the device has a hinge sensor
*/
bool ODevice::hasHingeSensor() const
{
return false;
}
/**
* @return a value from the hinge sensor
*/
OHingeStatus ODevice::readHingeSensor()
{
return CASE_UNKNOWN;
}
/**
* @return a list with CPU frequencies supported by the hardware
*/
const QStrList &ODevice::allowedCpuFrequencies() const
{
return *d->m_cpu_frequencies;
}
/**
* Set desired CPU frequency
*
* @param index index into d->m_cpu_frequencies of the frequency to be set
*/
bool ODevice::setCurrentCpuFrequency(uint index)
{
if (index >= d->m_cpu_frequencies->count())
return false;
char *freq = d->m_cpu_frequencies->at(index);
qWarning("set freq to %s", freq);
int fd;
if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
char writeCommand[50];
const int count = sprintf(writeCommand, "%s\n", freq);
int res = (::write(fd, writeCommand, count) != -1);
::close(fd);
return res;
}
return false;
}
/**
* @return a list of hardware buttons
*/
const QValueList <ODeviceButton> &ODevice::buttons()
{
initButtons();
return *d->m_buttons;
}
/**
* @return The amount of time that would count as a hold
*/
uint ODevice::buttonHoldTime() const
{
return d->m_holdtime;
}
/**
* This method return a ODeviceButton for a key code
* or 0 if no special hardware button is available for the device
*
* @return The devicebutton or 0l
* @see ODeviceButton
*/
const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
{
initButtons();
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()
{
if(!d->m_buttons)
- initButtons();
+ initButtons();
if(!d->m_initializedButtonQcop) {
- connect(qApp,SIGNAL(systemMessageSignal(const QCString&,const QByteArray&)),
+ QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel");
+ connect(chan,SIGNAL(received(const QCString&,const QByteArray&)),
this,SLOT(systemMessage(const QCString&,const QByteArray&)));
d->m_initializedButtonQcop = true;
}
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 )
{
initButtons();
QString mb_chan;
if ( button >= (int) d->m_buttons->count())
return;
ODeviceButton &b = ( *d->m_buttons ) [button];
b. setPressedAction ( action );
mb_chan=b. pressedAction(). channel();
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
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 )
{
initButtons();
if ( button >= (int) d->m_buttons->count())
return;
ODeviceButton &b = ( *d->m_buttons ) [button];
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()" );
}
/**
* @internal
*/
void ODevice::virtual_hook(int, void* ){
}
/**
* \brief Send a QCOP Message before suspending
*
* Sends a QCOP message to channel QPE/System
* with the message "aboutToSuspend()" if this
* is the windowing server.
*
* Call this in your custom \sa suspend() Method
* before going to suspend.
*
*/
void ODevice::sendSuspendmsg()
{
if ( isQWS() )