summaryrefslogtreecommitdiff
path: root/libopie2/opiecore
authormickeyl <mickeyl>2004-06-12 16:54:50 (UTC)
committer mickeyl <mickeyl>2004-06-12 16:54:50 (UTC)
commitb1235df3628d178891eeefed630a22da46b25952 (patch) (unidiff)
treec88a3cb04adcc9fe214ff08e3c0b96b21e3c4f0a /libopie2/opiecore
parent7a62e8e3601ee98f5f06261c361fe8132334cd56 (diff)
downloadopie-b1235df3628d178891eeefed630a22da46b25952.zip
opie-b1235df3628d178891eeefed630a22da46b25952.tar.gz
opie-b1235df3628d178891eeefed630a22da46b25952.tar.bz2
- refactor the distribution detection code
- add detection of OpenEmbedded and generic linux distributions - simplify the zaurus model detection code
Diffstat (limited to 'libopie2/opiecore') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp65
-rw-r--r--libopie2/opiecore/device/odevice.h64
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp25
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp19
-rw-r--r--libopie2/opiecore/device/odevice_ramses.cpp12
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp65
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp11
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp69
8 files changed, 141 insertions, 189 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index cef7f63..5b73e59 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,48 +1,48 @@
1/* 1/*
2 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6           .>+-=
7_;:, .> :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13 .%`+i> _;_. 13    .%`+i>       _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
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_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
@@ -122,51 +122,72 @@ ODevice *ODevice::inst()
122 } 122 }
123 if ( !dev ) dev = new ODevice(); 123 if ( !dev ) dev = new ODevice();
124 dev->init(cpu_info); 124 dev->init(cpu_info);
125 } 125 }
126 return dev; 126 return dev;
127} 127}
128 128
129ODevice::ODevice() 129ODevice::ODevice()
130{ 130{
131 d = new ODeviceData; 131 d = new ODeviceData;
132 132
133 d->m_modelstr = "Unknown"; 133 d->m_modelstr = "Unknown";
134 d->m_model = Model_Unknown; 134 d->m_model = Model_Unknown;
135 d->m_vendorstr = "Unknown"; 135 d->m_vendorstr = "Unknown";
136 d->m_vendor = Vendor_Unknown; 136 d->m_vendor = Vendor_Unknown;
137 d->m_systemstr = "Unknown"; 137 d->m_systemstr = "Unknown";
138 d->m_system = System_Unknown; 138 d->m_system = System_Unknown;
139 d->m_sysverstr = "0.0"; 139 d->m_sysverstr = "0.0";
140 d->m_rotation = Rot0; 140 d->m_rotation = Rot0;
141 d->m_direction = CW; 141 d->m_direction = CW;
142 142
143 d->m_holdtime = 1000; // 1000ms 143 d->m_holdtime = 1000; // 1000ms
144 d->m_buttons = 0; 144 d->m_buttons = 0;
145 d->m_cpu_frequencies = new QStrList; 145 d->m_cpu_frequencies = new QStrList;
146
147 // New distribution detection code first checks for legacy distributions,
148 // identified by /etc/familiar-version or /etc/oz_version.
149 // Then check for OpenEmbedded and lastly, read /etc/issue
150
151 for ( unsigned int i = 0; i < sizeof distributions; ++i )
152 {
153 if ( QFile::exists( distributions[i].sysvfile ) )
154 {
155 d->m_systemstr = distributions[i].sysstr;
156 d->m_system = distributions[i].system;
157 d->m_sysverstr = "<Unknown>";
158 QFile f( distributions[i].sysvfile );
159 if ( f.open( IO_ReadOnly ) )
160 {
161 QTextStream ts( &f );
162 d->m_sysverstr = ts.readLine();
163 }
164 break;
165 }
166 }
146} 167}
147 168
148void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 169void ODevice::systemMessage( const QCString &msg, const QByteArray & )
149{ 170{
150 if ( msg == "deviceButtonMappingChanged()" ) { 171 if ( msg == "deviceButtonMappingChanged()" ) {
151 reloadButtonMapping(); 172 reloadButtonMapping();
152 } 173 }
153} 174}
154 175
155void ODevice::init(const QString&) 176void ODevice::init(const QString&)
156{ 177{
157} 178}
158 179
159/** 180/**
160* This method initialises the button mapping 181* This method initialises the button mapping
161*/ 182*/
162void ODevice::initButtons() 183void ODevice::initButtons()
163{ 184{
164 if ( d->m_buttons ) 185 if ( d->m_buttons )
165 return; 186 return;
166 187
167 qDebug ( "init Buttons" ); 188 qDebug ( "init Buttons" );
168 d->m_buttons = new QValueList <ODeviceButton>; 189 d->m_buttons = new QValueList <ODeviceButton>;
169 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 190 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
170 default_button *db = default_buttons + i; 191 default_button *db = default_buttons + i;
171 ODeviceButton b; 192 ODeviceButton b;
172 b. setKeycode ( db->code ); 193 b. setKeycode ( db->code );
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index aaebde3..474d792 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,48 +1,48 @@
1/* 1/*
2 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6           .>+-=
7_;:, .> :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13 .%`+i> _;_. 13    .%`+i>       _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
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#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42 42
43namespace Opie{ 43namespace Opie{
44namespace Core{ 44namespace Core{
45 45
46 class ODeviceData; 46 class ODeviceData;
47/** 47/**
48 * The available devices 48 * The available devices
@@ -73,73 +73,95 @@ enum OModel {
73 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 73 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
74 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 74 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
75 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 75 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
76 76
77 Model_SIMpad = ( 3 << 24 ), 77 Model_SIMpad = ( 3 << 24 ),
78 78
79 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 79 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
80 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 80 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
81 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 81 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
82 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 82 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
83 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 83 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
84 84
85 Model_Ramses = ( 4 << 24 ), 85 Model_Ramses = ( 4 << 24 ),
86 86
87 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 87 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
88 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 88 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
89 89
90 Model_Yopy = ( 5 << 24 ), 90 Model_Yopy = ( 5 << 24 ),
91 91
92 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 92 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
93 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 93 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
94 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 94 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
95 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 95 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
96 96
97 Model_Beagle = ( 6 << 24 ),
98
99 Model_Beagle_All = ( Model_Beagle | 0xffffff ),
100 Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ),
101
97}; 102};
98 103
99/** 104/**
100 * The vendor of the device 105 * The vendor of the device
101 */ 106 */
102enum OVendor { 107enum OVendor {
103 Vendor_Unknown, 108 Vendor_Unknown,
104 109
105 Vendor_HP, 110 Vendor_HP,
106 Vendor_Sharp, 111 Vendor_Sharp,
107 Vendor_SIEMENS, 112 Vendor_SIEMENS,
108 Vendor_MundN, 113 Vendor_MundN,
109 Vendor_GMate, 114 Vendor_GMate,
115 Vendor_MasterIA,
110}; 116};
111 117
112/** 118/**
113 * The System used 119 * The System used
114 */ 120 */
115enum OSystem { 121enum OSystem {
116 System_Unknown, 122 System_Unknown,
117 123
118 System_Familiar, 124 System_Familiar,
119 System_Zaurus, 125 System_Zaurus,
120 System_OpenZaurus, 126 System_OpenZaurus,
121 System_Linupy, 127 System_Linupy,
128 System_OpenEmbedded,
129};
130
131typedef struct {
132 OSystem system;
133 char* sysstr;
134 char* sysvfile;
135} ODistribution;
136
137static ODistribution distributions[] =
138{
139 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
140 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
141 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
142 { System_Unknown, "Linux", "/etc/issue" },
143
122}; 144};
123 145
124enum OLedState { 146enum OLedState {
125 Led_Off, 147 Led_Off,
126 Led_On, 148 Led_On,
127 Led_BlinkSlow, 149 Led_BlinkSlow,
128 Led_BlinkFast 150 Led_BlinkFast
129}; 151};
130 152
131enum OLed { 153enum OLed {
132 Led_Mail, 154 Led_Mail,
133 Led_Power, 155 Led_Power,
134 Led_BlueTooth 156 Led_BlueTooth
135}; 157};
136 158
137enum OHardKey { 159enum OHardKey {
138 HardKey_Datebook = Qt::Key_F9, 160 HardKey_Datebook = Qt::Key_F9,
139 HardKey_Contacts = Qt::Key_F10, 161 HardKey_Contacts = Qt::Key_F10,
140 HardKey_Menu = Qt::Key_F11, 162 HardKey_Menu = Qt::Key_F11,
141 HardKey_Home = Qt::Key_F12, 163 HardKey_Home = Qt::Key_F12,
142 HardKey_Mail = Qt::Key_F13, 164 HardKey_Mail = Qt::Key_F13,
143 HardKey_Record = Qt::Key_F24, 165 HardKey_Record = Qt::Key_F24,
144 HardKey_Suspend = Qt::Key_F34, 166 HardKey_Suspend = Qt::Key_F34,
145 HardKey_Backlight = Qt::Key_F35, 167 HardKey_Backlight = Qt::Key_F35,
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index efe35e7..16c0538 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -117,91 +117,66 @@ struct i_button ipaq_buttons [] = {
117void iPAQ::init(const QString& model) 117void iPAQ::init(const QString& model)
118{ 118{
119 d->m_vendorstr = "HP"; 119 d->m_vendorstr = "HP";
120 d->m_vendor = Vendor_HP; 120 d->m_vendor = Vendor_HP;
121 121
122 d->m_modelstr = model.mid(model.findRev('H')); 122 d->m_modelstr = model.mid(model.findRev('H'));
123 123
124 if ( d->m_modelstr == "H3100" ) 124 if ( d->m_modelstr == "H3100" )
125 d->m_model = Model_iPAQ_H31xx; 125 d->m_model = Model_iPAQ_H31xx;
126 else if ( d->m_modelstr == "H3600" ) 126 else if ( d->m_modelstr == "H3600" )
127 d->m_model = Model_iPAQ_H36xx; 127 d->m_model = Model_iPAQ_H36xx;
128 else if ( d->m_modelstr == "H3700" ) 128 else if ( d->m_modelstr == "H3700" )
129 d->m_model = Model_iPAQ_H37xx; 129 d->m_model = Model_iPAQ_H37xx;
130 else if ( d->m_modelstr == "H3800" ) 130 else if ( d->m_modelstr == "H3800" )
131 d->m_model = Model_iPAQ_H38xx; 131 d->m_model = Model_iPAQ_H38xx;
132 else if ( d->m_modelstr == "H3900" ) 132 else if ( d->m_modelstr == "H3900" )
133 d->m_model = Model_iPAQ_H39xx; 133 d->m_model = Model_iPAQ_H39xx;
134 else if ( d->m_modelstr == "H5400" ) 134 else if ( d->m_modelstr == "H5400" )
135 d->m_model = Model_iPAQ_H5xxx; 135 d->m_model = Model_iPAQ_H5xxx;
136 else if ( d->m_modelstr == "H2200" ) 136 else if ( d->m_modelstr == "H2200" )
137 d->m_model = Model_iPAQ_H22xx; 137 d->m_model = Model_iPAQ_H22xx;
138 else 138 else
139 d->m_model = Model_Unknown; 139 d->m_model = Model_Unknown;
140 140
141
142
143 switch ( d->m_model ) { 141 switch ( d->m_model ) {
144 case Model_iPAQ_H31xx: 142 case Model_iPAQ_H31xx:
145 case Model_iPAQ_H38xx: 143 case Model_iPAQ_H38xx:
146 d->m_rotation = Rot90; 144 d->m_rotation = Rot90;
147 break; 145 break;
148 case Model_iPAQ_H5xxx: 146 case Model_iPAQ_H5xxx:
149 case Model_iPAQ_H22xx: 147 case Model_iPAQ_H22xx:
150 d->m_rotation = Rot0; 148 d->m_rotation = Rot0;
151 break; 149 break;
152 case Model_iPAQ_H36xx: 150 case Model_iPAQ_H36xx:
153 case Model_iPAQ_H37xx: 151 case Model_iPAQ_H37xx:
154 case Model_iPAQ_H39xx: 152 case Model_iPAQ_H39xx:
155 default: 153 default:
156 d->m_rotation = Rot270; 154 d->m_rotation = Rot270;
157 break; 155 break;
158 156
159 } 157 }
160 158
161 QFile f( "/etc/familiar-version" );
162 if ( f. open ( IO_ReadOnly )) {
163 d->m_systemstr = "Familiar";
164 d->m_system = System_Familiar;
165
166 QTextStream ts ( &f );
167 d->m_sysverstr = ts. readLine(). mid ( 10 );
168
169 f. close();
170 } else {
171 f. setName ( "/etc/oz_version" );
172
173 if ( f. open ( IO_ReadOnly )) {
174 d->m_systemstr = "OpenEmbedded/iPaq";
175 d->m_system = System_Familiar;
176
177 QTextStream ts ( &f );
178 ts.setDevice ( &f );
179 d->m_sysverstr = ts. readLine();
180 f. close();
181 }
182 }
183
184 m_leds [0] = m_leds [1] = Led_Off; 159 m_leds [0] = m_leds [1] = Led_Off;
185 160
186 m_power_timer = 0; 161 m_power_timer = 0;
187 162
188} 163}
189 164
190void iPAQ::initButtons() 165void iPAQ::initButtons()
191{ 166{
192 if ( d->m_buttons ) 167 if ( d->m_buttons )
193 return; 168 return;
194 169
195 if ( isQWS( ) ) 170 if ( isQWS( ) )
196 QWSServer::setKeyboardFilter ( this ); 171 QWSServer::setKeyboardFilter ( this );
197 172
198 d->m_buttons = new QValueList <ODeviceButton>; 173 d->m_buttons = new QValueList <ODeviceButton>;
199 174
200 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 175 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
201 i_button *ib = ipaq_buttons + i; 176 i_button *ib = ipaq_buttons + i;
202 ODeviceButton b; 177 ODeviceButton b;
203 178
204 if (( ib->model & d->m_model ) == d->m_model ) { 179 if (( ib->model & d->m_model ) == d->m_model ) {
205 b. setKeycode ( ib->code ); 180 b. setKeycode ( ib->code );
206 b. setUserText ( QObject::tr ( "Button", ib->utext )); 181 b. setUserText ( QObject::tr ( "Button", ib->utext ));
207 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 182 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index 1f69326..5d32901 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -93,61 +93,50 @@ struct j_button jornada56x_buttons [] = {
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_systemstr = "Familiar";
118 d->m_system = System_Familiar;
119 d->m_rotation = Rot0; 117 d->m_rotation = Rot0;
120 118 //Distribution detecting code is now in base class
121 QFile f ( "/etc/familiar-version" );
122 f.setName ( "/etc/familiar-version" );
123 if ( f.open ( IO_ReadOnly )) {
124
125 QTextStream ts ( &f );
126 d->m_sysverstr = ts.readLine().mid( 10 );
127
128 f. close();
129 }
130} 119}
131 120
132void Jornada::initButtons() 121void Jornada::initButtons()
133{ 122{
134 if ( d->m_buttons ) 123 if ( d->m_buttons )
135 return; 124 return;
136 125
137 d->m_buttons = new QValueList <ODeviceButton>; 126 d->m_buttons = new QValueList <ODeviceButton>;
138 127
139 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++ ) {
140 j_button *ib = jornada56x_buttons + i; 129 j_button *ib = jornada56x_buttons + i;
141 ODeviceButton b; 130 ODeviceButton b;
142 131
143 if (( ib->model & d->m_model ) == d->m_model ) { 132 if (( ib->model & d->m_model ) == d->m_model ) {
144 b. setKeycode ( ib->code ); 133 b. setKeycode ( ib->code );
145 b. setUserText ( QObject::tr ( "Button", ib->utext )); 134 b. setUserText ( QObject::tr ( "Button", ib->utext ));
146 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 135 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
147 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 136 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
148 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 137 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
149 138
150 d->m_buttons->append ( b ); 139 d->m_buttons->append ( b );
151 } 140 }
152 } 141 }
153 reloadButtonMapping(); 142 reloadButtonMapping();
@@ -157,63 +146,63 @@ void Jornada::initButtons()
157} 146}
158 147
159int Jornada::displayBrightnessResolution() const 148int Jornada::displayBrightnessResolution() const
160{ 149{
161 return 255; 150 return 255;
162} 151}
163 152
164 153
165bool Jornada::setDisplayBrightness( int bright ) 154bool Jornada::setDisplayBrightness( int bright )
166{ 155{
167 bool res = false; 156 bool res = false;
168 157
169 if ( bright > 255 ) 158 if ( bright > 255 )
170 bright = 255; 159 bright = 255;
171 if ( bright < 0 ) 160 if ( bright < 0 )
172 bright = 0; 161 bright = 0;
173 162
174 QString cmdline; 163 QString cmdline;
175 164
176 int value = 255 - bright; 165 int value = 255 - bright;
177 if ( !bright ) 166 if ( !bright )
178 cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power"); 167 cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power");
179 else 168 else
180 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", value ); 169 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", value );
181 170
182 res = ( ::system( (const char*) cmdline ) == 0 ); 171 res = ( ::system( (const char*) cmdline ) == 0 );
183 172
184 return res; 173 return res;
185} 174}
186 175
187 176
188bool Jornada::suspend( ) 177bool Jornada::suspend( )
189{ 178{
190 qDebug("ODevice::suspend"); 179 qDebug("ODevice::suspend");
191 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 180 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
192 return false; 181 return false;
193 182
194 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 183 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
195 return false; 184 return false;
196 185
197 bool res = false; 186 bool res = false;
198 ODevice::sendSuspendmsg(); 187 ODevice::sendSuspendmsg();
199 188
200 struct timeval tvs; 189 struct timeval tvs;
201 ::gettimeofday ( &tvs, 0 ); 190 ::gettimeofday ( &tvs, 0 );
202 191
203 ::sync(); // flush fs caches 192 ::sync(); // flush fs caches
204 res = ( ::system ( "apm --suspend" ) == 0 ); 193 res = ( ::system ( "apm --suspend" ) == 0 );
205 194
206 return res; 195 return res;
207} 196}
208 197
209bool Jornada::setDisplayStatus ( bool on ) 198bool Jornada::setDisplayStatus ( bool on )
210{ 199{
211 bool res = false; 200 bool res = false;
212 201
213 QString cmdline = QString().sprintf( "echo %d > /sys/class/lcd/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/power", on ? "0" : "4", on? "0" : "4" ); 202 QString cmdline = QString().sprintf( "echo %d > /sys/class/lcd/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/power", on ? "0" : "4", on? "0" : "4" );
214 203
215 res = ( ::system( (const char*) cmdline ) == 0 ); 204 res = ( ::system( (const char*) cmdline ) == 0 );
216 205
217 return res; 206 return res;
218} 207}
219 208
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp
index 32467f1..7db2af1 100644
--- a/libopie2/opiecore/device/odevice_ramses.cpp
+++ b/libopie2/opiecore/device/odevice_ramses.cpp
@@ -61,59 +61,49 @@ struct r_button ramses_buttons [] = {
61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
62 "devicebuttons/z_menu", 62 "devicebuttons/z_menu",
63 "QPE/TaskBar", "toggleMenu()", 63 "QPE/TaskBar", "toggleMenu()",
64 "QPE/TaskBar", "toggleStartMenu()" }, 64 "QPE/TaskBar", "toggleStartMenu()" },
65 { Model_Ramses_MNCI, 65 { Model_Ramses_MNCI,
66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
67 "devicebuttons/ipaq_home", 67 "devicebuttons/ipaq_home",
68 "QPE/Launcher", "home()", 68 "QPE/Launcher", "home()",
69 "buttonsettings", "raise()" }, 69 "buttonsettings", "raise()" },
70}; 70};
71 71
72void Ramses::init(const QString&) 72void Ramses::init(const QString&)
73{ 73{
74 d->m_vendorstr = "M und N"; 74 d->m_vendorstr = "M und N";
75 d->m_vendor = Vendor_MundN; 75 d->m_vendor = Vendor_MundN;
76 76
77 QFile f("/proc/sys/board/ramses"); 77 QFile f("/proc/sys/board/ramses");
78 78
79 d->m_modelstr = "Ramses"; 79 d->m_modelstr = "Ramses";
80 d->m_model = Model_Ramses_MNCI; 80 d->m_model = Model_Ramses_MNCI;
81 81
82 d->m_rotation = Rot0; 82 d->m_rotation = Rot0;
83 d->m_holdtime = 1000; 83 d->m_holdtime = 1000;
84 84
85 f.setName("/etc/oz_version"); 85 // Distribution detection code now in the base class
86
87 if (f.open(IO_ReadOnly)) {
88 d->m_systemstr = "OpenEmbedded/Ramses";
89 d->m_system = System_OpenZaurus;
90
91 QTextStream ts(&f);
92 ts.setDevice(&f);
93 d->m_sysverstr = ts.readLine();
94 f.close();
95 }
96 86
97 m_power_timer = 0; 87 m_power_timer = 0;
98 88
99#ifdef QT_QWS_ALLOW_OVERCLOCK 89#ifdef QT_QWS_ALLOW_OVERCLOCK
100#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 90#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
101#define OC(x...) x 91#define OC(x...) x
102#else 92#else
103#define OC(x...) 93#define OC(x...)
104#endif 94#endif
105 95
106 // This table is true for a Intel XScale PXA 255 96 // This table is true for a Intel XScale PXA 255
107 97
108 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 98 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
109OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 99OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
110 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 100 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
111OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 101OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
112 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 102 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
113OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 103OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
114 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 104 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
115 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 105 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
116OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 106OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
117 107
118} 108}
119 109
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 6630763..6d4624b 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,48 +1,48 @@
1/* 1/*
2 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6           .>+-=
7_;:, .> :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13 .%`+i> _;_. 13    .%`+i>       _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
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_simpad.h" 30#include "odevice_simpad.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>
@@ -113,70 +113,49 @@ struct s_button simpad_buttons [] = {
113}; 113};
114 114
115void SIMpad::init(const QString&) 115void SIMpad::init(const QString&)
116{ 116{
117 d->m_vendorstr = "SIEMENS"; 117 d->m_vendorstr = "SIEMENS";
118 d->m_vendor = Vendor_SIEMENS; 118 d->m_vendor = Vendor_SIEMENS;
119 119
120 QFile f ( "/proc/hal/model" ); 120 QFile f ( "/proc/hal/model" );
121 121
122 //TODO Implement model checking 122 //TODO Implement model checking
123 //FIXME For now we assume an SL4 123 //FIXME For now we assume an SL4
124 124
125 d->m_modelstr = "SL4"; 125 d->m_modelstr = "SL4";
126 d->m_model = Model_SIMpad_SL4; 126 d->m_model = Model_SIMpad_SL4;
127 127
128 switch ( d->m_model ) { 128 switch ( d->m_model ) {
129 default: 129 default:
130 d->m_rotation = Rot0; 130 d->m_rotation = Rot0;
131 d->m_direction = CCW; 131 d->m_direction = CCW;
132 d->m_holdtime = 1000; // 1000ms 132 d->m_holdtime = 1000; // 1000ms
133 133
134 break; 134 break;
135 } 135 }
136 136
137 f. setName ( "/etc/familiar-version" ); 137 //Distribution detecting code is now in base class
138 if ( f. open ( IO_ReadOnly )) {
139 d->m_systemstr = "Familiar";
140 d->m_system = System_Familiar;
141
142 QTextStream ts ( &f );
143 d->m_sysverstr = ts. readLine(). mid ( 10 );
144
145 f. close();
146 } else {
147 f. setName ( "/etc/oz_version" );
148
149 if ( f. open ( IO_ReadOnly )) {
150 d->m_systemstr = "OpenEmbedded/SIMpad";
151 d->m_system = System_OpenZaurus;
152
153 QTextStream ts ( &f );
154 ts.setDevice ( &f );
155 d->m_sysverstr = ts. readLine();
156 f. close();
157 }
158 }
159 138
160 m_leds [0] = m_leds [1] = Led_Off; 139 m_leds [0] = m_leds [1] = Led_Off;
161 140
162 m_power_timer = 0; 141 m_power_timer = 0;
163 142
164} 143}
165 144
166void SIMpad::initButtons() 145void SIMpad::initButtons()
167{ 146{
168 if ( d->m_buttons ) 147 if ( d->m_buttons )
169 return; 148 return;
170 149
171 if ( isQWS( ) ) 150 if ( isQWS( ) )
172 QWSServer::setKeyboardFilter ( this ); 151 QWSServer::setKeyboardFilter ( this );
173 152
174 d->m_buttons = new QValueList <ODeviceButton>; 153 d->m_buttons = new QValueList <ODeviceButton>;
175 154
176 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 155 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
177 s_button *sb = simpad_buttons + i; 156 s_button *sb = simpad_buttons + i;
178 ODeviceButton b; 157 ODeviceButton b;
179 158
180 if (( sb->model & d->m_model ) == d->m_model ) { 159 if (( sb->model & d->m_model ) == d->m_model ) {
181 b. setKeycode ( sb->code ); 160 b. setKeycode ( sb->code );
182 b. setUserText ( QObject::tr ( "Button", sb->utext )); 161 b. setUserText ( QObject::tr ( "Button", sb->utext ));
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index 493ed25..223aa76 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -57,60 +57,51 @@ using 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
82 d->m_systemstr = "Linupy"; 81 d->m_systemstr = "Linupy";
83 d->m_system = System_Linupy; 82 d->m_system = System_Linupy;
84 83 // Distribution detection code now in the base class
85 QFile f ( "/etc/issue" );
86 if ( f. open ( IO_ReadOnly ) )
87 {
88 QTextStream ts ( &f );
89 ts.readLine();
90 d->m_sysverstr = ts. readLine();
91 f. close();
92 }
93} 84}
94 85
95 86
96void Yopy::initButtons() 87void Yopy::initButtons()
97{ 88{
98 if ( d->m_buttons ) 89 if ( d->m_buttons )
99 return ; 90 return ;
100 91
101 d->m_buttons = new QValueList <ODeviceButton>; 92 d->m_buttons = new QValueList <ODeviceButton>;
102 93
103 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++ )
104 { 95 {
105 96
106 yopy_button *ib = yopy_buttons + i; 97 yopy_button *ib = yopy_buttons + i;
107 98
108 ODeviceButton b; 99 ODeviceButton b;
109 100
110 b. setKeycode ( ib->code ); 101 b. setKeycode ( ib->code );
111 b. setUserText ( QObject::tr ( "Button", ib->utext ) ); 102 b. setUserText ( QObject::tr ( "Button", ib->utext ) );
112 b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); 103 b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
113 b. setFactoryPresetPressedAction 104 b. setFactoryPresetPressedAction
114 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); 105 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
115 b. setFactoryPresetHeldAction 106 b. setFactoryPresetHeldAction
116 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); 107 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index e8b813e..6ac3157 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -94,129 +94,114 @@ struct z_button z_buttons_c700 [] = {
94 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
96 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
97 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
98 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
100 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
101 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
102 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
103}; 103};
104 104
105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
106// class up into individual classes. We need three classes 106// class up into individual classes. We need three classes
107// 107//
108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
111// 111//
112// Only question right now is: Do we really need to do it? Because as soon 112// Only question right now is: Do we really need to do it? Because as soon
113// as the OpenZaurus kernel is ready, there will be a unified interface for all 113// as the OpenZaurus kernel is ready, there will be a unified interface for all
114// Zaurus models (concerning apm, backlight, buttons, etc.) 114// Zaurus models (concerning apm, backlight, buttons, etc.)
115// 115//
116// Comments? - mickeyl. 116// Comments? - mickeyl.
117 117
118void Zaurus::init(const QString&) 118void Zaurus::init(const QString& cpu_info)
119{ 119{
120 d->m_vendorstr = "Sharp"; 120 // generic distribution code already scanned /etc/issue at that point -
121 d->m_vendor = Vendor_Sharp; 121 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
122 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 122 if ( d->m_sysverstr.contains( "embedix", false ) )
123 123 {
124 // QFile f ( "/proc/filesystems" ); 124 d->m_vendorstr = "Sharp";
125 QString model; 125 d->m_vendor = Vendor_Sharp;
126 126 d->m_systemstr = "Zaurus";
127 // It isn't a good idea to check the system configuration to 127 d->m_system = System_Zaurus;
128 // detect the distribution ! 128 m_embedix = true;
129 // Otherwise it may happen that any other distribution is detected as openzaurus, just 129 }
130 // because it uses a jffs2 filesystem.. 130 else
131 // (eilers) 131 {
132 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) {
133 QFile f ("/etc/oz_version");
134 if ( f.exists() ){
135 d->m_vendorstr = "OpenZaurus Team"; 132 d->m_vendorstr = "OpenZaurus Team";
136 d->m_systemstr = "OpenZaurus"; 133 d->m_systemstr = "OpenZaurus";
137 d->m_system = System_OpenZaurus; 134 d->m_system = System_OpenZaurus;
135 // sysver already gathered
138 136
139 if ( f. open ( IO_ReadOnly )) { 137 // Openzaurus sometimes uses the embedix kernel, check if this is one
140 QTextStream ts ( &f );
141 d->m_sysverstr = ts. readLine();//. mid ( 10 );
142 f. close();
143 }
144
145 // Openzaurus sometimes uses the embedix kernel!
146 // => Check whether this is an embedix kernel
147 FILE *uname = popen("uname -r", "r"); 138 FILE *uname = popen("uname -r", "r");
139 QFile f;
148 QString line; 140 QString line;
149 if ( f.open(IO_ReadOnly, uname) ) { 141 if ( f.open(IO_ReadOnly, uname) ) {
150 QTextStream ts ( &f ); 142 QTextStream ts ( &f );
151 line = ts. readLine(); 143 line = ts. readLine();
152 int loc = line. find ( "embedix" ); 144 int loc = line. find ( "embedix" );
153 if ( loc != -1 ) 145 if ( loc != -1 )
154 m_embedix = true; 146 m_embedix = true;
155 else 147 else
156 m_embedix = false; 148 m_embedix = false;
157 f. close(); 149 f.close();
158 } 150 }
159 pclose(uname); 151 pclose(uname);
160 } 152 }
161 else {
162 d->m_systemstr = "Zaurus";
163 d->m_system = System_Zaurus;
164 }
165 153
166 f. setName ( "/proc/cpuinfo" ); 154 // check the Zaurus model
167 if ( f. open ( IO_ReadOnly ) ) { 155 QString model;
168 QTextStream ts ( &f ); 156 int loc = cpu_info.find( ":" );
169 QString line; 157 if ( loc != -1 )
170 while( line = ts. readLine() ) { 158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
171 if ( line. left ( 8 ) == "Hardware" ) 159 else
172 break; 160 model = cpu_info;
173 }
174 int loc = line. find ( ":" );
175 if ( loc != -1 )
176 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
177 }
178 161
179 if ( model == "SHARP Corgi" ) { 162 if ( model == "SHARP Corgi" ) {
180 d->m_model = Model_Zaurus_SLC7x0; 163 d->m_model = Model_Zaurus_SLC7x0;
181 d->m_modelstr = "Zaurus SL-C700"; 164 d->m_modelstr = "Zaurus SL-C700";
182 } else if ( model == "SHARP Shepherd" ) { 165 } else if ( model == "SHARP Shepherd" ) {
183 d->m_model = Model_Zaurus_SLC7x0; 166 d->m_model = Model_Zaurus_SLC7x0;
184 d->m_modelstr = "Zaurus SL-C750"; 167 d->m_modelstr = "Zaurus SL-C750";
185 } else if ( model == "SHARP Husky" ) { 168 } else if ( model == "SHARP Husky" ) {
186 d->m_model = Model_Zaurus_SLC7x0; 169 d->m_model = Model_Zaurus_SLC7x0;
187 d->m_modelstr = "Zaurus SL-C760"; 170 d->m_modelstr = "Zaurus SL-C760";
188 } else if ( model == "SHARP Poodle" ) { 171 } else if ( model == "SHARP Poodle" ) {
189 d->m_model = Model_Zaurus_SLB600; 172 d->m_model = Model_Zaurus_SLB600;
190 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 173 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
191 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 174 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
192 d->m_model = Model_Zaurus_SL5500; 175 d->m_model = Model_Zaurus_SL5500;
193 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
194 } else { 177 } else {
195 d->m_model = Model_Zaurus_SL5500; 178 d->m_model = Model_Zaurus_SL5500;
196 d->m_modelstr = "Zaurus (Model unknown)"; 179 d->m_modelstr = "Unkown Zaurus";
197 } 180 }
198 181
182 // set initial rotation
183
199 bool flipstate = false; 184 bool flipstate = false;
200 switch ( d->m_model ) { 185 switch ( d->m_model ) {
201 case Model_Zaurus_SLA300: 186 case Model_Zaurus_SLA300:
202 d->m_rotation = Rot0; 187 d->m_rotation = Rot0;
203 break; 188 break;
204 case Model_Zaurus_SLC7x0: 189 case Model_Zaurus_SLC7x0:
205 d->m_rotation = rotation(); 190 d->m_rotation = rotation();
206 d->m_direction = direction(); 191 d->m_direction = direction();
207 break; 192 break;
208 case Model_Zaurus_SLB600: 193 case Model_Zaurus_SLB600:
209 case Model_Zaurus_SL5500: 194 case Model_Zaurus_SL5500:
210 case Model_Zaurus_SL5000: 195 case Model_Zaurus_SL5000:
211 default: 196 default:
212 d->m_rotation = Rot270; 197 d->m_rotation = Rot270;
213 break; 198 break;
214 } 199 }
215 m_leds [0] = Led_Off; 200 m_leds [0] = Led_Off;
216} 201}
217 202
218void Zaurus::initButtons() 203void Zaurus::initButtons()
219{ 204{
220 if ( d->m_buttons ) 205 if ( d->m_buttons )
221 return; 206 return;
222 207