author | harlekin <harlekin> | 2002-10-23 22:30:45 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-23 22:30:45 (UTC) |
commit | fc14573b3327d3087416fe158efaf09568260e55 (patch) (unidiff) | |
tree | 0bfa334fe27f9967c8432f5bc4c8481cea526e49 | |
parent | f5ee7b6584fe8c6e03494a241e30854cd658bb71 (diff) | |
download | opie-fc14573b3327d3087416fe158efaf09568260e55.zip opie-fc14573b3327d3087416fe158efaf09568260e55.tar.gz opie-fc14573b3327d3087416fe158efaf09568260e55.tar.bz2 |
thanks go to the programming god to point some bool alg stuff to me .-)
-rw-r--r-- | core/launcher/desktop.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index c4c6050..986ae5d 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,1162 +1,1162 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "desktop.h" | 21 | #include "desktop.h" |
22 | #include "info.h" | 22 | #include "info.h" |
23 | #include "launcher.h" | 23 | #include "launcher.h" |
24 | #include "qcopbridge.h" | 24 | #include "qcopbridge.h" |
25 | #include "shutdownimpl.h" | 25 | #include "shutdownimpl.h" |
26 | #include "startmenu.h" | 26 | #include "startmenu.h" |
27 | #include "taskbar.h" | 27 | #include "taskbar.h" |
28 | #include "transferserver.h" | 28 | #include "transferserver.h" |
29 | #include "irserver.h" | 29 | #include "irserver.h" |
30 | #include "packageslave.h" | 30 | #include "packageslave.h" |
31 | 31 | ||
32 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
33 | #include <qpe/mimetype.h> | 33 | #include <qpe/mimetype.h> |
34 | #include <qpe/password.h> | 34 | #include <qpe/password.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/power.h> | 36 | #include <qpe/power.h> |
37 | #include <qpe/timeconversion.h> | 37 | #include <qpe/timeconversion.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qpe/network.h> | 39 | #include <qpe/network.h> |
40 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
41 | 41 | ||
42 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 42 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
43 | #include <qpe/custom.h> | 43 | #include <qpe/custom.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #include <opie/odevice.h> | 46 | #include <opie/odevice.h> |
47 | 47 | ||
48 | #include <qgfx_qws.h> | 48 | #include <qgfx_qws.h> |
49 | #include <qmainwindow.h> | 49 | #include <qmainwindow.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qtimer.h> | 51 | #include <qtimer.h> |
52 | #include <qwindowsystem_qws.h> | 52 | #include <qwindowsystem_qws.h> |
53 | 53 | ||
54 | #include <qvaluelist.h> | 54 | #include <qvaluelist.h> |
55 | 55 | ||
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | #include <fcntl.h> | 58 | #include <fcntl.h> |
59 | 59 | ||
60 | using namespace Opie; | 60 | using namespace Opie; |
61 | 61 | ||
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 ( 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 ( 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 ( 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 ( ( 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 | } | 318 | } |
319 | 319 | ||
320 | void setMode ( int mode ) | 320 | void setMode ( int mode ) |
321 | { | 321 | { |
322 | if ( mode > m_disable_suspend ) | 322 | if ( mode > m_disable_suspend ) |
323 | setInterval( -1 ); | 323 | setInterval( -1 ); |
324 | m_disable_suspend = mode; | 324 | m_disable_suspend = mode; |
325 | } | 325 | } |
326 | 326 | ||
327 | void setBacklight ( int bright ) | 327 | void setBacklight ( int bright ) |
328 | { | 328 | { |
329 | // Read from config | 329 | // Read from config |
330 | Config config ( "qpe" ); | 330 | Config config ( "qpe" ); |
331 | config. setGroup ( "Screensaver" ); | 331 | config. setGroup ( "Screensaver" ); |
332 | m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); | 332 | m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); |
333 | 333 | ||
334 | setBacklightInternal ( bright ); | 334 | setBacklightInternal ( bright ); |
335 | } | 335 | } |
336 | 336 | ||
337 | private: | 337 | private: |
338 | void setBacklightInternal ( int bright ) | 338 | void setBacklightInternal ( int bright ) |
339 | { | 339 | { |
340 | if ( bright == -3 ) { | 340 | if ( bright == -3 ) { |
341 | // Forced on | 341 | // Forced on |
342 | m_backlight_forcedoff = false; | 342 | m_backlight_forcedoff = false; |
343 | bright = -1; | 343 | bright = -1; |
344 | } | 344 | } |
345 | if ( m_backlight_forcedoff && bright != -2 ) | 345 | if ( m_backlight_forcedoff && bright != -2 ) |
346 | return ; | 346 | return ; |
347 | if ( bright == -2 ) { | 347 | if ( bright == -2 ) { |
348 | // Toggle between off and on | 348 | // Toggle between off and on |
349 | bright = m_backlight_current ? 0 : -1; | 349 | bright = m_backlight_current ? 0 : -1; |
350 | m_backlight_forcedoff = !bright; | 350 | m_backlight_forcedoff = !bright; |
351 | } | 351 | } |
352 | if ( bright == -1 ) | 352 | if ( bright == -1 ) |
353 | bright = m_backlight_normal; | 353 | bright = m_backlight_normal; |
354 | 354 | ||
355 | if ( bright != m_backlight_current ) { | 355 | if ( bright != m_backlight_current ) { |
356 | ODevice::inst ( )-> setDisplayBrightness ( bright ); | 356 | ODevice::inst ( )-> setDisplayBrightness ( bright ); |
357 | m_backlight_current = bright; | 357 | m_backlight_current = bright; |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | public: | 361 | public: |
362 | void setDisplayState ( bool on ) | 362 | void setDisplayState ( bool on ) |
363 | { | 363 | { |
364 | if ( m_lcd_status != on ) { | 364 | if ( m_lcd_status != on ) { |
365 | ODevice::inst ( ) -> setDisplayStatus ( on ); | 365 | ODevice::inst ( ) -> setDisplayStatus ( on ); |
366 | m_lcd_status = on; | 366 | m_lcd_status = on; |
367 | } | 367 | } |
368 | } | 368 | } |
369 | 369 | ||
370 | private: | 370 | private: |
371 | int m_disable_suspend; | 371 | int m_disable_suspend; |
372 | bool m_enable_dim; | 372 | bool m_enable_dim; |
373 | bool m_enable_lightoff; | 373 | bool m_enable_lightoff; |
374 | bool m_enable_onlylcdoff; | 374 | bool m_enable_onlylcdoff; |
375 | 375 | ||
376 | int m_disable_suspend_ac; | 376 | int m_disable_suspend_ac; |
377 | bool m_enable_dim_ac; | 377 | bool m_enable_dim_ac; |
378 | bool m_enable_lightoff_ac; | 378 | bool m_enable_lightoff_ac; |
379 | bool m_enable_onlylcdoff_ac; | 379 | bool m_enable_onlylcdoff_ac; |
380 | bool m_disable_apm_ac; | 380 | bool m_disable_apm_ac; |
381 | 381 | ||
382 | bool m_lcd_status; | 382 | bool m_lcd_status; |
383 | 383 | ||
384 | int m_backlight_normal; | 384 | int m_backlight_normal; |
385 | int m_backlight_current; | 385 | int m_backlight_current; |
386 | bool m_backlight_forcedoff; | 386 | bool m_backlight_forcedoff; |
387 | }; | 387 | }; |
388 | 388 | ||
389 | void DesktopApplication::switchLCD ( bool on ) | 389 | void DesktopApplication::switchLCD ( bool on ) |
390 | { | 390 | { |
391 | if ( qApp ) { | 391 | if ( qApp ) { |
392 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 392 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
393 | 393 | ||
394 | if ( dapp-> m_screensaver ) { | 394 | if ( dapp-> m_screensaver ) { |
395 | if ( on ) { | 395 | if ( on ) { |
396 | dapp-> m_screensaver-> setDisplayState ( true ); | 396 | dapp-> m_screensaver-> setDisplayState ( true ); |
397 | dapp-> m_screensaver-> setBacklight ( -3 ); | 397 | dapp-> m_screensaver-> setBacklight ( -3 ); |
398 | } | 398 | } |
399 | else { | 399 | else { |
400 | dapp-> m_screensaver-> setDisplayState ( false ); | 400 | dapp-> m_screensaver-> setDisplayState ( false ); |
401 | } | 401 | } |
402 | } | 402 | } |
403 | } | 403 | } |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 407 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
408 | : QPEApplication( argc, argv, appType ) | 408 | : QPEApplication( argc, argv, appType ) |
409 | { | 409 | { |
410 | 410 | ||
411 | m_timer = new QTimer( this ); | 411 | m_timer = new QTimer( this ); |
412 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); | 412 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); |
413 | Config cfg( "apm" ); | 413 | Config cfg( "apm" ); |
414 | cfg.setGroup( "Warnings" ); | 414 | cfg.setGroup( "Warnings" ); |
415 | m_timer->start( 5000 ); | 415 | m_timer->start( 5000 ); |
416 | //cfg.readNumEntry( "checkinterval", 10000 ) | 416 | //cfg.readNumEntry( "checkinterval", 10000 ) |
417 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 417 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
418 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); | 418 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); |
419 | ps = new PowerStatus; | 419 | ps = new PowerStatus; |
420 | pa = new DesktopPowerAlerter( 0 ); | 420 | pa = new DesktopPowerAlerter( 0 ); |
421 | 421 | ||
422 | channel = new QCopChannel( "QPE/Desktop", this ); | 422 | channel = new QCopChannel( "QPE/Desktop", this ); |
423 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 423 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
424 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 424 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
425 | 425 | ||
426 | channel = new QCopChannel( "QPE/System", this ); | 426 | channel = new QCopChannel( "QPE/System", this ); |
427 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 427 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
428 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 428 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
429 | 429 | ||
430 | m_screensaver = new QPEScreenSaver; | 430 | m_screensaver = new QPEScreenSaver; |
431 | 431 | ||
432 | m_screensaver-> setInterval ( -1 ); | 432 | m_screensaver-> setInterval ( -1 ); |
433 | QWSServer::setScreenSaver( m_screensaver ); | 433 | QWSServer::setScreenSaver( m_screensaver ); |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | DesktopApplication::~DesktopApplication() | 437 | DesktopApplication::~DesktopApplication() |
438 | { | 438 | { |
439 | delete ps; | 439 | delete ps; |
440 | delete pa; | 440 | delete pa; |
441 | } | 441 | } |
442 | 442 | ||
443 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 443 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
444 | { | 444 | { |
445 | QDataStream stream( data, IO_ReadOnly ); | 445 | QDataStream stream( data, IO_ReadOnly ); |
446 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 446 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
447 | int k; | 447 | int k; |
448 | QString c, m; | 448 | QString c, m; |
449 | stream >> k; | 449 | stream >> k; |
450 | stream >> c; | 450 | stream >> c; |
451 | stream >> m; | 451 | stream >> m; |
452 | 452 | ||
453 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 453 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
454 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 454 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 459 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
460 | { | 460 | { |
461 | QDataStream stream ( data, IO_ReadOnly ); | 461 | QDataStream stream ( data, IO_ReadOnly ); |
462 | 462 | ||
463 | if ( msg == "setScreenSaverInterval(int)" ) { | 463 | if ( msg == "setScreenSaverInterval(int)" ) { |
464 | int time; | 464 | int time; |
465 | stream >> time; | 465 | stream >> time; |
466 | m_screensaver-> setInterval( time ); | 466 | m_screensaver-> setInterval( time ); |
467 | } | 467 | } |
468 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 468 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
469 | int t1, t2, t3; | 469 | int t1, t2, t3; |
470 | stream >> t1 >> t2 >> t3; | 470 | stream >> t1 >> t2 >> t3; |
471 | m_screensaver-> setIntervals( t1, t2, t3 ); | 471 | m_screensaver-> setIntervals( t1, t2, t3 ); |
472 | } | 472 | } |
473 | else if ( msg == "setScreenSaverIntervalsAC(int,int,int)" ) { | 473 | else if ( msg == "setScreenSaverIntervalsAC(int,int,int)" ) { |
474 | int t1, t2, t3; | 474 | int t1, t2, t3; |
475 | stream >> t1 >> t2 >> t3; | 475 | stream >> t1 >> t2 >> t3; |
476 | m_screensaver-> setIntervalsAC( t1, t2, t3 ); | 476 | m_screensaver-> setIntervalsAC( t1, t2, t3 ); |
477 | } | 477 | } |
478 | else if ( msg == "setBacklight(int)" ) { | 478 | else if ( msg == "setBacklight(int)" ) { |
479 | int bright; | 479 | int bright; |
480 | stream >> bright; | 480 | stream >> bright; |
481 | m_screensaver-> setBacklight( bright ); | 481 | m_screensaver-> setBacklight( bright ); |
482 | } | 482 | } |
483 | else if ( msg == "setScreenSaverMode(int)" ) { | 483 | else if ( msg == "setScreenSaverMode(int)" ) { |
484 | int mode; | 484 | int mode; |
485 | stream >> mode; | 485 | stream >> mode; |
486 | m_screensaver-> setMode ( mode ); | 486 | m_screensaver-> setMode ( mode ); |
487 | } | 487 | } |
488 | else if ( msg == "reloadPowerWarnSettings()" ) { | 488 | else if ( msg == "reloadPowerWarnSettings()" ) { |
489 | reloadPowerWarnSettings(); | 489 | reloadPowerWarnSettings(); |
490 | } | 490 | } |
491 | else if ( msg == "setDisplayState(int)" ) { | 491 | else if ( msg == "setDisplayState(int)" ) { |
492 | int state; | 492 | int state; |
493 | stream >> state; | 493 | stream >> state; |
494 | m_screensaver-> setDisplayState ( state != 0 ); | 494 | m_screensaver-> setDisplayState ( state != 0 ); |
495 | } | 495 | } |
496 | else if ( msg == "suspend()" ) { | 496 | else if ( msg == "suspend()" ) { |
497 | emit power(); | 497 | emit power(); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | void DesktopApplication::reloadPowerWarnSettings() { | 501 | void DesktopApplication::reloadPowerWarnSettings() { |
502 | Config cfg( "apm" ); | 502 | Config cfg( "apm" ); |
503 | cfg.setGroup( "Warnings" ); | 503 | cfg.setGroup( "Warnings" ); |
504 | 504 | ||
505 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); | 505 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); |
506 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 506 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
507 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); | 507 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); |
508 | } | 508 | } |
509 | 509 | ||
510 | 510 | ||
511 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 511 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
512 | 512 | ||
513 | #ifdef Q_WS_QWS | 513 | #ifdef Q_WS_QWS |
514 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 514 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
515 | { | 515 | { |
516 | qpedesktop->checkMemory(); | 516 | qpedesktop->checkMemory(); |
517 | 517 | ||
518 | if ( e->type == QWSEvent::Key ) { | 518 | if ( e->type == QWSEvent::Key ) { |
519 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 519 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
520 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 520 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
521 | return TRUE; | 521 | return TRUE; |
522 | bool press = ke->simpleData.is_press; | 522 | bool press = ke->simpleData.is_press; |
523 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 523 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
524 | 524 | ||
525 | /* | 525 | /* |
526 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 526 | 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. | 527 | when user presses key, unless keyboard has been requested from app. |
528 | will not send multiple repeats if user holds key | 528 | will not send multiple repeats if user holds key |
529 | i.e. one shot | 529 | i.e. one shot |
530 | */ | 530 | */ |
531 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { | 531 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { |
532 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); | 532 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); |
533 | KeyRegisterList::Iterator it; | 533 | KeyRegisterList::Iterator it; |
534 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 534 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
535 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { | 535 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { |
536 | if ( press ) | 536 | if ( press ) |
537 | qDebug( "press" ); | 537 | qDebug( "press" ); |
538 | else | 538 | else |
539 | qDebug( "release" ); | 539 | qDebug( "release" ); |
540 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); | 540 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); |
541 | } | 541 | } |
542 | } | 542 | } |
543 | } | 543 | } |
544 | 544 | ||
545 | if ( !keyboardGrabbed() ) { | 545 | if ( !keyboardGrabbed() ) { |
546 | if ( ke->simpleData.keycode == Key_F9 ) { | 546 | if ( ke->simpleData.keycode == Key_F9 ) { |
547 | if ( press ) | 547 | if ( press ) |
548 | emit datebook(); | 548 | emit datebook(); |
549 | return TRUE; | 549 | return TRUE; |
550 | } | 550 | } |
551 | if ( ke->simpleData.keycode == Key_F10 ) { | 551 | if ( ke->simpleData.keycode == Key_F10 ) { |
552 | if ( !press && cardSendTimer ) { | 552 | if ( !press && cardSendTimer ) { |
553 | emit contacts(); | 553 | emit contacts(); |
554 | delete cardSendTimer; | 554 | delete cardSendTimer; |
555 | } | 555 | } |
556 | else if ( press ) { | 556 | else if ( press ) { |
557 | cardSendTimer = new QTimer(); | 557 | cardSendTimer = new QTimer(); |
558 | cardSendTimer->start( 2000, TRUE ); | 558 | cardSendTimer->start( 2000, TRUE ); |
559 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 559 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
560 | } | 560 | } |
561 | return TRUE; | 561 | return TRUE; |
562 | } | 562 | } |
563 | 563 | ||
564 | // if ( ke->simpleData.keycode == Key_F11 ) { | 564 | // if ( ke->simpleData.keycode == Key_F11 ) { |
565 | // if ( press ) emit menu(); | 565 | // if ( press ) emit menu(); |
566 | // return TRUE; | 566 | // return TRUE; |
567 | // } | 567 | // } |
568 | 568 | ||
569 | if ( ke->simpleData.keycode == Key_F12 ) { | 569 | if ( ke->simpleData.keycode == Key_F12 ) { |
570 | while ( activePopupWidget() ) | 570 | while ( activePopupWidget() ) |
571 | activePopupWidget() ->close(); | 571 | activePopupWidget() ->close(); |
572 | if ( press ) | 572 | if ( press ) |
573 | emit launch(); | 573 | emit launch(); |
574 | return TRUE; | 574 | return TRUE; |
575 | } | 575 | } |
576 | if ( ke->simpleData.keycode == Key_F13 ) { | 576 | if ( ke->simpleData.keycode == Key_F13 ) { |
577 | if ( press ) | 577 | if ( press ) |
578 | emit email(); | 578 | emit email(); |
579 | return TRUE; | 579 | return TRUE; |
580 | } | 580 | } |
581 | } | 581 | } |
582 | 582 | ||
583 | if ( ke->simpleData.keycode == Key_F34 ) { | 583 | if ( ke->simpleData.keycode == Key_F34 ) { |
584 | if ( press ) | 584 | if ( press ) |
585 | emit power(); | 585 | emit power(); |
586 | return TRUE; | 586 | return TRUE; |
587 | } | 587 | } |
588 | // This was used for the iPAQ PowerButton | 588 | // This was used for the iPAQ PowerButton |
589 | // See main.cpp for new KeyboardFilter | 589 | // See main.cpp for new KeyboardFilter |
590 | // | 590 | // |
591 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 591 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
592 | // if ( press ) emit power(); | 592 | // if ( press ) emit power(); |
593 | // return TRUE; | 593 | // return TRUE; |
594 | // } | 594 | // } |
595 | if ( ke->simpleData.keycode == Key_F35 ) { | 595 | if ( ke->simpleData.keycode == Key_F35 ) { |
596 | if ( press ) | 596 | if ( press ) |
597 | emit backlight(); | 597 | emit backlight(); |
598 | return TRUE; | 598 | return TRUE; |
599 | } | 599 | } |
600 | if ( ke->simpleData.keycode == Key_F32 ) { | 600 | if ( ke->simpleData.keycode == Key_F32 ) { |
601 | if ( press ) | 601 | if ( press ) |
602 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 602 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
603 | return TRUE; | 603 | return TRUE; |
604 | } | 604 | } |
605 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 605 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
606 | if ( press ) | 606 | if ( press ) |
607 | emit symbol(); | 607 | emit symbol(); |
608 | return TRUE; | 608 | return TRUE; |
609 | } | 609 | } |
610 | if ( ke->simpleData.keycode == Key_NumLock ) { | 610 | if ( ke->simpleData.keycode == Key_NumLock ) { |
611 | if ( press ) | 611 | if ( press ) |
612 | emit numLockStateToggle(); | 612 | emit numLockStateToggle(); |
613 | } | 613 | } |
614 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 614 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
615 | if ( press ) | 615 | if ( press ) |
616 | emit capsLockStateToggle(); | 616 | emit capsLockStateToggle(); |
617 | } | 617 | } |
618 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | 618 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) |
619 | qpedesktop->keyClick(); | 619 | qpedesktop->keyClick(); |
620 | } | 620 | } |
621 | else { | 621 | else { |
622 | if ( e->type == QWSEvent::Mouse ) { | 622 | if ( e->type == QWSEvent::Mouse ) { |
623 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 623 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
624 | static bool up = TRUE; | 624 | static bool up = TRUE; |
625 | if ( me->simpleData.state & LeftButton ) { | 625 | if ( me->simpleData.state & LeftButton ) { |
626 | if ( up ) { | 626 | if ( up ) { |
627 | up = FALSE; | 627 | up = FALSE; |
628 | qpedesktop->screenClick(); | 628 | qpedesktop->screenClick(); |
629 | } | 629 | } |
630 | } | 630 | } |
631 | else { | 631 | else { |
632 | up = TRUE; | 632 | up = TRUE; |
633 | } | 633 | } |
634 | } | 634 | } |
635 | } | 635 | } |
636 | 636 | ||
637 | return QPEApplication::qwsEventFilter( e ); | 637 | return QPEApplication::qwsEventFilter( e ); |
638 | } | 638 | } |
639 | #endif | 639 | #endif |
640 | 640 | ||
641 | void DesktopApplication::psTimeout( int batRemaining ) | 641 | void DesktopApplication::psTimeout( int batRemaining ) |
642 | { | 642 | { |
643 | *ps = PowerStatusManager::readStatus(); | 643 | *ps = PowerStatusManager::readStatus(); |
644 | 644 | ||
645 | // maybe now since its triggered by apm change there might be to few warnings | 645 | // maybe now since its triggered by apm change there might be to few warnings |
646 | // if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 646 | // if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
647 | if ( ( batRemaining == m_powerVeryLow ) ) { | 647 | if ( ( batRemaining == m_powerVeryLow ) ) { |
648 | pa->alert( tr( "Battery is running very low." ), 6 ); | 648 | pa->alert( tr( "Battery is running very low." ), 2 ); |
649 | } | 649 | } |
650 | 650 | ||
651 | // if ( ps->batteryStatus() == PowerStatus::Critical ) { | 651 | // if ( ps->batteryStatus() == PowerStatus::Critical ) { |
652 | if ( batRemaining == m_powerCritical ) { | 652 | if ( batRemaining == m_powerCritical ) { |
653 | pa->alert( tr( "Battery level is critical!\n" | 653 | pa->alert( tr( "Battery level is critical!\n" |
654 | "Keep power off until power restored!" ), 1 ); | 654 | "Keep power off until power restored!" ), 1 ); |
655 | } | 655 | } |
656 | 656 | ||
657 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 657 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
658 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 658 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | 661 | ||
662 | void DesktopApplication::apmTimeout() | 662 | void DesktopApplication::apmTimeout() |
663 | { | 663 | { |
664 | qpedesktop->checkMemory(); // in case no events are being generated | 664 | qpedesktop->checkMemory(); // in case no events are being generated |
665 | 665 | ||
666 | *ps = PowerStatusManager::readStatus(); | 666 | *ps = PowerStatusManager::readStatus(); |
667 | 667 | ||
668 | if ( m_currentPowerLevel != ps->batteryPercentRemaining() ) { | 668 | if ( m_currentPowerLevel != ps->batteryPercentRemaining() ) { |
669 | // not very nice, since psTimeout parses the again | 669 | // not very nice, since psTimeout parses the again |
670 | m_currentPowerLevel = ps->batteryPercentRemaining(); | 670 | m_currentPowerLevel = ps->batteryPercentRemaining(); |
671 | psTimeout( m_currentPowerLevel ); | 671 | psTimeout( m_currentPowerLevel ); |
672 | } | 672 | } |
673 | } | 673 | } |
674 | 674 | ||
675 | void DesktopApplication::sendCard() | 675 | void DesktopApplication::sendCard() |
676 | { | 676 | { |
677 | delete cardSendTimer; | 677 | delete cardSendTimer; |
678 | cardSendTimer = 0; | 678 | cardSendTimer = 0; |
679 | QString card = getenv( "HOME" ); | 679 | QString card = getenv( "HOME" ); |
680 | card += "/Applications/addressbook/businesscard.vcf"; | 680 | card += "/Applications/addressbook/businesscard.vcf"; |
681 | 681 | ||
682 | if ( QFile::exists( card ) ) { | 682 | if ( QFile::exists( card ) ) { |
683 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); | 683 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); |
684 | QString mimetype = "text/x-vCard"; | 684 | QString mimetype = "text/x-vCard"; |
685 | e << tr( "business card" ) << card << mimetype; | 685 | e << tr( "business card" ) << card << mimetype; |
686 | } | 686 | } |
687 | } | 687 | } |
688 | 688 | ||
689 | #if defined(QPE_HAVE_MEMALERTER) | 689 | #if defined(QPE_HAVE_MEMALERTER) |
690 | QPE_MEMALERTER_IMPL | 690 | QPE_MEMALERTER_IMPL |
691 | #endif | 691 | #endif |
692 | 692 | ||
693 | //=========================================================================== | 693 | //=========================================================================== |
694 | 694 | ||
695 | Desktop::Desktop() : | 695 | Desktop::Desktop() : |
696 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 696 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
697 | qcopBridge( 0 ), | 697 | qcopBridge( 0 ), |
698 | transferServer( 0 ), | 698 | transferServer( 0 ), |
699 | packageSlave( 0 ) | 699 | packageSlave( 0 ) |
700 | { | 700 | { |
701 | qpedesktop = this; | 701 | qpedesktop = this; |
702 | 702 | ||
703 | // bg = new Info( this ); | 703 | // bg = new Info( this ); |
704 | tb = new TaskBar; | 704 | tb = new TaskBar; |
705 | 705 | ||
706 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 706 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
707 | 707 | ||
708 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 708 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
709 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 709 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
710 | 710 | ||
711 | int displayw = qApp->desktop() ->width(); | 711 | int displayw = qApp->desktop() ->width(); |
712 | int displayh = qApp->desktop() ->height(); | 712 | int displayh = qApp->desktop() ->height(); |
713 | 713 | ||
714 | 714 | ||
715 | QSize sz = tb->sizeHint(); | 715 | QSize sz = tb->sizeHint(); |
716 | 716 | ||
717 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 717 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
718 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 718 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
719 | 719 | ||
720 | tb->show(); | 720 | tb->show(); |
721 | launcher->showMaximized(); | 721 | launcher->showMaximized(); |
722 | launcher->show(); | 722 | launcher->show(); |
723 | launcher->raise(); | 723 | launcher->raise(); |
724 | #if defined(QPE_HAVE_MEMALERTER) | 724 | #if defined(QPE_HAVE_MEMALERTER) |
725 | 725 | ||
726 | initMemalerter(); | 726 | initMemalerter(); |
727 | #endif | 727 | #endif |
728 | // start services | 728 | // start services |
729 | startTransferServer(); | 729 | startTransferServer(); |
730 | ( void ) new IrServer( this ); | 730 | ( void ) new IrServer( this ); |
731 | rereadVolumes(); | 731 | rereadVolumes(); |
732 | 732 | ||
733 | packageSlave = new PackageSlave( this ); | 733 | packageSlave = new PackageSlave( this ); |
734 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); | 734 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); |
735 | 735 | ||
736 | qApp->installEventFilter( this ); | 736 | qApp->installEventFilter( this ); |
737 | 737 | ||
738 | qApp-> setMainWidget ( launcher ); | 738 | qApp-> setMainWidget ( launcher ); |
739 | } | 739 | } |
740 | 740 | ||
741 | void Desktop::show() | 741 | void Desktop::show() |
742 | { | 742 | { |
743 | login( TRUE ); | 743 | login( TRUE ); |
744 | QWidget::show(); | 744 | QWidget::show(); |
745 | } | 745 | } |
746 | 746 | ||
747 | Desktop::~Desktop() | 747 | Desktop::~Desktop() |
748 | { | 748 | { |
749 | delete launcher; | 749 | delete launcher; |
750 | delete tb; | 750 | delete tb; |
751 | delete qcopBridge; | 751 | delete qcopBridge; |
752 | delete transferServer; | 752 | delete transferServer; |
753 | } | 753 | } |
754 | 754 | ||
755 | bool Desktop::recoverMemory() | 755 | bool Desktop::recoverMemory() |
756 | { | 756 | { |
757 | return tb->recoverMemory(); | 757 | return tb->recoverMemory(); |
758 | } | 758 | } |
759 | 759 | ||
760 | void Desktop::checkMemory() | 760 | void Desktop::checkMemory() |
761 | { | 761 | { |
762 | #if defined(QPE_HAVE_MEMALERTER) | 762 | #if defined(QPE_HAVE_MEMALERTER) |
763 | static bool ignoreNormal = FALSE; | 763 | static bool ignoreNormal = FALSE; |
764 | static bool existingMessage = FALSE; | 764 | static bool existingMessage = FALSE; |
765 | 765 | ||
766 | if ( existingMessage ) | 766 | if ( existingMessage ) |
767 | return ; // don't show a second message while still on first | 767 | return ; // don't show a second message while still on first |
768 | 768 | ||
769 | existingMessage = TRUE; | 769 | existingMessage = TRUE; |
770 | switch ( memstate ) { | 770 | switch ( memstate ) { |
771 | case Unknown: | 771 | case Unknown: |
772 | break; | 772 | break; |
773 | case Low: | 773 | case Low: |
774 | memstate = Unknown; | 774 | memstate = Unknown; |
775 | if ( recoverMemory() ) | 775 | if ( recoverMemory() ) |
776 | ignoreNormal = TRUE; | 776 | ignoreNormal = TRUE; |
777 | else | 777 | else |
778 | QMessageBox::warning( 0 , "Memory Status", | 778 | QMessageBox::warning( 0 , "Memory Status", |
779 | "The memory smacks of shortage. \n" | 779 | "The memory smacks of shortage. \n" |
780 | "Please save data. " ); | 780 | "Please save data. " ); |
781 | break; | 781 | break; |
782 | case Normal: | 782 | case Normal: |
783 | memstate = Unknown; | 783 | memstate = Unknown; |
784 | if ( ignoreNormal ) | 784 | if ( ignoreNormal ) |
785 | ignoreNormal = FALSE; | 785 | ignoreNormal = FALSE; |
786 | // else | 786 | // else |
787 | // QMessageBox::information ( 0 , "Memory Status", | 787 | // QMessageBox::information ( 0 , "Memory Status", |
788 | // "There is enough memory again." ); | 788 | // "There is enough memory again." ); |
789 | break; | 789 | break; |
790 | case VeryLow: | 790 | case VeryLow: |
791 | memstate = Unknown; | 791 | memstate = Unknown; |
792 | QMessageBox::critical( 0 , "Memory Status", | 792 | QMessageBox::critical( 0 , "Memory Status", |
793 | "The memory is very low. \n" | 793 | "The memory is very low. \n" |
794 | "Please end this application \n" | 794 | "Please end this application \n" |
795 | "immediately." ); | 795 | "immediately." ); |
796 | recoverMemory(); | 796 | recoverMemory(); |
797 | } | 797 | } |
798 | existingMessage = FALSE; | 798 | existingMessage = FALSE; |
799 | #endif | 799 | #endif |
800 | } | 800 | } |
801 | 801 | ||
802 | static bool isVisibleWindow( int wid ) | 802 | static bool isVisibleWindow( int wid ) |
803 | { | 803 | { |
804 | #ifdef QWS | 804 | #ifdef QWS |
805 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 805 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
806 | QWSWindow* w; | 806 | QWSWindow* w; |
807 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 807 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
808 | if ( w->winId() == wid ) | 808 | if ( w->winId() == wid ) |
809 | return !w->isFullyObscured(); | 809 | return !w->isFullyObscured(); |
810 | } | 810 | } |
811 | #endif | 811 | #endif |
812 | return FALSE; | 812 | return FALSE; |
813 | } | 813 | } |
814 | 814 | ||
815 | static bool hasVisibleWindow( const QString& clientname ) | 815 | static bool hasVisibleWindow( const QString& clientname ) |
816 | { | 816 | { |
817 | #ifdef QWS | 817 | #ifdef QWS |
818 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 818 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
819 | QWSWindow* w; | 819 | QWSWindow* w; |
820 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 820 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
821 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 821 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
822 | return TRUE; | 822 | return TRUE; |
823 | } | 823 | } |
824 | #endif | 824 | #endif |
825 | return FALSE; | 825 | return FALSE; |
826 | } | 826 | } |
827 | 827 | ||
828 | void Desktop::raiseLauncher() | 828 | void Desktop::raiseLauncher() |
829 | { | 829 | { |
830 | Config cfg( "qpe" ); //F12 'Home' | 830 | Config cfg( "qpe" ); //F12 'Home' |
831 | cfg.setGroup( "AppsKey" ); | 831 | cfg.setGroup( "AppsKey" ); |
832 | QString tempItem; | 832 | QString tempItem; |
833 | tempItem = cfg.readEntry( "Middle", "Home" ); | 833 | tempItem = cfg.readEntry( "Middle", "Home" ); |
834 | if ( tempItem == "Home" || tempItem.isEmpty() ) { | 834 | if ( tempItem == "Home" || tempItem.isEmpty() ) { |
835 | home ( ); | 835 | home ( ); |
836 | } | 836 | } |
837 | else { | 837 | else { |
838 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 838 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
839 | e << tempItem; | 839 | e << tempItem; |
840 | } | 840 | } |
841 | } | 841 | } |
842 | 842 | ||
843 | void Desktop::home ( ) | 843 | void Desktop::home ( ) |
844 | { | 844 | { |
845 | if ( isVisibleWindow( launcher->winId() ) ) | 845 | if ( isVisibleWindow( launcher->winId() ) ) |
846 | launcher->nextView(); | 846 | launcher->nextView(); |
847 | else | 847 | else |
848 | launcher->raise(); | 848 | launcher->raise(); |
849 | } | 849 | } |
850 | 850 | ||
851 | void Desktop::executeOrModify( const QString& appLnkFile ) | 851 | void Desktop::executeOrModify( const QString& appLnkFile ) |
852 | { | 852 | { |
853 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 853 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
854 | if ( lnk.isValid() ) { | 854 | if ( lnk.isValid() ) { |
855 | QCString app = lnk.exec().utf8(); | 855 | QCString app = lnk.exec().utf8(); |
856 | Global::terminateBuiltin( "calibrate" ); | 856 | Global::terminateBuiltin( "calibrate" ); |
857 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 857 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
858 | // MRUList::addTask( &lnk ); | 858 | // MRUList::addTask( &lnk ); |
859 | if ( hasVisibleWindow( app ) ) | 859 | if ( hasVisibleWindow( app ) ) |
860 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 860 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
861 | else | 861 | else |
862 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 862 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
863 | } | 863 | } |
864 | else { | 864 | else { |
865 | lnk.execute(); | 865 | lnk.execute(); |
866 | } | 866 | } |
867 | } | 867 | } |
868 | } | 868 | } |
869 | 869 | ||
870 | void Desktop::raiseDatebook() | 870 | void Desktop::raiseDatebook() |
871 | { | 871 | { |
872 | Config cfg( "qpe" ); //F9 'Activity' | 872 | Config cfg( "qpe" ); //F9 'Activity' |
873 | cfg.setGroup( "AppsKey" ); | 873 | cfg.setGroup( "AppsKey" ); |
874 | QString tempItem; | 874 | QString tempItem; |
875 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); | 875 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); |
876 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { | 876 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { |
877 | tempItem = "datebook"; | 877 | tempItem = "datebook"; |
878 | } | 878 | } |
879 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 879 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
880 | e << tempItem; | 880 | e << tempItem; |
881 | } | 881 | } |
882 | 882 | ||
883 | void Desktop::raiseContacts() | 883 | void Desktop::raiseContacts() |
884 | { | 884 | { |
885 | Config cfg( "qpe" ); //F10, 'Contacts' | 885 | Config cfg( "qpe" ); //F10, 'Contacts' |
886 | cfg.setGroup( "AppsKey" ); | 886 | cfg.setGroup( "AppsKey" ); |
887 | QString tempItem; | 887 | QString tempItem; |
888 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | 888 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
889 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | 889 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
890 | tempItem = "addressbook"; | 890 | tempItem = "addressbook"; |
891 | } | 891 | } |
892 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 892 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
893 | e << tempItem; | 893 | e << tempItem; |
894 | } | 894 | } |
895 | 895 | ||
896 | void Desktop::raiseMenu() | 896 | void Desktop::raiseMenu() |
897 | { | 897 | { |
898 | Config cfg( "qpe" ); //F11, 'Menu | 898 | Config cfg( "qpe" ); //F11, 'Menu |
899 | cfg.setGroup( "AppsKey" ); | 899 | cfg.setGroup( "AppsKey" ); |
900 | QString tempItem; | 900 | QString tempItem; |
901 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); | 901 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); |
902 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | 902 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
903 | Global::terminateBuiltin( "calibrate" ); | 903 | Global::terminateBuiltin( "calibrate" ); |
904 | tb->startMenu() ->launch(); | 904 | tb->startMenu() ->launch(); |
905 | } | 905 | } |
906 | else { | 906 | else { |
907 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 907 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
908 | e << tempItem; | 908 | e << tempItem; |
909 | } | 909 | } |
910 | } | 910 | } |
911 | 911 | ||
912 | void Desktop::raiseEmail() | 912 | void Desktop::raiseEmail() |
913 | { | 913 | { |
914 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 | 914 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 |
915 | cfg.setGroup( "AppsKey" ); | 915 | cfg.setGroup( "AppsKey" ); |
916 | QString tempItem; | 916 | QString tempItem; |
917 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); | 917 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); |
918 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { | 918 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { |
919 | tempItem = "mail"; | 919 | tempItem = "mail"; |
920 | } | 920 | } |
921 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 921 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
922 | e << tempItem; | 922 | e << tempItem; |
923 | } | 923 | } |
924 | 924 | ||
925 | // autoStarts apps on resume and start | 925 | // autoStarts apps on resume and start |
926 | void Desktop::execAutoStart() | 926 | void Desktop::execAutoStart() |
927 | { | 927 | { |
928 | QString appName; | 928 | QString appName; |
929 | int delay; | 929 | int delay; |
930 | QDateTime now = QDateTime::currentDateTime(); | 930 | QDateTime now = QDateTime::currentDateTime(); |
931 | Config cfg( "autostart" ); | 931 | Config cfg( "autostart" ); |
932 | cfg.setGroup( "AutoStart" ); | 932 | cfg.setGroup( "AutoStart" ); |
933 | appName = cfg.readEntry( "Apps", "" ); | 933 | appName = cfg.readEntry( "Apps", "" ); |
934 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 934 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
935 | // If the time between suspend and resume was longer then the | 935 | // If the time between suspend and resume was longer then the |
936 | // value saved as delay, start the app | 936 | // value saved as delay, start the app |
937 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 937 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
938 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 938 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
939 | e << QString( appName ); | 939 | e << QString( appName ); |
940 | } | 940 | } |
941 | } | 941 | } |
942 | 942 | ||
943 | #if defined(QPE_HAVE_TOGGLELIGHT) | 943 | #if defined(QPE_HAVE_TOGGLELIGHT) |
944 | #include <qpe/config.h> | 944 | #include <qpe/config.h> |
945 | 945 | ||
946 | #include <sys/ioctl.h> | 946 | #include <sys/ioctl.h> |
947 | #include <sys/types.h> | 947 | #include <sys/types.h> |
948 | #include <fcntl.h> | 948 | #include <fcntl.h> |
949 | #include <unistd.h> | 949 | #include <unistd.h> |
950 | #include <errno.h> | 950 | #include <errno.h> |
951 | #include <linux/ioctl.h> | 951 | #include <linux/ioctl.h> |
952 | #include <time.h> | 952 | #include <time.h> |
953 | #endif | 953 | #endif |
954 | 954 | ||
955 | 955 | ||
956 | void Desktop::togglePower() | 956 | void Desktop::togglePower() |
957 | { | 957 | { |
958 | static bool excllock = false; | 958 | static bool excllock = false; |
959 | 959 | ||
960 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); | 960 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); |
961 | 961 | ||
962 | if ( excllock ) | 962 | if ( excllock ) |
963 | return; | 963 | return; |
964 | 964 | ||
965 | excllock = true; | 965 | excllock = true; |
966 | 966 | ||
967 | bool wasloggedin = loggedin; | 967 | bool wasloggedin = loggedin; |
968 | loggedin = 0; | 968 | loggedin = 0; |
969 | suspendTime = QDateTime::currentDateTime(); | 969 | suspendTime = QDateTime::currentDateTime(); |
970 | 970 | ||
971 | #ifdef QWS | 971 | #ifdef QWS |
972 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 972 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
973 | // Should use a big black window instead. | 973 | // Should use a big black window instead. |
974 | // But this would not show up fast enough | 974 | // But this would not show up fast enough |
975 | QGfx *g = qt_screen-> screenGfx ( ); | 975 | QGfx *g = qt_screen-> screenGfx ( ); |
976 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 976 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
977 | delete g; | 977 | delete g; |
978 | } | 978 | } |
979 | #endif | 979 | #endif |
980 | 980 | ||
981 | ODevice::inst ( )-> suspend ( ); | 981 | ODevice::inst ( )-> suspend ( ); |
982 | 982 | ||
983 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 983 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
984 | QWSServer::screenSaverActivate ( false ); | 984 | QWSServer::screenSaverActivate ( false ); |
985 | 985 | ||
986 | { | 986 | { |
987 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 987 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
988 | } | 988 | } |
989 | 989 | ||
990 | if ( wasloggedin ) | 990 | if ( wasloggedin ) |
991 | login ( true ); | 991 | login ( true ); |
992 | 992 | ||
993 | execAutoStart(); | 993 | execAutoStart(); |
994 | //qcopBridge->closeOpenConnections(); | 994 | //qcopBridge->closeOpenConnections(); |
995 | 995 | ||
996 | excllock = false; | 996 | excllock = false; |
997 | } | 997 | } |
998 | 998 | ||
999 | void Desktop::toggleLight() | 999 | void Desktop::toggleLight() |
1000 | { | 1000 | { |
1001 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 1001 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
1002 | e << -2; // toggle | 1002 | e << -2; // toggle |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | void Desktop::toggleSymbolInput() | 1005 | void Desktop::toggleSymbolInput() |
1006 | { | 1006 | { |
1007 | tb->toggleSymbolInput(); | 1007 | tb->toggleSymbolInput(); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | void Desktop::toggleNumLockState() | 1010 | void Desktop::toggleNumLockState() |
1011 | { | 1011 | { |
1012 | tb->toggleNumLockState(); | 1012 | tb->toggleNumLockState(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | void Desktop::toggleCapsLockState() | 1015 | void Desktop::toggleCapsLockState() |
1016 | { | 1016 | { |
1017 | tb->toggleCapsLockState(); | 1017 | tb->toggleCapsLockState(); |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | void Desktop::styleChange( QStyle &s ) | 1020 | void Desktop::styleChange( QStyle &s ) |
1021 | { | 1021 | { |
1022 | QWidget::styleChange( s ); | 1022 | QWidget::styleChange( s ); |
1023 | int displayw = qApp->desktop() ->width(); | 1023 | int displayw = qApp->desktop() ->width(); |
1024 | int displayh = qApp->desktop() ->height(); | 1024 | int displayh = qApp->desktop() ->height(); |
1025 | 1025 | ||
1026 | QSize sz = tb->sizeHint(); | 1026 | QSize sz = tb->sizeHint(); |
1027 | 1027 | ||
1028 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 1028 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | void DesktopApplication::shutdown() | 1031 | void DesktopApplication::shutdown() |
1032 | { | 1032 | { |
1033 | if ( type() != GuiServer ) | 1033 | if ( type() != GuiServer ) |
1034 | return ; | 1034 | return ; |
1035 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 1035 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
1036 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 1036 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
1037 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); | 1037 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); |
1038 | sd->showMaximized(); | 1038 | sd->showMaximized(); |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 1041 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
1042 | { | 1042 | { |
1043 | switch ( t ) { | 1043 | switch ( t ) { |
1044 | case ShutdownImpl::ShutdownSystem: | 1044 | case ShutdownImpl::ShutdownSystem: |
1045 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); | 1045 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); |
1046 | break; | 1046 | break; |
1047 | case ShutdownImpl::RebootSystem: | 1047 | case ShutdownImpl::RebootSystem: |
1048 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); | 1048 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); |
1049 | break; | 1049 | break; |
1050 | case ShutdownImpl::RestartDesktop: | 1050 | case ShutdownImpl::RestartDesktop: |
1051 | restart(); | 1051 | restart(); |
1052 | break; | 1052 | break; |
1053 | case ShutdownImpl::TerminateDesktop: | 1053 | case ShutdownImpl::TerminateDesktop: |
1054 | prepareForTermination( FALSE ); | 1054 | prepareForTermination( FALSE ); |
1055 | 1055 | ||
1056 | // This is a workaround for a Qt bug | 1056 | // This is a workaround for a Qt bug |
1057 | // clipboard applet has to stop its poll timer, or Qt/E | 1057 | // clipboard applet has to stop its poll timer, or Qt/E |
1058 | // will hang on quit() right before it emits aboutToQuit() | 1058 | // will hang on quit() right before it emits aboutToQuit() |
1059 | emit aboutToQuit ( ); | 1059 | emit aboutToQuit ( ); |
1060 | 1060 | ||
1061 | quit(); | 1061 | quit(); |
1062 | break; | 1062 | break; |
1063 | } | 1063 | } |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | void DesktopApplication::restart() | 1066 | void DesktopApplication::restart() |
1067 | { | 1067 | { |
1068 | prepareForTermination( TRUE ); | 1068 | prepareForTermination( TRUE ); |
1069 | 1069 | ||
1070 | #ifdef Q_WS_QWS | 1070 | #ifdef Q_WS_QWS |
1071 | 1071 | ||
1072 | for ( int fd = 3; fd < 100; fd++ ) | 1072 | for ( int fd = 3; fd < 100; fd++ ) |
1073 | close( fd ); | 1073 | close( fd ); |
1074 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 1074 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
1075 | 1075 | ||
1076 | execl( "/sbin/init", "qpe", 0 ); | 1076 | execl( "/sbin/init", "qpe", 0 ); |
1077 | #elif defined(QT_QWS_CASSIOPEIA) | 1077 | #elif defined(QT_QWS_CASSIOPEIA) |
1078 | 1078 | ||
1079 | execl( "/bin/sh", "sh", 0 ); | 1079 | execl( "/bin/sh", "sh", 0 ); |
1080 | #else | 1080 | #else |
1081 | 1081 | ||
1082 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 1082 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
1083 | #endif | 1083 | #endif |
1084 | 1084 | ||
1085 | exit( 1 ); | 1085 | exit( 1 ); |
1086 | #endif | 1086 | #endif |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | void Desktop::startTransferServer() | 1089 | void Desktop::startTransferServer() |
1090 | { | 1090 | { |
1091 | // start qcop bridge server | 1091 | // start qcop bridge server |
1092 | qcopBridge = new QCopBridge( 4243 ); | 1092 | qcopBridge = new QCopBridge( 4243 ); |
1093 | if ( !qcopBridge->ok() ) { | 1093 | if ( !qcopBridge->ok() ) { |
1094 | delete qcopBridge; | 1094 | delete qcopBridge; |
1095 | qcopBridge = 0; | 1095 | qcopBridge = 0; |
1096 | } | 1096 | } |
1097 | // start transfer server | 1097 | // start transfer server |
1098 | transferServer = new TransferServer( 4242 ); | 1098 | transferServer = new TransferServer( 4242 ); |
1099 | if ( !transferServer->ok() ) { | 1099 | if ( !transferServer->ok() ) { |
1100 | delete transferServer; | 1100 | delete transferServer; |
1101 | transferServer = 0; | 1101 | transferServer = 0; |
1102 | } | 1102 | } |
1103 | if ( !transferServer || !qcopBridge ) | 1103 | if ( !transferServer || !qcopBridge ) |
1104 | startTimer( 2000 ); | 1104 | startTimer( 2000 ); |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | void Desktop::timerEvent( QTimerEvent *e ) | 1107 | void Desktop::timerEvent( QTimerEvent *e ) |
1108 | { | 1108 | { |
1109 | killTimer( e->timerId() ); | 1109 | killTimer( e->timerId() ); |
1110 | startTransferServer(); | 1110 | startTransferServer(); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | void Desktop::terminateServers() | 1113 | void Desktop::terminateServers() |
1114 | { | 1114 | { |
1115 | delete transferServer; | 1115 | delete transferServer; |
1116 | delete qcopBridge; | 1116 | delete qcopBridge; |
1117 | transferServer = 0; | 1117 | transferServer = 0; |
1118 | qcopBridge = 0; | 1118 | qcopBridge = 0; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | void Desktop::rereadVolumes() | 1121 | void Desktop::rereadVolumes() |
1122 | { | 1122 | { |
1123 | Config cfg( "qpe" ); | 1123 | Config cfg( "qpe" ); |
1124 | cfg.setGroup( "Volume" ); | 1124 | cfg.setGroup( "Volume" ); |
1125 | touchclick = cfg.readBoolEntry( "TouchSound" ); | 1125 | touchclick = cfg.readBoolEntry( "TouchSound" ); |
1126 | keyclick = cfg.readBoolEntry( "KeySound" ); | 1126 | keyclick = cfg.readBoolEntry( "KeySound" ); |
1127 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); | 1127 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | void Desktop::keyClick() | 1130 | void Desktop::keyClick() |
1131 | { | 1131 | { |
1132 | if ( keyclick ) | 1132 | if ( keyclick ) |
1133 | ODevice::inst ( ) -> keySound ( ); | 1133 | ODevice::inst ( ) -> keySound ( ); |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void Desktop::screenClick() | 1136 | void Desktop::screenClick() |
1137 | { | 1137 | { |
1138 | if ( touchclick ) | 1138 | if ( touchclick ) |
1139 | ODevice::inst ( ) -> touchSound ( ); | 1139 | ODevice::inst ( ) -> touchSound ( ); |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | void Desktop::soundAlarm() | 1142 | void Desktop::soundAlarm() |
1143 | { | 1143 | { |
1144 | if ( qpedesktop-> alarmsound ) | 1144 | if ( qpedesktop-> alarmsound ) |
1145 | ODevice::inst ( ) -> alarmSound ( ); | 1145 | ODevice::inst ( ) -> alarmSound ( ); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | 1148 | bool Desktop::eventFilter( QObject *, QEvent *ev ) |
1149 | { | 1149 | { |
1150 | if ( ev->type() == QEvent::KeyPress ) { | 1150 | if ( ev->type() == QEvent::KeyPress ) { |
1151 | QKeyEvent *ke = (QKeyEvent *)ev; | 1151 | QKeyEvent *ke = (QKeyEvent *)ev; |
1152 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 1152 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
1153 | QWidget *active = qApp->activeWindow(); | 1153 | QWidget *active = qApp->activeWindow(); |
1154 | if ( active && active->isPopup() ) { | 1154 | if ( active && active->isPopup() ) { |
1155 | active->close(); | 1155 | active->close(); |
1156 | } | 1156 | } |
1157 | raiseMenu(); | 1157 | raiseMenu(); |
1158 | return TRUE; | 1158 | return TRUE; |
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | return FALSE; | 1161 | return FALSE; |
1162 | } | 1162 | } |