author | mickeyl <mickeyl> | 2006-06-09 00:21:31 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2006-06-09 00:21:31 (UTC) |
commit | ab1422b3e7df8644d6df2519f5ef5b5c831e3965 (patch) (unidiff) | |
tree | 8e25b980c4898f3253a8d1f9efb23494ff4033ed /libopie2 | |
parent | f469b23ef6f69b379dcb75834c14d19dbc4676d0 (diff) | |
download | opie-ab1422b3e7df8644d6df2519f5ef5b5c831e3965.zip opie-ab1422b3e7df8644d6df2519f5ef5b5c831e3965.tar.gz opie-ab1422b3e7df8644d6df2519f5ef5b5c831e3965.tar.bz2 |
add brightness control for motorola ezx
-rw-r--r-- | libopie2/opiecore/device/odevice_motorola_ezx.cpp | 55 |
1 files changed, 11 insertions, 44 deletions
diff --git a/libopie2/opiecore/device/odevice_motorola_ezx.cpp b/libopie2/opiecore/device/odevice_motorola_ezx.cpp index 69256dd..eed81ac 100644 --- a/libopie2/opiecore/device/odevice_motorola_ezx.cpp +++ b/libopie2/opiecore/device/odevice_motorola_ezx.cpp | |||
@@ -1,325 +1,292 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2006 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2006 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ._= =} : | 11 | ._= =} : |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "odevice_motorola_ezx.h" | 29 | #include "odevice_motorola_ezx.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <opie2/oinputsystem.h> | 32 | #include <opie2/oinputsystem.h> |
33 | #include <opie2/oresource.h> | 33 | #include <opie2/oresource.h> |
34 | 34 | ||
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/sound.h> | 36 | #include <qpe/sound.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qwindowsystem_qws.h> | 42 | #include <qwindowsystem_qws.h> |
43 | #include <qcopchannel_qws.h> | 43 | #include <qcopchannel_qws.h> |
44 | 44 | ||
45 | /* STD */ | 45 | /* STD */ |
46 | #include <assert.h> | 46 | #include <assert.h> |
47 | #include <string.h> | 47 | #include <string.h> |
48 | #include <errno.h> | 48 | #include <errno.h> |
49 | #include <fcntl.h> | 49 | #include <fcntl.h> |
50 | #include <math.h> | 50 | #include <math.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <signal.h> | 52 | #include <signal.h> |
53 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
54 | #include <sys/time.h> | 54 | #include <sys/time.h> |
55 | #include <unistd.h> | 55 | #include <unistd.h> |
56 | #ifndef QT_NO_SOUND | 56 | #ifndef QT_NO_SOUND |
57 | #include <linux/soundcard.h> | 57 | #include <linux/soundcard.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | using namespace Opie::Core; | 60 | using namespace Opie::Core; |
61 | using namespace Opie::Core::Internal; | 61 | using namespace Opie::Core::Internal; |
62 | 62 | ||
63 | struct ezx_button ezx_buttons [] = { | 63 | struct ezx_button ezx_buttons [] = { |
64 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 64 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
65 | "devicebuttons/z_calendar", | 65 | "devicebuttons/z_calendar", |
66 | "datebook", "nextView()", | 66 | "datebook", "nextView()", |
67 | "today", "raise()" }, | 67 | "today", "raise()" }, |
68 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 68 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
69 | "devicebuttons/z_contact", | 69 | "devicebuttons/z_contact", |
70 | "addressbook", "raise()", | 70 | "addressbook", "raise()", |
71 | "addressbook", "beamBusinessCard()" }, | 71 | "addressbook", "beamBusinessCard()" }, |
72 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 72 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
73 | "devicebuttons/z_home", | 73 | "devicebuttons/z_home", |
74 | "QPE/Launcher", "home()", | 74 | "QPE/Launcher", "home()", |
75 | "buttonsettings", "raise()" }, | 75 | "buttonsettings", "raise()" }, |
76 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 76 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
77 | "devicebuttons/z_menu", | 77 | "devicebuttons/z_menu", |
78 | "QPE/TaskBar", "toggleMenu()", | 78 | "QPE/TaskBar", "toggleMenu()", |
79 | "QPE/TaskBar", "toggleStartMenu()" }, | 79 | "QPE/TaskBar", "toggleStartMenu()" }, |
80 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 80 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
81 | "devicebuttons/z_mail", | 81 | "devicebuttons/z_mail", |
82 | "opiemail", "raise()", | 82 | "opiemail", "raise()", |
83 | "opiemail", "newMail()" }, | 83 | "opiemail", "newMail()" }, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | void Motorola_EZX::init(const QString& cpu_info) | 86 | void Motorola_EZX::init(const QString& cpu_info) |
87 | { | 87 | { |
88 | qDebug( "Motorola_EZX::init()" ); | 88 | qDebug( "Motorola_EZX::init()" ); |
89 | // Set the time to wait until the system is really suspended | 89 | // Set the time to wait until the system is really suspended |
90 | // the delta between apm --suspend and sleeping | 90 | // the delta between apm --suspend and sleeping |
91 | setAPMTimeOut( 15000 ); | 91 | setAPMTimeOut( 15000 ); |
92 | 92 | ||
93 | d->m_vendorstr = "OpenEZX Team"; | 93 | d->m_vendorstr = "OpenEZX Team"; |
94 | d->m_systemstr = "OpenEZX"; | 94 | d->m_systemstr = "OpenEZX"; |
95 | d->m_system = System_OpenEZX; | 95 | d->m_system = System_OpenEZX; |
96 | // sysver already gathered | 96 | // sysver already gathered |
97 | 97 | ||
98 | // check the Motorola_EZX model | 98 | // check the Motorola_EZX model |
99 | QString model; | 99 | QString model; |
100 | int loc = cpu_info.find( ":" ); | 100 | int loc = cpu_info.find( ":" ); |
101 | if ( loc != -1 ) | 101 | if ( loc != -1 ) |
102 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 102 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
103 | else | 103 | else |
104 | model = cpu_info; | 104 | model = cpu_info; |
105 | 105 | ||
106 | if ( model == "Motorola Ezx Platform" ) { | 106 | if ( model == "Motorola Ezx Platform" ) { |
107 | d->m_model = Model_Motorola_EZX; | 107 | d->m_model = Model_Motorola_EZX; |
108 | d->m_modelstr = "Motorola_EZX"; | 108 | d->m_modelstr = "Motorola_EZX"; |
109 | } else assert( 0 ); | 109 | } else assert( 0 ); |
110 | 110 | ||
111 | // set path to backlight device in kernel 2.6 | 111 | // set path to backlight device in kernel 2.6 |
112 | m_backlightdev = "/sys/class/backlight/ezx-bl/"; | 112 | m_backlightdev = "/sys/class/backlight/ezx-bl/"; |
113 | d->m_rotation = Rot0; | 113 | d->m_rotation = Rot0; |
114 | //initHingeSensor(); | 114 | //initHingeSensor(); |
115 | 115 | ||
116 | // set default qte driver and led state | 116 | // set default qte driver and led state |
117 | d->m_qteDriver = "Transformed"; | 117 | d->m_qteDriver = "Transformed"; |
118 | m_leds[0] = Led_Off; | 118 | m_leds[0] = Led_Off; |
119 | 119 | ||
120 | qDebug( "Motorola_EZX::init() - Using the 2.6 OpenEZX HAL on a %s", (const char*) d->m_modelstr ); | 120 | qDebug( "Motorola_EZX::init() - Using the 2.6 OpenEZX HAL on a %s", (const char*) d->m_modelstr ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void Motorola_EZX::initButtons() | 123 | void Motorola_EZX::initButtons() |
124 | { | 124 | { |
125 | qDebug( "Motorola_EZX::initButtons()" ); | 125 | qDebug( "Motorola_EZX::initButtons()" ); |
126 | if ( d->m_buttons ) | 126 | if ( d->m_buttons ) |
127 | return; | 127 | return; |
128 | 128 | ||
129 | d->m_buttons = new QValueList <ODeviceButton>; | 129 | d->m_buttons = new QValueList <ODeviceButton>; |
130 | 130 | ||
131 | struct ezx_button * ezx_buttons; | 131 | struct ezx_button * ezx_buttons; |
132 | int buttoncount; | 132 | int buttoncount; |
133 | 133 | ||
134 | /* | 134 | /* |
135 | 135 | ||
136 | switch ( d->m_model ) | 136 | switch ( d->m_model ) |
137 | { | 137 | { |
138 | case Model_Motorola_EZX_SL6000: | 138 | case Model_Motorola_EZX_SL6000: |
139 | pezx_buttons = ezx_buttons_6000; | 139 | pezx_buttons = ezx_buttons_6000; |
140 | buttoncount = ARRAY_SIZE(ezx_buttons_6000); | 140 | buttoncount = ARRAY_SIZE(ezx_buttons_6000); |
141 | break; | 141 | break; |
142 | case Model_Motorola_EZX_SLC3100: // fallthrough | 142 | case Model_Motorola_EZX_SLC3100: // fallthrough |
143 | case Model_Motorola_EZX_SLC3000: // fallthrough | 143 | case Model_Motorola_EZX_SLC3000: // fallthrough |
144 | case Model_Motorola_EZX_SLC1000: // fallthrough | 144 | case Model_Motorola_EZX_SLC1000: // fallthrough |
145 | case Model_Motorola_EZX_SLC7x0: | 145 | case Model_Motorola_EZX_SLC7x0: |
146 | if ( isQWS( ) ) | 146 | if ( isQWS( ) ) |
147 | { | 147 | { |
148 | addPreHandler(this); | 148 | addPreHandler(this); |
149 | } | 149 | } |
150 | pezx_buttons = ezx_buttons_c700; | 150 | pezx_buttons = ezx_buttons_c700; |
151 | buttoncount = ARRAY_SIZE(ezx_buttons_c700); | 151 | buttoncount = ARRAY_SIZE(ezx_buttons_c700); |
152 | break; | 152 | break; |
153 | default: | 153 | default: |
154 | pezx_buttons = ezx_buttons; | 154 | pezx_buttons = ezx_buttons; |
155 | buttoncount = ARRAY_SIZE(ezx_buttons); | 155 | buttoncount = ARRAY_SIZE(ezx_buttons); |
156 | break; | 156 | break; |
157 | } | 157 | } |
158 | 158 | ||
159 | for ( int i = 0; i < buttoncount; i++ ) { | 159 | for ( int i = 0; i < buttoncount; i++ ) { |
160 | struct ezx_button *zb = pezx_buttons + i; | 160 | struct ezx_button *zb = pezx_buttons + i; |
161 | ODeviceButton b; | 161 | ODeviceButton b; |
162 | 162 | ||
163 | b.setKeycode( zb->code ); | 163 | b.setKeycode( zb->code ); |
164 | b.setUserText( QObject::tr( "Button", zb->utext )); | 164 | b.setUserText( QObject::tr( "Button", zb->utext )); |
165 | b.setPixmap( OResource::loadPixmap( zb->pix )); | 165 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
166 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 166 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
167 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 167 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
168 | d->m_buttons->append( b ); | 168 | d->m_buttons->append( b ); |
169 | } | 169 | } |
170 | */ | 170 | */ |
171 | reloadButtonMapping(); | 171 | reloadButtonMapping(); |
172 | } | 172 | } |
173 | 173 | ||
174 | void Motorola_EZX::playAlarmSound() | 174 | void Motorola_EZX::playAlarmSound() |
175 | { | 175 | { |
176 | #ifndef QT_NO_SOUND | 176 | #ifndef QT_NO_SOUND |
177 | static Sound snd ( "alarm" ); | 177 | static Sound snd ( "alarm" ); |
178 | if(!snd.isFinished()) | 178 | if(!snd.isFinished()) |
179 | return; | 179 | return; |
180 | 180 | ||
181 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 181 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
182 | snd. play(); | 182 | snd. play(); |
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | 185 | ||
186 | QValueList <OLed> Motorola_EZX::ledList() const | 186 | QValueList <OLed> Motorola_EZX::ledList() const |
187 | { | 187 | { |
188 | QValueList <OLed> vl; | 188 | QValueList <OLed> vl; |
189 | vl << Led_Mail; | 189 | vl << Led_Mail; |
190 | return vl; | 190 | return vl; |
191 | } | 191 | } |
192 | 192 | ||
193 | QValueList <OLedState> Motorola_EZX::ledStateList( OLed l ) const | 193 | QValueList <OLedState> Motorola_EZX::ledStateList( OLed l ) const |
194 | { | 194 | { |
195 | QValueList <OLedState> vl; | 195 | QValueList <OLedState> vl; |
196 | 196 | ||
197 | if ( l == Led_Mail ) | 197 | if ( l == Led_Mail ) |
198 | vl << Led_Off << Led_On << Led_BlinkSlow; | 198 | vl << Led_Off << Led_On << Led_BlinkSlow; |
199 | return vl; | 199 | return vl; |
200 | } | 200 | } |
201 | 201 | ||
202 | OLedState Motorola_EZX::ledState( OLed which ) const | 202 | OLedState Motorola_EZX::ledState( OLed which ) const |
203 | { | 203 | { |
204 | if ( which == Led_Mail ) | 204 | if ( which == Led_Mail ) |
205 | return m_leds [0]; | 205 | return m_leds [0]; |
206 | else | 206 | else |
207 | return Led_Off; | 207 | return Led_Off; |
208 | } | 208 | } |
209 | 209 | ||
210 | bool Motorola_EZX::setLedState( OLed which, OLedState st ) | 210 | bool Motorola_EZX::setLedState( OLed which, OLedState st ) |
211 | { | 211 | { |
212 | // Currently not supported | 212 | // Currently not supported |
213 | qDebug( "Motorola_EZX::setLedState: ODevice handling not yet implemented" ); | 213 | qDebug( "Motorola_EZX::setLedState: ODevice handling not yet implemented" ); |
214 | return false; | 214 | return false; |
215 | } | 215 | } |
216 | 216 | ||
217 | int Motorola_EZX::displayBrightnessResolution() const | 217 | int Motorola_EZX::displayBrightnessResolution() const |
218 | { | 218 | { |
219 | // Currently not supported | ||
220 | qDebug( "Motorola_EZX::displayBrightnessResolution: ODevice handling not yet implemented" ); | ||
221 | return 100; | ||
222 | |||
223 | #if 0 | ||
224 | int res = 1; | 219 | int res = 1; |
225 | if (m_embedix) | 220 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
226 | { | 221 | if ( fd ) |
227 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | ||
228 | if ( fd ) | ||
229 | { | ||
230 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | ||
231 | ::close( fd ); | ||
232 | return value ? value : res; | ||
233 | } | ||
234 | } | ||
235 | else | ||
236 | { | 222 | { |
237 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 223 | char buf[100]; |
238 | if ( fd ) | 224 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
239 | { | 225 | ::close( fd ); |
240 | char buf[100]; | ||
241 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | ||
242 | ::close( fd ); | ||
243 | } | ||
244 | } | 226 | } |
245 | return res; | 227 | return res; |
246 | #endif | ||
247 | } | 228 | } |
248 | 229 | ||
249 | bool Motorola_EZX::setDisplayBrightness( int bright ) | 230 | bool Motorola_EZX::setDisplayBrightness( int bright ) |
250 | { | 231 | { |
251 | qDebug( "Motorola_EZX::setDisplayBrightness( %d )", bright ); | 232 | qDebug( "Motorola_EZX::setDisplayBrightness( %d )", bright ); |
252 | return false; | 233 | return false; |
253 | 234 | ||
254 | #if 0 | ||
255 | bool res = false; | 235 | bool res = false; |
256 | 236 | ||
257 | if ( bright > 255 ) bright = 255; | 237 | if ( bright > 255 ) bright = 255; |
258 | if ( bright < 0 ) bright = 0; | 238 | if ( bright < 0 ) bright = 0; |
259 | 239 | ||
260 | int numberOfSteps = displayBrightnessResolution(); | 240 | int numberOfSteps = displayBrightnessResolution(); |
261 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 241 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
262 | 242 | ||
263 | if ( m_embedix ) | 243 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
264 | { | 244 | if ( fd ) |
265 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | ||
266 | if ( fd ) | ||
267 | { | ||
268 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | ||
269 | ::close( fd ); | ||
270 | } | ||
271 | } | ||
272 | else | ||
273 | { | 245 | { |
274 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 246 | char buf[100]; |
275 | if ( fd ) | 247 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
276 | { | 248 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
277 | char buf[100]; | 249 | ::close( fd ); |
278 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | ||
279 | res = ( ::write( fd, &buf[0], len ) == 0 ); | ||
280 | ::close( fd ); | ||
281 | } | ||
282 | } | 250 | } |
283 | return res; | 251 | return res; |
284 | #endif | ||
285 | } | 252 | } |
286 | 253 | ||
287 | bool Motorola_EZX::setDisplayStatus( bool on ) | 254 | bool Motorola_EZX::setDisplayStatus( bool on ) |
288 | { | 255 | { |
289 | bool res = false; | 256 | bool res = false; |
290 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 257 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
291 | if ( fd ) | 258 | if ( fd ) |
292 | { | 259 | { |
293 | char buf[10]; | 260 | char buf[10]; |
294 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 261 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
295 | buf[1] = '\0'; | 262 | buf[1] = '\0'; |
296 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 263 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
297 | ::close( fd ); | 264 | ::close( fd ); |
298 | } | 265 | } |
299 | return res; | 266 | return res; |
300 | } | 267 | } |
301 | 268 | ||
302 | void Motorola_EZX::systemMessage( const QCString &msg, const QByteArray & ) | 269 | void Motorola_EZX::systemMessage( const QCString &msg, const QByteArray & ) |
303 | { | 270 | { |
304 | if ( msg == "deviceButtonMappingChanged()" ) { | 271 | if ( msg == "deviceButtonMappingChanged()" ) { |
305 | reloadButtonMapping(); | 272 | reloadButtonMapping(); |
306 | } | 273 | } |
307 | } | 274 | } |
308 | 275 | ||
309 | bool Motorola_EZX::suspend() { | 276 | bool Motorola_EZX::suspend() { |
310 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 277 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
311 | return false; | 278 | return false; |
312 | 279 | ||
313 | bool res = false; | 280 | bool res = false; |
314 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); | 281 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); |
315 | 282 | ||
316 | struct timeval tvs, tvn; | 283 | struct timeval tvs, tvn; |
317 | ::gettimeofday ( &tvs, 0 ); | 284 | ::gettimeofday ( &tvs, 0 ); |
318 | 285 | ||
319 | ::sync(); // flush fs caches | 286 | ::sync(); // flush fs caches |
320 | res = ( ::system ( "apm --suspend" ) == 0 ); | 287 | res = ( ::system ( "apm --suspend" ) == 0 ); |
321 | 288 | ||
322 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); | 289 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); |
323 | 290 | ||
324 | return res; | 291 | return res; |
325 | } | 292 | } |