summaryrefslogtreecommitdiff
authorsandman <sandman>2002-07-27 22:45:04 (UTC)
committer sandman <sandman>2002-07-27 22:45:04 (UTC)
commit9cc89b6a54ee267953b0422c4607097d075ecab9 (patch) (unidiff)
tree4bde48d162a97ef74cf9e276c0194b8138fb4e0c
parentdac5c073c3e04ceb6900aeb72e53cf6d7350c3c9 (diff)
downloadopie-9cc89b6a54ee267953b0422c4607097d075ecab9.zip
opie-9cc89b6a54ee267953b0422c4607097d075ecab9.tar.gz
opie-9cc89b6a54ee267953b0422c4607097d075ecab9.tar.bz2
Small extension to read the system version
(currently only functional for familiar)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp16
-rw-r--r--libopie/odevice.h1
2 files changed, 16 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9931684..bc8014a 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -16,48 +16,50 @@
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#include <qpe/sound.h> 22#include <qpe/sound.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25 25
26#include "odevice.h" 26#include "odevice.h"
27 27
28 28
29class ODeviceData { 29class ODeviceData {
30public: 30public:
31 QString m_vendorstr; 31 QString m_vendorstr;
32 OVendor m_vendor; 32 OVendor m_vendor;
33 33
34 QString m_modelstr; 34 QString m_modelstr;
35 OModel m_model; 35 OModel m_model;
36 36
37 QString m_systemstr; 37 QString m_systemstr;
38 OSystem m_system; 38 OSystem m_system;
39 39
40 QString m_sysverstr;
41
40 OLedState m_leds [4]; // just for convenience ... 42 OLedState m_leds [4]; // just for convenience ...
41}; 43};
42 44
43class ODeviceIPAQ : public ODevice { 45class ODeviceIPAQ : public ODevice {
44protected: 46protected:
45 virtual void init ( ); 47 virtual void init ( );
46 48
47public: 49public:
48 virtual void alarmSound ( ); 50 virtual void alarmSound ( );
49 51
50 virtual uint hasLeds ( ) const; 52 virtual uint hasLeds ( ) const;
51 virtual OLedState led ( uint which ) const; 53 virtual OLedState led ( uint which ) const;
52 virtual bool setLed ( uint which, OLedState st ); 54 virtual bool setLed ( uint which, OLedState st );
53}; 55};
54 56
55class ODeviceZaurus : public ODevice { 57class ODeviceZaurus : public ODevice {
56protected: 58protected:
57 virtual void init ( ); 59 virtual void init ( );
58 60
59 public: 61 public:
60 virtual void alarmSound ( ); 62 virtual void alarmSound ( );
61 virtual void keySound ( ); 63 virtual void keySound ( );
62 virtual void touchSound ( ); 64 virtual void touchSound ( );
63 65
@@ -78,89 +80,95 @@ ODevice *ODevice::inst ( )
78 80
79 if ( !dev ) { 81 if ( !dev ) {
80 if ( QFile::exists ( "/proc/hal/model" )) 82 if ( QFile::exists ( "/proc/hal/model" ))
81 dev = new ODeviceIPAQ ( ); 83 dev = new ODeviceIPAQ ( );
82 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 84 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
83 dev = new ODeviceZaurus ( ); 85 dev = new ODeviceZaurus ( );
84 else 86 else
85 dev = new ODevice ( ); 87 dev = new ODevice ( );
86 88
87 dev-> init ( ); 89 dev-> init ( );
88 } 90 }
89 return dev; 91 return dev;
90} 92}
91 93
92ODevice::ODevice ( ) 94ODevice::ODevice ( )
93{ 95{
94 d = new ODeviceData; 96 d = new ODeviceData;
95 97
96 d-> m_modelstr = "Unknown"; 98 d-> m_modelstr = "Unknown";
97 d-> m_model = OMODEL_Unknown; 99 d-> m_model = OMODEL_Unknown;
98 d-> m_vendorstr = "Unkown"; 100 d-> m_vendorstr = "Unkown";
99 d-> m_vendor = OVENDOR_Unknown; 101 d-> m_vendor = OVENDOR_Unknown;
100 d-> m_systemstr = "Unkown"; 102 d-> m_systemstr = "Unkown";
101 d-> m_system = OSYSTEM_Unknown; 103 d-> m_system = OSYSTEM_Unknown;
104 d-> m_sysverstr = "0.0";
102} 105}
103 106
104void ODevice::init ( ) 107void ODevice::init ( )
105{ 108{
106} 109}
107 110
108ODevice::~ODevice ( ) 111ODevice::~ODevice ( )
109{ 112{
110 delete d; 113 delete d;
111} 114}
112 115
113QString ODevice::vendorString ( ) 116QString ODevice::vendorString ( )
114{ 117{
115 return d-> m_vendorstr; 118 return d-> m_vendorstr;
116} 119}
117 120
118OVendor ODevice::vendor ( ) 121OVendor ODevice::vendor ( )
119{ 122{
120 return d-> m_vendor; 123 return d-> m_vendor;
121} 124}
122 125
123QString ODevice::modelString ( ) 126QString ODevice::modelString ( )
124{ 127{
125 return d-> m_modelstr; 128 return d-> m_modelstr;
126} 129}
127 130
128OModel ODevice::model ( ) 131OModel ODevice::model ( )
129{ 132{
130 return d-> m_model; 133 return d-> m_model;
131} 134}
132 135
133QString ODevice::systemString ( ) 136QString ODevice::systemString ( )
134{ 137{
135 return d-> m_systemstr; 138 return d-> m_systemstr;
136} 139}
137 140
138OSystem ODevice::system ( ) 141OSystem ODevice::system ( )
139{ 142{
140 return d-> m_system; 143 return d-> m_system;
141} 144}
142 145
146QString ODevice::systemVersionString ( )
147{
148 return d-> m_sysverstr;
149}
150
143void ODevice::alarmSound ( ) 151void ODevice::alarmSound ( )
144{ 152{
145#ifndef QT_QWS_EBX 153#ifndef QT_QWS_EBX
146#ifndef QT_NO_SOUND 154#ifndef QT_NO_SOUND
147 static Sound snd ( "alarm" ); 155 static Sound snd ( "alarm" );
148 156
149 if ( snd. isFinished ( )) 157 if ( snd. isFinished ( ))
150 snd. play ( ); 158 snd. play ( );
151#endif 159#endif
152#endif 160#endif
153} 161}
154 162
155void ODevice::keySound ( ) 163void ODevice::keySound ( )
156{ 164{
157#ifndef QT_QWS_EBX 165#ifndef QT_QWS_EBX
158#ifndef QT_NO_SOUND 166#ifndef QT_NO_SOUND
159 static Sound snd ( "keysound" ); 167 static Sound snd ( "keysound" );
160 168
161 if ( snd. isFinished ( )) 169 if ( snd. isFinished ( ))
162 snd. play ( ); 170 snd. play ( );
163#endif 171#endif
164#endif 172#endif
165} 173}
166 174
@@ -205,51 +213,57 @@ void ODeviceIPAQ::init ( )
205 d-> m_vendorstr = "HP"; 213 d-> m_vendorstr = "HP";
206 d-> m_vendor = OVENDOR_HP; 214 d-> m_vendor = OVENDOR_HP;
207 215
208 QFile f ( "/proc/hal/model" ); 216 QFile f ( "/proc/hal/model" );
209 217
210 if ( f. open ( IO_ReadOnly )) { 218 if ( f. open ( IO_ReadOnly )) {
211 QTextStream ts ( &f ); 219 QTextStream ts ( &f );
212 220
213 d-> m_modelstr = "H" + ts. readLine ( ); 221 d-> m_modelstr = "H" + ts. readLine ( );
214 222
215 if ( d-> m_modelstr == "H3100" ) 223 if ( d-> m_modelstr == "H3100" )
216 d-> m_model = OMODEL_iPAQ_H31xx; 224 d-> m_model = OMODEL_iPAQ_H31xx;
217 else if ( d-> m_modelstr == "H3600" ) 225 else if ( d-> m_modelstr == "H3600" )
218 d-> m_model = OMODEL_iPAQ_H36xx; 226 d-> m_model = OMODEL_iPAQ_H36xx;
219 else if ( d-> m_modelstr == "H3700" ) 227 else if ( d-> m_modelstr == "H3700" )
220 d-> m_model = OMODEL_iPAQ_H37xx; 228 d-> m_model = OMODEL_iPAQ_H37xx;
221 else if ( d-> m_modelstr == "H3800" ) 229 else if ( d-> m_modelstr == "H3800" )
222 d-> m_model = OMODEL_iPAQ_H38xx; 230 d-> m_model = OMODEL_iPAQ_H38xx;
223 else 231 else
224 d-> m_model = OMODEL_Unknown; 232 d-> m_model = OMODEL_Unknown;
225 233
226 f. close ( ); 234 f. close ( );
227 } 235 }
228 236
229 if ( QFile::exists ( "/etc/familiar-version" )) { 237 f. setName ( "/etc/familiar-version" );
238 if ( f. open ( IO_ReadOnly )) {
230 d-> m_systemstr = "Familiar"; 239 d-> m_systemstr = "Familiar";
231 d-> m_system = OSYSTEM_Familiar; 240 d-> m_system = OSYSTEM_Familiar;
241
242 QTextStream ts ( &f );
243 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
244
245 f. close ( );
232 } 246 }
233 247
234 d-> m_leds [0] = OLED_Off; 248 d-> m_leds [0] = OLED_Off;
235} 249}
236 250
237#include <unistd.h> 251#include <unistd.h>
238#include <fcntl.h> 252#include <fcntl.h>
239#include <sys/ioctl.h> 253#include <sys/ioctl.h>
240#include <linux/soundcard.h> 254#include <linux/soundcard.h>
241#include <qapplication.h> 255#include <qapplication.h>
242#include <qpe/config.h> 256#include <qpe/config.h>
243 257
244//#include <linux/h3600_ts.h> // including kernel headers is evil ... 258//#include <linux/h3600_ts.h> // including kernel headers is evil ...
245 259
246typedef struct h3600_ts_led { 260typedef struct h3600_ts_led {
247 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 261 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
248 unsigned char TotalTime; /* Units of 5 seconds */ 262 unsigned char TotalTime; /* Units of 5 seconds */
249 unsigned char OnTime; /* units of 100m/s */ 263 unsigned char OnTime; /* units of 100m/s */
250 unsigned char OffTime; /* units of 100m/s */ 264 unsigned char OffTime; /* units of 100m/s */
251} LED_IN; 265} LED_IN;
252 266
253 267
254// #define IOC_H3600_TS_MAGIC 'f' 268// #define IOC_H3600_TS_MAGIC 'f'
255// #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) 269// #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led)
diff --git a/libopie/odevice.h b/libopie/odevice.h
index b40abe7..b54e576 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -57,48 +57,49 @@ enum OLedState {
57 OLED_BlinkSlow, 57 OLED_BlinkSlow,
58 OLED_BlinkFast 58 OLED_BlinkFast
59}; 59};
60 60
61 61
62class ODevice 62class ODevice
63{ 63{
64public: 64public:
65 65
66public: 66public:
67 static ODevice *inst ( ); 67 static ODevice *inst ( );
68 68
69 69
70// information 70// information
71 71
72 QString modelString ( ); 72 QString modelString ( );
73 OModel model ( ); 73 OModel model ( );
74 74
75 QString vendorString ( ); 75 QString vendorString ( );
76 OVendor vendor ( ); 76 OVendor vendor ( );
77 77
78 QString systemString ( ); 78 QString systemString ( );
79 OSystem system ( ); 79 OSystem system ( );
80 80
81 QString systemVersionString ( );
81 82
82// input / output 83// input / output
83 84
84 virtual void alarmSound ( ); 85 virtual void alarmSound ( );
85 virtual void keySound ( ); 86 virtual void keySound ( );
86 virtual void touchSound ( ); 87 virtual void touchSound ( );
87 88
88 virtual uint hasLeds ( ) const; 89 virtual uint hasLeds ( ) const;
89 virtual OLedState led ( uint which ) const; 90 virtual OLedState led ( uint which ) const;
90 virtual bool setLed ( uint which, OLedState st ); 91 virtual bool setLed ( uint which, OLedState st );
91 92
92 virtual ~ODevice ( ); 93 virtual ~ODevice ( );
93 94
94protected: 95protected:
95 ODevice ( ); 96 ODevice ( );
96 virtual void init ( ); 97 virtual void init ( );
97 98
98 ODeviceData *d; 99 ODeviceData *d;
99 100
100private: 101private:
101 ODevice ( const ODevice & ); 102 ODevice ( const ODevice & );
102 103
103}; 104};
104 105