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