summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 1da8862..2f40731 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -53,206 +53,208 @@ public:
53 53
54 OLedState m_leds [4]; // just for convenience ... 54 OLedState m_leds [4]; // just for convenience ...
55}; 55};
56 56
57class ODeviceIPAQ : public ODevice { 57class ODeviceIPAQ : public ODevice {
58protected: 58protected:
59 virtual void init ( ); 59 virtual void init ( );
60 60
61public: 61public:
62 virtual void alarmSound ( ); 62 virtual void alarmSound ( );
63 63
64 virtual uint hasLeds ( ) const; 64 virtual uint hasLeds ( ) const;
65 virtual OLedState led ( uint which ) const; 65 virtual OLedState led ( uint which ) const;
66 virtual bool setLed ( uint which, OLedState st ); 66 virtual bool setLed ( uint which, OLedState st );
67}; 67};
68 68
69class ODeviceZaurus : public ODevice { 69class ODeviceZaurus : public ODevice {
70protected: 70protected:
71 virtual void init ( ); 71 virtual void init ( );
72 72
73 public: 73 public:
74 virtual void alarmSound ( ); 74 virtual void alarmSound ( );
75 virtual void keySound ( ); 75 virtual void keySound ( );
76 virtual void touchSound ( ); 76 virtual void touchSound ( );
77 77
78 virtual uint hasLeds ( ) const; 78 virtual uint hasLeds ( ) const;
79 virtual OLedState led ( uint which ) const; 79 virtual OLedState led ( uint which ) const;
80 virtual bool setLed ( uint which, OLedState st ); 80 virtual bool setLed ( uint which, OLedState st );
81 81
82protected: 82protected:
83 virtual void buzzer ( int snd ); 83 virtual void buzzer ( int snd );
84}; 84};
85 85
86 86
87 87
88 88
89ODevice *ODevice::inst ( ) 89ODevice *ODevice::inst ( )
90{ 90{
91 static ODevice *dev = 0; 91 static ODevice *dev = 0;
92 92
93 if ( !dev ) { 93 if ( !dev ) {
94 if ( QFile::exists ( "/proc/hal/model" )) 94 if ( QFile::exists ( "/proc/hal/model" ))
95 dev = new ODeviceIPAQ ( ); 95 dev = new ODeviceIPAQ ( );
96 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 96 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
97 dev = new ODeviceZaurus ( ); 97 dev = new ODeviceZaurus ( );
98 else 98 else
99 dev = new ODevice ( ); 99 dev = new ODevice ( );
100 100
101 dev-> init ( ); 101 dev-> init ( );
102 } 102 }
103 return dev; 103 return dev;
104} 104}
105 105
106ODevice::ODevice ( ) 106ODevice::ODevice ( )
107{ 107{
108 d = new ODeviceData; 108 d = new ODeviceData;
109 109
110 d-> m_modelstr = "Unknown"; 110 d-> m_modelstr = "Unknown";
111 d-> m_model = OMODEL_Unknown; 111 d-> m_model = OMODEL_Unknown;
112 d-> m_vendorstr = "Unkown"; 112 d-> m_vendorstr = "Unkown";
113 d-> m_vendor = OVENDOR_Unknown; 113 d-> m_vendor = OVENDOR_Unknown;
114 d-> m_systemstr = "Unkown"; 114 d-> m_systemstr = "Unkown";
115 d-> m_system = OSYSTEM_Unknown; 115 d-> m_system = OSYSTEM_Unknown;
116 d-> m_sysverstr = "0.0"; 116 d-> m_sysverstr = "0.0";
117} 117}
118 118
119void ODevice::init ( ) 119void ODevice::init ( )
120{ 120{
121} 121}
122 122
123ODevice::~ODevice ( ) 123ODevice::~ODevice ( )
124{ 124{
125 delete d; 125 delete d;
126} 126}
127 127
128//#include <linux/apm_bios.h> 128//#include <linux/apm_bios.h>
129 129
130//#define APM_IOC_SUSPEND _IO('A',2) 130//#define APM_IOC_SUSPEND _IO('A',2)
131 131
132#define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) 132#define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 ))
133 133
134bool ODevice::suspend ( ) 134bool ODevice::suspend ( )
135{ 135{
136 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices 136 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices
137 return false; 137 return false;
138 138
139 int fd; 139 int fd;
140 bool res = false; 140 bool res = false;
141 141
142 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 142 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
143 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 143 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
144 struct timeval tvs, tvn; 144 struct timeval tvs, tvn;
145 145
146 ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped 146 ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped
147 ::gettimeofday ( &tvs, 0 ); 147 ::gettimeofday ( &tvs, 0 );
148 148
149 ::sync ( ); // flush fs caches
150
149 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending 151 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending
150 ::close ( fd );
151 152
152 if ( res ) { 153 if ( res ) {
153 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in out process group 154 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group
154 155
155 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 156 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
156 ::usleep ( 200 * 1000 ); 157 ::usleep ( 200 * 1000 );
157 ::gettimeofday ( &tvn, 0 ); 158 ::gettimeofday ( &tvn, 0 );
158 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 159 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
159 160
160 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group 161 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group
161 } 162 }
162 163
164 ::close ( fd );
163 ::signal ( SIGTSTP, SIG_DFL ); 165 ::signal ( SIGTSTP, SIG_DFL );
164 } 166 }
165 167
166 return res; 168 return res;
167} 169}
168 170
169 171
170QString ODevice::vendorString ( ) 172QString ODevice::vendorString ( )
171{ 173{
172 return d-> m_vendorstr; 174 return d-> m_vendorstr;
173} 175}
174 176
175OVendor ODevice::vendor ( ) 177OVendor ODevice::vendor ( )
176{ 178{
177 return d-> m_vendor; 179 return d-> m_vendor;
178} 180}
179 181
180QString ODevice::modelString ( ) 182QString ODevice::modelString ( )
181{ 183{
182 return d-> m_modelstr; 184 return d-> m_modelstr;
183} 185}
184 186
185OModel ODevice::model ( ) 187OModel ODevice::model ( )
186{ 188{
187 return d-> m_model; 189 return d-> m_model;
188} 190}
189 191
190QString ODevice::systemString ( ) 192QString ODevice::systemString ( )
191{ 193{
192 return d-> m_systemstr; 194 return d-> m_systemstr;
193} 195}
194 196
195OSystem ODevice::system ( ) 197OSystem ODevice::system ( )
196{ 198{
197 return d-> m_system; 199 return d-> m_system;
198} 200}
199 201
200QString ODevice::systemVersionString ( ) 202QString ODevice::systemVersionString ( )
201{ 203{
202 return d-> m_sysverstr; 204 return d-> m_sysverstr;
203} 205}
204 206
205void ODevice::alarmSound ( ) 207void ODevice::alarmSound ( )
206{ 208{
207#ifndef QT_QWS_EBX 209#ifndef QT_QWS_EBX
208#ifndef QT_NO_SOUND 210#ifndef QT_NO_SOUND
209 static Sound snd ( "alarm" ); 211 static Sound snd ( "alarm" );
210 212
211 if ( snd. isFinished ( )) 213 if ( snd. isFinished ( ))
212 snd. play ( ); 214 snd. play ( );
213#endif 215#endif
214#endif 216#endif
215} 217}
216 218
217void ODevice::keySound ( ) 219void ODevice::keySound ( )
218{ 220{
219#ifndef QT_QWS_EBX 221#ifndef QT_QWS_EBX
220#ifndef QT_NO_SOUND 222#ifndef QT_NO_SOUND
221 static Sound snd ( "keysound" ); 223 static Sound snd ( "keysound" );
222 224
223 if ( snd. isFinished ( )) 225 if ( snd. isFinished ( ))
224 snd. play ( ); 226 snd. play ( );
225#endif 227#endif
226#endif 228#endif
227} 229}
228 230
229void ODevice::touchSound ( ) 231void ODevice::touchSound ( )
230{ 232{
231 233
232#ifndef QT_QWS_EBX 234#ifndef QT_QWS_EBX
233#ifndef QT_NO_SOUND 235#ifndef QT_NO_SOUND
234 static Sound snd ( "touchsound" ); 236 static Sound snd ( "touchsound" );
235//qDebug("touchSound"); 237//qDebug("touchSound");
236 if ( snd. isFinished ( )) { 238 if ( snd. isFinished ( )) {
237 snd. play ( ); 239 snd. play ( );
238 // qDebug("sound should play"); 240 // qDebug("sound should play");
239 } 241 }
240#endif 242#endif
241#endif 243#endif
242} 244}
243 245
244uint ODevice::hasLeds ( ) const 246uint ODevice::hasLeds ( ) const
245{ 247{
246 return 0; 248 return 0;
247} 249}
248 250
249OLedState ODevice::led ( uint /*which*/ ) const 251OLedState ODevice::led ( uint /*which*/ ) const
250{ 252{
251 return OLED_Off; 253 return OLED_Off;
252} 254}
253 255
254bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) 256bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ )
255{ 257{
256 return false; 258 return false;
257} 259}
258 260