author | eilers <eilers> | 2004-03-31 15:11:38 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-03-31 15:11:38 (UTC) |
commit | 10ed731c865d41955bf2aeb721cad592cd56b545 (patch) (unidiff) | |
tree | 2c05853293b3e0a1020a51bb84a804e0074e2c2b | |
parent | 0a56adea03683be6066622bbbbae1f0b8c73db12 (diff) | |
download | opie-10ed731c865d41955bf2aeb721cad592cd56b545.zip opie-10ed731c865d41955bf2aeb721cad592cd56b545.tar.gz opie-10ed731c865d41955bf2aeb721cad592cd56b545.tar.bz2 |
Fixed small bug, causes some crashes at startup: qDebug("... %s"); is bad.. ;)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index f3e2cfb..1ad0327 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,288 +1,288 @@ | |||
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 | ||
49 | /* STD */ | 49 | /* STD */ |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> |
51 | #include <math.h> | 51 | #include <math.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | #include <signal.h> | 53 | #include <signal.h> |
54 | #include <sys/ioctl.h> | 54 | #include <sys/ioctl.h> |
55 | #include <sys/time.h> | 55 | #include <sys/time.h> |
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #ifndef QT_NO_SOUND | 57 | #ifndef QT_NO_SOUND |
58 | #include <linux/soundcard.h> | 58 | #include <linux/soundcard.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 61 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
62 | 62 | ||
63 | using namespace Opie::Core; | 63 | using namespace Opie::Core; |
64 | 64 | ||
65 | ODevice *ODevice::inst() | 65 | ODevice *ODevice::inst() |
66 | { | 66 | { |
67 | static ODevice *dev = 0; | 67 | static ODevice *dev = 0; |
68 | 68 | ||
69 | // rewrite this to only use /proc/cpuinfo or so | 69 | // rewrite this to only use /proc/cpuinfo or so |
70 | 70 | ||
71 | if ( !dev ) | 71 | if ( !dev ) |
72 | { | 72 | { |
73 | QFile f( PATH_PROC_CPUINFO ); | 73 | QFile f( PATH_PROC_CPUINFO ); |
74 | if ( f.open( IO_ReadOnly ) ) | 74 | if ( f.open( IO_ReadOnly ) ) |
75 | { | 75 | { |
76 | QTextStream s( &f ); | 76 | QTextStream s( &f ); |
77 | while ( !s.atEnd() ) | 77 | while ( !s.atEnd() ) |
78 | { | 78 | { |
79 | QString line; | 79 | QString line; |
80 | line = s.readLine(); | 80 | line = s.readLine(); |
81 | if ( line.startsWith( "Hardware" ) ) | 81 | if ( line.startsWith( "Hardware" ) ) |
82 | { | 82 | { |
83 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 83 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
84 | if ( line.contains( "sharp", false ) ) dev = new Private::Zaurus(); | 84 | if ( line.contains( "sharp", false ) ) dev = new Private::Zaurus(); |
85 | else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ(); | 85 | else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ(); |
86 | else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad(); | 86 | else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad(); |
87 | else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada(); | 87 | else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada(); |
88 | else if ( line.contains( "ramses", false ) ) dev = new Private::Ramses(); | 88 | else if ( line.contains( "ramses", false ) ) dev = new Private::Ramses(); |
89 | else qWarning( "ODevice() - unknown hardware - using default." ); | 89 | else qWarning( "ODevice() - unknown hardware - using default." ); |
90 | break; | 90 | break; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
94 | else | 94 | else |
95 | { | 95 | { |
96 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." ); | 96 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
97 | } | 97 | } |
98 | if ( !dev ) dev = new ODevice(); | 98 | if ( !dev ) dev = new ODevice(); |
99 | dev->init(); | 99 | dev->init(); |
100 | } | 100 | } |
101 | return dev; | 101 | return dev; |
102 | } | 102 | } |
103 | 103 | ||
104 | ODevice::ODevice() | 104 | ODevice::ODevice() |
105 | { | 105 | { |
106 | d = new ODeviceData; | 106 | d = new ODeviceData; |
107 | 107 | ||
108 | d->m_modelstr = "Unknown"; | 108 | d->m_modelstr = "Unknown"; |
109 | d->m_model = Model_Unknown; | 109 | d->m_model = Model_Unknown; |
110 | d->m_vendorstr = "Unknown"; | 110 | d->m_vendorstr = "Unknown"; |
111 | d->m_vendor = Vendor_Unknown; | 111 | d->m_vendor = Vendor_Unknown; |
112 | d->m_systemstr = "Unknown"; | 112 | d->m_systemstr = "Unknown"; |
113 | d->m_system = System_Unknown; | 113 | d->m_system = System_Unknown; |
114 | d->m_sysverstr = "0.0"; | 114 | d->m_sysverstr = "0.0"; |
115 | d->m_rotation = Rot0; | 115 | d->m_rotation = Rot0; |
116 | d->m_direction = CW; | 116 | d->m_direction = CW; |
117 | 117 | ||
118 | d->m_holdtime = 1000; // 1000ms | 118 | d->m_holdtime = 1000; // 1000ms |
119 | d->m_buttons = 0; | 119 | d->m_buttons = 0; |
120 | d->m_cpu_frequencies = new QStrList; | 120 | d->m_cpu_frequencies = new QStrList; |
121 | } | 121 | } |
122 | 122 | ||
123 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 123 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
124 | { | 124 | { |
125 | if ( msg == "deviceButtonMappingChanged()" ) { | 125 | if ( msg == "deviceButtonMappingChanged()" ) { |
126 | reloadButtonMapping(); | 126 | reloadButtonMapping(); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | void ODevice::init() | 130 | void ODevice::init() |
131 | { | 131 | { |
132 | } | 132 | } |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * This method initialises the button mapping | 135 | * This method initialises the button mapping |
136 | */ | 136 | */ |
137 | void ODevice::initButtons() | 137 | void ODevice::initButtons() |
138 | { | 138 | { |
139 | if ( d->m_buttons ) | 139 | if ( d->m_buttons ) |
140 | return; | 140 | return; |
141 | 141 | ||
142 | qDebug ( "init Buttons" ); | 142 | qDebug ( "init Buttons" ); |
143 | d->m_buttons = new QValueList <ODeviceButton>; | 143 | d->m_buttons = new QValueList <ODeviceButton>; |
144 | 144 | ||
145 | reloadButtonMapping(); | 145 | reloadButtonMapping(); |
146 | 146 | ||
147 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 147 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
148 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 148 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
149 | } | 149 | } |
150 | 150 | ||
151 | ODevice::~ODevice() | 151 | ODevice::~ODevice() |
152 | { | 152 | { |
153 | // we leak m_devicebuttons and m_cpu_frequency | 153 | // we leak m_devicebuttons and m_cpu_frequency |
154 | // but it's a singleton and it is not so importantant | 154 | // but it's a singleton and it is not so importantant |
155 | // -zecke | 155 | // -zecke |
156 | delete d; | 156 | delete d; |
157 | } | 157 | } |
158 | 158 | ||
159 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 159 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
160 | { | 160 | { |
161 | return false; | 161 | return false; |
162 | } | 162 | } |
163 | 163 | ||
164 | //#include <linux/apm_bios.h> | 164 | //#include <linux/apm_bios.h> |
165 | 165 | ||
166 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 166 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
167 | 167 | ||
168 | /** | 168 | /** |
169 | * This method will try to suspend the device | 169 | * This method will try to suspend the device |
170 | * It only works if the user is the QWS Server and the apm application | 170 | * It only works if the user is the QWS Server and the apm application |
171 | * is installed. | 171 | * is installed. |
172 | * It tries to suspend and then waits some time cause some distributions | 172 | * It tries to suspend and then waits some time cause some distributions |
173 | * do have asynchronus apm implementations. | 173 | * do have asynchronus apm implementations. |
174 | * This method will either fail and return false or it'll suspend the | 174 | * This method will either fail and return false or it'll suspend the |
175 | * device and return once the device got woken up | 175 | * device and return once the device got woken up |
176 | * | 176 | * |
177 | * @return if the device got suspended | 177 | * @return if the device got suspended |
178 | */ | 178 | */ |
179 | bool ODevice::suspend() | 179 | bool ODevice::suspend() |
180 | { | 180 | { |
181 | qDebug("ODevice::suspend"); | 181 | qDebug("ODevice::suspend"); |
182 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 182 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
183 | return false; | 183 | return false; |
184 | 184 | ||
185 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 185 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
186 | return false; | 186 | return false; |
187 | 187 | ||
188 | bool res = false; | 188 | bool res = false; |
189 | ODevice::sendSuspendmsg(); | 189 | ODevice::sendSuspendmsg(); |
190 | 190 | ||
191 | struct timeval tvs, tvn; | 191 | struct timeval tvs, tvn; |
192 | ::gettimeofday ( &tvs, 0 ); | 192 | ::gettimeofday ( &tvs, 0 ); |
193 | 193 | ||
194 | ::sync(); // flush fs caches | 194 | ::sync(); // flush fs caches |
195 | res = ( ::system ( "apm --suspend" ) == 0 ); | 195 | res = ( ::system ( "apm --suspend" ) == 0 ); |
196 | 196 | ||
197 | // This is needed because the iPAQ apm implementation is asynchronous and we | 197 | // This is needed because the iPAQ apm implementation is asynchronous and we |
198 | // can not be sure when exactly the device is really suspended | 198 | // can not be sure when exactly the device is really suspended |
199 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 199 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
200 | 200 | ||
201 | if ( res ) { | 201 | if ( res ) { |
202 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 202 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
203 | ::usleep ( 200 * 1000 ); | 203 | ::usleep ( 200 * 1000 ); |
204 | ::gettimeofday ( &tvn, 0 ); | 204 | ::gettimeofday ( &tvn, 0 ); |
205 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 205 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
206 | } | 206 | } |
207 | 207 | ||
208 | return res; | 208 | return res; |
209 | } | 209 | } |
210 | 210 | ||
211 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 211 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
212 | 212 | ||
213 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 213 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
214 | 214 | ||
215 | /* VESA Blanking Levels */ | 215 | /* VESA Blanking Levels */ |
216 | #define VESA_NO_BLANKING 0 | 216 | #define VESA_NO_BLANKING 0 |
217 | #define VESA_VSYNC_SUSPEND 1 | 217 | #define VESA_VSYNC_SUSPEND 1 |
218 | #define VESA_HSYNC_SUSPEND 2 | 218 | #define VESA_HSYNC_SUSPEND 2 |
219 | #define VESA_POWERDOWN 3 | 219 | #define VESA_POWERDOWN 3 |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * This sets the display on or off | 222 | * This sets the display on or off |
223 | */ | 223 | */ |
224 | bool ODevice::setDisplayStatus ( bool on ) | 224 | bool ODevice::setDisplayStatus ( bool on ) |
225 | { | 225 | { |
226 | qDebug("ODevice::setDisplayStatus(%d)", on); | 226 | qDebug("ODevice::setDisplayStatus(%d)", on); |
227 | 227 | ||
228 | if ( d->m_model == Model_Unknown ) | 228 | if ( d->m_model == Model_Unknown ) |
229 | return false; | 229 | return false; |
230 | 230 | ||
231 | bool res = false; | 231 | bool res = false; |
232 | int fd; | 232 | int fd; |
233 | 233 | ||
234 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 234 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
235 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 235 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
236 | ::close ( fd ); | 236 | ::close ( fd ); |
237 | } | 237 | } |
238 | return res; | 238 | return res; |
239 | } | 239 | } |
240 | 240 | ||
241 | /** | 241 | /** |
242 | * This sets the display brightness | 242 | * This sets the display brightness |
243 | * | 243 | * |
244 | * @param p The brightness to be set on a scale from 0 to 255 | 244 | * @param p The brightness to be set on a scale from 0 to 255 |
245 | * @return success or failure | 245 | * @return success or failure |
246 | */ | 246 | */ |
247 | bool ODevice::setDisplayBrightness ( int p) | 247 | bool ODevice::setDisplayBrightness ( int p) |
248 | { | 248 | { |
249 | Q_UNUSED( p ) | 249 | Q_UNUSED( p ) |
250 | return false; | 250 | return false; |
251 | } | 251 | } |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * @return returns the number of steppings on the brightness slider | 254 | * @return returns the number of steppings on the brightness slider |
255 | * in the Light-'n-Power settings. | 255 | * in the Light-'n-Power settings. |
256 | */ | 256 | */ |
257 | int ODevice::displayBrightnessResolution() const | 257 | int ODevice::displayBrightnessResolution() const |
258 | { | 258 | { |
259 | return 16; | 259 | return 16; |
260 | } | 260 | } |
261 | 261 | ||
262 | /** | 262 | /** |
263 | * This sets the display contrast | 263 | * This sets the display contrast |
264 | * @param p The contrast to be set on a scale from 0 to 255 | 264 | * @param p The contrast to be set on a scale from 0 to 255 |
265 | * @return success or failure | 265 | * @return success or failure |
266 | */ | 266 | */ |
267 | bool ODevice::setDisplayContrast ( int p) | 267 | bool ODevice::setDisplayContrast ( int p) |
268 | { | 268 | { |
269 | Q_UNUSED( p ) | 269 | Q_UNUSED( p ) |
270 | return false; | 270 | return false; |
271 | } | 271 | } |
272 | 272 | ||
273 | /** | 273 | /** |
274 | * @return return the max value for the brightness settings slider | 274 | * @return return the max value for the brightness settings slider |
275 | * or 0 if the device doesn't support setting of a contrast | 275 | * or 0 if the device doesn't support setting of a contrast |
276 | */ | 276 | */ |
277 | int ODevice::displayContrastResolution() const | 277 | int ODevice::displayContrastResolution() const |
278 | { | 278 | { |
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | 281 | ||
282 | /** | 282 | /** |
283 | * This returns the vendor as string | 283 | * This returns the vendor as string |
284 | * @return Vendor as QString | 284 | * @return Vendor as QString |
285 | */ | 285 | */ |
286 | QString ODevice::vendorString() const | 286 | QString ODevice::vendorString() const |
287 | { | 287 | { |
288 | return d->m_vendorstr; | 288 | return d->m_vendorstr; |