summaryrefslogtreecommitdiff
path: root/libopie
Side-by-side diff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp15
-rw-r--r--libopie/odevicebutton.cpp3
2 files changed, 12 insertions, 6 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9e97c56..d5e3c5c 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -259,49 +259,48 @@ ODevice::ODevice ( )
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
@@ -495,79 +494,85 @@ const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
}
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;
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp
index 2270343..4b22358 100644
--- a/libopie/odevicebutton.cpp
+++ b/libopie/odevicebutton.cpp
@@ -49,49 +49,49 @@ OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
{
init ( assign. channel ( ), assign. message ( ), assign. data ( ));
return *this;
}
OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
: d ( 0 )
{
init ( ch, m, arg );
}
void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
{
if ( !d )
d = new OQCopMessageData ( );
d-> m_channel = ch;
d-> m_message = m;
d-> m_data = arg;
}
bool OQCopMessage::send ( )
{
- if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ))
+ if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) )
return false;
QCopEnvelope e ( d-> m_channel, d-> m_message );
if ( d-> m_data. size ( ))
e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
return true;
}
QCString OQCopMessage::channel ( ) const
{
return d-> m_channel;
}
QCString OQCopMessage::message ( ) const
{
return d-> m_message;
}
QByteArray OQCopMessage::data ( ) const
{
return d-> m_data;
}
@@ -197,38 +197,39 @@ OQCopMessage ODeviceButton::heldAction() const
return factoryPresetHeldAction();
return m_HeldAction;
}
void ODeviceButton::setKeycode(ushort keycode)
{
m_Keycode = keycode;
}
void ODeviceButton::setUserText(const QString& text)
{
m_UserText = text;
}
void ODeviceButton::setPixmap(const QPixmap& picture)
{
m_Pixmap = picture;
}
void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
{
m_FactoryPresetPressedAction = action;
}
+
void ODeviceButton::setPressedAction(const OQCopMessage& action)
{
m_PressedAction = action;
}
void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
{
m_FactoryPresetHeldAction = action;
}
void ODeviceButton::setHeldAction(const OQCopMessage& action)
{
m_HeldAction = action;
}