-rw-r--r-- | core/launcher/desktop.cpp | 28 | ||||
-rw-r--r-- | core/launcher/desktop.h | 4 |
2 files changed, 18 insertions, 14 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 649862b..6771a66 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,788 +1,792 @@ | |||
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/global.h> | 40 | #include <qpe/global.h> |
41 | #ifdef QT_QWS_CUSTOM | 41 | #ifdef QT_QWS_CUSTOM |
42 | #include "qpe/custom.h" | 42 | #include "qpe/custom.h" |
43 | #endif | 43 | #endif |
44 | #if defined(QT_QWS_IPAQ) | ||
45 | #include "qpe/custom-ipaq.h" | ||
46 | #endif | ||
47 | 44 | ||
48 | #include <qgfx_qws.h> | 45 | #include <qgfx_qws.h> |
49 | #include <qmainwindow.h> | 46 | #include <qmainwindow.h> |
50 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
51 | #include <qtimer.h> | 48 | #include <qtimer.h> |
52 | #include <qwindowsystem_qws.h> | 49 | #include <qwindowsystem_qws.h> |
53 | 50 | ||
54 | #include <qvaluelist.h> | 51 | #include <qvaluelist.h> |
55 | 52 | ||
56 | #include <stdlib.h> | 53 | #include <stdlib.h> |
57 | #include <unistd.h> | 54 | #include <unistd.h> |
58 | 55 | ||
59 | class QCopKeyRegister | 56 | class QCopKeyRegister |
60 | { | 57 | { |
61 | public: | 58 | public: |
62 | QCopKeyRegister() : keyCode(0) { } | 59 | QCopKeyRegister() : keyCode(0) { } |
63 | QCopKeyRegister(int k, const QString &c, const QString &m) | 60 | QCopKeyRegister(int k, const QString &c, const QString &m) |
64 | : keyCode(k), channel(c), message(m) { } | 61 | : keyCode(k), channel(c), message(m) { } |
65 | 62 | ||
66 | int getKeyCode() const { return keyCode; } | 63 | int getKeyCode() const { return keyCode; } |
67 | QString getChannel() const { return channel; } | 64 | QString getChannel() const { return channel; } |
68 | QString getMessage() const { return message; } | 65 | QString getMessage() const { return message; } |
69 | 66 | ||
70 | private: | 67 | private: |
71 | int keyCode; | 68 | int keyCode; |
72 | QString channel, message; | 69 | QString channel, message; |
73 | }; | 70 | }; |
74 | 71 | ||
75 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 72 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
76 | KeyRegisterList keyRegisterList; | 73 | KeyRegisterList keyRegisterList; |
77 | 74 | ||
78 | static Desktop* qpedesktop = 0; | 75 | static Desktop* qpedesktop = 0; |
79 | static int loggedin=0; | 76 | static int loggedin=0; |
80 | static void login(bool at_poweron) | 77 | static void login(bool at_poweron) |
81 | { | 78 | { |
82 | if ( !loggedin ) { | 79 | if ( !loggedin ) { |
83 | Global::terminateBuiltin("calibrate"); | 80 | Global::terminateBuiltin("calibrate"); |
84 | Password::authenticate(at_poweron); | 81 | Password::authenticate(at_poweron); |
85 | loggedin=1; | 82 | loggedin=1; |
86 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 83 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
87 | } | 84 | } |
88 | } | 85 | } |
89 | 86 | ||
90 | bool Desktop::screenLocked() | 87 | bool Desktop::screenLocked() |
91 | { | 88 | { |
92 | return loggedin == 0; | 89 | return loggedin == 0; |
93 | } | 90 | } |
94 | 91 | ||
95 | /* | 92 | /* |
96 | Priority is number of alerts that are needed to pop up | 93 | Priority is number of alerts that are needed to pop up |
97 | alert. | 94 | alert. |
98 | */ | 95 | */ |
99 | class DesktopPowerAlerter : public QMessageBox | 96 | class DesktopPowerAlerter : public QMessageBox |
100 | { | 97 | { |
101 | public: | 98 | public: |
102 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 99 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
103 | : QMessageBox( tr("Battery Status"), "Low Battery", | 100 | : QMessageBox( tr("Battery Status"), "Low Battery", |
104 | QMessageBox::Critical, | 101 | QMessageBox::Critical, |
105 | QMessageBox::Ok | QMessageBox::Default, | 102 | QMessageBox::Ok | QMessageBox::Default, |
106 | QMessageBox::NoButton, QMessageBox::NoButton, | 103 | QMessageBox::NoButton, QMessageBox::NoButton, |
107 | parent, name, FALSE ) | 104 | parent, name, FALSE ) |
108 | { | 105 | { |
109 | currentPriority = INT_MAX; | 106 | currentPriority = INT_MAX; |
110 | alertCount = 0; | 107 | alertCount = 0; |
111 | } | 108 | } |
112 | 109 | ||
113 | void alert( const QString &text, int priority ); | 110 | void alert( const QString &text, int priority ); |
114 | void hideEvent( QHideEvent * ); | 111 | void hideEvent( QHideEvent * ); |
115 | private: | 112 | private: |
116 | int currentPriority; | 113 | int currentPriority; |
117 | int alertCount; | 114 | int alertCount; |
118 | }; | 115 | }; |
119 | 116 | ||
120 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 117 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
121 | { | 118 | { |
122 | alertCount++; | 119 | alertCount++; |
123 | if ( alertCount < priority ) | 120 | if ( alertCount < priority ) |
124 | return; | 121 | return; |
125 | if ( priority > currentPriority ) | 122 | if ( priority > currentPriority ) |
126 | return; | 123 | return; |
127 | currentPriority = priority; | 124 | currentPriority = priority; |
128 | setText( text ); | 125 | setText( text ); |
129 | show(); | 126 | show(); |
130 | } | 127 | } |
131 | 128 | ||
132 | 129 | ||
133 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 130 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
134 | { | 131 | { |
135 | QMessageBox::hideEvent( e ); | 132 | QMessageBox::hideEvent( e ); |
136 | alertCount = 0; | 133 | alertCount = 0; |
137 | currentPriority = INT_MAX; | 134 | currentPriority = INT_MAX; |
138 | } | 135 | } |
139 | 136 | ||
140 | 137 | ||
141 | 138 | ||
142 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 139 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
143 | : QPEApplication( argc, argv, appType ) | 140 | : QPEApplication( argc, argv, appType ) |
144 | { | 141 | { |
145 | 142 | ||
146 | QTimer *t = new QTimer( this ); | 143 | QTimer *t = new QTimer( this ); |
147 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); | 144 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); |
148 | t->start( 10000 ); | 145 | t->start( 10000 ); |
149 | ps = new PowerStatus; | 146 | ps = new PowerStatus; |
150 | pa = new DesktopPowerAlerter( 0 ); | 147 | pa = new DesktopPowerAlerter( 0 ); |
151 | 148 | ||
152 | channel = new QCopChannel( "QPE/Desktop", this ); | 149 | channel = new QCopChannel( "QPE/Desktop", this ); |
153 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 150 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
154 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 151 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
155 | } | 152 | } |
156 | 153 | ||
157 | 154 | ||
158 | DesktopApplication::~DesktopApplication() | 155 | DesktopApplication::~DesktopApplication() |
159 | { | 156 | { |
160 | delete ps; | 157 | delete ps; |
161 | delete pa; | 158 | delete pa; |
162 | } | 159 | } |
163 | 160 | ||
164 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | 161 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) |
165 | { | 162 | { |
166 | QDataStream stream( data, IO_ReadOnly ); | 163 | QDataStream stream( data, IO_ReadOnly ); |
167 | if (msg == "keyRegister(int key, QString channel, QString message)") | 164 | if (msg == "keyRegister(int key, QString channel, QString message)") |
168 | { | 165 | { |
169 | int k; | 166 | int k; |
170 | QString c, m; | 167 | QString c, m; |
171 | |||
172 | stream >> k; | 168 | stream >> k; |
173 | stream >> c; | 169 | stream >> c; |
174 | stream >> m; | 170 | stream >> m; |
175 | 171 | ||
176 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); | 172 | qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); |
177 | keyRegisterList.append(QCopKeyRegister(k,c,m)); | 173 | keyRegisterList.append(QCopKeyRegister(k,c,m)); |
178 | } | 174 | } |
179 | else if (msg == "suspend()"){ | 175 | else if (msg == "suspend()"){ |
180 | emit power(); | 176 | emit power(); |
181 | } | 177 | } |
182 | 178 | ||
183 | } | 179 | } |
184 | 180 | ||
185 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 181 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
186 | 182 | ||
187 | #ifdef Q_WS_QWS | 183 | #ifdef Q_WS_QWS |
188 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 184 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
189 | { | 185 | { |
190 | qpedesktop->checkMemory(); | 186 | qpedesktop->checkMemory(); |
191 | 187 | ||
192 | if ( e->type == QWSEvent::Key ) { | 188 | if ( e->type == QWSEvent::Key ) { |
193 | QWSKeyEvent *ke = (QWSKeyEvent *)e; | 189 | QWSKeyEvent *ke = (QWSKeyEvent *)e; |
194 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 190 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
195 | return TRUE; | 191 | return TRUE; |
196 | bool press = ke->simpleData.is_press; | 192 | bool press = ke->simpleData.is_press; |
197 | bool autoRepeat = ke ->simpleData.is_auto_repeat; | 193 | bool autoRepeat= ke->simpleData.is_auto_repeat; |
198 | if (!keyRegisterList.isEmpty()) | 194 | if (!keyRegisterList.isEmpty()) |
199 | { | 195 | { |
200 | KeyRegisterList::Iterator it; | 196 | KeyRegisterList::Iterator it; |
201 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) | 197 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) |
202 | { | 198 | { |
203 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) | 199 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) { |
204 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 200 | if(press) qDebug("press"); else qDebug("release"); |
201 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | ||
202 | } | ||
205 | } | 203 | } |
206 | } | 204 | } |
207 | 205 | ||
208 | if ( !keyboardGrabbed() ) { | 206 | if ( !keyboardGrabbed() ) { |
209 | if ( ke->simpleData.keycode == Key_F9 ) { | 207 | if ( ke->simpleData.keycode == Key_F9 ) { |
210 | if ( press ) emit datebook(); | 208 | if ( press ) emit datebook(); |
211 | return TRUE; | 209 | return TRUE; |
212 | } | 210 | } |
213 | if ( ke->simpleData.keycode == Key_F10 ) { | 211 | if ( ke->simpleData.keycode == Key_F10 ) { |
214 | if ( !press && cardSendTimer ) { | 212 | if ( !press && cardSendTimer ) { |
215 | emit contacts(); | 213 | emit contacts(); |
216 | delete cardSendTimer; | 214 | delete cardSendTimer; |
217 | } else if ( press ) { | 215 | } else if ( press ) { |
218 | cardSendTimer = new QTimer(); | 216 | cardSendTimer = new QTimer(); |
219 | cardSendTimer->start( 2000, TRUE ); | 217 | cardSendTimer->start( 2000, TRUE ); |
220 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 218 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
221 | } | 219 | } |
222 | return TRUE; | 220 | return TRUE; |
223 | } | 221 | } |
224 | /* menu key now opens application menu/toolbar | 222 | /* menu key now opens application menu/toolbar |
225 | if ( ke->simpleData.keycode == Key_F11 ) { | 223 | if ( ke->simpleData.keycode == Key_F11 ) { |
226 | if ( press ) emit menu(); | 224 | if ( press ) emit menu(); |
227 | return TRUE; | 225 | return TRUE; |
228 | } | 226 | } |
229 | */ | 227 | */ |
230 | if ( ke->simpleData.keycode == Key_F12 ) { | 228 | if ( ke->simpleData.keycode == Key_F12 ) { |
231 | while( activePopupWidget() ) | 229 | while( activePopupWidget() ) |
232 | activePopupWidget()->close(); | 230 | activePopupWidget()->close(); |
233 | if ( press ) emit launch(); | 231 | if ( press ) emit launch(); |
234 | return TRUE; | 232 | return TRUE; |
235 | } | 233 | } |
236 | if ( ke->simpleData.keycode == Key_F13 ) { | 234 | if ( ke->simpleData.keycode == Key_F13 ) { |
237 | if ( press ) emit email(); | 235 | if ( press ) emit email(); |
238 | return TRUE; | 236 | return TRUE; |
239 | } | 237 | } |
240 | } | 238 | } |
241 | 239 | ||
242 | if ( ke->simpleData.keycode == Key_F34 ) { | 240 | if ( ke->simpleData.keycode == Key_F34 ) { |
243 | if ( press ) emit power(); | 241 | if ( press ) emit power(); |
244 | return TRUE; | 242 | return TRUE; |
245 | } | 243 | } |
246 | if ( ke->simpleData.keycode == Key_SysReq ) { | 244 | if ( ke->simpleData.keycode == Key_SysReq ) { |
247 | if ( press ) emit power(); | 245 | if ( press ) emit power(); |
248 | return TRUE; | 246 | return TRUE; |
249 | } | 247 | } |
250 | if ( ke->simpleData.keycode == Key_F35 ) { | 248 | if ( ke->simpleData.keycode == Key_F35 ) { |
251 | if ( press ) emit backlight(); | 249 | if ( press ) emit backlight(); |
252 | return TRUE; | 250 | return TRUE; |
253 | } | 251 | } |
254 | if ( ke->simpleData.keycode == Key_F32 ) { | 252 | if ( ke->simpleData.keycode == Key_F32 ) { |
255 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 253 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
256 | return TRUE; | 254 | return TRUE; |
257 | } | 255 | } |
258 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 256 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
259 | if ( press ) emit symbol(); | 257 | if ( press ) emit symbol(); |
260 | return TRUE; | 258 | return TRUE; |
261 | } | 259 | } |
262 | if ( ke->simpleData.keycode == Key_NumLock ) { | 260 | if ( ke->simpleData.keycode == Key_NumLock ) { |
263 | if ( press ) emit numLockStateToggle(); | 261 | if ( press ) emit numLockStateToggle(); |
264 | } | 262 | } |
265 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 263 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
266 | if ( press ) emit capsLockStateToggle(); | 264 | if ( press ) emit capsLockStateToggle(); |
267 | } | 265 | } |
268 | if ( press ) | 266 | if ( press ) |
269 | qpedesktop->keyClick(); | 267 | qpedesktop->keyClick(); |
270 | } else { | 268 | } else { |
271 | if ( e->type == QWSEvent::Mouse ) { | 269 | if ( e->type == QWSEvent::Mouse ) { |
272 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 270 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
273 | static bool up = TRUE; | 271 | static bool up = TRUE; |
274 | if ( me->simpleData.state&LeftButton ) { | 272 | if ( me->simpleData.state&LeftButton ) { |
275 | if ( up ) { | 273 | if ( up ) { |
276 | up = FALSE; | 274 | up = FALSE; |
277 | qpedesktop->screenClick(); | 275 | qpedesktop->screenClick(); |
278 | } | 276 | } |
279 | } else { | 277 | } else { |
280 | up = TRUE; | 278 | up = TRUE; |
281 | } | 279 | } |
282 | } | 280 | } |
283 | } | 281 | } |
284 | 282 | ||
285 | return QPEApplication::qwsEventFilter( e ); | 283 | return QPEApplication::qwsEventFilter( e ); |
286 | } | 284 | } |
287 | #endif | 285 | #endif |
288 | 286 | ||
289 | void DesktopApplication::psTimeout() | 287 | void DesktopApplication::psTimeout() |
290 | { | 288 | { |
291 | qpedesktop->checkMemory(); // in case no events are being generated | 289 | qpedesktop->checkMemory(); // in case no events are being generated |
292 | 290 | ||
293 | *ps = PowerStatusManager::readStatus(); | 291 | *ps = PowerStatusManager::readStatus(); |
294 | 292 | ||
295 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 293 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
296 | pa->alert( tr( "Battery is running very low." ), 6 ); | 294 | pa->alert( tr( "Battery is running very low." ), 6 ); |
297 | } | 295 | } |
298 | 296 | ||
299 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 297 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
300 | pa->alert( tr( "Battery level is critical!\n" | 298 | pa->alert( tr( "Battery level is critical!\n" |
301 | "Keep power off until power restored!" ), 1 ); | 299 | "Keep power off until power restored!" ), 1 ); |
302 | } | 300 | } |
303 | 301 | ||
304 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 302 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
305 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 303 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
306 | } | 304 | } |
307 | } | 305 | } |
308 | 306 | ||
309 | 307 | ||
310 | void DesktopApplication::sendCard() | 308 | void DesktopApplication::sendCard() |
311 | { | 309 | { |
312 | delete cardSendTimer; | 310 | delete cardSendTimer; |
313 | cardSendTimer = 0; | 311 | cardSendTimer = 0; |
314 | QString card = getenv("HOME"); | 312 | QString card = getenv("HOME"); |
315 | card += "/Applications/addressbook/businesscard.vcf"; | 313 | card += "/Applications/addressbook/businesscard.vcf"; |
316 | 314 | ||
317 | if ( QFile::exists( card ) ) { | 315 | if ( QFile::exists( card ) ) { |
318 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); | 316 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); |
319 | QString mimetype = "text/x-vCard"; | 317 | QString mimetype = "text/x-vCard"; |
320 | e << tr("business card") << card << mimetype; | 318 | e << tr("business card") << card << mimetype; |
321 | } | 319 | } |
322 | } | 320 | } |
323 | 321 | ||
324 | #if defined(QPE_HAVE_MEMALERTER) | 322 | #if defined(QPE_HAVE_MEMALERTER) |
325 | QPE_MEMALERTER_IMPL | 323 | QPE_MEMALERTER_IMPL |
326 | #endif | 324 | #endif |
327 | 325 | ||
328 | #if defined(CUSTOM_SOUND_IMPL) | 326 | #if defined(CUSTOM_SOUND_IMPL) |
329 | CUSTOM_SOUND_IMPL | 327 | CUSTOM_SOUND_IMPL |
330 | #endif | 328 | #endif |
331 | 329 | ||
332 | //=========================================================================== | 330 | //=========================================================================== |
333 | 331 | ||
334 | Desktop::Desktop() : | 332 | Desktop::Desktop() : |
335 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 333 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
336 | qcopBridge( 0 ), | 334 | qcopBridge( 0 ), |
337 | transferServer( 0 ), | 335 | transferServer( 0 ), |
338 | packageSlave( 0 ) | 336 | packageSlave( 0 ) |
339 | { | 337 | { |
340 | #ifdef CUSTOM_SOUND_INIT | 338 | #ifdef CUSTOM_SOUND_INIT |
341 | CUSTOM_SOUND_INIT; | 339 | CUSTOM_SOUND_INIT; |
342 | #endif | 340 | #endif |
343 | 341 | ||
344 | qpedesktop = this; | 342 | qpedesktop = this; |
345 | 343 | ||
346 | // bg = new Info( this ); | 344 | // bg = new Info( this ); |
347 | tb = new TaskBar; | 345 | tb = new TaskBar; |
348 | 346 | ||
349 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 347 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
350 | 348 | ||
351 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); | 349 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); |
352 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); | 350 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); |
353 | 351 | ||
354 | int displayw = qApp->desktop()->width(); | 352 | int displayw = qApp->desktop()->width(); |
355 | int displayh = qApp->desktop()->height(); | 353 | int displayh = qApp->desktop()->height(); |
356 | 354 | ||
357 | 355 | ||
358 | QSize sz = tb->sizeHint(); | 356 | QSize sz = tb->sizeHint(); |
359 | 357 | ||
360 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 358 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
361 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 359 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
362 | 360 | ||
363 | tb->show(); | 361 | tb->show(); |
364 | launcher->showMaximized(); | 362 | launcher->showMaximized(); |
365 | launcher->show(); | 363 | launcher->show(); |
366 | launcher->raise(); | 364 | launcher->raise(); |
367 | #if defined(QPE_HAVE_MEMALERTER) | 365 | #if defined(QPE_HAVE_MEMALERTER) |
368 | initMemalerter(); | 366 | initMemalerter(); |
369 | #endif | 367 | #endif |
370 | // start services | 368 | // start services |
371 | startTransferServer(); | 369 | startTransferServer(); |
372 | (void) new IrServer( this ); | 370 | (void) new IrServer( this ); |
373 | rereadVolumes(); | 371 | rereadVolumes(); |
374 | 372 | ||
375 | packageSlave = new PackageSlave( this ); | 373 | packageSlave = new PackageSlave( this ); |
376 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); | 374 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); |
377 | 375 | ||
378 | qApp->installEventFilter( this ); | 376 | qApp->installEventFilter( this ); |
379 | } | 377 | } |
380 | 378 | ||
381 | void Desktop::show() | 379 | void Desktop::show() |
382 | { | 380 | { |
383 | login(TRUE); | 381 | login(TRUE); |
384 | QWidget::show(); | 382 | QWidget::show(); |
385 | } | 383 | } |
386 | 384 | ||
387 | Desktop::~Desktop() | 385 | Desktop::~Desktop() |
388 | { | 386 | { |
389 | delete launcher; | 387 | delete launcher; |
390 | delete tb; | 388 | delete tb; |
391 | delete qcopBridge; | 389 | delete qcopBridge; |
392 | delete transferServer; | 390 | delete transferServer; |
393 | } | 391 | } |
394 | 392 | ||
395 | bool Desktop::recoverMemory() | 393 | bool Desktop::recoverMemory() |
396 | { | 394 | { |
397 | return tb->recoverMemory(); | 395 | return tb->recoverMemory(); |
398 | } | 396 | } |
399 | 397 | ||
400 | void Desktop::checkMemory() | 398 | void Desktop::checkMemory() |
401 | { | 399 | { |
402 | #if defined(QPE_HAVE_MEMALERTER) | 400 | #if defined(QPE_HAVE_MEMALERTER) |
403 | static bool ignoreNormal=FALSE; | 401 | static bool ignoreNormal=FALSE; |
404 | static bool existingMessage=FALSE; | 402 | static bool existingMessage=FALSE; |
405 | 403 | ||
406 | if(existingMessage) | 404 | if(existingMessage) |
407 | return; // don't show a second message while still on first | 405 | return; // don't show a second message while still on first |
408 | 406 | ||
409 | existingMessage = TRUE; | 407 | existingMessage = TRUE; |
410 | switch ( memstate ) { | 408 | switch ( memstate ) { |
411 | case Unknown: | 409 | case Unknown: |
412 | break; | 410 | break; |
413 | case Low: | 411 | case Low: |
414 | memstate = Unknown; | 412 | memstate = Unknown; |
415 | if ( recoverMemory() ) | 413 | if ( recoverMemory() ) |
416 | ignoreNormal = TRUE; | 414 | ignoreNormal = TRUE; |
417 | else | 415 | else |
418 | QMessageBox::warning( 0 , "Memory Status", | 416 | QMessageBox::warning( 0 , "Memory Status", |
419 | "The memory smacks of shortage. \n" | 417 | "The memory smacks of shortage. \n" |
420 | "Please save data. " ); | 418 | "Please save data. " ); |
421 | break; | 419 | break; |
422 | case Normal: | 420 | case Normal: |
423 | memstate = Unknown; | 421 | memstate = Unknown; |
424 | if ( ignoreNormal ) | 422 | if ( ignoreNormal ) |
425 | ignoreNormal = FALSE; | 423 | ignoreNormal = FALSE; |
426 | else | 424 | else |
427 | QMessageBox::information ( 0 , "Memory Status", | 425 | QMessageBox::information ( 0 , "Memory Status", |
428 | "There is enough memory again." ); | 426 | "There is enough memory again." ); |
429 | break; | 427 | break; |
430 | case VeryLow: | 428 | case VeryLow: |
431 | memstate = Unknown; | 429 | memstate = Unknown; |
432 | QMessageBox::critical( 0 , "Memory Status", | 430 | QMessageBox::critical( 0 , "Memory Status", |
433 | "The memory is very low. \n" | 431 | "The memory is very low. \n" |
434 | "Please end this application \n" | 432 | "Please end this application \n" |
435 | "immediately." ); | 433 | "immediately." ); |
436 | recoverMemory(); | 434 | recoverMemory(); |
437 | } | 435 | } |
438 | existingMessage = FALSE; | 436 | existingMessage = FALSE; |
439 | #endif | 437 | #endif |
440 | } | 438 | } |
441 | 439 | ||
442 | static bool isVisibleWindow(int wid) | 440 | static bool isVisibleWindow(int wid) |
443 | { | 441 | { |
444 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 442 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
445 | QWSWindow* w; | 443 | QWSWindow* w; |
446 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 444 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
447 | if ( w->winId() == wid ) | 445 | if ( w->winId() == wid ) |
448 | return !w->isFullyObscured(); | 446 | return !w->isFullyObscured(); |
449 | } | 447 | } |
450 | return FALSE; | 448 | return FALSE; |
451 | } | 449 | } |
452 | 450 | ||
453 | static bool hasVisibleWindow(const QString& clientname) | 451 | static bool hasVisibleWindow(const QString& clientname) |
454 | { | 452 | { |
455 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 453 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
456 | QWSWindow* w; | 454 | QWSWindow* w; |
457 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 455 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
458 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) | 456 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) |
459 | return TRUE; | 457 | return TRUE; |
460 | } | 458 | } |
461 | return FALSE; | 459 | return FALSE; |
462 | } | 460 | } |
463 | 461 | ||
464 | void Desktop::raiseLauncher() | 462 | void Desktop::raiseLauncher() |
465 | { | 463 | { |
466 | Config cfg("qpe"); //F12 'Home' | 464 | Config cfg("qpe"); //F12 'Home' |
467 | cfg.setGroup("AppsKey"); | 465 | cfg.setGroup("AppsKey"); |
468 | QString tempItem; | 466 | QString tempItem; |
469 | tempItem = cfg.readEntry("Middle","Home"); | 467 | tempItem = cfg.readEntry("Middle","Home"); |
470 | if(tempItem == "Home" || tempItem.isEmpty()) { | 468 | if(tempItem == "Home" || tempItem.isEmpty()) { |
471 | if ( isVisibleWindow(launcher->winId()) ) | 469 | if ( isVisibleWindow(launcher->winId()) ) |
472 | launcher->nextView(); | 470 | launcher->nextView(); |
473 | else | 471 | else |
474 | launcher->raise(); | 472 | launcher->raise(); |
475 | } else { | 473 | } else { |
476 | QCopEnvelope e("QPE/System","execute(QString)"); | 474 | QCopEnvelope e("QPE/System","execute(QString)"); |
477 | e << tempItem; | 475 | e << tempItem; |
478 | } | 476 | } |
479 | } | 477 | } |
480 | 478 | ||
481 | void Desktop::executeOrModify(const QString& appLnkFile) | 479 | void Desktop::executeOrModify(const QString& appLnkFile) |
482 | { | 480 | { |
483 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); | 481 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); |
484 | if ( lnk.isValid() ) { | 482 | if ( lnk.isValid() ) { |
485 | QCString app = lnk.exec().utf8(); | 483 | QCString app = lnk.exec().utf8(); |
486 | Global::terminateBuiltin("calibrate"); | 484 | Global::terminateBuiltin("calibrate"); |
487 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { | 485 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { |
488 | MRUList::addTask(&lnk); | 486 | MRUList::addTask(&lnk); |
489 | if ( hasVisibleWindow(app) ) | 487 | if ( hasVisibleWindow(app) ) |
490 | QCopChannel::send("QPE/Application/" + app, "nextView()"); | 488 | QCopChannel::send("QPE/Application/" + app, "nextView()"); |
491 | else | 489 | else |
492 | QCopChannel::send("QPE/Application/" + app, "raise()"); | 490 | QCopChannel::send("QPE/Application/" + app, "raise()"); |
493 | } else { | 491 | } else { |
494 | lnk.execute(); | 492 | lnk.execute(); |
495 | } | 493 | } |
496 | } | 494 | } |
497 | } | 495 | } |
498 | 496 | ||
499 | void Desktop::raiseDatebook() | 497 | void Desktop::raiseDatebook() |
500 | { | 498 | { |
501 | Config cfg("qpe"); //F9 'Activity' | 499 | Config cfg("qpe"); //F9 'Activity' |
502 | cfg.setGroup("AppsKey"); | 500 | cfg.setGroup("AppsKey"); |
503 | QString tempItem; | 501 | QString tempItem; |
504 | tempItem = cfg.readEntry("LeftEnd","Calender"); | 502 | tempItem = cfg.readEntry("LeftEnd","Calender"); |
505 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); | 503 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); |
506 | else { | 504 | else { |
507 | QCopEnvelope e("QPE/System","execute(QString)"); | 505 | QCopEnvelope e("QPE/System","execute(QString)"); |
508 | e << tempItem; | 506 | e << tempItem; |
509 | } | 507 | } |
510 | } | 508 | } |
511 | 509 | ||
512 | void Desktop::raiseContacts() | 510 | void Desktop::raiseContacts() |
513 | { | 511 | { |
514 | Config cfg("qpe"); //F10, 'Contacts' | 512 | Config cfg("qpe"); //F10, 'Contacts' |
515 | cfg.setGroup("AppsKey"); | 513 | cfg.setGroup("AppsKey"); |
516 | QString tempItem; | 514 | QString tempItem; |
517 | tempItem = cfg.readEntry("Left2nd","Address Book"); | 515 | tempItem = cfg.readEntry("Left2nd","Address Book"); |
518 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); | 516 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); |
519 | else { | 517 | else { |
520 | QCopEnvelope e("QPE/System","execute(QString)"); | 518 | QCopEnvelope e("QPE/System","execute(QString)"); |
521 | e << tempItem; | 519 | e << tempItem; |
522 | } | 520 | } |
523 | } | 521 | } |
524 | 522 | ||
525 | void Desktop::raiseMenu() | 523 | void Desktop::raiseMenu() |
526 | { | 524 | { |
527 | Config cfg("qpe"); //F11, 'Menu' | 525 | Config cfg("qpe"); //F11, 'Menu' |
528 | cfg.setGroup("AppsKey"); | 526 | cfg.setGroup("AppsKey"); |
529 | QString tempItem; | 527 | QString tempItem; |
530 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); | 528 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); |
531 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { | 529 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { |
532 | Global::terminateBuiltin("calibrate"); | 530 | Global::terminateBuiltin("calibrate"); |
533 | tb->startMenu()->launch(); | 531 | tb->startMenu()->launch(); |
534 | } else { | 532 | } else { |
535 | QCopEnvelope e("QPE/System","execute(QString)"); | 533 | QCopEnvelope e("QPE/System","execute(QString)"); |
536 | e << tempItem; | 534 | e << tempItem; |
537 | } | 535 | } |
538 | } | 536 | } |
539 | 537 | ||
540 | void Desktop::raiseEmail() | 538 | void Desktop::raiseEmail() |
541 | { | 539 | { |
542 | Config cfg("qpe"); //F13, 'Mail' | 540 | Config cfg("qpe"); //F13, 'Mail' |
543 | cfg.setGroup("AppsKey"); | 541 | cfg.setGroup("AppsKey"); |
544 | QString tempItem; | 542 | QString tempItem; |
545 | tempItem = cfg.readEntry("RightEnd","Mail"); | 543 | tempItem = cfg.readEntry("RightEnd","Mail"); |
546 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); | 544 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); |
547 | else { | 545 | else { |
548 | QCopEnvelope e("QPE/System","execute(QString)"); | 546 | QCopEnvelope e("QPE/System","execute(QString)"); |
549 | e << tempItem; | 547 | e << tempItem; |
550 | } | 548 | } |
551 | } | 549 | } |
552 | 550 | ||
553 | // autoStarts apps on resume and start | 551 | // autoStarts apps on resume and start |
554 | void Desktop::execAutoStart() { | 552 | void Desktop::execAutoStart() { |
555 | QString appName; | 553 | QString appName; |
556 | int delay; | 554 | int delay; |
557 | QDateTime now = QDateTime::currentDateTime(); | 555 | QDateTime now = QDateTime::currentDateTime(); |
558 | Config cfg( "autostart" ); | 556 | Config cfg( "autostart" ); |
559 | cfg.setGroup( "AutoStart" ); | 557 | cfg.setGroup( "AutoStart" ); |
560 | appName = cfg.readEntry("Apps", ""); | 558 | appName = cfg.readEntry("Apps", ""); |
561 | delay = (cfg.readEntry("Delay", "0" )).toInt(); | 559 | delay = (cfg.readEntry("Delay", "0" )).toInt(); |
562 | // If the time between suspend and resume was longer then the | 560 | // If the time between suspend and resume was longer then the |
563 | // value saved as delay, start the app | 561 | // value saved as delay, start the app |
564 | if ( suspendTime.secsTo(now) >= (delay*60) ) { | 562 | if ( suspendTime.secsTo(now) >= (delay*60) ) { |
565 | QCopEnvelope e("QPE/System", "execute(QString)"); | 563 | QCopEnvelope e("QPE/System", "execute(QString)"); |
566 | e << QString(appName); | 564 | e << QString(appName); |
567 | } else { | 565 | } else { |
568 | } | 566 | } |
569 | } | 567 | } |
570 | 568 | ||
571 | #if defined(QPE_HAVE_TOGGLELIGHT) | 569 | #if defined(QPE_HAVE_TOGGLELIGHT) |
572 | #include <qpe/config.h> | 570 | #include <qpe/config.h> |
573 | 571 | ||
574 | #include <sys/ioctl.h> | 572 | #include <sys/ioctl.h> |
575 | #include <sys/types.h> | 573 | #include <sys/types.h> |
576 | #include <fcntl.h> | 574 | #include <fcntl.h> |
577 | #include <unistd.h> | 575 | #include <unistd.h> |
578 | #include <errno.h> | 576 | #include <errno.h> |
579 | #include <linux/ioctl.h> | 577 | #include <linux/ioctl.h> |
580 | #include <time.h> | 578 | #include <time.h> |
581 | #endif | 579 | #endif |
582 | 580 | ||
583 | static bool blanked=FALSE; | 581 | static bool blanked=FALSE; |
584 | 582 | ||
585 | static void blankScreen() | 583 | static void blankScreen() |
586 | { | 584 | { |
587 | if ( !qt_screen ) return; | 585 | if ( !qt_screen ) return; |
588 | /* Should use a big black window instead. | 586 | /* Should use a big black window instead. |
589 | QGfx* g = qt_screen->screenGfx(); | 587 | QGfx* g = qt_screen->screenGfx(); |
590 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); | 588 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); |
591 | delete g; | 589 | delete g; |
592 | */ | 590 | */ |
593 | blanked = TRUE; | 591 | blanked = TRUE; |
594 | } | 592 | } |
595 | 593 | ||
596 | static void darkScreen() | 594 | static void darkScreen() |
597 | { | 595 | { |
598 | extern void qpe_setBacklight(int); | 596 | extern void qpe_setBacklight(int); |
599 | qpe_setBacklight(0); // force off | 597 | qpe_setBacklight(0); // force off |
600 | } | 598 | } |
601 | 599 | ||
602 | 600 | ||
603 | void Desktop::togglePower() | 601 | void Desktop::togglePower() |
604 | { | 602 | { |
605 | bool wasloggedin = loggedin; | 603 | bool wasloggedin = loggedin; |
606 | loggedin=0; | 604 | loggedin=0; |
607 | suspendTime = QDateTime::currentDateTime(); | 605 | suspendTime = QDateTime::currentDateTime(); |
608 | darkScreen(); | 606 | darkScreen(); |
609 | if ( wasloggedin ) | 607 | if ( wasloggedin ) |
610 | blankScreen(); | 608 | blankScreen(); |
611 | 609 | ||
612 | system("apm --suspend"); | 610 | system("apm --suspend"); |
613 | 611 | ||
614 | 612 | ||
615 | 613 | ||
616 | QWSServer::screenSaverActivate( FALSE ); | 614 | QWSServer::screenSaverActivate( FALSE ); |
617 | { | 615 | { |
618 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 616 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
619 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 617 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
620 | e << -3; // Force on | 618 | e << -3; // Force on |
621 | } | 619 | } |
622 | if ( wasloggedin ) { | 620 | if ( wasloggedin ) { |
623 | login(TRUE); | 621 | login(TRUE); |
624 | } | 622 | } |
625 | sleep(1); | 623 | sleep(1); |
626 | execAutoStart(); | 624 | execAutoStart(); |
627 | //qcopBridge->closeOpenConnections(); | 625 | //qcopBridge->closeOpenConnections(); |
628 | //qDebug("called togglePower()!!!!!!"); | 626 | //qDebug("called togglePower()!!!!!!"); |
629 | } | 627 | } |
630 | 628 | ||
631 | void Desktop::toggleLight() | 629 | void Desktop::toggleLight() |
632 | { | 630 | { |
633 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 631 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
634 | e << -2; // toggle | 632 | e << -2; // toggle |
635 | } | 633 | } |
636 | 634 | ||
637 | void Desktop::toggleSymbolInput() | 635 | void Desktop::toggleSymbolInput() |
638 | { | 636 | { |
639 | tb->toggleSymbolInput(); | 637 | tb->toggleSymbolInput(); |
640 | } | 638 | } |
641 | 639 | ||
642 | void Desktop::toggleNumLockState() | 640 | void Desktop::toggleNumLockState() |
643 | { | 641 | { |
644 | tb->toggleNumLockState(); | 642 | tb->toggleNumLockState(); |
645 | } | 643 | } |
646 | 644 | ||
647 | void Desktop::toggleCapsLockState() | 645 | void Desktop::toggleCapsLockState() |
648 | { | 646 | { |
649 | tb->toggleCapsLockState(); | 647 | tb->toggleCapsLockState(); |
650 | } | 648 | } |
651 | 649 | ||
652 | void Desktop::styleChange( QStyle &s ) | 650 | void Desktop::styleChange( QStyle &s ) |
653 | { | 651 | { |
654 | QWidget::styleChange( s ); | 652 | QWidget::styleChange( s ); |
655 | int displayw = qApp->desktop()->width(); | 653 | int displayw = qApp->desktop()->width(); |
656 | int displayh = qApp->desktop()->height(); | 654 | int displayh = qApp->desktop()->height(); |
657 | 655 | ||
658 | QSize sz = tb->sizeHint(); | 656 | QSize sz = tb->sizeHint(); |
659 | 657 | ||
660 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 658 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
661 | } | 659 | } |
662 | 660 | ||
663 | void DesktopApplication::shutdown() | 661 | void DesktopApplication::shutdown() |
664 | { | 662 | { |
665 | if ( type() != GuiServer ) | 663 | if ( type() != GuiServer ) |
666 | return; | 664 | return; |
667 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 665 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
668 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 666 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
669 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 667 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
670 | sd->showMaximized(); | 668 | sd->showMaximized(); |
671 | } | 669 | } |
672 | 670 | ||
673 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 671 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
674 | { | 672 | { |
675 | switch ( t ) { | 673 | switch ( t ) { |
676 | case ShutdownImpl::ShutdownSystem: | 674 | case ShutdownImpl::ShutdownSystem: |
677 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); | 675 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); |
678 | break; | 676 | break; |
679 | case ShutdownImpl::RebootSystem: | 677 | case ShutdownImpl::RebootSystem: |
680 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); | 678 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); |
681 | break; | 679 | break; |
682 | case ShutdownImpl::RestartDesktop: | 680 | case ShutdownImpl::RestartDesktop: |
683 | restart(); | 681 | restart(); |
684 | break; | 682 | break; |
685 | case ShutdownImpl::TerminateDesktop: | 683 | case ShutdownImpl::TerminateDesktop: |
686 | prepareForTermination(FALSE); | 684 | prepareForTermination(FALSE); |
687 | quit(); | 685 | quit(); |
688 | break; | 686 | break; |
689 | } | 687 | } |
690 | } | 688 | } |
691 | 689 | ||
692 | void DesktopApplication::restart() | 690 | void DesktopApplication::restart() |
693 | { | 691 | { |
694 | prepareForTermination(TRUE); | 692 | prepareForTermination(TRUE); |
695 | 693 | ||
696 | #ifdef Q_WS_QWS | 694 | #ifdef Q_WS_QWS |
697 | for ( int fd = 3; fd < 100; fd++ ) | 695 | for ( int fd = 3; fd < 100; fd++ ) |
698 | close( fd ); | 696 | close( fd ); |
699 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 697 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
700 | execl( "/sbin/init", "qpe", 0 ); | 698 | execl( "/sbin/init", "qpe", 0 ); |
701 | #elif defined(QT_QWS_CASSIOPEIA) | 699 | #elif defined(QT_QWS_CASSIOPEIA) |
702 | execl( "/bin/sh", "sh", 0 ); | 700 | execl( "/bin/sh", "sh", 0 ); |
703 | #else | 701 | #else |
704 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); | 702 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); |
705 | #endif | 703 | #endif |
706 | exit(1); | 704 | exit(1); |
707 | #endif | 705 | #endif |
708 | } | 706 | } |
709 | 707 | ||
710 | void Desktop::startTransferServer() | 708 | void Desktop::startTransferServer() |
711 | { | 709 | { |
712 | // start qcop bridge server | 710 | // start qcop bridge server |
713 | qcopBridge = new QCopBridge( 4243 ); | 711 | qcopBridge = new QCopBridge( 4243 ); |
714 | if ( !qcopBridge->ok() ) { | 712 | if ( !qcopBridge->ok() ) { |
715 | delete qcopBridge; | 713 | delete qcopBridge; |
716 | qcopBridge = 0; | 714 | qcopBridge = 0; |
717 | } | 715 | } |
718 | // start transfer server | 716 | // start transfer server |
719 | transferServer = new TransferServer( 4242 ); | 717 | transferServer = new TransferServer( 4242 ); |
720 | if ( !transferServer->ok() ) { | 718 | if ( !transferServer->ok() ) { |
721 | delete transferServer; | 719 | delete transferServer; |
722 | transferServer = 0; | 720 | transferServer = 0; |
723 | } | 721 | } |
724 | if ( !transferServer || !qcopBridge ) | 722 | if ( !transferServer || !qcopBridge ) |
725 | startTimer( 2000 ); | 723 | startTimer( 2000 ); |
726 | } | 724 | } |
727 | 725 | ||
728 | void Desktop::timerEvent( QTimerEvent *e ) | 726 | void Desktop::timerEvent( QTimerEvent *e ) |
729 | { | 727 | { |
730 | killTimer( e->timerId() ); | 728 | killTimer( e->timerId() ); |
731 | startTransferServer(); | 729 | startTransferServer(); |
732 | } | 730 | } |
733 | 731 | ||
734 | void Desktop::terminateServers() | 732 | void Desktop::terminateServers() |
735 | { | 733 | { |
736 | delete transferServer; | 734 | delete transferServer; |
737 | delete qcopBridge; | 735 | delete qcopBridge; |
738 | transferServer = 0; | 736 | transferServer = 0; |
739 | qcopBridge = 0; | 737 | qcopBridge = 0; |
740 | } | 738 | } |
741 | 739 | ||
742 | void Desktop::rereadVolumes() | 740 | void Desktop::rereadVolumes() |
743 | { | 741 | { |
744 | Config cfg("Sound"); | 742 | Config cfg("qpe"); |
745 | cfg.setGroup("System"); | 743 | cfg.setGroup("Volume"); |
746 | touchclick = cfg.readBoolEntry("Touch"); | 744 | touchclick = cfg.readBoolEntry("TouchSound"); |
747 | keyclick = cfg.readBoolEntry("Key"); | 745 | keyclick = cfg.readBoolEntry("KeySound"); |
746 | alarmsound = cfg.readBoolEntry("AlarmSound"); | ||
747 | // Config cfg("Sound"); | ||
748 | // cfg.setGroup("System"); | ||
749 | // touchclick = cfg.readBoolEntry("Touch"); | ||
750 | // keyclick = cfg.readBoolEntry("Key"); | ||
748 | } | 751 | } |
749 | 752 | ||
750 | void Desktop::keyClick() | 753 | void Desktop::keyClick() |
751 | { | 754 | { |
752 | #ifdef CUSTOM_SOUND_KEYCLICK | 755 | #ifdef CUSTOM_SOUND_KEYCLICK |
753 | if ( keyclick ) | 756 | if ( keyclick ) |
754 | CUSTOM_SOUND_KEYCLICK; | 757 | CUSTOM_SOUND_KEYCLICK; |
755 | #endif | 758 | #endif |
756 | } | 759 | } |
757 | 760 | ||
758 | void Desktop::screenClick() | 761 | void Desktop::screenClick() |
759 | { | 762 | { |
760 | #ifdef CUSTOM_SOUND_TOUCH | 763 | #ifdef CUSTOM_SOUND_TOUCH |
761 | if ( touchclick ) | 764 | if ( touchclick ) |
762 | CUSTOM_SOUND_TOUCH; | 765 | CUSTOM_SOUND_TOUCH; |
763 | #endif | 766 | #endif |
764 | } | 767 | } |
765 | 768 | ||
766 | void Desktop::soundAlarm() | 769 | void Desktop::soundAlarm() |
767 | { | 770 | { |
768 | #ifdef CUSTOM_SOUND_ALARM | 771 | #ifdef CUSTOM_SOUND_ALARM |
772 | if (alarmsound) | ||
769 | CUSTOM_SOUND_ALARM; | 773 | CUSTOM_SOUND_ALARM; |
770 | #endif | 774 | #endif |
771 | } | 775 | } |
772 | 776 | ||
773 | bool Desktop::eventFilter( QObject *w, QEvent *ev ) | 777 | bool Desktop::eventFilter( QObject *w, QEvent *ev ) |
774 | { | 778 | { |
775 | if ( ev->type() == QEvent::KeyPress ) { | 779 | if ( ev->type() == QEvent::KeyPress ) { |
776 | QKeyEvent *ke = (QKeyEvent *)ev; | 780 | QKeyEvent *ke = (QKeyEvent *)ev; |
777 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 781 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
778 | QWidget *active = qApp->activeWindow(); | 782 | QWidget *active = qApp->activeWindow(); |
779 | if ( active && active->isPopup() ) { | 783 | if ( active && active->isPopup() ) { |
780 | active->close(); | 784 | active->close(); |
781 | } | 785 | } |
782 | raiseMenu(); | 786 | raiseMenu(); |
783 | return TRUE; | 787 | return TRUE; |
784 | } | 788 | } |
785 | } | 789 | } |
786 | return FALSE; | 790 | return FALSE; |
787 | } | 791 | } |
788 | 792 | ||
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index e094dc0..9bc4be9 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -1,136 +1,136 @@ | |||
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 | #ifndef __DESKTOP_H__ | 21 | #ifndef __DESKTOP_H__ |
22 | #define __DESKTOP_H__ | 22 | #define __DESKTOP_H__ |
23 | 23 | ||
24 | 24 | ||
25 | #include "shutdownimpl.h" | 25 | #include "shutdownimpl.h" |
26 | 26 | ||
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
31 | 31 | ||
32 | class Background; | 32 | class Background; |
33 | class Launcher; | 33 | class Launcher; |
34 | class TaskBar; | 34 | class TaskBar; |
35 | class PowerStatus; | 35 | class PowerStatus; |
36 | class QCopBridge; | 36 | class QCopBridge; |
37 | class TransferServer; | 37 | class TransferServer; |
38 | class DesktopPowerAlerter; | 38 | class DesktopPowerAlerter; |
39 | class PackageSlave; | 39 | class PackageSlave; |
40 | 40 | ||
41 | class DesktopApplication : public QPEApplication | 41 | class DesktopApplication : public QPEApplication |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | DesktopApplication( int& argc, char **argv, Type t ); | 45 | DesktopApplication( int& argc, char **argv, Type t ); |
46 | ~DesktopApplication(); | 46 | ~DesktopApplication(); |
47 | signals: | 47 | signals: |
48 | void home(); | 48 | void home(); |
49 | void datebook(); | 49 | void datebook(); |
50 | void contacts(); | 50 | void contacts(); |
51 | void launch(); | 51 | void launch(); |
52 | void email(); | 52 | void email(); |
53 | void backlight(); | 53 | void backlight(); |
54 | void power(); | 54 | void power(); |
55 | void symbol(); | 55 | void symbol(); |
56 | void numLockStateToggle(); | 56 | void numLockStateToggle(); |
57 | void capsLockStateToggle(); | 57 | void capsLockStateToggle(); |
58 | void prepareForRestart(); | 58 | void prepareForRestart(); |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | #ifdef Q_WS_QWS | 61 | #ifdef Q_WS_QWS |
62 | bool qwsEventFilter( QWSEvent * ); | 62 | bool qwsEventFilter( QWSEvent * ); |
63 | #endif | 63 | #endif |
64 | void shutdown(); | 64 | void shutdown(); |
65 | void restart(); | 65 | void restart(); |
66 | 66 | ||
67 | public slots: | 67 | public slots: |
68 | void receive( const QCString &msg, const QByteArray &data ); | 68 | void receive( const QCString &msg, const QByteArray &data ); |
69 | 69 | ||
70 | protected slots: | 70 | protected slots: |
71 | void shutdown(ShutdownImpl::Type); | 71 | void shutdown(ShutdownImpl::Type); |
72 | void psTimeout(); | 72 | void psTimeout(); |
73 | void sendCard(); | 73 | void sendCard(); |
74 | private: | 74 | private: |
75 | DesktopPowerAlerter *pa; | 75 | DesktopPowerAlerter *pa; |
76 | PowerStatus *ps; | 76 | PowerStatus *ps; |
77 | QTimer *cardSendTimer; | 77 | QTimer *cardSendTimer; |
78 | QCopChannel *channel; | 78 | QCopChannel *channel; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | 81 | ||
82 | class Desktop : public QWidget { | 82 | class Desktop : public QWidget { |
83 | Q_OBJECT | 83 | Q_OBJECT |
84 | public: | 84 | public: |
85 | Desktop(); | 85 | Desktop(); |
86 | ~Desktop(); | 86 | ~Desktop(); |
87 | 87 | ||
88 | static bool screenLocked(); | 88 | static bool screenLocked(); |
89 | 89 | ||
90 | void show(); | 90 | void show(); |
91 | void checkMemory(); | 91 | void checkMemory(); |
92 | 92 | ||
93 | void keyClick(); | 93 | void keyClick(); |
94 | void screenClick(); | 94 | void screenClick(); |
95 | static void soundAlarm(); | 95 | static void soundAlarm(); |
96 | 96 | ||
97 | public slots: | 97 | public slots: |
98 | void raiseDatebook(); | 98 | void raiseDatebook(); |
99 | void raiseContacts(); | 99 | void raiseContacts(); |
100 | void raiseMenu(); | 100 | void raiseMenu(); |
101 | void raiseLauncher(); | 101 | void raiseLauncher(); |
102 | void raiseEmail(); | 102 | void raiseEmail(); |
103 | void execAutoStart(); | 103 | void execAutoStart(); |
104 | void togglePower(); | 104 | void togglePower(); |
105 | void toggleLight(); | 105 | void toggleLight(); |
106 | void toggleNumLockState(); | 106 | void toggleNumLockState(); |
107 | void toggleCapsLockState(); | 107 | void toggleCapsLockState(); |
108 | void toggleSymbolInput(); | 108 | void toggleSymbolInput(); |
109 | void terminateServers(); | 109 | void terminateServers(); |
110 | void rereadVolumes(); | 110 | void rereadVolumes(); |
111 | 111 | ||
112 | protected: | 112 | protected: |
113 | void executeOrModify(const QString& appLnkFile); | 113 | void executeOrModify(const QString& appLnkFile); |
114 | void styleChange( QStyle & ); | 114 | void styleChange( QStyle & ); |
115 | void timerEvent( QTimerEvent *e ); | 115 | void timerEvent( QTimerEvent *e ); |
116 | bool eventFilter( QObject *, QEvent * ); | 116 | bool eventFilter( QObject *, QEvent * ); |
117 | 117 | ||
118 | QWidget *bg; | 118 | QWidget *bg; |
119 | Launcher *launcher; | 119 | Launcher *launcher; |
120 | TaskBar *tb; | 120 | TaskBar *tb; |
121 | 121 | ||
122 | private: | 122 | private: |
123 | void startTransferServer(); | 123 | void startTransferServer(); |
124 | bool recoverMemory(); | 124 | bool recoverMemory(); |
125 | 125 | ||
126 | QCopBridge *qcopBridge; | 126 | QCopBridge *qcopBridge; |
127 | TransferServer *transferServer; | 127 | TransferServer *transferServer; |
128 | PackageSlave *packageSlave; | 128 | PackageSlave *packageSlave; |
129 | 129 | ||
130 | QDateTime suspendTime; | 130 | QDateTime suspendTime; |
131 | bool keyclick,touchclick; | 131 | bool keyclick,touchclick,alarmsound; |
132 | }; | 132 | }; |
133 | 133 | ||
134 | 134 | ||
135 | #endif // __DESKTOP_H__ | 135 | #endif // __DESKTOP_H__ |
136 | 136 | ||