-rw-r--r-- | core/launcher/desktop.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 986ae5d..2ea6d27 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -62,512 +62,513 @@ using namespace Opie; | |||
62 | class QCopKeyRegister | 62 | class QCopKeyRegister |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | QCopKeyRegister() : keyCode( 0 ) | 65 | QCopKeyRegister() : keyCode( 0 ) |
66 | { } | 66 | { } |
67 | QCopKeyRegister( int k, const QString &c, const QString &m ) | 67 | QCopKeyRegister( int k, const QString &c, const QString &m ) |
68 | : keyCode( k ), channel( c ), message( m ) | 68 | : keyCode( k ), channel( c ), message( m ) |
69 | { } | 69 | { } |
70 | 70 | ||
71 | int getKeyCode() const | 71 | int getKeyCode() const |
72 | { | 72 | { |
73 | return keyCode; | 73 | return keyCode; |
74 | } | 74 | } |
75 | QString getChannel() const | 75 | QString getChannel() const |
76 | { | 76 | { |
77 | return channel; | 77 | return channel; |
78 | } | 78 | } |
79 | QString getMessage() const | 79 | QString getMessage() const |
80 | { | 80 | { |
81 | return message; | 81 | return message; |
82 | } | 82 | } |
83 | 83 | ||
84 | private: | 84 | private: |
85 | int keyCode; | 85 | int keyCode; |
86 | QString channel, message; | 86 | QString channel, message; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 89 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
90 | KeyRegisterList keyRegisterList; | 90 | KeyRegisterList keyRegisterList; |
91 | 91 | ||
92 | static Desktop* qpedesktop = 0; | 92 | static Desktop* qpedesktop = 0; |
93 | static int loggedin = 0; | 93 | static int loggedin = 0; |
94 | static void login( bool at_poweron ) | 94 | static void login( bool at_poweron ) |
95 | { | 95 | { |
96 | if ( !loggedin ) { | 96 | if ( !loggedin ) { |
97 | Global::terminateBuiltin( "calibrate" ); | 97 | Global::terminateBuiltin( "calibrate" ); |
98 | Password::authenticate( at_poweron ); | 98 | Password::authenticate( at_poweron ); |
99 | loggedin = 1; | 99 | loggedin = 1; |
100 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 100 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | bool Desktop::screenLocked() | 104 | bool Desktop::screenLocked() |
105 | { | 105 | { |
106 | return loggedin == 0; | 106 | return loggedin == 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | /* | 109 | /* |
110 | Priority is number of alerts that are needed to pop up | 110 | Priority is number of alerts that are needed to pop up |
111 | alert. | 111 | alert. |
112 | */ | 112 | */ |
113 | class DesktopPowerAlerter : public QMessageBox | 113 | class DesktopPowerAlerter : public QMessageBox |
114 | { | 114 | { |
115 | public: | 115 | public: |
116 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 116 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
117 | : QMessageBox( tr( "Battery Status" ), "Low Battery", | 117 | : QMessageBox( tr( "Battery Status" ), "Low Battery", |
118 | QMessageBox::Critical, | 118 | QMessageBox::Critical, |
119 | QMessageBox::Ok | QMessageBox::Default, | 119 | QMessageBox::Ok | QMessageBox::Default, |
120 | QMessageBox::NoButton, QMessageBox::NoButton, | 120 | QMessageBox::NoButton, QMessageBox::NoButton, |
121 | parent, name, FALSE ) | 121 | parent, name, FALSE ) |
122 | { | 122 | { |
123 | currentPriority = INT_MAX; | 123 | currentPriority = INT_MAX; |
124 | alertCount = 0; | 124 | alertCount = 0; |
125 | } | 125 | } |
126 | 126 | ||
127 | void alert( const QString &text, int priority ); | 127 | void alert( const QString &text, int priority ); |
128 | void hideEvent( QHideEvent * ); | 128 | void hideEvent( QHideEvent * ); |
129 | private: | 129 | private: |
130 | int currentPriority; | 130 | int currentPriority; |
131 | int alertCount; | 131 | int alertCount; |
132 | }; | 132 | }; |
133 | 133 | ||
134 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 134 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
135 | { | 135 | { |
136 | alertCount++; | 136 | alertCount++; |
137 | if ( alertCount < priority ) | 137 | if ( alertCount < priority ) |
138 | return ; | 138 | return ; |
139 | if ( priority > currentPriority ) | 139 | if ( priority > currentPriority ) |
140 | return ; | 140 | return ; |
141 | currentPriority = priority; | 141 | currentPriority = priority; |
142 | setText( text ); | 142 | setText( text ); |
143 | show(); | 143 | show(); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 147 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
148 | { | 148 | { |
149 | QMessageBox::hideEvent( e ); | 149 | QMessageBox::hideEvent( e ); |
150 | alertCount = 0; | 150 | alertCount = 0; |
151 | currentPriority = INT_MAX; | 151 | currentPriority = INT_MAX; |
152 | } | 152 | } |
153 | 153 | ||
154 | class QPEScreenSaver : public QWSScreenSaver | 154 | class QPEScreenSaver : public QWSScreenSaver |
155 | { | 155 | { |
156 | private: | 156 | private: |
157 | int LcdOn; | 157 | int LcdOn; |
158 | 158 | ||
159 | public: | 159 | public: |
160 | QPEScreenSaver() | 160 | QPEScreenSaver() |
161 | { | 161 | { |
162 | m_disable_suspend = 100; | 162 | m_disable_suspend = 100; |
163 | m_enable_dim = false; | 163 | m_enable_dim = false; |
164 | m_enable_lightoff = false; | 164 | m_enable_lightoff = false; |
165 | m_enable_onlylcdoff = false; | 165 | m_enable_onlylcdoff = false; |
166 | 166 | ||
167 | m_disable_suspend_ac = 100; | 167 | m_disable_suspend_ac = 100; |
168 | m_enable_dim_ac = false; | 168 | m_enable_dim_ac = false; |
169 | m_enable_lightoff_ac = false; | 169 | m_enable_lightoff_ac = false; |
170 | m_enable_onlylcdoff_ac = false; | 170 | m_enable_onlylcdoff_ac = false; |
171 | m_disable_apm_ac = false; | 171 | m_disable_apm_ac = false; |
172 | 172 | ||
173 | m_lcd_status = true; | 173 | m_lcd_status = true; |
174 | 174 | ||
175 | m_backlight_normal = -1; | 175 | m_backlight_normal = -1; |
176 | m_backlight_current = -1; | 176 | m_backlight_current = -1; |
177 | m_backlight_forcedoff = false; | 177 | m_backlight_forcedoff = false; |
178 | 178 | ||
179 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 179 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
180 | ODevice::inst ( )-> setDisplayStatus ( true ); | 180 | ODevice::inst ( )-> setDisplayStatus ( true ); |
181 | setBacklight ( -1 ); | 181 | setBacklight ( -1 ); |
182 | } | 182 | } |
183 | void restore() | 183 | void restore() |
184 | { | 184 | { |
185 | if ( !m_lcd_status ) { // We must have turned it off | 185 | if ( !m_lcd_status ) { // We must have turned it off |
186 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 186 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
187 | m_lcd_status = true; | 187 | m_lcd_status = true; |
188 | } | 188 | } |
189 | 189 | ||
190 | setBacklightInternal ( -1 ); | 190 | setBacklightInternal ( -1 ); |
191 | } | 191 | } |
192 | bool save( int level ) | 192 | bool save( int level ) |
193 | { | 193 | { |
194 | bool onAC = ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ); | 194 | bool onAC = ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ); |
195 | 195 | ||
196 | switch ( level ) { | 196 | switch ( level ) { |
197 | case 0: | 197 | case 0: |
198 | 198 | ||
199 | if ( m_disable_suspend_ac > 0 && m_enable_dim_ac && onAC ) { | 199 | if ( m_disable_suspend_ac > 0 && m_enable_dim_ac && onAC ) { |
200 | if ( m_backlight_current > 1 ) | 200 | if ( m_backlight_current > 1 ) |
201 | setBacklight( 1 ); // lowest non-off | 201 | setBacklight( 1 ); // lowest non-off |
202 | } else if ( !onAC && m_disable_suspend > 0 && m_enable_dim ) { | 202 | } else if ( !onAC && m_disable_suspend > 0 && m_enable_dim ) { |
203 | if ( m_backlight_current > 1 ) | 203 | if ( m_backlight_current > 1 ) |
204 | setBacklightInternal( 1 ); // lowest non-off | 204 | setBacklightInternal( 1 ); // lowest non-off |
205 | } | 205 | } |
206 | return true; | 206 | return true; |
207 | break; | 207 | break; |
208 | case 1: | 208 | case 1: |
209 | 209 | ||
210 | if ( m_disable_suspend_ac > 1 && m_enable_lightoff_ac && onAC ) { | 210 | if ( m_disable_suspend_ac > 1 && m_enable_lightoff_ac && onAC ) { |
211 | setBacklightInternal( 0 ); // off | 211 | setBacklightInternal( 0 ); // off |
212 | } else if ( !onAC && m_disable_suspend > 1 && m_enable_lightoff ) { | 212 | } else if ( !onAC && m_disable_suspend > 1 && m_enable_lightoff ) { |
213 | setBacklightInternal( 0 ); // off | 213 | setBacklightInternal( 0 ); // off |
214 | } | 214 | } |
215 | return true; | 215 | return true; |
216 | break; | 216 | break; |
217 | case 2: | 217 | case 2: |
218 | if ( m_disable_apm_ac && onAC ) { | 218 | if ( m_disable_apm_ac && onAC ) { |
219 | return true; | 219 | return true; |
220 | } | 220 | } |
221 | 221 | ||
222 | if ( m_enable_onlylcdoff_ac && onAC ) { | 222 | if ( m_enable_onlylcdoff_ac && onAC ) { |
223 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 223 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
224 | m_lcd_status = false; | 224 | m_lcd_status = false; |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | else if ( !onAC && m_enable_onlylcdoff ) { | 227 | else if ( !onAC && m_enable_onlylcdoff ) { |
228 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 228 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
229 | m_lcd_status = false; | 229 | m_lcd_status = false; |
230 | return true; | 230 | return true; |
231 | } | 231 | } |
232 | else // We're going to suspend the whole machine | 232 | else // We're going to suspend the whole machine |
233 | { | 233 | { |
234 | if ( ( m_disable_suspend_ac > 2 && onAC ) && ( !Network::networkOnline ( ) ) ) { | 234 | if ( ( m_disable_suspend_ac > 2 && onAC ) && ( !Network::networkOnline ( ) ) ) { |
235 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 235 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
236 | return true; | 236 | return true; |
237 | } | 237 | } |
238 | if ( !onAC && ( m_disable_suspend > 2 ) && ( !Network::networkOnline ( ) ) ) { | 238 | if ( !onAC && ( m_disable_suspend > 2 ) && ( !Network::networkOnline ( ) ) ) { |
239 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 239 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
240 | return true; | 240 | return true; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | return false; | 245 | return false; |
246 | } | 246 | } |
247 | 247 | ||
248 | private: | 248 | private: |
249 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) | 249 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) |
250 | { | 250 | { |
251 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) | 251 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) |
252 | return 0; | 252 | return 0; |
253 | 253 | ||
254 | if ( interval < 0 ) { | 254 | if ( interval < 0 ) { |
255 | // Restore screen blanking and power saving state | 255 | // Restore screen blanking and power saving state |
256 | interval = config.readNumEntry( value, def ); | 256 | interval = config.readNumEntry( value, def ); |
257 | } | 257 | } |
258 | return interval; | 258 | return interval; |
259 | } | 259 | } |
260 | 260 | ||
261 | public: | 261 | public: |
262 | void setIntervals( int i1, int i2, int i3 ) | 262 | void setIntervals( int i1, int i2, int i3 ) |
263 | { | 263 | { |
264 | Config config( "qpe" ); | 264 | Config config( "qpe" ); |
265 | config.setGroup( "Screensaver" ); | 265 | config.setGroup( "Screensaver" ); |
266 | 266 | ||
267 | int v[ 4 ]; | 267 | int v[ 4 ]; |
268 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); | 268 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); |
269 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); | 269 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); |
270 | i3 = ssi( i3, config, "", "Interval", 60 ); | 270 | i3 = ssi( i3, config, "", "Interval", 60 ); |
271 | 271 | ||
272 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | 272 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); |
273 | 273 | ||
274 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 274 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
275 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 275 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
276 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 276 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
277 | v [ 3 ] = 0; | 277 | v [ 3 ] = 0; |
278 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); | 278 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); |
279 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); | 279 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); |
280 | m_enable_onlylcdoff = config.readNumEntry ( "LcdOffOnly", 0 ); | 280 | m_enable_onlylcdoff = config.readNumEntry ( "LcdOffOnly", 0 ); |
281 | 281 | ||
282 | if ( !i1 && !i2 && !i3 ) | 282 | if ( !i1 && !i2 && !i3 ) |
283 | QWSServer::setScreenSaverInterval( 0 ); | 283 | QWSServer::setScreenSaverInterval( 0 ); |
284 | else | 284 | else |
285 | QWSServer::setScreenSaverIntervals( v ); | 285 | QWSServer::setScreenSaverIntervals( v ); |
286 | } | 286 | } |
287 | 287 | ||
288 | void setIntervalsAC( int i1, int i2, int i3 ) | 288 | void setIntervalsAC( int i1, int i2, int i3 ) |
289 | { | 289 | { |
290 | Config config( "qpe" ); | 290 | Config config( "qpe" ); |
291 | config.setGroup( "Screensaver" ); | 291 | config.setGroup( "Screensaver" ); |
292 | 292 | ||
293 | int v[ 4 ]; | 293 | int v[ 4 ]; |
294 | i1 = ssi( i1, config, "DimAC", "Interval_DimAC", 30 ); | 294 | i1 = ssi( i1, config, "DimAC", "Interval_DimAC", 30 ); |
295 | i2 = ssi( i2, config, "LightOffAC", "Interval_LightOffAC", 20 ); | 295 | i2 = ssi( i2, config, "LightOffAC", "Interval_LightOffAC", 20 ); |
296 | i3 = ssi( i3, config, "", "IntervalAC", 60 ); | 296 | i3 = ssi( i3, config, "", "IntervalAC", 60 ); |
297 | 297 | ||
298 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | 298 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); |
299 | 299 | ||
300 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 300 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
301 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 301 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
302 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 302 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
303 | v [ 3 ] = 0; | 303 | v [ 3 ] = 0; |
304 | m_enable_dim_ac = ( ( i1 != 0 ) ? config.readNumEntry ( "DimAC", 1 ) : false ); | 304 | m_enable_dim_ac = ( ( i1 != 0 ) ? config.readNumEntry ( "DimAC", 1 ) : false ); |
305 | m_enable_lightoff_ac = ( ( i2 != 0 ) ? config.readNumEntry ( "LightOffAC", 1 ) : false ); | 305 | m_enable_lightoff_ac = ( ( i2 != 0 ) ? config.readNumEntry ( "LightOffAC", 1 ) : false ); |
306 | m_enable_onlylcdoff_ac = config.readNumEntry ( "LcdOffOnlyAC", 0 ); | 306 | m_enable_onlylcdoff_ac = config.readNumEntry ( "LcdOffOnlyAC", 0 ); |
307 | m_disable_apm_ac = config.readNumEntry ( "NoApmAC", 0 ); | 307 | m_disable_apm_ac = config.readNumEntry ( "NoApmAC", 0 ); |
308 | 308 | ||
309 | if ( !i1 && !i2 && !i3 ) | 309 | if ( !i1 && !i2 && !i3 ) |
310 | QWSServer::setScreenSaverInterval( 0 ); | 310 | QWSServer::setScreenSaverInterval( 0 ); |
311 | else | 311 | else |
312 | QWSServer::setScreenSaverIntervals( v ); | 312 | QWSServer::setScreenSaverIntervals( v ); |
313 | } | 313 | } |
314 | 314 | ||
315 | void setInterval ( int interval ) | 315 | void setInterval ( int interval ) |
316 | { | 316 | { |
317 | setIntervals ( -1, -1, interval ); | 317 | setIntervals ( -1, -1, interval ); |
318 | setIntervalsAC ( -1, -1, interval ); | ||
318 | } | 319 | } |
319 | 320 | ||
320 | void setMode ( int mode ) | 321 | void setMode ( int mode ) |
321 | { | 322 | { |
322 | if ( mode > m_disable_suspend ) | 323 | if ( mode > m_disable_suspend ) |
323 | setInterval( -1 ); | 324 | setInterval( -1 ); |
324 | m_disable_suspend = mode; | 325 | m_disable_suspend = mode; |
325 | } | 326 | } |
326 | 327 | ||
327 | void setBacklight ( int bright ) | 328 | void setBacklight ( int bright ) |
328 | { | 329 | { |
329 | // Read from config | 330 | // Read from config |
330 | Config config ( "qpe" ); | 331 | Config config ( "qpe" ); |
331 | config. setGroup ( "Screensaver" ); | 332 | config. setGroup ( "Screensaver" ); |
332 | m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); | 333 | m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); |
333 | 334 | ||
334 | setBacklightInternal ( bright ); | 335 | setBacklightInternal ( bright ); |
335 | } | 336 | } |
336 | 337 | ||
337 | private: | 338 | private: |
338 | void setBacklightInternal ( int bright ) | 339 | void setBacklightInternal ( int bright ) |
339 | { | 340 | { |
340 | if ( bright == -3 ) { | 341 | if ( bright == -3 ) { |
341 | // Forced on | 342 | // Forced on |
342 | m_backlight_forcedoff = false; | 343 | m_backlight_forcedoff = false; |
343 | bright = -1; | 344 | bright = -1; |
344 | } | 345 | } |
345 | if ( m_backlight_forcedoff && bright != -2 ) | 346 | if ( m_backlight_forcedoff && bright != -2 ) |
346 | return ; | 347 | return ; |
347 | if ( bright == -2 ) { | 348 | if ( bright == -2 ) { |
348 | // Toggle between off and on | 349 | // Toggle between off and on |
349 | bright = m_backlight_current ? 0 : -1; | 350 | bright = m_backlight_current ? 0 : -1; |
350 | m_backlight_forcedoff = !bright; | 351 | m_backlight_forcedoff = !bright; |
351 | } | 352 | } |
352 | if ( bright == -1 ) | 353 | if ( bright == -1 ) |
353 | bright = m_backlight_normal; | 354 | bright = m_backlight_normal; |
354 | 355 | ||
355 | if ( bright != m_backlight_current ) { | 356 | if ( bright != m_backlight_current ) { |
356 | ODevice::inst ( )-> setDisplayBrightness ( bright ); | 357 | ODevice::inst ( )-> setDisplayBrightness ( bright ); |
357 | m_backlight_current = bright; | 358 | m_backlight_current = bright; |
358 | } | 359 | } |
359 | } | 360 | } |
360 | 361 | ||
361 | public: | 362 | public: |
362 | void setDisplayState ( bool on ) | 363 | void setDisplayState ( bool on ) |
363 | { | 364 | { |
364 | if ( m_lcd_status != on ) { | 365 | if ( m_lcd_status != on ) { |
365 | ODevice::inst ( ) -> setDisplayStatus ( on ); | 366 | ODevice::inst ( ) -> setDisplayStatus ( on ); |
366 | m_lcd_status = on; | 367 | m_lcd_status = on; |
367 | } | 368 | } |
368 | } | 369 | } |
369 | 370 | ||
370 | private: | 371 | private: |
371 | int m_disable_suspend; | 372 | int m_disable_suspend; |
372 | bool m_enable_dim; | 373 | bool m_enable_dim; |
373 | bool m_enable_lightoff; | 374 | bool m_enable_lightoff; |
374 | bool m_enable_onlylcdoff; | 375 | bool m_enable_onlylcdoff; |
375 | 376 | ||
376 | int m_disable_suspend_ac; | 377 | int m_disable_suspend_ac; |
377 | bool m_enable_dim_ac; | 378 | bool m_enable_dim_ac; |
378 | bool m_enable_lightoff_ac; | 379 | bool m_enable_lightoff_ac; |
379 | bool m_enable_onlylcdoff_ac; | 380 | bool m_enable_onlylcdoff_ac; |
380 | bool m_disable_apm_ac; | 381 | bool m_disable_apm_ac; |
381 | 382 | ||
382 | bool m_lcd_status; | 383 | bool m_lcd_status; |
383 | 384 | ||
384 | int m_backlight_normal; | 385 | int m_backlight_normal; |
385 | int m_backlight_current; | 386 | int m_backlight_current; |
386 | bool m_backlight_forcedoff; | 387 | bool m_backlight_forcedoff; |
387 | }; | 388 | }; |
388 | 389 | ||
389 | void DesktopApplication::switchLCD ( bool on ) | 390 | void DesktopApplication::switchLCD ( bool on ) |
390 | { | 391 | { |
391 | if ( qApp ) { | 392 | if ( qApp ) { |
392 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 393 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
393 | 394 | ||
394 | if ( dapp-> m_screensaver ) { | 395 | if ( dapp-> m_screensaver ) { |
395 | if ( on ) { | 396 | if ( on ) { |
396 | dapp-> m_screensaver-> setDisplayState ( true ); | 397 | dapp-> m_screensaver-> setDisplayState ( true ); |
397 | dapp-> m_screensaver-> setBacklight ( -3 ); | 398 | dapp-> m_screensaver-> setBacklight ( -3 ); |
398 | } | 399 | } |
399 | else { | 400 | else { |
400 | dapp-> m_screensaver-> setDisplayState ( false ); | 401 | dapp-> m_screensaver-> setDisplayState ( false ); |
401 | } | 402 | } |
402 | } | 403 | } |
403 | } | 404 | } |
404 | } | 405 | } |
405 | 406 | ||
406 | 407 | ||
407 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 408 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
408 | : QPEApplication( argc, argv, appType ) | 409 | : QPEApplication( argc, argv, appType ) |
409 | { | 410 | { |
410 | 411 | ||
411 | m_timer = new QTimer( this ); | 412 | m_timer = new QTimer( this ); |
412 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); | 413 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); |
413 | Config cfg( "apm" ); | 414 | Config cfg( "apm" ); |
414 | cfg.setGroup( "Warnings" ); | 415 | cfg.setGroup( "Warnings" ); |
415 | m_timer->start( 5000 ); | 416 | m_timer->start( 5000 ); |
416 | //cfg.readNumEntry( "checkinterval", 10000 ) | 417 | //cfg.readNumEntry( "checkinterval", 10000 ) |
417 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 418 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
418 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); | 419 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); |
419 | ps = new PowerStatus; | 420 | ps = new PowerStatus; |
420 | pa = new DesktopPowerAlerter( 0 ); | 421 | pa = new DesktopPowerAlerter( 0 ); |
421 | 422 | ||
422 | channel = new QCopChannel( "QPE/Desktop", this ); | 423 | channel = new QCopChannel( "QPE/Desktop", this ); |
423 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 424 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
424 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 425 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
425 | 426 | ||
426 | channel = new QCopChannel( "QPE/System", this ); | 427 | channel = new QCopChannel( "QPE/System", this ); |
427 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 428 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
428 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 429 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
429 | 430 | ||
430 | m_screensaver = new QPEScreenSaver; | 431 | m_screensaver = new QPEScreenSaver; |
431 | 432 | ||
432 | m_screensaver-> setInterval ( -1 ); | 433 | m_screensaver-> setInterval ( -1 ); |
433 | QWSServer::setScreenSaver( m_screensaver ); | 434 | QWSServer::setScreenSaver( m_screensaver ); |
434 | } | 435 | } |
435 | 436 | ||
436 | 437 | ||
437 | DesktopApplication::~DesktopApplication() | 438 | DesktopApplication::~DesktopApplication() |
438 | { | 439 | { |
439 | delete ps; | 440 | delete ps; |
440 | delete pa; | 441 | delete pa; |
441 | } | 442 | } |
442 | 443 | ||
443 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 444 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
444 | { | 445 | { |
445 | QDataStream stream( data, IO_ReadOnly ); | 446 | QDataStream stream( data, IO_ReadOnly ); |
446 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 447 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
447 | int k; | 448 | int k; |
448 | QString c, m; | 449 | QString c, m; |
449 | stream >> k; | 450 | stream >> k; |
450 | stream >> c; | 451 | stream >> c; |
451 | stream >> m; | 452 | stream >> m; |
452 | 453 | ||
453 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 454 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
454 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 455 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
455 | } | 456 | } |
456 | } | 457 | } |
457 | 458 | ||
458 | 459 | ||
459 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 460 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
460 | { | 461 | { |
461 | QDataStream stream ( data, IO_ReadOnly ); | 462 | QDataStream stream ( data, IO_ReadOnly ); |
462 | 463 | ||
463 | if ( msg == "setScreenSaverInterval(int)" ) { | 464 | if ( msg == "setScreenSaverInterval(int)" ) { |
464 | int time; | 465 | int time; |
465 | stream >> time; | 466 | stream >> time; |
466 | m_screensaver-> setInterval( time ); | 467 | m_screensaver-> setInterval( time ); |
467 | } | 468 | } |
468 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 469 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
469 | int t1, t2, t3; | 470 | int t1, t2, t3; |
470 | stream >> t1 >> t2 >> t3; | 471 | stream >> t1 >> t2 >> t3; |
471 | m_screensaver-> setIntervals( t1, t2, t3 ); | 472 | m_screensaver-> setIntervals( t1, t2, t3 ); |
472 | } | 473 | } |
473 | else if ( msg == "setScreenSaverIntervalsAC(int,int,int)" ) { | 474 | else if ( msg == "setScreenSaverIntervalsAC(int,int,int)" ) { |
474 | int t1, t2, t3; | 475 | int t1, t2, t3; |
475 | stream >> t1 >> t2 >> t3; | 476 | stream >> t1 >> t2 >> t3; |
476 | m_screensaver-> setIntervalsAC( t1, t2, t3 ); | 477 | m_screensaver-> setIntervalsAC( t1, t2, t3 ); |
477 | } | 478 | } |
478 | else if ( msg == "setBacklight(int)" ) { | 479 | else if ( msg == "setBacklight(int)" ) { |
479 | int bright; | 480 | int bright; |
480 | stream >> bright; | 481 | stream >> bright; |
481 | m_screensaver-> setBacklight( bright ); | 482 | m_screensaver-> setBacklight( bright ); |
482 | } | 483 | } |
483 | else if ( msg == "setScreenSaverMode(int)" ) { | 484 | else if ( msg == "setScreenSaverMode(int)" ) { |
484 | int mode; | 485 | int mode; |
485 | stream >> mode; | 486 | stream >> mode; |
486 | m_screensaver-> setMode ( mode ); | 487 | m_screensaver-> setMode ( mode ); |
487 | } | 488 | } |
488 | else if ( msg == "reloadPowerWarnSettings()" ) { | 489 | else if ( msg == "reloadPowerWarnSettings()" ) { |
489 | reloadPowerWarnSettings(); | 490 | reloadPowerWarnSettings(); |
490 | } | 491 | } |
491 | else if ( msg == "setDisplayState(int)" ) { | 492 | else if ( msg == "setDisplayState(int)" ) { |
492 | int state; | 493 | int state; |
493 | stream >> state; | 494 | stream >> state; |
494 | m_screensaver-> setDisplayState ( state != 0 ); | 495 | m_screensaver-> setDisplayState ( state != 0 ); |
495 | } | 496 | } |
496 | else if ( msg == "suspend()" ) { | 497 | else if ( msg == "suspend()" ) { |
497 | emit power(); | 498 | emit power(); |
498 | } | 499 | } |
499 | } | 500 | } |
500 | 501 | ||
501 | void DesktopApplication::reloadPowerWarnSettings() { | 502 | void DesktopApplication::reloadPowerWarnSettings() { |
502 | Config cfg( "apm" ); | 503 | Config cfg( "apm" ); |
503 | cfg.setGroup( "Warnings" ); | 504 | cfg.setGroup( "Warnings" ); |
504 | 505 | ||
505 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); | 506 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); |
506 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 507 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
507 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); | 508 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); |
508 | } | 509 | } |
509 | 510 | ||
510 | 511 | ||
511 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 512 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
512 | 513 | ||
513 | #ifdef Q_WS_QWS | 514 | #ifdef Q_WS_QWS |
514 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 515 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
515 | { | 516 | { |
516 | qpedesktop->checkMemory(); | 517 | qpedesktop->checkMemory(); |
517 | 518 | ||
518 | if ( e->type == QWSEvent::Key ) { | 519 | if ( e->type == QWSEvent::Key ) { |
519 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 520 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
520 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 521 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
521 | return TRUE; | 522 | return TRUE; |
522 | bool press = ke->simpleData.is_press; | 523 | bool press = ke->simpleData.is_press; |
523 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 524 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
524 | 525 | ||
525 | /* | 526 | /* |
526 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 527 | app that registers key/message to be sent back to the app, when it doesn't have focus, |
527 | when user presses key, unless keyboard has been requested from app. | 528 | when user presses key, unless keyboard has been requested from app. |
528 | will not send multiple repeats if user holds key | 529 | will not send multiple repeats if user holds key |
529 | i.e. one shot | 530 | i.e. one shot |
530 | */ | 531 | */ |
531 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { | 532 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { |
532 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); | 533 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); |
533 | KeyRegisterList::Iterator it; | 534 | KeyRegisterList::Iterator it; |
534 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 535 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
535 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { | 536 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { |
536 | if ( press ) | 537 | if ( press ) |
537 | qDebug( "press" ); | 538 | qDebug( "press" ); |
538 | else | 539 | else |
539 | qDebug( "release" ); | 540 | qDebug( "release" ); |
540 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); | 541 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); |
541 | } | 542 | } |
542 | } | 543 | } |
543 | } | 544 | } |
544 | 545 | ||
545 | if ( !keyboardGrabbed() ) { | 546 | if ( !keyboardGrabbed() ) { |
546 | if ( ke->simpleData.keycode == Key_F9 ) { | 547 | if ( ke->simpleData.keycode == Key_F9 ) { |
547 | if ( press ) | 548 | if ( press ) |
548 | emit datebook(); | 549 | emit datebook(); |
549 | return TRUE; | 550 | return TRUE; |
550 | } | 551 | } |
551 | if ( ke->simpleData.keycode == Key_F10 ) { | 552 | if ( ke->simpleData.keycode == Key_F10 ) { |
552 | if ( !press && cardSendTimer ) { | 553 | if ( !press && cardSendTimer ) { |
553 | emit contacts(); | 554 | emit contacts(); |
554 | delete cardSendTimer; | 555 | delete cardSendTimer; |
555 | } | 556 | } |
556 | else if ( press ) { | 557 | else if ( press ) { |
557 | cardSendTimer = new QTimer(); | 558 | cardSendTimer = new QTimer(); |
558 | cardSendTimer->start( 2000, TRUE ); | 559 | cardSendTimer->start( 2000, TRUE ); |
559 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 560 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
560 | } | 561 | } |
561 | return TRUE; | 562 | return TRUE; |
562 | } | 563 | } |
563 | 564 | ||
564 | // if ( ke->simpleData.keycode == Key_F11 ) { | 565 | // if ( ke->simpleData.keycode == Key_F11 ) { |
565 | // if ( press ) emit menu(); | 566 | // if ( press ) emit menu(); |
566 | // return TRUE; | 567 | // return TRUE; |
567 | // } | 568 | // } |
568 | 569 | ||
569 | if ( ke->simpleData.keycode == Key_F12 ) { | 570 | if ( ke->simpleData.keycode == Key_F12 ) { |
570 | while ( activePopupWidget() ) | 571 | while ( activePopupWidget() ) |
571 | activePopupWidget() ->close(); | 572 | activePopupWidget() ->close(); |
572 | if ( press ) | 573 | if ( press ) |
573 | emit launch(); | 574 | emit launch(); |