summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 8b64c41..67cae1c 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -84,251 +84,251 @@ static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
84 if ( str && !::strchr ( str, '/' )) 84 if ( str && !::strchr ( str, '/' ))
85 return QCString ( "QPE/Application/" ) + str; 85 return QCString ( "QPE/Application/" ) + str;
86 else 86 else
87 return str; 87 return str;
88} 88}
89 89
90 90
91 91
92/* Now the default implementation of ODevice */ 92/* Now the default implementation of ODevice */
93 93
94struct default_button default_buttons [] = { 94struct default_button default_buttons [] = {
95 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 95 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
96 "devicebuttons/z_calendar", 96 "devicebuttons/z_calendar",
97 "datebook", "nextView()", 97 "datebook", "nextView()",
98 "today", "raise()" }, 98 "today", "raise()" },
99 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 99 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
100 "devicebuttons/z_contact", 100 "devicebuttons/z_contact",
101 "addressbook", "raise()", 101 "addressbook", "raise()",
102 "addressbook", "beamBusinessCard()" }, 102 "addressbook", "beamBusinessCard()" },
103 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 103 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
104 "devicebuttons/z_home", 104 "devicebuttons/z_home",
105 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
106 "buttonsettings", "raise()" }, 106 "buttonsettings", "raise()" },
107 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 107 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
108 "devicebuttons/z_menu", 108 "devicebuttons/z_menu",
109 "QPE/TaskBar", "toggleMenu()", 109 "QPE/TaskBar", "toggleMenu()",
110 "QPE/TaskBar", "toggleStartMenu()" }, 110 "QPE/TaskBar", "toggleStartMenu()" },
111 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 111 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
112 "devicebuttons/z_mail", 112 "devicebuttons/z_mail",
113 "opiemail", "raise()", 113 "opiemail", "raise()",
114 "opiemail", "newMail()" }, 114 "opiemail", "newMail()" },
115}; 115};
116 116
117ODevice *ODevice::inst() 117ODevice *ODevice::inst()
118{ 118{
119 static ODevice *dev = 0; 119 static ODevice *dev = 0;
120 120
121 // rewrite this to only use /proc/cpuinfo or so 121 // rewrite this to only use /proc/cpuinfo or so
122 QString cpu_info; 122 QString cpu_info;
123 123
124 if ( !dev ) 124 if ( !dev )
125 { 125 {
126 QFile f( PATH_PROC_CPUINFO ); 126 QFile f( PATH_PROC_CPUINFO );
127 if ( f.open( IO_ReadOnly ) ) 127 if ( f.open( IO_ReadOnly ) )
128 { 128 {
129 QTextStream s( &f ); 129 QTextStream s( &f );
130 while ( !s.atEnd() ) 130 while ( !s.atEnd() )
131 { 131 {
132 QString line; 132 QString line;
133 line = s.readLine(); 133 line = s.readLine();
134 if ( line.startsWith( "Hardware" ) ) 134 if ( line.startsWith( "Hardware" ) )
135 { 135 {
136 qDebug( "ODevice() - found '%s'", (const char*) line ); 136 qDebug( "ODevice() - found '%s'", (const char*) line );
137 cpu_info = line; 137 cpu_info = line;
138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 138 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 139 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 140 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 141 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 142 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 143 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
144 else qWarning( "ODevice() - unknown hardware - using default." ); 144 else qWarning( "ODevice() - unknown hardware - using default." );
145 break; 145 break;
146 } 146 }
147 } 147 }
148 } 148 }
149 else 149 else
150 { 150 {
151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 151 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
152 } 152 }
153 if ( !dev ) dev = new ODevice(); 153 if ( !dev ) dev = new ODevice();
154 dev->init(cpu_info); 154 dev->init(cpu_info);
155 } 155 }
156 return dev; 156 return dev;
157} 157}
158 158
159ODevice::ODevice() 159ODevice::ODevice()
160{ 160{
161 d = new ODeviceData; 161 d = new ODeviceData;
162 162
163 d->m_modelstr = "Unknown"; 163 d->m_modelstr = "Unknown";
164 d->m_model = Model_Unknown; 164 d->m_model = Model_Unknown;
165 d->m_vendorstr = "Unknown"; 165 d->m_vendorstr = "Unknown";
166 d->m_vendor = Vendor_Unknown; 166 d->m_vendor = Vendor_Unknown;
167 d->m_systemstr = "Unknown"; 167 d->m_systemstr = "Unknown";
168 d->m_system = System_Unknown; 168 d->m_system = System_Unknown;
169 d->m_sysverstr = "0.0"; 169 d->m_sysverstr = "0.0";
170 d->m_rotation = Rot0; 170 d->m_rotation = Rot0;
171 d->m_direction = CW; 171 d->m_direction = CW;
172 172
173 d->m_holdtime = 1000; // 1000ms 173 d->m_holdtime = 1000; // 1000ms
174 d->m_buttons = 0; 174 d->m_buttons = 0;
175 d->m_cpu_frequencies = new QStrList; 175 d->m_cpu_frequencies = new QStrList;
176 176
177 177
178 /* mixer */ 178 /* mixer */
179 d->m_sound = d->m_vol = d->m_mixer = -1; 179 d->m_sound = d->m_vol = d->m_mixer = -1;
180
181 /* System QCopChannel created */
182 d->m_initializedButtonQcop = false;
180 183
181 // New distribution detection code first checks for legacy distributions, 184 // New distribution detection code first checks for legacy distributions,
182 // identified by /etc/familiar-version or /etc/oz_version. 185 // identified by /etc/familiar-version or /etc/oz_version.
183 // Then check for OpenEmbedded and lastly, read /etc/issue 186 // Then check for OpenEmbedded and lastly, read /etc/issue
184 187
185 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 188 for ( unsigned int i = 0; i < sizeof distributions; ++i )
186 { 189 {
187 if ( QFile::exists( distributions[i].sysvfile ) ) 190 if ( QFile::exists( distributions[i].sysvfile ) )
188 { 191 {
189 d->m_systemstr = distributions[i].sysstr; 192 d->m_systemstr = distributions[i].sysstr;
190 d->m_system = distributions[i].system; 193 d->m_system = distributions[i].system;
191 d->m_sysverstr = "<Unknown>"; 194 d->m_sysverstr = "<Unknown>";
192 QFile f( distributions[i].sysvfile ); 195 QFile f( distributions[i].sysvfile );
193 if ( f.open( IO_ReadOnly ) ) 196 if ( f.open( IO_ReadOnly ) )
194 { 197 {
195 QTextStream ts( &f ); 198 QTextStream ts( &f );
196 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 199 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
197 } 200 }
198 break; 201 break;
199 } 202 }
200 } 203 }
201} 204}
202 205
203void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 206void ODevice::systemMessage( const QCString &msg, const QByteArray & )
204{ 207{
205 if ( msg == "deviceButtonMappingChanged()" ) { 208 if ( msg == "deviceButtonMappingChanged()" ) {
206 reloadButtonMapping(); 209 reloadButtonMapping();
207 } 210 }
208} 211}
209 212
210void ODevice::init(const QString&) 213void ODevice::init(const QString&)
211{ 214{
212} 215}
213 216
214/** 217/**
215* This method initialises the button mapping 218* This method initialises the button mapping
216*/ 219*/
217void ODevice::initButtons() 220void ODevice::initButtons()
218{ 221{
219 if ( d->m_buttons ) 222 if ( d->m_buttons )
220 return; 223 return;
221 224
222 qDebug ( "init Buttons" ); 225 qDebug ( "init Buttons" );
223 d->m_buttons = new QValueList <ODeviceButton>; 226 d->m_buttons = new QValueList <ODeviceButton>;
224 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 227 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
225 default_button *db = default_buttons + i; 228 default_button *db = default_buttons + i;
226 ODeviceButton b; 229 ODeviceButton b;
227 b. setKeycode ( db->code ); 230 b. setKeycode ( db->code );
228 b. setUserText ( QObject::tr ( "Button", db->utext )); 231 b. setUserText ( QObject::tr ( "Button", db->utext ));
229 b. setPixmap ( Resource::loadPixmap ( db->pix )); 232 b. setPixmap ( Resource::loadPixmap ( db->pix ));
230 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 233 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
231 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
232 d->m_buttons->append ( b ); 235 d->m_buttons->append ( b );
233 } 236 }
234 237
235 reloadButtonMapping(); 238 reloadButtonMapping();
236
237 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
238 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
239} 239}
240 240
241ODevice::~ODevice() 241ODevice::~ODevice()
242{ 242{
243// we leak m_devicebuttons and m_cpu_frequency 243// we leak m_devicebuttons and m_cpu_frequency
244// but it's a singleton and it is not so importantant 244// but it's a singleton and it is not so importantant
245// -zecke 245// -zecke
246 delete d; 246 delete d;
247} 247}
248 248
249bool ODevice::setSoftSuspend ( bool /*soft*/ ) 249bool ODevice::setSoftSuspend ( bool /*soft*/ )
250{ 250{
251 return false; 251 return false;
252} 252}
253 253
254//#include <linux/apm_bios.h> 254//#include <linux/apm_bios.h>
255 255
256#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 256#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
257 257
258/** 258/**
259* This method will try to suspend the device 259* This method will try to suspend the device
260* It only works if the user is the QWS Server and the apm application 260* It only works if the user is the QWS Server and the apm application
261* is installed. 261* is installed.
262* It tries to suspend and then waits some time cause some distributions 262* It tries to suspend and then waits some time cause some distributions
263* do have asynchronus apm implementations. 263* do have asynchronus apm implementations.
264* This method will either fail and return false or it'll suspend the 264* This method will either fail and return false or it'll suspend the
265* device and return once the device got woken up 265* device and return once the device got woken up
266* 266*
267* @return if the device got suspended 267* @return if the device got suspended
268*/ 268*/
269bool ODevice::suspend() 269bool ODevice::suspend()
270{ 270{
271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 271 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
272 return false; 272 return false;
273 273
274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 274 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
275 return false; 275 return false;
276 276
277 bool res = false; 277 bool res = false;
278 ODevice::sendSuspendmsg(); 278 ODevice::sendSuspendmsg();
279 279
280 struct timeval tvs, tvn; 280 struct timeval tvs, tvn;
281 ::gettimeofday ( &tvs, 0 ); 281 ::gettimeofday ( &tvs, 0 );
282 282
283 ::sync(); // flush fs caches 283 ::sync(); // flush fs caches
284 res = ( ::system ( "apm --suspend" ) == 0 ); 284 res = ( ::system ( "apm --suspend" ) == 0 );
285 285
286 // This is needed because the iPAQ apm implementation is asynchronous and we 286 // This is needed because the iPAQ apm implementation is asynchronous and we
287 // can not be sure when exactly the device is really suspended 287 // can not be sure when exactly the device is really suspended
288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 288 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
289 289
290 if ( res ) { 290 if ( res ) {
291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 291 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
292 ::usleep ( 200 * 1000 ); 292 ::usleep ( 200 * 1000 );
293 ::gettimeofday ( &tvn, 0 ); 293 ::gettimeofday ( &tvn, 0 );
294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 294 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
295 } 295 }
296 296
297 return res; 297 return res;
298} 298}
299 299
300//#include <linux/fb.h> better not rely on kernel headers in userspace ... 300//#include <linux/fb.h> better not rely on kernel headers in userspace ...
301 301
302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 302#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
303 303
304/* VESA Blanking Levels */ 304/* VESA Blanking Levels */
305#define VESA_NO_BLANKING 0 305#define VESA_NO_BLANKING 0
306#define VESA_VSYNC_SUSPEND 1 306#define VESA_VSYNC_SUSPEND 1
307#define VESA_HSYNC_SUSPEND 2 307#define VESA_HSYNC_SUSPEND 2
308#define VESA_POWERDOWN 3 308#define VESA_POWERDOWN 3
309 309
310/** 310/**
311* This sets the display on or off 311* This sets the display on or off
312*/ 312*/
313bool ODevice::setDisplayStatus ( bool on ) 313bool ODevice::setDisplayStatus ( bool on )
314{ 314{
315 qDebug("ODevice::setDisplayStatus(%d)", on); 315 qDebug("ODevice::setDisplayStatus(%d)", on);
316 316
317 if ( d->m_model == Model_Unknown ) 317 if ( d->m_model == Model_Unknown )
318 return false; 318 return false;
319 319
320 bool res = false; 320 bool res = false;
321 int fd; 321 int fd;
322 322
323#ifdef QT_QWS_DEVFS 323#ifdef QT_QWS_DEVFS
324 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { 324 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
325#else 325#else
326 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 326 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
327#endif 327#endif
328 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 328 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
329 ::close ( fd ); 329 ::close ( fd );
330 } 330 }
331 return res; 331 return res;
332} 332}
333 333
334/** 334/**
@@ -552,192 +552,199 @@ int ODevice::readLightSensor()
552int ODevice::lightSensorResolution() const 552int ODevice::lightSensorResolution() const
553{ 553{
554 return 0; 554 return 0;
555} 555}
556 556
557/** 557/**
558* @return if the device has a hinge sensor 558* @return if the device has a hinge sensor
559*/ 559*/
560bool ODevice::hasHingeSensor() const 560bool ODevice::hasHingeSensor() const
561{ 561{
562 return false; 562 return false;
563} 563}
564 564
565/** 565/**
566* @return a value from the hinge sensor 566* @return a value from the hinge sensor
567*/ 567*/
568OHingeStatus ODevice::readHingeSensor() 568OHingeStatus ODevice::readHingeSensor()
569{ 569{
570 return CASE_UNKNOWN; 570 return CASE_UNKNOWN;
571} 571}
572 572
573/** 573/**
574* @return a list with CPU frequencies supported by the hardware 574* @return a list with CPU frequencies supported by the hardware
575*/ 575*/
576const QStrList &ODevice::allowedCpuFrequencies() const 576const QStrList &ODevice::allowedCpuFrequencies() const
577{ 577{
578 return *d->m_cpu_frequencies; 578 return *d->m_cpu_frequencies;
579} 579}
580 580
581 581
582/** 582/**
583* Set desired CPU frequency 583* Set desired CPU frequency
584* 584*
585* @param index index into d->m_cpu_frequencies of the frequency to be set 585* @param index index into d->m_cpu_frequencies of the frequency to be set
586*/ 586*/
587bool ODevice::setCurrentCpuFrequency(uint index) 587bool ODevice::setCurrentCpuFrequency(uint index)
588{ 588{
589 if (index >= d->m_cpu_frequencies->count()) 589 if (index >= d->m_cpu_frequencies->count())
590 return false; 590 return false;
591 591
592 char *freq = d->m_cpu_frequencies->at(index); 592 char *freq = d->m_cpu_frequencies->at(index);
593 qWarning("set freq to %s", freq); 593 qWarning("set freq to %s", freq);
594 594
595 int fd; 595 int fd;
596 596
597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
598 char writeCommand[50]; 598 char writeCommand[50];
599 const int count = sprintf(writeCommand, "%s\n", freq); 599 const int count = sprintf(writeCommand, "%s\n", freq);
600 int res = (::write(fd, writeCommand, count) != -1); 600 int res = (::write(fd, writeCommand, count) != -1);
601 ::close(fd); 601 ::close(fd);
602 return res; 602 return res;
603 } 603 }
604 604
605 return false; 605 return false;
606} 606}
607 607
608 608
609/** 609/**
610* @return a list of hardware buttons 610* @return a list of hardware buttons
611*/ 611*/
612const QValueList <ODeviceButton> &ODevice::buttons() 612const QValueList <ODeviceButton> &ODevice::buttons()
613{ 613{
614 initButtons(); 614 initButtons();
615 615
616 return *d->m_buttons; 616 return *d->m_buttons;
617} 617}
618 618
619/** 619/**
620* @return The amount of time that would count as a hold 620* @return The amount of time that would count as a hold
621*/ 621*/
622uint ODevice::buttonHoldTime() const 622uint ODevice::buttonHoldTime() const
623{ 623{
624 return d->m_holdtime; 624 return d->m_holdtime;
625} 625}
626 626
627/** 627/**
628* This method return a ODeviceButton for a key code 628* This method return a ODeviceButton for a key code
629* or 0 if no special hardware button is available for the device 629* or 0 if no special hardware button is available for the device
630* 630*
631* @return The devicebutton or 0l 631* @return The devicebutton or 0l
632* @see ODeviceButton 632* @see ODeviceButton
633*/ 633*/
634const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 634const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
635{ 635{
636 initButtons(); 636 initButtons();
637 637
638 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 638 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
639 if ( (*it). keycode() == code ) 639 if ( (*it). keycode() == code )
640 return &(*it); 640 return &(*it);
641 } 641 }
642 return 0; 642 return 0;
643} 643}
644 644
645void ODevice::reloadButtonMapping() 645void ODevice::reloadButtonMapping()
646{ 646{
647 initButtons(); 647 initButtons();
648
649 if(!d->m_initializedButtonQcop) {
650 QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel");
651 connect(chan,SIGNAL(received(const QCString&,const QByteArray&)),
652 this,SLOT(systemMessage(const QCString&,const QByteArray&)));
653 d->m_initializedButtonQcop = true;
654 }
648 655
649 Config cfg ( "ButtonSettings" ); 656 Config cfg ( "ButtonSettings" );
650 657
651 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 658 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
652 ODeviceButton &b = ( *d->m_buttons ) [i]; 659 ODeviceButton &b = ( *d->m_buttons ) [i];
653 QString group = "Button" + QString::number ( i ); 660 QString group = "Button" + QString::number ( i );
654 661
655 QCString pch, hch; 662 QCString pch, hch;
656 QCString pm, hm; 663 QCString pm, hm;
657 QByteArray pdata, hdata; 664 QByteArray pdata, hdata;
658 665
659 if ( cfg. hasGroup ( group )) { 666 if ( cfg. hasGroup ( group )) {
660 cfg. setGroup ( group ); 667 cfg. setGroup ( group );
661 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 668 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
662 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 669 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
663 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 670 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
664 671
665 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 672 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
666 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 673 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
667 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 674 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
668 } 675 }
669 676
670 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 677 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
671 678
672 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 679 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
673 } 680 }
674} 681}
675 682
676void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 683void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
677{ 684{
678 initButtons(); 685 initButtons();
679 686
680 QString mb_chan; 687 QString mb_chan;
681 688
682 if ( button >= (int) d->m_buttons->count()) 689 if ( button >= (int) d->m_buttons->count())
683 return; 690 return;
684 691
685 ODeviceButton &b = ( *d->m_buttons ) [button]; 692 ODeviceButton &b = ( *d->m_buttons ) [button];
686 b. setPressedAction ( action ); 693 b. setPressedAction ( action );
687 694
688 mb_chan=b. pressedAction(). channel(); 695 mb_chan=b. pressedAction(). channel();
689 696
690 Config buttonFile ( "ButtonSettings" ); 697 Config buttonFile ( "ButtonSettings" );
691 buttonFile. setGroup ( "Button" + QString::number ( button )); 698 buttonFile. setGroup ( "Button" + QString::number ( button ));
692 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 699 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
693 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 700 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
694 701
695// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 702// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
696 703
697 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 704 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
698} 705}
699 706
700void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 707void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
701{ 708{
702 initButtons(); 709 initButtons();
703 710
704 if ( button >= (int) d->m_buttons->count()) 711 if ( button >= (int) d->m_buttons->count())
705 return; 712 return;
706 713
707 ODeviceButton &b = ( *d->m_buttons ) [button]; 714 ODeviceButton &b = ( *d->m_buttons ) [button];
708 b. setHeldAction ( action ); 715 b. setHeldAction ( action );
709 716
710 Config buttonFile ( "ButtonSettings" ); 717 Config buttonFile ( "ButtonSettings" );
711 buttonFile. setGroup ( "Button" + QString::number ( button )); 718 buttonFile. setGroup ( "Button" + QString::number ( button ));
712 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 719 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
713 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 720 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
714 721
715// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 722// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
716 723
717 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 724 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
718} 725}
719 726
720/** 727/**
721 * @internal 728 * @internal
722 */ 729 */
723void ODevice::virtual_hook(int, void* ){ 730void ODevice::virtual_hook(int, void* ){
724 731
725} 732}
726 733
727/** 734/**
728 * \brief Send a QCOP Message before suspending 735 * \brief Send a QCOP Message before suspending
729 * 736 *
730 * Sends a QCOP message to channel QPE/System 737 * Sends a QCOP message to channel QPE/System
731 * with the message "aboutToSuspend()" if this 738 * with the message "aboutToSuspend()" if this
732 * is the windowing server. 739 * is the windowing server.
733 * 740 *
734 * Call this in your custom \sa suspend() Method 741 * Call this in your custom \sa suspend() Method
735 * before going to suspend. 742 * before going to suspend.
736 * 743 *
737 */ 744 */
738void ODevice::sendSuspendmsg() 745void ODevice::sendSuspendmsg()
739{ 746{
740 if ( isQWS() ) 747 if ( isQWS() )
741 return; 748 return;
742 749
743 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 750 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );