summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp13
-rw-r--r--libopie2/opiecore/device/odevice.h1
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp4
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp4
6 files changed, 11 insertions, 17 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()" );
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 6f0d036..21fcc3f 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -264,111 +264,112 @@ public:
264 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 264 // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
265 // and in your subclass do overwrite 265 // and in your subclass do overwrite
266 // protected virtual int virtual_hook(int, void *) 266 // protected virtual int virtual_hook(int, void *)
267 // which is defined below 267 // which is defined below
268 268
269 // input / output 269 // input / output
270 virtual void playAlarmSound(); 270 virtual void playAlarmSound();
271 virtual void playKeySound(); 271 virtual void playKeySound();
272 virtual void playTouchSound(); 272 virtual void playTouchSound();
273 273
274 virtual QValueList <OLed> ledList() const; 274 virtual QValueList <OLed> ledList() const;
275 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 275 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
276 virtual OLedState ledState ( OLed led ) const; 276 virtual OLedState ledState ( OLed led ) const;
277 virtual bool setLedState ( OLed led, OLedState st ); 277 virtual bool setLedState ( OLed led, OLedState st );
278 278
279 virtual bool hasLightSensor() const; 279 virtual bool hasLightSensor() const;
280 virtual int readLightSensor(); 280 virtual int readLightSensor();
281 virtual int lightSensorResolution() const; 281 virtual int lightSensorResolution() const;
282 282
283 virtual bool hasHingeSensor() const; 283 virtual bool hasHingeSensor() const;
284 virtual OHingeStatus readHingeSensor(); 284 virtual OHingeStatus readHingeSensor();
285 285
286 const QStrList &allowedCpuFrequencies() const; 286 const QStrList &allowedCpuFrequencies() const;
287 bool setCurrentCpuFrequency(uint index); 287 bool setCurrentCpuFrequency(uint index);
288 288
289 /** 289 /**
290 * Returns the available buttons on this device. The number and location 290 * Returns the available buttons on this device. The number and location
291 * of buttons will vary depending on the device. Button numbers will be assigned 291 * of buttons will vary depending on the device. Button numbers will be assigned
292 * by the device manufacturer and will be from most preferred button to least preffered 292 * by the device manufacturer and will be from most preferred button to least preffered
293 * button. Note that this list only contains "user mappable" buttons. 293 * button. Note that this list only contains "user mappable" buttons.
294 * 294 *
295 * @todo Make method const and take care of calling initButtons or make that const too 295 * @todo Make method const and take care of calling initButtons or make that const too
296 * 296 *
297 */ 297 */
298 const QValueList<ODeviceButton> &buttons(); 298 const QValueList<ODeviceButton> &buttons();
299 299
300 /** 300 /**
301 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 301 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
302 * returns 0L 302 * returns 0L
303 */ 303 */
304 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 304 const ODeviceButton *buttonForKeycode ( ushort keyCode );
305 305
306 /** 306 /**
307 * Reassigns the pressed action for \a button. To return to the factory 307 * Reassigns the pressed action for \a button. To return to the factory
308 * default pass an empty string as \a qcopMessage. 308 * default pass an empty string as \a qcopMessage.
309 */ 309 */
310 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 310 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
311 311
312 /** 312 /**
313 * Reassigns the held action for \a button. To return to the factory 313 * Reassigns the held action for \a button. To return to the factory
314 * default pass an empty string as \a qcopMessage. 314 * default pass an empty string as \a qcopMessage.
315 */ 315 */
316 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 316 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
317 317
318 /** 318 /**
319 * How long (in ms) you have to press a button for a "hold" action 319 * How long (in ms) you have to press a button for a "hold" action
320 */ 320 */
321 uint buttonHoldTime() const; 321 uint buttonHoldTime() const;
322 322
323signals: 323signals:
324 void buttonMappingChanged(); 324 void buttonMappingChanged();
325 325
326private slots: 326private slots:
327 void systemMessage ( const QCString &, const QByteArray & ); 327 void systemMessage ( const QCString &, const QByteArray & );
328 void playingStopped(); 328 void playingStopped();
329 329
330protected: 330protected:
331 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 331 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
332 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 332 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
333 void reloadButtonMapping(); 333 void reloadButtonMapping();
334 void changeMixerForAlarm( int mixer, const char* file, Sound *snd); 334 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
335 335
336 /* ugly virtual hook */ 336 /* ugly virtual hook */
337 virtual void virtual_hook( int id, void* data ); 337 virtual void virtual_hook( int id, void* data );
338}; 338};
339 339
340class ODeviceData { 340class ODeviceData {
341 341
342 public: 342 public:
343 QString m_vendorstr; 343 QString m_vendorstr;
344 OVendor m_vendor; 344 OVendor m_vendor;
345 345
346 QString m_modelstr; 346 QString m_modelstr;
347 OModel m_model; 347 OModel m_model;
348 348
349 QString m_systemstr; 349 QString m_systemstr;
350 OSystem m_system; 350 OSystem m_system;
351 351
352 QString m_sysverstr; 352 QString m_sysverstr;
353 353
354 Transformation m_rotation; 354 Transformation m_rotation;
355 ODirection m_direction; 355 ODirection m_direction;
356 356
357 QValueList <ODeviceButton> *m_buttons; 357 QValueList <ODeviceButton> *m_buttons;
358 uint m_holdtime; 358 uint m_holdtime;
359 QStrList *m_cpu_frequencies; 359 QStrList *m_cpu_frequencies;
360 boolm_initializedButtonQcop : 1;
360 361
361 /* values for changeMixerForAlarm */ 362 /* values for changeMixerForAlarm */
362 int m_sound, m_vol, m_mixer; 363 int m_sound, m_vol, m_mixer;
363}; 364};
364 365
365extern bool isQWS(); 366extern bool isQWS();
366extern QCString makeChannel ( const char *str ); 367extern QCString makeChannel ( const char *str );
367} 368}
368} 369}
369 370
370 371
371 372
372 373
373#endif 374#endif
374 375
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 6193ddc..9e01a0c 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -96,195 +96,192 @@ struct i_button ipaq_buttons [] = {
96 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 96 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
97 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 97 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
98 "devicebuttons/ipaq_menu", 98 "devicebuttons/ipaq_menu",
99 "QPE/TaskBar", "toggleMenu()", 99 "QPE/TaskBar", "toggleMenu()",
100 "QPE/TaskBar", "toggleStartMenu()" }, 100 "QPE/TaskBar", "toggleStartMenu()" },
101 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 101 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
102 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 102 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
103 "devicebuttons/ipaq_mail", 103 "devicebuttons/ipaq_mail",
104 "opiemail", "raise()", 104 "opiemail", "raise()",
105 "opiemail", "newMail()" }, 105 "opiemail", "newMail()" },
106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
108 "devicebuttons/ipaq_home", 108 "devicebuttons/ipaq_home",
109 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
110 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
111 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 111 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
112 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 112 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
113 "devicebuttons/ipaq_record", 113 "devicebuttons/ipaq_record",
114 "QPE/VMemo", "toggleRecord()", 114 "QPE/VMemo", "toggleRecord()",
115 "sound", "raise()" }, 115 "sound", "raise()" },
116}; 116};
117 117
118void iPAQ::init(const QString& model) 118void iPAQ::init(const QString& model)
119{ 119{
120 d->m_vendorstr = "HP"; 120 d->m_vendorstr = "HP";
121 d->m_vendor = Vendor_HP; 121 d->m_vendor = Vendor_HP;
122 122
123 d->m_modelstr = model.mid(model.findRev('H')); 123 d->m_modelstr = model.mid(model.findRev('H'));
124 124
125 if ( d->m_modelstr == "H3100" ) 125 if ( d->m_modelstr == "H3100" )
126 d->m_model = Model_iPAQ_H31xx; 126 d->m_model = Model_iPAQ_H31xx;
127 else if ( d->m_modelstr == "H3600" ) 127 else if ( d->m_modelstr == "H3600" )
128 d->m_model = Model_iPAQ_H36xx; 128 d->m_model = Model_iPAQ_H36xx;
129 else if ( d->m_modelstr == "H3700" ) 129 else if ( d->m_modelstr == "H3700" )
130 d->m_model = Model_iPAQ_H37xx; 130 d->m_model = Model_iPAQ_H37xx;
131 else if ( d->m_modelstr == "H3800" ) 131 else if ( d->m_modelstr == "H3800" )
132 d->m_model = Model_iPAQ_H38xx; 132 d->m_model = Model_iPAQ_H38xx;
133 else if ( d->m_modelstr == "H3900" ) 133 else if ( d->m_modelstr == "H3900" )
134 d->m_model = Model_iPAQ_H39xx; 134 d->m_model = Model_iPAQ_H39xx;
135 else if ( d->m_modelstr == "H5400" ) 135 else if ( d->m_modelstr == "H5400" )
136 d->m_model = Model_iPAQ_H5xxx; 136 d->m_model = Model_iPAQ_H5xxx;
137 else if ( d->m_modelstr == "H2200" ) 137 else if ( d->m_modelstr == "H2200" )
138 d->m_model = Model_iPAQ_H22xx; 138 d->m_model = Model_iPAQ_H22xx;
139 else 139 else
140 d->m_model = Model_Unknown; 140 d->m_model = Model_Unknown;
141 141
142 switch ( d->m_model ) { 142 switch ( d->m_model ) {
143 case Model_iPAQ_H31xx: 143 case Model_iPAQ_H31xx:
144 case Model_iPAQ_H38xx: 144 case Model_iPAQ_H38xx:
145 d->m_rotation = Rot90; 145 d->m_rotation = Rot90;
146 break; 146 break;
147 case Model_iPAQ_H5xxx: 147 case Model_iPAQ_H5xxx:
148 case Model_iPAQ_H22xx: 148 case Model_iPAQ_H22xx:
149 d->m_rotation = Rot0; 149 d->m_rotation = Rot0;
150 break; 150 break;
151 case Model_iPAQ_H36xx: 151 case Model_iPAQ_H36xx:
152 case Model_iPAQ_H37xx: 152 case Model_iPAQ_H37xx:
153 case Model_iPAQ_H39xx: 153 case Model_iPAQ_H39xx:
154 default: 154 default:
155 d->m_rotation = Rot270; 155 d->m_rotation = Rot270;
156 break; 156 break;
157 157
158 } 158 }
159 159
160 m_leds [0] = m_leds [1] = Led_Off; 160 m_leds [0] = m_leds [1] = Led_Off;
161 161
162 m_power_timer = 0; 162 m_power_timer = 0;
163 163
164} 164}
165 165
166void iPAQ::initButtons() 166void iPAQ::initButtons()
167{ 167{
168 if ( d->m_buttons ) 168 if ( d->m_buttons )
169 return; 169 return;
170 170
171 if ( isQWS( ) ) { 171 if ( isQWS( ) ) {
172 addPreHandler(this); 172 addPreHandler(this);
173 } 173 }
174 174
175 d->m_buttons = new QValueList <ODeviceButton>; 175 d->m_buttons = new QValueList <ODeviceButton>;
176 176
177 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 177 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
178 i_button *ib = ipaq_buttons + i; 178 i_button *ib = ipaq_buttons + i;
179 ODeviceButton b; 179 ODeviceButton b;
180 180
181 if (( ib->model & d->m_model ) == d->m_model ) { 181 if (( ib->model & d->m_model ) == d->m_model ) {
182 b. setKeycode ( ib->code ); 182 b. setKeycode ( ib->code );
183 b. setUserText ( QObject::tr ( "Button", ib->utext )); 183 b. setUserText ( QObject::tr ( "Button", ib->utext ));
184 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 184 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
187 187
188 d->m_buttons->append ( b ); 188 d->m_buttons->append ( b );
189 } 189 }
190 } 190 }
191 reloadButtonMapping(); 191 reloadButtonMapping();
192
193 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
194 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
195} 192}
196 193
197QValueList <OLed> iPAQ::ledList() const 194QValueList <OLed> iPAQ::ledList() const
198{ 195{
199 QValueList <OLed> vl; 196 QValueList <OLed> vl;
200 vl << Led_Power; 197 vl << Led_Power;
201 198
202 if ( d->m_model == Model_iPAQ_H38xx ) 199 if ( d->m_model == Model_iPAQ_H38xx )
203 vl << Led_BlueTooth; 200 vl << Led_BlueTooth;
204 return vl; 201 return vl;
205} 202}
206 203
207QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 204QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
208{ 205{
209 QValueList <OLedState> vl; 206 QValueList <OLedState> vl;
210 207
211 if ( l == Led_Power ) 208 if ( l == Led_Power )
212 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 209 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
213 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 210 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
214 vl << Led_Off; // << Led_On << ??? 211 vl << Led_Off; // << Led_On << ???
215 212
216 return vl; 213 return vl;
217} 214}
218 215
219OLedState iPAQ::ledState ( OLed l ) const 216OLedState iPAQ::ledState ( OLed l ) const
220{ 217{
221 switch ( l ) { 218 switch ( l ) {
222 case Led_Power: 219 case Led_Power:
223 return m_leds [0]; 220 return m_leds [0];
224 case Led_BlueTooth: 221 case Led_BlueTooth:
225 return m_leds [1]; 222 return m_leds [1];
226 default: 223 default:
227 return Led_Off; 224 return Led_Off;
228 } 225 }
229} 226}
230 227
231bool iPAQ::setLedState ( OLed l, OLedState st ) 228bool iPAQ::setLedState ( OLed l, OLedState st )
232{ 229{
233 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 230 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
234 231
235 if ( l == Led_Power ) { 232 if ( l == Led_Power ) {
236 if ( fd >= 0 ) { 233 if ( fd >= 0 ) {
237 LED_IN leds; 234 LED_IN leds;
238 ::memset ( &leds, 0, sizeof( leds )); 235 ::memset ( &leds, 0, sizeof( leds ));
239 leds. TotalTime = 0; 236 leds. TotalTime = 0;
240 leds. OnTime = 0; 237 leds. OnTime = 0;
241 leds. OffTime = 1; 238 leds. OffTime = 1;
242 leds. OffOnBlink = 2; 239 leds. OffOnBlink = 2;
243 240
244 switch ( st ) { 241 switch ( st ) {
245 case Led_Off : leds. OffOnBlink = 0; break; 242 case Led_Off : leds. OffOnBlink = 0; break;
246 case Led_On : leds. OffOnBlink = 1; break; 243 case Led_On : leds. OffOnBlink = 1; break;
247 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 244 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
248 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 245 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
249 } 246 }
250 247
251 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 248 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
252 m_leds [0] = st; 249 m_leds [0] = st;
253 return true; 250 return true;
254 } 251 }
255 } 252 }
256 } 253 }
257 return false; 254 return false;
258} 255}
259 256
260 257
261bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 258bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
262{ 259{
263 int newkeycode = keycode; 260 int newkeycode = keycode;
264 261
265 switch ( keycode ) { 262 switch ( keycode ) {
266 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 263 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
267 case HardKey_Menu: { 264 case HardKey_Menu: {
268 if (( d->m_model == Model_iPAQ_H38xx ) || 265 if (( d->m_model == Model_iPAQ_H38xx ) ||
269 ( d->m_model == Model_iPAQ_H39xx ) || 266 ( d->m_model == Model_iPAQ_H39xx ) ||
270 ( d->m_model == Model_iPAQ_H5xxx)) { 267 ( d->m_model == Model_iPAQ_H5xxx)) {
271 newkeycode = HardKey_Mail; 268 newkeycode = HardKey_Mail;
272 } 269 }
273 break; 270 break;
274 } 271 }
275 272
276 // Rotate cursor keys 180 or 270 273 // Rotate cursor keys 180 or 270
277 case Key_Left : 274 case Key_Left :
278 case Key_Right: 275 case Key_Right:
279 case Key_Up : 276 case Key_Up :
280 case Key_Down : { 277 case Key_Down : {
281 if (( d->m_model == Model_iPAQ_H31xx ) || 278 if (( d->m_model == Model_iPAQ_H31xx ) ||
282 ( d->m_model == Model_iPAQ_H38xx )) { 279 ( d->m_model == Model_iPAQ_H38xx )) {
283 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 280 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
284 } 281 }
285 // Rotate the cursor keys by 270 282 // Rotate the cursor keys by 270
286 // keycode - Key_Left = position of the button starting from left clockwise 283 // keycode - Key_Left = position of the button starting from left clockwise
287 // add the rotation to it and modolo. No we've the original offset 284 // add the rotation to it and modolo. No we've the original offset
288 // add the offset to the Key_Left key 285 // add the offset to the Key_Left key
289 if ( d-> m_model == Model_iPAQ_H5xxx ) 286 if ( d-> m_model == Model_iPAQ_H5xxx )
290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 287 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index 2cab0c8..8141f1c 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -47,161 +47,158 @@
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56/* KERNEL */ 56/* KERNEL */
57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
58 58
59#define OD_IO(type,number) OD_IOC(0,type,number,0) 59#define OD_IO(type,number) OD_IOC(0,type,number,0)
60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
63 63
64typedef struct { 64typedef struct {
65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
66 unsigned char TotalTime; /* Units of 5 seconds */ 66 unsigned char TotalTime; /* Units of 5 seconds */
67 unsigned char OnTime; /* units of 100m/s */ 67 unsigned char OnTime; /* units of 100m/s */
68 unsigned char OffTime; /* units of 100m/s */ 68 unsigned char OffTime; /* units of 100m/s */
69} LED_IN; 69} LED_IN;
70 70
71typedef struct { 71typedef struct {
72 unsigned char mode; 72 unsigned char mode;
73 unsigned char pwr; 73 unsigned char pwr;
74 unsigned char brightness; 74 unsigned char brightness;
75} FLITE_IN; 75} FLITE_IN;
76 76
77#define LED_ON OD_IOW( 'f', 5, LED_IN ) 77#define LED_ON OD_IOW( 'f', 5, LED_IN )
78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
79 79
80using namespace Opie::Core; 80using namespace Opie::Core;
81using namespace Opie::Core::Internal; 81using namespace Opie::Core::Internal;
82 82
83struct j_button jornada56x_buttons [] = { 83struct j_button jornada56x_buttons [] = {
84 { Model_Jornada_56x, 84 { Model_Jornada_56x,
85 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 85 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
86 "devicebuttons/jornada56x_calendar", 86 "devicebuttons/jornada56x_calendar",
87 "datebook", "nextView()", 87 "datebook", "nextView()",
88 "today", "raise()" }, 88 "today", "raise()" },
89 { Model_Jornada_56x, 89 { Model_Jornada_56x,
90 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 90 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
91 "devicebuttons/jornada56x_contact", 91 "devicebuttons/jornada56x_contact",
92 "addressbook", "raise()", 92 "addressbook", "raise()",
93 "addressbook", "beamBusinessCard()" }, 93 "addressbook", "beamBusinessCard()" },
94 { Model_Jornada_56x, 94 { Model_Jornada_56x,
95 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), 95 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"),
96 "devicebuttons/jornada56x_todo", 96 "devicebuttons/jornada56x_todo",
97 "todolist", "raise()", 97 "todolist", "raise()",
98 "todolist", "create()" }, 98 "todolist", "create()" },
99 { Model_Jornada_56x, 99 { Model_Jornada_56x,
100 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), 100 Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"),
101 "devicebuttons/jornada56x_home", 101 "devicebuttons/jornada56x_home",
102 "QPE/Launcher", "home()", 102 "QPE/Launcher", "home()",
103 "buttonsettings", "raise()" }, 103 "buttonsettings", "raise()" },
104 { Model_Jornada_56x, 104 { Model_Jornada_56x,
105 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), 105 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"),
106 "devicebuttons/jornada56x_record", 106 "devicebuttons/jornada56x_record",
107 "QPE/VMemo", "toggleRecord()", 107 "QPE/VMemo", "toggleRecord()",
108 "sound", "raise()" }, 108 "sound", "raise()" },
109}; 109};
110 110
111void Jornada::init(const QString&) 111void Jornada::init(const QString&)
112{ 112{
113 d->m_vendorstr = "HP"; 113 d->m_vendorstr = "HP";
114 d->m_vendor = Vendor_HP; 114 d->m_vendor = Vendor_HP;
115 d->m_modelstr = "Jornada 56x"; 115 d->m_modelstr = "Jornada 56x";
116 d->m_model = Model_Jornada_56x; 116 d->m_model = Model_Jornada_56x;
117 d->m_rotation = Rot0; 117 d->m_rotation = Rot0;
118 //Distribution detecting code is now in base class 118 //Distribution detecting code is now in base class
119} 119}
120 120
121void Jornada::initButtons() 121void Jornada::initButtons()
122{ 122{
123 if ( d->m_buttons ) 123 if ( d->m_buttons )
124 return; 124 return;
125 125
126 d->m_buttons = new QValueList <ODeviceButton>; 126 d->m_buttons = new QValueList <ODeviceButton>;
127 127
128 for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { 128 for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) {
129 j_button *ib = jornada56x_buttons + i; 129 j_button *ib = jornada56x_buttons + i;
130 ODeviceButton b; 130 ODeviceButton b;
131 131
132 if (( ib->model & d->m_model ) == d->m_model ) { 132 if (( ib->model & d->m_model ) == d->m_model ) {
133 b. setKeycode ( ib->code ); 133 b. setKeycode ( ib->code );
134 b. setUserText ( QObject::tr ( "Button", ib->utext )); 134 b. setUserText ( QObject::tr ( "Button", ib->utext ));
135 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 135 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
136 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 136 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
137 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 137 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
138 138
139 d->m_buttons->append ( b ); 139 d->m_buttons->append ( b );
140 } 140 }
141 } 141 }
142 reloadButtonMapping(); 142 reloadButtonMapping();
143
144 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
145 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
146} 143}
147 144
148int Jornada::displayBrightnessResolution() const 145int Jornada::displayBrightnessResolution() const
149{ 146{
150 return 255; 147 return 255;
151} 148}
152 149
153 150
154bool Jornada::setDisplayBrightness( int bright ) 151bool Jornada::setDisplayBrightness( int bright )
155{ 152{
156 bool res = false; 153 bool res = false;
157 154
158 if ( bright > 255 ) 155 if ( bright > 255 )
159 bright = 255; 156 bright = 255;
160 if ( bright < 0 ) 157 if ( bright < 0 )
161 bright = 0; 158 bright = 0;
162 159
163 QString cmdline; 160 QString cmdline;
164 161
165 if ( !bright ) 162 if ( !bright )
166 cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power"); 163 cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power");
167 else 164 else
168 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright ); 165 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright );
169 166
170 res = ( ::system( (const char*) cmdline ) == 0 ); 167 res = ( ::system( (const char*) cmdline ) == 0 );
171 168
172 return res; 169 return res;
173} 170}
174 171
175 172
176bool Jornada::suspend( ) 173bool Jornada::suspend( )
177{ 174{
178 qDebug("ODevice::suspend"); 175 qDebug("ODevice::suspend");
179 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 176 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
180 return false; 177 return false;
181 178
182 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 179 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
183 return false; 180 return false;
184 181
185 bool res = false; 182 bool res = false;
186 ODevice::sendSuspendmsg(); 183 ODevice::sendSuspendmsg();
187 184
188 struct timeval tvs; 185 struct timeval tvs;
189 ::gettimeofday ( &tvs, 0 ); 186 ::gettimeofday ( &tvs, 0 );
190 187
191 ::sync(); // flush fs caches 188 ::sync(); // flush fs caches
192 res = ( ::system ( "apm --suspend" ) == 0 ); 189 res = ( ::system ( "apm --suspend" ) == 0 );
193 190
194 return res; 191 return res;
195} 192}
196 193
197bool Jornada::setDisplayStatus ( bool on ) 194bool Jornada::setDisplayStatus ( bool on )
198{ 195{
199 bool res = false; 196 bool res = false;
200 197
201 QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); 198 QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
202 199
203 res = ( ::system( (const char*) cmdline ) == 0 ); 200 res = ( ::system( (const char*) cmdline ) == 0 );
204 201
205 return res; 202 return res;
206} 203}
207 204
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index a06d7ec..8f22514 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -16,142 +16,138 @@ _;:,     .>    :=|. This program is free software; you can
16   : ..    .:,     . . . without even the implied warranty of 16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21:     =  ...= . :.=- 21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU 22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with 23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB. 24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_yopy.h" 30#include "odevice_yopy.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct yopy_button yopy_buttons [] = { 59struct yopy_button yopy_buttons [] = {
60 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), 60 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ),
61 "devicebuttons/yopy_action", 61 "devicebuttons/yopy_action",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), 64 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ),
65 "devicebuttons/yopy_ok", 65 "devicebuttons/yopy_ok",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ),
69 "devicebuttons/yopy_end", 69 "devicebuttons/yopy_end",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72}; 72};
73 73
74void Yopy::init(const QString&) 74void Yopy::init(const QString&)
75{ 75{
76 d->m_vendorstr = "G.Mate"; 76 d->m_vendorstr = "G.Mate";
77 d->m_vendor = Vendor_GMate; 77 d->m_vendor = Vendor_GMate;
78 d->m_modelstr = "Yopy3700"; 78 d->m_modelstr = "Yopy3700";
79 d->m_model = Model_Yopy_3700; 79 d->m_model = Model_Yopy_3700;
80 d->m_rotation = Rot0; 80 d->m_rotation = Rot0;
81 d->m_systemstr = "Linupy"; 81 d->m_systemstr = "Linupy";
82 d->m_system = System_Linupy; 82 d->m_system = System_Linupy;
83 // Distribution detection code now in the base class 83 // Distribution detection code now in the base class
84} 84}
85 85
86 86
87void Yopy::initButtons() 87void Yopy::initButtons()
88{ 88{
89 if ( d->m_buttons ) 89 if ( d->m_buttons )
90 return ; 90 return ;
91 91
92 d->m_buttons = new QValueList <ODeviceButton>; 92 d->m_buttons = new QValueList <ODeviceButton>;
93 93
94 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) 94 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ )
95 { 95 {
96 96
97 yopy_button *ib = yopy_buttons + i; 97 yopy_button *ib = yopy_buttons + i;
98 98
99 ODeviceButton b; 99 ODeviceButton b;
100 100
101 b. setKeycode ( ib->code ); 101 b. setKeycode ( ib->code );
102 b. setUserText ( QObject::tr ( "Button", ib->utext ) ); 102 b. setUserText ( QObject::tr ( "Button", ib->utext ) );
103 b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); 103 b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
104 b. setFactoryPresetPressedAction 104 b. setFactoryPresetPressedAction
105 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); 105 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
106 b. setFactoryPresetHeldAction 106 b. setFactoryPresetHeldAction
107 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); 107 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
108 108
109 d->m_buttons->append ( b ); 109 d->m_buttons->append ( b );
110 } 110 }
111 reloadButtonMapping(); 111 reloadButtonMapping();
112
113 QCopChannel *sysch = new QCopChannel( "QPE/System", this );
114 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ),
115 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
116} 112}
117 113
118 114
119bool Yopy::suspend() 115bool Yopy::suspend()
120{ 116{
121 /* Opie for Yopy does not implement its own power management at the 117 /* Opie for Yopy does not implement its own power management at the
122 moment. The public version runs parallel to X, and relies on the 118 moment. The public version runs parallel to X, and relies on the
123 existing power management features. */ 119 existing power management features. */
124 return false; 120 return false;
125} 121}
126 122
127 123
128bool Yopy::setDisplayBrightness( int bright ) 124bool Yopy::setDisplayBrightness( int bright )
129{ 125{
130 /* The code here works, but is disabled as the current version runs 126 /* The code here works, but is disabled as the current version runs
131 parallel to X, and relies on the existing backlight demon. */ 127 parallel to X, and relies on the existing backlight demon. */
132#if 0 128#if 0
133 if ( QFile::exists( "/proc/sys/pm/light" ) ) 129 if ( QFile::exists( "/proc/sys/pm/light" ) )
134 { 130 {
135 int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); 131 int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
136 if ( fd >= 0 ) 132 if ( fd >= 0 )
137 { 133 {
138 if ( bright ) 134 if ( bright )
139 ::write( fd, "1\n", 2 ); 135 ::write( fd, "1\n", 2 );
140 else 136 else
141 ::write( fd, "0\n", 2 ); 137 ::write( fd, "0\n", 2 );
142 ::close( fd ); 138 ::close( fd );
143 return true; 139 return true;
144 } 140 }
145 } 141 }
146#else 142#else
147 Q_UNUSED( bright ) 143 Q_UNUSED( bright )
148#endif 144#endif
149 return false; 145 return false;
150} 146}
151 147
152 148
153int Yopy::displayBrightnessResolution() const 149int Yopy::displayBrightnessResolution() const
154{ 150{
155 return 2; 151 return 2;
156} 152}
157 153
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 733479e..ebe1949 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -145,196 +145,192 @@ void Zaurus::init(const QString& cpu_info)
145 if ( loc != -1 ) 145 if ( loc != -1 )
146 m_embedix = true; 146 m_embedix = true;
147 else 147 else
148 m_embedix = false; 148 m_embedix = false;
149 f.close(); 149 f.close();
150 } 150 }
151 pclose(uname); 151 pclose(uname);
152 } 152 }
153 153
154 // check the Zaurus model 154 // check the Zaurus model
155 QString model; 155 QString model;
156 int loc = cpu_info.find( ":" ); 156 int loc = cpu_info.find( ":" );
157 if ( loc != -1 ) 157 if ( loc != -1 )
158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
159 else 159 else
160 model = cpu_info; 160 model = cpu_info;
161 161
162 if ( model == "SHARP Corgi" ) { 162 if ( model == "SHARP Corgi" ) {
163 d->m_model = Model_Zaurus_SLC7x0; 163 d->m_model = Model_Zaurus_SLC7x0;
164 d->m_modelstr = "Zaurus SL-C700"; 164 d->m_modelstr = "Zaurus SL-C700";
165 } else if ( model == "SHARP Shepherd" ) { 165 } else if ( model == "SHARP Shepherd" ) {
166 d->m_model = Model_Zaurus_SLC7x0; 166 d->m_model = Model_Zaurus_SLC7x0;
167 d->m_modelstr = "Zaurus SL-C750"; 167 d->m_modelstr = "Zaurus SL-C750";
168 } else if ( model == "SHARP Husky" ) { 168 } else if ( model == "SHARP Husky" ) {
169 d->m_model = Model_Zaurus_SLC7x0; 169 d->m_model = Model_Zaurus_SLC7x0;
170 d->m_modelstr = "Zaurus SL-C760"; 170 d->m_modelstr = "Zaurus SL-C760";
171 } else if ( model == "SHARP Poodle" ) { 171 } else if ( model == "SHARP Poodle" ) {
172 d->m_model = Model_Zaurus_SLB600; 172 d->m_model = Model_Zaurus_SLB600;
173 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 173 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
174 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 174 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
175 d->m_model = Model_Zaurus_SL5500; 175 d->m_model = Model_Zaurus_SL5500;
176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
177 } else if ( model == "SHARP Tosa" ) { 177 } else if ( model == "SHARP Tosa" ) {
178 d->m_model = Model_Zaurus_SL6000; 178 d->m_model = Model_Zaurus_SL6000;
179 d->m_modelstr = "Zaurus SL-6000"; 179 d->m_modelstr = "Zaurus SL-6000";
180 } else { 180 } else {
181 d->m_model = Model_Zaurus_SL5500; 181 d->m_model = Model_Zaurus_SL5500;
182 d->m_modelstr = "Unkown Zaurus"; 182 d->m_modelstr = "Unkown Zaurus";
183 } 183 }
184 184
185 // set initial rotation 185 // set initial rotation
186 switch ( d->m_model ) { 186 switch ( d->m_model ) {
187 case Model_Zaurus_SL6000: 187 case Model_Zaurus_SL6000:
188 case Model_Zaurus_SLA300: 188 case Model_Zaurus_SLA300:
189 d->m_rotation = Rot0; 189 d->m_rotation = Rot0;
190 break; 190 break;
191 case Model_Zaurus_SLC7x0: 191 case Model_Zaurus_SLC7x0:
192 d->m_rotation = rotation(); 192 d->m_rotation = rotation();
193 d->m_direction = direction(); 193 d->m_direction = direction();
194 break; 194 break;
195 case Model_Zaurus_SLB600: 195 case Model_Zaurus_SLB600:
196 case Model_Zaurus_SL5500: 196 case Model_Zaurus_SL5500:
197 case Model_Zaurus_SL5000: 197 case Model_Zaurus_SL5000:
198 default: 198 default:
199 d->m_rotation = Rot270; 199 d->m_rotation = Rot270;
200 break; 200 break;
201 } 201 }
202 m_leds [0] = Led_Off; 202 m_leds [0] = Led_Off;
203} 203}
204 204
205void Zaurus::initButtons() 205void Zaurus::initButtons()
206{ 206{
207 if ( d->m_buttons ) 207 if ( d->m_buttons )
208 return; 208 return;
209 209
210 d->m_buttons = new QValueList <ODeviceButton>; 210 d->m_buttons = new QValueList <ODeviceButton>;
211 211
212 struct z_button * pz_buttons; 212 struct z_button * pz_buttons;
213 int buttoncount; 213 int buttoncount;
214 switch ( d->m_model ) { 214 switch ( d->m_model ) {
215 case Model_Zaurus_SLC7x0: 215 case Model_Zaurus_SLC7x0:
216 pz_buttons = z_buttons_c700; 216 pz_buttons = z_buttons_c700;
217 buttoncount = ARRAY_SIZE(z_buttons_c700); 217 buttoncount = ARRAY_SIZE(z_buttons_c700);
218 break; 218 break;
219 default: 219 default:
220 pz_buttons = z_buttons; 220 pz_buttons = z_buttons;
221 buttoncount = ARRAY_SIZE(z_buttons); 221 buttoncount = ARRAY_SIZE(z_buttons);
222 break; 222 break;
223 } 223 }
224 224
225 for ( int i = 0; i < buttoncount; i++ ) { 225 for ( int i = 0; i < buttoncount; i++ ) {
226 struct z_button *zb = pz_buttons + i; 226 struct z_button *zb = pz_buttons + i;
227 ODeviceButton b; 227 ODeviceButton b;
228 228
229 b. setKeycode ( zb->code ); 229 b. setKeycode ( zb->code );
230 b. setUserText ( QObject::tr ( "Button", zb->utext )); 230 b. setUserText ( QObject::tr ( "Button", zb->utext ));
231 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 231 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
233 zb->fpressedaction )); 233 zb->fpressedaction ));
234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
235 zb->fheldaction )); 235 zb->fheldaction ));
236 236
237 d->m_buttons->append ( b ); 237 d->m_buttons->append ( b );
238 } 238 }
239 239
240 reloadButtonMapping(); 240 reloadButtonMapping();
241
242 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
243 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
244 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
245} 241}
246 242
247#include <unistd.h> 243#include <unistd.h>
248#include <fcntl.h> 244#include <fcntl.h>
249#include <sys/ioctl.h> 245#include <sys/ioctl.h>
250 246
251//#include <asm/sharp_char.h> // including kernel headers is evil ... 247//#include <asm/sharp_char.h> // including kernel headers is evil ...
252 248
253#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 249#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
254 250
255 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 251 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
256#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 252#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
257 253
258#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 254#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
259#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 255#define SHARP_BUZ_KEYSOUND 2 /* key sound */
260#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 256#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
261 257
262/* --- for SHARP_BUZZER device --- */ 258/* --- for SHARP_BUZZER device --- */
263 259
264 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 260 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
265//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 261//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
266 262
267#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 263#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
268#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 264#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
269#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 265#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
270#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 266#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
271#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 267#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
272 268
273//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 269//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
274//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 270//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
275 271
276//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 272//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
277//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 273//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
278//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 274//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
279//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 275//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
280//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 276//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
281//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 277//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
282//#define SHARP_PDA_APPSTART 9 /* application start */ 278//#define SHARP_PDA_APPSTART 9 /* application start */
283//#define SHARP_PDA_APPQUIT 10 /* application ends */ 279//#define SHARP_PDA_APPQUIT 10 /* application ends */
284 280
285//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 281//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
286//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 282//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
287//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 283//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
288//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 284//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
289// 285//
290 286
291 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 287 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
292#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 288#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
293 289
294#define SHARP_IOCTL_GET_ROTATION 0x413c 290#define SHARP_IOCTL_GET_ROTATION 0x413c
295 291
296typedef struct sharp_led_status { 292typedef struct sharp_led_status {
297int which; /* select which LED status is wanted. */ 293int which; /* select which LED status is wanted. */
298int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 294int status; /* set new led status if you call SHARP_LED_SETSTATUS */
299} sharp_led_status; 295} sharp_led_status;
300 296
301#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 297#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
302 298
303#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 299#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
304#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 300#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
305#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 301#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
306 302
307// #include <asm/sharp_apm.h> // including kernel headers is evil ... 303// #include <asm/sharp_apm.h> // including kernel headers is evil ...
308 304
309#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 305#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
310#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 306#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
311#define APM_EVT_POWER_BUTTON (1 << 0) 307#define APM_EVT_POWER_BUTTON (1 << 0)
312 308
313#define FL_IOCTL_STEP_CONTRAST 100 309#define FL_IOCTL_STEP_CONTRAST 100
314 310
315 311
316void Zaurus::buzzer ( int sound ) 312void Zaurus::buzzer ( int sound )
317{ 313{
318#ifndef QT_NO_SOUND 314#ifndef QT_NO_SOUND
319 Sound *snd = 0; 315 Sound *snd = 0;
320 316
321 // Not all devices have real sound 317 // Not all devices have real sound
322 if ( d->m_model == Model_Zaurus_SLC7x0 318 if ( d->m_model == Model_Zaurus_SLC7x0
323 || d->m_model == Model_Zaurus_SLB600 ){ 319 || d->m_model == Model_Zaurus_SLB600 ){
324 320
325 switch ( sound ){ 321 switch ( sound ){
326 case SHARP_BUZ_TOUCHSOUND: { 322 case SHARP_BUZ_TOUCHSOUND: {
327 static Sound touch_sound("touchsound"); 323 static Sound touch_sound("touchsound");
328 snd = &touch_sound; 324 snd = &touch_sound;
329 } 325 }
330 break; 326 break;
331 case SHARP_BUZ_KEYSOUND: { 327 case SHARP_BUZ_KEYSOUND: {
332 static Sound key_sound( "keysound" ); 328 static Sound key_sound( "keysound" );
333 snd = &key_sound; 329 snd = &key_sound;
334 } 330 }
335 break; 331 break;
336 case SHARP_BUZ_SCHEDULE_ALARM: 332 case SHARP_BUZ_SCHEDULE_ALARM:
337 default: { 333 default: {
338 static Sound alarm_sound("alarm"); 334 static Sound alarm_sound("alarm");
339 snd = &alarm_sound; 335 snd = &alarm_sound;
340 } 336 }