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