author | zecke <zecke> | 2003-09-03 18:58:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-03 18:58:20 (UTC) |
commit | 3038503f6ffc2d58b00650d5feae23cc8e842bcb (patch) (unidiff) | |
tree | 33b2b319307b9a5abda47b51c31329131295d703 | |
parent | 577cdc4f2ce81eaceb132af08d8ab6fe12b4eadc (diff) | |
download | opie-3038503f6ffc2d58b00650d5feae23cc8e842bcb.zip opie-3038503f6ffc2d58b00650d5feae23cc8e842bcb.tar.gz opie-3038503f6ffc2d58b00650d5feae23cc8e842bcb.tar.bz2 |
Failure free restart of the launcher and a comment
why we do that
-rw-r--r-- | core/launcher/serverapp.cpp | 19 | ||||
-rw-r--r-- | core/launcher/systray.cpp | 8 | ||||
-rw-r--r-- | core/launcher/systray.h | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index 522ef07..28316a4 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -1,813 +1,832 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 "serverapp.h" | 21 | #include "serverapp.h" |
22 | 22 | ||
23 | #include <opie/odevice.h> | 23 | #include <opie/odevice.h> |
24 | 24 | ||
25 | #include <qtopia/password.h> | 25 | #include <qtopia/password.h> |
26 | #include <qtopia/config.h> | 26 | #include <qtopia/config.h> |
27 | #include <qtopia/power.h> | 27 | #include <qtopia/power.h> |
28 | 28 | ||
29 | #ifdef Q_WS_QWS | 29 | #ifdef Q_WS_QWS |
30 | #include <qtopia/qcopenvelope_qws.h> | 30 | #include <qtopia/qcopenvelope_qws.h> |
31 | #endif | 31 | #endif |
32 | #include <qtopia/global.h> | 32 | #include <qtopia/global.h> |
33 | #include <qtopia/custom.h> | 33 | #include <qtopia/custom.h> |
34 | 34 | ||
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | #include <qgfx_qws.h> | 36 | #include <qgfx_qws.h> |
37 | #endif | 37 | #endif |
38 | #ifdef Q_OS_WIN32 | 38 | #ifdef Q_OS_WIN32 |
39 | #include <io.h> | 39 | #include <io.h> |
40 | #include <process.h> | 40 | #include <process.h> |
41 | #else | 41 | #else |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #endif | 43 | #endif |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qtimer.h> | 45 | #include <qtimer.h> |
46 | #include <qpainter.h> | 46 | #include <qpainter.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qpixmapcache.h> | 48 | #include <qpixmapcache.h> |
49 | 49 | ||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include "screensaver.h" | 51 | #include "screensaver.h" |
52 | 52 | ||
53 | static ServerApplication *serverApp = 0; | 53 | static ServerApplication *serverApp = 0; |
54 | static int loggedin=0; | 54 | static int loggedin=0; |
55 | 55 | ||
56 | using namespace Opie; | 56 | using namespace Opie; |
57 | 57 | ||
58 | QCopKeyRegister::QCopKeyRegister() | 58 | QCopKeyRegister::QCopKeyRegister() |
59 | : m_keyCode( 0 ) { | 59 | : m_keyCode( 0 ) { |
60 | } | 60 | } |
61 | 61 | ||
62 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) | 62 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) |
63 | :m_keyCode( k ), m_channel( c ), m_message( m ) { | 63 | :m_keyCode( k ), m_channel( c ), m_message( m ) { |
64 | } | 64 | } |
65 | 65 | ||
66 | int QCopKeyRegister::keyCode()const { | 66 | int QCopKeyRegister::keyCode()const { |
67 | return m_keyCode; | 67 | return m_keyCode; |
68 | } | 68 | } |
69 | 69 | ||
70 | QCString QCopKeyRegister::channel()const { | 70 | QCString QCopKeyRegister::channel()const { |
71 | return m_channel; | 71 | return m_channel; |
72 | } | 72 | } |
73 | 73 | ||
74 | QCString QCopKeyRegister::message()const { | 74 | QCString QCopKeyRegister::message()const { |
75 | return m_message; | 75 | return m_message; |
76 | } | 76 | } |
77 | 77 | ||
78 | bool QCopKeyRegister::send() { | 78 | bool QCopKeyRegister::send() { |
79 | if (m_channel.isNull() ) | 79 | if (m_channel.isNull() ) |
80 | return false; | 80 | return false; |
81 | 81 | ||
82 | QCopEnvelope( m_channel, m_message ); | 82 | QCopEnvelope( m_channel, m_message ); |
83 | 83 | ||
84 | return true; | 84 | return true; |
85 | } | 85 | } |
86 | 86 | ||
87 | //--------------------------------------------------------------------------- | 87 | //--------------------------------------------------------------------------- |
88 | 88 | ||
89 | /* | 89 | /* |
90 | Priority is number of alerts that are needed to pop up | 90 | Priority is number of alerts that are needed to pop up |
91 | alert. | 91 | alert. |
92 | */ | 92 | */ |
93 | class DesktopPowerAlerter : public QMessageBox | 93 | class DesktopPowerAlerter : public QMessageBox |
94 | { | 94 | { |
95 | Q_OBJECT | 95 | Q_OBJECT |
96 | public: | 96 | public: |
97 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 97 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
98 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), | 98 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), |
99 | QMessageBox::Critical, | 99 | QMessageBox::Critical, |
100 | QMessageBox::Ok | QMessageBox::Default, | 100 | QMessageBox::Ok | QMessageBox::Default, |
101 | QMessageBox::NoButton, QMessageBox::NoButton, | 101 | QMessageBox::NoButton, QMessageBox::NoButton, |
102 | parent, name, FALSE ) | 102 | parent, name, FALSE ) |
103 | { | 103 | { |
104 | currentPriority = INT_MAX; | 104 | currentPriority = INT_MAX; |
105 | alertCount = 0; | 105 | alertCount = 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | void alert( const QString &text, int priority ); | 108 | void alert( const QString &text, int priority ); |
109 | void hideEvent( QHideEvent * ); | 109 | void hideEvent( QHideEvent * ); |
110 | private: | 110 | private: |
111 | int currentPriority; | 111 | int currentPriority; |
112 | int alertCount; | 112 | int alertCount; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 115 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
116 | { | 116 | { |
117 | alertCount++; | 117 | alertCount++; |
118 | if ( alertCount < priority ) | 118 | if ( alertCount < priority ) |
119 | return; | 119 | return; |
120 | if ( priority > currentPriority ) | 120 | if ( priority > currentPriority ) |
121 | return; | 121 | return; |
122 | currentPriority = priority; | 122 | currentPriority = priority; |
123 | setText( text ); | 123 | setText( text ); |
124 | show(); | 124 | show(); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 128 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
129 | { | 129 | { |
130 | QMessageBox::hideEvent( e ); | 130 | QMessageBox::hideEvent( e ); |
131 | alertCount = 0; | 131 | alertCount = 0; |
132 | currentPriority = INT_MAX; | 132 | currentPriority = INT_MAX; |
133 | } | 133 | } |
134 | 134 | ||
135 | //--------------------------------------------------------------------------- | 135 | //--------------------------------------------------------------------------- |
136 | 136 | ||
137 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) | 137 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) |
138 | { | 138 | { |
139 | /* We don't do this cause it would interfere with ODevice */ | 139 | /* We don't do this cause it would interfere with ODevice */ |
140 | #if 0 | 140 | #if 0 |
141 | qwsServer->setKeyboardFilter(this); | 141 | qwsServer->setKeyboardFilter(this); |
142 | #endif | 142 | #endif |
143 | } | 143 | } |
144 | 144 | ||
145 | void KeyFilter::timerEvent(QTimerEvent* e) | 145 | void KeyFilter::timerEvent(QTimerEvent* e) |
146 | { | 146 | { |
147 | if ( e->timerId() == held_tid ) { | 147 | if ( e->timerId() == held_tid ) { |
148 | killTimer(held_tid); | 148 | killTimer(held_tid); |
149 | // button held | 149 | // button held |
150 | if ( heldButton ) { | 150 | if ( heldButton ) { |
151 | emit activate(heldButton, TRUE); | 151 | emit activate(heldButton, TRUE); |
152 | heldButton = 0; | 152 | heldButton = 0; |
153 | } | 153 | } |
154 | held_tid = 0; | 154 | held_tid = 0; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { | 158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { |
159 | m_keys.insert( key.keyCode(), key ); | 159 | m_keys.insert( key.keyCode(), key ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { | 162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { |
163 | m_keys.remove( key.keyCode() ); | 163 | m_keys.remove( key.keyCode() ); |
164 | } | 164 | } |
165 | 165 | ||
166 | bool KeyFilter::keyRegistered( int key ) { | 166 | bool KeyFilter::keyRegistered( int key ) { |
167 | /* | 167 | /* |
168 | * Check if we've a key registered | 168 | * Check if we've a key registered |
169 | */ | 169 | */ |
170 | if ( !m_keys[key].send()) | 170 | if ( !m_keys[key].send()) |
171 | return false; | 171 | return false; |
172 | else | 172 | else |
173 | return true; | 173 | return true; |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
178 | { | 178 | { |
179 | if ( !loggedin | 179 | if ( !loggedin |
180 | // Permitted keys | 180 | // Permitted keys |
181 | && keycode != Key_F34 // power | 181 | && keycode != Key_F34 // power |
182 | && keycode != Key_F30 // select | 182 | && keycode != Key_F30 // select |
183 | && keycode != Key_Enter | 183 | && keycode != Key_Enter |
184 | && keycode != Key_Return | 184 | && keycode != Key_Return |
185 | && keycode != Key_Space | 185 | && keycode != Key_Space |
186 | && keycode != Key_Left | 186 | && keycode != Key_Left |
187 | && keycode != Key_Right | 187 | && keycode != Key_Right |
188 | && keycode != Key_Up | 188 | && keycode != Key_Up |
189 | && keycode != Key_Down ) | 189 | && keycode != Key_Down ) |
190 | return TRUE; | 190 | return TRUE; |
191 | 191 | ||
192 | /* check if it was registered */ | 192 | /* check if it was registered */ |
193 | if (!db ) { | 193 | if (!db ) { |
194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
195 | return true; | 195 | return true; |
196 | }else { | 196 | }else { |
197 | 197 | ||
198 | 198 | ||
199 | // First check to see if DeviceButtonManager knows something about this button: | 199 | // First check to see if DeviceButtonManager knows something about this button: |
200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); | 200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); |
201 | if (button && !autoRepeat) { | 201 | if (button && !autoRepeat) { |
202 | if ( held_tid ) { | 202 | if ( held_tid ) { |
203 | killTimer(held_tid); | 203 | killTimer(held_tid); |
204 | held_tid = 0; | 204 | held_tid = 0; |
205 | } | 205 | } |
206 | if ( button->heldAction().isNull() ) { | 206 | if ( button->heldAction().isNull() ) { |
207 | if ( press ) | 207 | if ( press ) |
208 | emit activate(button, FALSE); | 208 | emit activate(button, FALSE); |
209 | } else if ( press ) { | 209 | } else if ( press ) { |
210 | heldButton = button; | 210 | heldButton = button; |
211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
212 | } else if ( heldButton ) { | 212 | } else if ( heldButton ) { |
213 | heldButton = 0; | 213 | heldButton = 0; |
214 | emit activate(button, FALSE); | 214 | emit activate(button, FALSE); |
215 | } | 215 | } |
216 | QWSServer::screenSaverActivate(FALSE); | 216 | QWSServer::screenSaverActivate(FALSE); |
217 | return TRUE; | 217 | return TRUE; |
218 | } | 218 | } |
219 | return false; | 219 | return false; |
220 | } | 220 | } |
221 | if ( keycode == HardKey_Suspend ) { | 221 | if ( keycode == HardKey_Suspend ) { |
222 | if ( press ) emit power(); | 222 | if ( press ) emit power(); |
223 | return TRUE; | 223 | return TRUE; |
224 | } | 224 | } |
225 | if ( keycode == HardKey_Backlight ) { | 225 | if ( keycode == HardKey_Backlight ) { |
226 | if ( press ) emit backlight(); | 226 | if ( press ) emit backlight(); |
227 | return TRUE; | 227 | return TRUE; |
228 | } | 228 | } |
229 | if ( keycode == Key_F32 ) { | 229 | if ( keycode == Key_F32 ) { |
230 | #ifndef QT_NO_COP | 230 | #ifndef QT_NO_COP |
231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
232 | #endif | 232 | #endif |
233 | return TRUE; | 233 | return TRUE; |
234 | } | 234 | } |
235 | if ( keycode == Key_F31 ) { | 235 | if ( keycode == Key_F31 ) { |
236 | if ( press ) emit symbol(); | 236 | if ( press ) emit symbol(); |
237 | QWSServer::screenSaverActivate(FALSE); | 237 | QWSServer::screenSaverActivate(FALSE); |
238 | return TRUE; | 238 | return TRUE; |
239 | } | 239 | } |
240 | 240 | ||
241 | if ( keycode == Key_NumLock ) | 241 | if ( keycode == Key_NumLock ) |
242 | if ( press ) emit numLockStateToggle(); | 242 | if ( press ) emit numLockStateToggle(); |
243 | 243 | ||
244 | if ( keycode == Key_CapsLock ) | 244 | if ( keycode == Key_CapsLock ) |
245 | if ( press ) emit capsLockStateToggle(); | 245 | if ( press ) emit capsLockStateToggle(); |
246 | 246 | ||
247 | if ( serverApp ) | 247 | if ( serverApp ) |
248 | serverApp->keyClick(keycode,press,autoRepeat); | 248 | serverApp->keyClick(keycode,press,autoRepeat); |
249 | 249 | ||
250 | return FALSE; | 250 | return FALSE; |
251 | } | 251 | } |
252 | 252 | ||
253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
254 | 254 | ||
255 | #if defined(QPE_HAVE_MEMALERTER) | 255 | #if defined(QPE_HAVE_MEMALERTER) |
256 | QPE_MEMALERTER_IMPL | 256 | QPE_MEMALERTER_IMPL |
257 | #endif | 257 | #endif |
258 | 258 | ||
259 | 259 | ||
260 | 260 | ||
261 | //--------------------------------------------------------------------------- | 261 | //--------------------------------------------------------------------------- |
262 | 262 | ||
263 | bool ServerApplication::doRestart = FALSE; | 263 | bool ServerApplication::doRestart = FALSE; |
264 | bool ServerApplication::allowRestart = TRUE; | 264 | bool ServerApplication::allowRestart = TRUE; |
265 | 265 | ||
266 | void ServerApplication::switchLCD( bool on ) { | 266 | void ServerApplication::switchLCD( bool on ) { |
267 | if ( !qApp ) | 267 | if ( !qApp ) |
268 | return; | 268 | return; |
269 | 269 | ||
270 | ServerApplication *dapp = ServerApplication::me() ; | 270 | ServerApplication *dapp = ServerApplication::me() ; |
271 | 271 | ||
272 | if ( !dapp-> m_screensaver ) | 272 | if ( !dapp-> m_screensaver ) |
273 | return; | 273 | return; |
274 | 274 | ||
275 | if ( on ) { | 275 | if ( on ) { |
276 | dapp-> m_screensaver-> setDisplayState ( true ); | 276 | dapp-> m_screensaver-> setDisplayState ( true ); |
277 | dapp-> m_screensaver-> setBacklight ( -3 ); | 277 | dapp-> m_screensaver-> setBacklight ( -3 ); |
278 | }else | 278 | }else |
279 | dapp-> m_screensaver-> setDisplayState ( false ); | 279 | dapp-> m_screensaver-> setDisplayState ( false ); |
280 | 280 | ||
281 | 281 | ||
282 | } | 282 | } |
283 | 283 | ||
284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |
285 | : QPEApplication( argc, argv, t ) | 285 | : QPEApplication( argc, argv, t ) |
286 | { | 286 | { |
287 | 287 | ||
288 | 288 | ||
289 | // We know we'll have lots of cached pixmaps due to App/DocLnks | 289 | // We know we'll have lots of cached pixmaps due to App/DocLnks |
290 | QPixmapCache::setCacheLimit(512); | 290 | QPixmapCache::setCacheLimit(512); |
291 | 291 | ||
292 | m_ps = new PowerStatus; | 292 | m_ps = new PowerStatus; |
293 | m_ps_last = new PowerStatus; | 293 | m_ps_last = new PowerStatus; |
294 | pa = new DesktopPowerAlerter( 0 ); | 294 | pa = new DesktopPowerAlerter( 0 ); |
295 | 295 | ||
296 | m_apm_timer = new QTimer( this ); | 296 | m_apm_timer = new QTimer( this ); |
297 | connect(m_apm_timer, SIGNAL( timeout() ), | 297 | connect(m_apm_timer, SIGNAL( timeout() ), |
298 | this, SLOT( apmTimeout() ) ); | 298 | this, SLOT( apmTimeout() ) ); |
299 | 299 | ||
300 | reloadPowerWarnSettings(); | 300 | reloadPowerWarnSettings(); |
301 | 301 | ||
302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), |
304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); | 304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); |
305 | 305 | ||
306 | channel = new QCopChannel("QPE/Launcher", this ); | 306 | channel = new QCopChannel("QPE/Launcher", this ); |
307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), |
308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); | 308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); |
309 | 309 | ||
310 | m_screensaver = new OpieScreenSaver(); | 310 | m_screensaver = new OpieScreenSaver(); |
311 | m_screensaver->setInterval( -1 ); | 311 | m_screensaver->setInterval( -1 ); |
312 | QWSServer::setScreenSaver( m_screensaver ); | 312 | QWSServer::setScreenSaver( m_screensaver ); |
313 | 313 | ||
314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), | 314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), |
315 | this, SLOT( rereadVolumes() ) ); | 315 | this, SLOT( rereadVolumes() ) ); |
316 | 316 | ||
317 | 317 | ||
318 | /* ### PluginLoader libqtopia SafeMode */ | 318 | /* ### PluginLoader libqtopia SafeMode */ |
319 | #if 0 | 319 | #if 0 |
320 | if ( PluginLoader::inSafeMode() ) | 320 | if ( PluginLoader::inSafeMode() ) |
321 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); | 321 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); |
322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
323 | #endif | 323 | #endif |
324 | 324 | ||
325 | kf = new KeyFilter(this); | 325 | kf = new KeyFilter(this); |
326 | 326 | ||
327 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); | 327 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); |
328 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); | 328 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); |
329 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); | 329 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); |
330 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); | 330 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); |
331 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); | 331 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); |
332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); | 334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); |
335 | 335 | ||
336 | connect( kf, SIGNAL(power()), this, SLOT(togglePower()) ); | 336 | connect( kf, SIGNAL(power()), this, SLOT(togglePower()) ); |
337 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); | 337 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); |
338 | 338 | ||
339 | connect( this, SIGNAL(power() ), | 339 | connect( this, SIGNAL(power() ), |
340 | SLOT(togglePower() ) ); | 340 | SLOT(togglePower() ) ); |
341 | 341 | ||
342 | rereadVolumes(); | 342 | rereadVolumes(); |
343 | 343 | ||
344 | serverApp = this; | 344 | serverApp = this; |
345 | 345 | ||
346 | apmTimeout(); | 346 | apmTimeout(); |
347 | grabKeyboard(); | 347 | grabKeyboard(); |
348 | 348 | ||
349 | /* make sure the event filter is installed */ | 349 | /* make sure the event filter is installed */ |
350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); | 350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | ServerApplication::~ServerApplication() | 354 | ServerApplication::~ServerApplication() |
355 | { | 355 | { |
356 | ungrabKeyboard(); | 356 | ungrabKeyboard(); |
357 | 357 | ||
358 | 358 | ||
359 | delete pa; | 359 | delete pa; |
360 | delete m_ps; | 360 | delete m_ps; |
361 | delete m_ps_last; | 361 | delete m_ps_last; |
362 | } | 362 | } |
363 | 363 | ||
364 | void ServerApplication::apmTimeout() { | 364 | void ServerApplication::apmTimeout() { |
365 | serverApp-> checkMemory( ); // in case no events are generated | 365 | serverApp-> checkMemory( ); // in case no events are generated |
366 | *m_ps_last = *m_ps; | 366 | *m_ps_last = *m_ps; |
367 | *m_ps = PowerStatusManager::readStatus(); | 367 | *m_ps = PowerStatusManager::readStatus(); |
368 | 368 | ||
369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | 369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) |
370 | m_screensaver-> powerStatusChanged( *m_ps ); | 370 | m_screensaver-> powerStatusChanged( *m_ps ); |
371 | 371 | ||
372 | if ( m_ps->acStatus() == PowerStatus::Online ) | 372 | if ( m_ps->acStatus() == PowerStatus::Online ) |
373 | return; | 373 | return; |
374 | 374 | ||
375 | int bat = m_ps-> batteryPercentRemaining(); | 375 | int bat = m_ps-> batteryPercentRemaining(); |
376 | 376 | ||
377 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { | 377 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { |
378 | if ( bat <= m_powerCritical ) | 378 | if ( bat <= m_powerCritical ) |
379 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); | 379 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); |
380 | else if ( bat <= m_powerVeryLow ) | 380 | else if ( bat <= m_powerVeryLow ) |
381 | pa->alert( tr( "Battery is running very low. "), 2 ); | 381 | pa->alert( tr( "Battery is running very low. "), 2 ); |
382 | } | 382 | } |
383 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) | 383 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) |
384 | pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); | 384 | pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); |
385 | 385 | ||
386 | } | 386 | } |
387 | 387 | ||
388 | void ServerApplication::systemMessage( const QCString& msg, | 388 | void ServerApplication::systemMessage( const QCString& msg, |
389 | const QByteArray& data ) { | 389 | const QByteArray& data ) { |
390 | QDataStream stream ( data, IO_ReadOnly ); | 390 | QDataStream stream ( data, IO_ReadOnly ); |
391 | 391 | ||
392 | if ( msg == "setScreenSaverInterval(int)" ) { | 392 | if ( msg == "setScreenSaverInterval(int)" ) { |
393 | int time; | 393 | int time; |
394 | stream >> time; | 394 | stream >> time; |
395 | m_screensaver-> setInterval( time ); | 395 | m_screensaver-> setInterval( time ); |
396 | } | 396 | } |
397 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 397 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
398 | int t1, t2, t3; | 398 | int t1, t2, t3; |
399 | stream >> t1 >> t2 >> t3; | 399 | stream >> t1 >> t2 >> t3; |
400 | m_screensaver-> setIntervals( t1, t2, t3 ); | 400 | m_screensaver-> setIntervals( t1, t2, t3 ); |
401 | } | 401 | } |
402 | else if ( msg == "setBacklight(int)" ) { | 402 | else if ( msg == "setBacklight(int)" ) { |
403 | int bright; | 403 | int bright; |
404 | stream >> bright; | 404 | stream >> bright; |
405 | m_screensaver-> setBacklight( bright ); | 405 | m_screensaver-> setBacklight( bright ); |
406 | } | 406 | } |
407 | else if ( msg == "setScreenSaverMode(int)" ) { | 407 | else if ( msg == "setScreenSaverMode(int)" ) { |
408 | int mode; | 408 | int mode; |
409 | stream >> mode; | 409 | stream >> mode; |
410 | m_screensaver-> setMode ( mode ); | 410 | m_screensaver-> setMode ( mode ); |
411 | } | 411 | } |
412 | else if ( msg == "reloadPowerWarnSettings()" ) { | 412 | else if ( msg == "reloadPowerWarnSettings()" ) { |
413 | reloadPowerWarnSettings(); | 413 | reloadPowerWarnSettings(); |
414 | } | 414 | } |
415 | else if ( msg == "setDisplayState(int)" ) { | 415 | else if ( msg == "setDisplayState(int)" ) { |
416 | int state; | 416 | int state; |
417 | stream >> state; | 417 | stream >> state; |
418 | m_screensaver-> setDisplayState ( state != 0 ); | 418 | m_screensaver-> setDisplayState ( state != 0 ); |
419 | } | 419 | } |
420 | else if ( msg == "suspend()" ) { | 420 | else if ( msg == "suspend()" ) { |
421 | emit power(); | 421 | emit power(); |
422 | } | 422 | } |
423 | else if ( msg == "sendBusinessCard()" ) { | 423 | else if ( msg == "sendBusinessCard()" ) { |
424 | QString card = ::getenv ( "HOME" ); | 424 | QString card = ::getenv ( "HOME" ); |
425 | card += "/Applications/addressbook/businesscard.vcf"; | 425 | card += "/Applications/addressbook/businesscard.vcf"; |
426 | 426 | ||
427 | if ( QFile::exists( card ) ) { | 427 | if ( QFile::exists( card ) ) { |
428 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 428 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
429 | QString mimetype = "text/x-vCard"; | 429 | QString mimetype = "text/x-vCard"; |
430 | e << tr( "business card" ) << card << mimetype; | 430 | e << tr( "business card" ) << card << mimetype; |
431 | } | 431 | } |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | void ServerApplication::reloadPowerWarnSettings ( ) | 435 | void ServerApplication::reloadPowerWarnSettings ( ) |
436 | { | 436 | { |
437 | Config cfg ( "apm" ); | 437 | Config cfg ( "apm" ); |
438 | cfg. setGroup ( "Warnings" ); | 438 | cfg. setGroup ( "Warnings" ); |
439 | 439 | ||
440 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); | 440 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); |
441 | 441 | ||
442 | m_apm_timer-> stop ( ); | 442 | m_apm_timer-> stop ( ); |
443 | if ( iv ) | 443 | if ( iv ) |
444 | m_apm_timer-> start ( iv ); | 444 | m_apm_timer-> start ( iv ); |
445 | 445 | ||
446 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); | 446 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); |
447 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); | 447 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); |
448 | } | 448 | } |
449 | 449 | ||
450 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) | 450 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) |
451 | { | 451 | { |
452 | QDataStream stream ( data, IO_ReadOnly ); | 452 | QDataStream stream ( data, IO_ReadOnly ); |
453 | 453 | ||
454 | if ( msg == "deviceButton(int,int,int)" ) { | 454 | if ( msg == "deviceButton(int,int,int)" ) { |
455 | int keycode, press, autoRepeat; | 455 | int keycode, press, autoRepeat; |
456 | stream >> keycode >> press >> autoRepeat; | 456 | stream >> keycode >> press >> autoRepeat; |
457 | 457 | ||
458 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); | 458 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); |
459 | } | 459 | } |
460 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | 460 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { |
461 | int k; | 461 | int k; |
462 | QCString c, m; | 462 | QCString c, m; |
463 | stream >> k >> c >> m; | 463 | stream >> k >> c >> m; |
464 | 464 | ||
465 | kf -> registerKey( QCopKeyRegister(k, c, m) ); | 465 | kf -> registerKey( QCopKeyRegister(k, c, m) ); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | 469 | ||
470 | bool ServerApplication::screenLocked() | 470 | bool ServerApplication::screenLocked() |
471 | { | 471 | { |
472 | return loggedin == 0; | 472 | return loggedin == 0; |
473 | } | 473 | } |
474 | 474 | ||
475 | void ServerApplication::login(bool at_poweron) | 475 | void ServerApplication::login(bool at_poweron) |
476 | { | 476 | { |
477 | if ( !loggedin ) { | 477 | if ( !loggedin ) { |
478 | Global::terminateBuiltin("calibrate"); // No tr | 478 | Global::terminateBuiltin("calibrate"); // No tr |
479 | Password::authenticate(at_poweron); | 479 | Password::authenticate(at_poweron); |
480 | loggedin=1; | 480 | loggedin=1; |
481 | #ifndef QT_NO_COP | 481 | #ifndef QT_NO_COP |
482 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 482 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
483 | #endif | 483 | #endif |
484 | } | 484 | } |
485 | } | 485 | } |
486 | 486 | ||
487 | #if defined(QPE_HAVE_TOGGLELIGHT) | 487 | #if defined(QPE_HAVE_TOGGLELIGHT) |
488 | #include <qtopia/config.h> | 488 | #include <qtopia/config.h> |
489 | 489 | ||
490 | #include <sys/ioctl.h> | 490 | #include <sys/ioctl.h> |
491 | #include <sys/types.h> | 491 | #include <sys/types.h> |
492 | #include <fcntl.h> | 492 | #include <fcntl.h> |
493 | #include <unistd.h> | 493 | #include <unistd.h> |
494 | #include <errno.h> | 494 | #include <errno.h> |
495 | #include <linux/ioctl.h> | 495 | #include <linux/ioctl.h> |
496 | #include <time.h> | 496 | #include <time.h> |
497 | #endif | 497 | #endif |
498 | 498 | ||
499 | #if 0 | 499 | #if 0 |
500 | static bool blanked=FALSE; | 500 | static bool blanked=FALSE; |
501 | 501 | ||
502 | static void blankScreen() | 502 | static void blankScreen() |
503 | { | 503 | { |
504 | #ifdef QWS | 504 | #ifdef QWS |
505 | QWidget w(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WStyle_StaysOnTop | Qt::WPaintUnclipped); | 505 | QWidget w(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WStyle_StaysOnTop | Qt::WPaintUnclipped); |
506 | w.resize( qt_screen->width(), qt_screen->height() ); | 506 | w.resize( qt_screen->width(), qt_screen->height() ); |
507 | w.move(0, 0); | 507 | w.move(0, 0); |
508 | 508 | ||
509 | QPainter p(&w); | 509 | QPainter p(&w); |
510 | p.fillRect(w.rect(), QBrush(QColor(255,255,255)) ); | 510 | p.fillRect(w.rect(), QBrush(QColor(255,255,255)) ); |
511 | p.end(); | 511 | p.end(); |
512 | w.repaint(); | 512 | w.repaint(); |
513 | 513 | ||
514 | blanked = TRUE; | 514 | blanked = TRUE; |
515 | #endif | 515 | #endif |
516 | } | 516 | } |
517 | 517 | ||
518 | static void darkScreen() | 518 | static void darkScreen() |
519 | { | 519 | { |
520 | /* ### Screen blanking ODevice */ | 520 | /* ### Screen blanking ODevice */ |
521 | #if 0 | 521 | #if 0 |
522 | qpe_setBacklight(0); // force off | 522 | qpe_setBacklight(0); // force off |
523 | #endif | 523 | #endif |
524 | } | 524 | } |
525 | #endif | 525 | #endif |
526 | 526 | ||
527 | namespace { | 527 | namespace { |
528 | void execAutoStart(const QDateTime& suspendTime ) { | 528 | void execAutoStart(const QDateTime& suspendTime ) { |
529 | QString appName; | 529 | QString appName; |
530 | int delay; | 530 | int delay; |
531 | QDateTime now = QDateTime::currentDateTime(); | 531 | QDateTime now = QDateTime::currentDateTime(); |
532 | 532 | ||
533 | Config cfg( "autostart" ); | 533 | Config cfg( "autostart" ); |
534 | cfg.setGroup( "AutoStart" ); | 534 | cfg.setGroup( "AutoStart" ); |
535 | appName = cfg.readEntry( "Apps", "" ); | 535 | appName = cfg.readEntry( "Apps", "" ); |
536 | delay = cfg.readNumEntry( "Delay", 0 ); | 536 | delay = cfg.readNumEntry( "Delay", 0 ); |
537 | 537 | ||
538 | // If the time between suspend and resume was longer then the | 538 | // If the time between suspend and resume was longer then the |
539 | // value saved as delay, start the app | 539 | // value saved as delay, start the app |
540 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 540 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
541 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 541 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
542 | e << QString( appName ); | 542 | e << QString( appName ); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | } | 545 | } |
546 | 546 | ||
547 | 547 | ||
548 | void ServerApplication::togglePower() | 548 | void ServerApplication::togglePower() |
549 | { | 549 | { |
550 | static bool excllock = false; | 550 | static bool excllock = false; |
551 | 551 | ||
552 | if ( excllock ) | 552 | if ( excllock ) |
553 | return ; | 553 | return ; |
554 | 554 | ||
555 | excllock = true; | 555 | excllock = true; |
556 | 556 | ||
557 | bool wasloggedin = loggedin; | 557 | bool wasloggedin = loggedin; |
558 | loggedin = 0; | 558 | loggedin = 0; |
559 | m_suspendTime = QDateTime::currentDateTime(); | 559 | m_suspendTime = QDateTime::currentDateTime(); |
560 | 560 | ||
561 | #ifdef QWS | 561 | #ifdef QWS |
562 | 562 | ||
563 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 563 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
564 | // Should use a big black window instead. | 564 | // Should use a big black window instead. |
565 | // But this would not show up fast enough | 565 | // But this would not show up fast enough |
566 | QGfx *g = qt_screen-> screenGfx ( ); | 566 | QGfx *g = qt_screen-> screenGfx ( ); |
567 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 567 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
568 | delete g; | 568 | delete g; |
569 | } | 569 | } |
570 | #endif | 570 | #endif |
571 | 571 | ||
572 | ODevice::inst ( )-> suspend ( ); | 572 | ODevice::inst ( )-> suspend ( ); |
573 | 573 | ||
574 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call | 574 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call |
575 | QWSServer::screenSaverActivate ( false ); | 575 | QWSServer::screenSaverActivate ( false ); |
576 | 576 | ||
577 | { | 577 | { |
578 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 578 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
579 | } | 579 | } |
580 | 580 | ||
581 | if ( wasloggedin ) | 581 | if ( wasloggedin ) |
582 | login ( true ); | 582 | login ( true ); |
583 | 583 | ||
584 | execAutoStart(m_suspendTime); | 584 | execAutoStart(m_suspendTime); |
585 | //qcopBridge->closeOpenConnections(); | 585 | //qcopBridge->closeOpenConnections(); |
586 | 586 | ||
587 | excllock = false; | 587 | excllock = false; |
588 | } | 588 | } |
589 | 589 | ||
590 | void ServerApplication::toggleLight() | 590 | void ServerApplication::toggleLight() |
591 | { | 591 | { |
592 | #ifndef QT_NO_COP | 592 | #ifndef QT_NO_COP |
593 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 593 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
594 | e << -2; // toggle | 594 | e << -2; // toggle |
595 | #endif | 595 | #endif |
596 | } | 596 | } |
597 | 597 | ||
598 | 598 | ||
599 | /* | 599 | /* |
600 | * We still listen to key events but handle them in | 600 | * We still listen to key events but handle them in |
601 | * a special class | 601 | * a special class |
602 | */ | 602 | */ |
603 | 603 | ||
604 | bool ServerApplication::eventFilter( QObject *o, QEvent *e) { | 604 | bool ServerApplication::eventFilter( QObject *o, QEvent *e) { |
605 | if ( e->type() != QEvent::KeyPress && | 605 | if ( e->type() != QEvent::KeyPress && |
606 | e->type() != QEvent::KeyRelease ) | 606 | e->type() != QEvent::KeyRelease ) |
607 | return QPEApplication::eventFilter( o, e ); | 607 | return QPEApplication::eventFilter( o, e ); |
608 | 608 | ||
609 | QKeyEvent *ke = static_cast<QKeyEvent*>( e ); | 609 | QKeyEvent *ke = static_cast<QKeyEvent*>( e ); |
610 | if ( kf->checkButtonAction( true, ke->key(), | 610 | if ( kf->checkButtonAction( true, ke->key(), |
611 | e->type() == QEvent::KeyPress, | 611 | e->type() == QEvent::KeyPress, |
612 | ke-> isAutoRepeat() )) | 612 | ke-> isAutoRepeat() )) |
613 | return true; | 613 | return true; |
614 | 614 | ||
615 | return QPEApplication::eventFilter( o, e ); | 615 | return QPEApplication::eventFilter( o, e ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | #ifdef Q_WS_QWS | 619 | #ifdef Q_WS_QWS |
620 | bool ServerApplication::qwsEventFilter( QWSEvent *e ) | 620 | bool ServerApplication::qwsEventFilter( QWSEvent *e ) |
621 | { | 621 | { |
622 | checkMemory(); | 622 | checkMemory(); |
623 | 623 | ||
624 | if ( e->type == QWSEvent::Mouse ) { | 624 | if ( e->type == QWSEvent::Mouse ) { |
625 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 625 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
626 | static bool up = TRUE; | 626 | static bool up = TRUE; |
627 | if ( me->simpleData.state&LeftButton ) { | 627 | if ( me->simpleData.state&LeftButton ) { |
628 | if ( up ) { | 628 | if ( up ) { |
629 | up = FALSE; | 629 | up = FALSE; |
630 | screenClick(TRUE); | 630 | screenClick(TRUE); |
631 | } | 631 | } |
632 | } else if ( !up ) { | 632 | } else if ( !up ) { |
633 | up = TRUE; | 633 | up = TRUE; |
634 | screenClick(FALSE); | 634 | screenClick(FALSE); |
635 | } | 635 | } |
636 | }else if ( e->type == QWSEvent::Key ) { | 636 | }else if ( e->type == QWSEvent::Key ) { |
637 | QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); | 637 | QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); |
638 | if ( kf->checkButtonAction( false, | 638 | if ( kf->checkButtonAction( false, |
639 | ke-> simpleData.keycode, | 639 | ke-> simpleData.keycode, |
640 | ke-> simpleData.is_press, | 640 | ke-> simpleData.is_press, |
641 | ke-> simpleData.is_auto_repeat ) ) | 641 | ke-> simpleData.is_auto_repeat ) ) |
642 | return true; | 642 | return true; |
643 | } | 643 | } |
644 | 644 | ||
645 | return QPEApplication::qwsEventFilter( e ); | 645 | return QPEApplication::qwsEventFilter( e ); |
646 | } | 646 | } |
647 | #endif | 647 | #endif |
648 | 648 | ||
649 | 649 | ||
650 | /* ### FIXME libqtopia Plugin Safe Mode */ | 650 | /* ### FIXME libqtopia Plugin Safe Mode */ |
651 | 651 | ||
652 | void ServerApplication::showSafeMode() | 652 | void ServerApplication::showSafeMode() |
653 | { | 653 | { |
654 | #if 0 | 654 | #if 0 |
655 | if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " | 655 | if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " |
656 | "and the system is now in Safe Mode. " | 656 | "and the system is now in Safe Mode. " |
657 | "Plugins are not loaded in Safe Mode. " | 657 | "Plugins are not loaded in Safe Mode. " |
658 | "You can use the Plugin Manager to " | 658 | "You can use the Plugin Manager to " |
659 | "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { | 659 | "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { |
660 | Global::execute( "pluginmanager" ); | 660 | Global::execute( "pluginmanager" ); |
661 | } | 661 | } |
662 | #endif | 662 | #endif |
663 | } | 663 | } |
664 | 664 | ||
665 | void ServerApplication::clearSafeMode() | 665 | void ServerApplication::clearSafeMode() |
666 | { | 666 | { |
667 | #if 0 | 667 | #if 0 |
668 | // If we've been running OK for a while then we won't bother going into | 668 | // If we've been running OK for a while then we won't bother going into |
669 | // safe mode immediately on the next crash. | 669 | // safe mode immediately on the next crash. |
670 | Config cfg( "PluginLoader" ); | 670 | Config cfg( "PluginLoader" ); |
671 | cfg.setGroup( "Global" ); | 671 | cfg.setGroup( "Global" ); |
672 | QString mode = cfg.readEntry( "Mode", "Normal" ); | 672 | QString mode = cfg.readEntry( "Mode", "Normal" ); |
673 | if ( mode == "MaybeSafe" ) { | 673 | if ( mode == "MaybeSafe" ) { |
674 | cfg.writeEntry( "Mode", "Normal" ); | 674 | cfg.writeEntry( "Mode", "Normal" ); |
675 | } | 675 | } |
676 | #endif | 676 | #endif |
677 | } | 677 | } |
678 | 678 | ||
679 | 679 | ||
680 | void ServerApplication::shutdown() | 680 | void ServerApplication::shutdown() |
681 | { | 681 | { |
682 | if ( type() != GuiServer ) | 682 | if ( type() != GuiServer ) |
683 | return; | 683 | return; |
684 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 684 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
685 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 685 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
686 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 686 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
687 | sd->showMaximized(); | 687 | sd->showMaximized(); |
688 | } | 688 | } |
689 | 689 | ||
690 | void ServerApplication::shutdown( ShutdownImpl::Type t ) | 690 | void ServerApplication::shutdown( ShutdownImpl::Type t ) |
691 | { | 691 | { |
692 | char *opt = 0; | 692 | char *opt = 0; |
693 | 693 | ||
694 | switch ( t ) { | 694 | switch ( t ) { |
695 | case ShutdownImpl::ShutdownSystem: | 695 | case ShutdownImpl::ShutdownSystem: |
696 | opt = "-h"; | 696 | opt = "-h"; |
697 | // fall through | 697 | // fall through |
698 | case ShutdownImpl::RebootSystem: | 698 | case ShutdownImpl::RebootSystem: |
699 | if ( opt == 0 ) | 699 | if ( opt == 0 ) |
700 | opt = "-r"; | 700 | opt = "-r"; |
701 | 701 | ||
702 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) | 702 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) |
703 | perror("shutdown"); | 703 | perror("shutdown"); |
704 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); | 704 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); |
705 | 705 | ||
706 | break; | 706 | break; |
707 | case ShutdownImpl::RestartDesktop: | 707 | case ShutdownImpl::RestartDesktop: |
708 | restart(); | 708 | restart(); |
709 | break; | 709 | break; |
710 | case ShutdownImpl::TerminateDesktop: | 710 | case ShutdownImpl::TerminateDesktop: |
711 | prepareForTermination( FALSE ); | 711 | prepareForTermination( FALSE ); |
712 | 712 | ||
713 | // This is a workaround for a Qt bug | 713 | // This is a workaround for a Qt bug |
714 | // clipboard applet has to stop its poll timer, or Qt/E | 714 | // clipboard applet has to stop its poll timer, or Qt/E |
715 | // will hang on quit() right before it emits aboutToQuit() | 715 | // will hang on quit() right before it emits aboutToQuit() |
716 | emit aboutToQuit ( ); | 716 | emit aboutToQuit ( ); |
717 | 717 | ||
718 | quit(); | 718 | quit(); |
719 | break; | 719 | break; |
720 | } | 720 | } |
721 | } | 721 | } |
722 | 722 | ||
723 | void ServerApplication::restart() | 723 | void ServerApplication::restart() |
724 | { | 724 | { |
725 | if ( allowRestart ) { | 725 | if ( allowRestart ) { |
726 | |||
727 | /* | ||
728 | * Applets and restart is a problem. Some applets delete | ||
729 | * their widgets even if ownership gets transfered to the | ||
730 | * parent (Systray ) but deleting the applet may be unsafe | ||
731 | * as well ( double deletion ). Some have topLevel widgets | ||
732 | * and when we dlclose and then delete the widget we will | ||
733 | * crash and an crash during restart is not nice | ||
734 | */ | ||
735 | #ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED | ||
736 | /* same as above */ | ||
737 | emit aboutToQuit(); | ||
726 | prepareForTermination(TRUE); | 738 | prepareForTermination(TRUE); |
727 | doRestart = TRUE; | 739 | doRestart = TRUE; |
728 | quit(); | 740 | quit(); |
741 | #else | ||
742 | prepareForTermination( true ); | ||
743 | for ( int fd = 3; fd < 100; fd++ ) | ||
744 | close( fd ); | ||
745 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | ||
746 | exit( 1 ); | ||
747 | #endif | ||
729 | } | 748 | } |
730 | } | 749 | } |
731 | 750 | ||
732 | void ServerApplication::rereadVolumes() | 751 | void ServerApplication::rereadVolumes() |
733 | { | 752 | { |
734 | Config cfg( "qpe" ); | 753 | Config cfg( "qpe" ); |
735 | cfg. setGroup ( "Volume" ); | 754 | cfg. setGroup ( "Volume" ); |
736 | 755 | ||
737 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); | 756 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); |
738 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); | 757 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); |
739 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); | 758 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); |
740 | } | 759 | } |
741 | 760 | ||
742 | 761 | ||
743 | void ServerApplication::checkMemory() | 762 | void ServerApplication::checkMemory() |
744 | { | 763 | { |
745 | #if defined(QPE_HAVE_MEMALERTER) | 764 | #if defined(QPE_HAVE_MEMALERTER) |
746 | static bool ignoreNormal=TRUE; | 765 | static bool ignoreNormal=TRUE; |
747 | static bool existingMessage=FALSE; | 766 | static bool existingMessage=FALSE; |
748 | 767 | ||
749 | if(existingMessage) | 768 | if(existingMessage) |
750 | return; // don't show a second message while still on first | 769 | return; // don't show a second message while still on first |
751 | 770 | ||
752 | existingMessage = TRUE; | 771 | existingMessage = TRUE; |
753 | switch ( memstate ) { | 772 | switch ( memstate ) { |
754 | case MemUnknown: | 773 | case MemUnknown: |
755 | break; | 774 | break; |
756 | case MemLow: | 775 | case MemLow: |
757 | memstate = MemUnknown; | 776 | memstate = MemUnknown; |
758 | if ( !recoverMemory() ) { | 777 | if ( !recoverMemory() ) { |
759 | QMessageBox::warning( 0 , tr("Memory Status"), | 778 | QMessageBox::warning( 0 , tr("Memory Status"), |
760 | tr("Memory Low\nPlease save data.") ); | 779 | tr("Memory Low\nPlease save data.") ); |
761 | ignoreNormal = FALSE; | 780 | ignoreNormal = FALSE; |
762 | } | 781 | } |
763 | break; | 782 | break; |
764 | case MemNormal: | 783 | case MemNormal: |
765 | memstate = MemUnknown; | 784 | memstate = MemUnknown; |
766 | if ( !ignoreNormal ) { | 785 | if ( !ignoreNormal ) { |
767 | ignoreNormal = TRUE; | 786 | ignoreNormal = TRUE; |
768 | QMessageBox::information ( 0 , tr("Memory Status"), | 787 | QMessageBox::information ( 0 , tr("Memory Status"), |
769 | "Memory OK" ); | 788 | "Memory OK" ); |
770 | } | 789 | } |
771 | break; | 790 | break; |
772 | case MemVeryLow: | 791 | case MemVeryLow: |
773 | memstate = MemUnknown; | 792 | memstate = MemUnknown; |
774 | QMessageBox::critical( 0 , tr("Memory Status"), | 793 | QMessageBox::critical( 0 , tr("Memory Status"), |
775 | tr("Critical Memory Shortage\n" | 794 | tr("Critical Memory Shortage\n" |
776 | "Please end this application\n" | 795 | "Please end this application\n" |
777 | "immediately.") ); | 796 | "immediately.") ); |
778 | recoverMemory(); | 797 | recoverMemory(); |
779 | } | 798 | } |
780 | existingMessage = FALSE; | 799 | existingMessage = FALSE; |
781 | #endif | 800 | #endif |
782 | } | 801 | } |
783 | 802 | ||
784 | bool ServerApplication::recoverMemory() | 803 | bool ServerApplication::recoverMemory() |
785 | { | 804 | { |
786 | return FALSE; | 805 | return FALSE; |
787 | } | 806 | } |
788 | 807 | ||
789 | void ServerApplication::keyClick(int , bool press, bool ) | 808 | void ServerApplication::keyClick(int , bool press, bool ) |
790 | { | 809 | { |
791 | if ( press && m_keyclick_sound ) | 810 | if ( press && m_keyclick_sound ) |
792 | ODevice::inst() -> keySound(); | 811 | ODevice::inst() -> keySound(); |
793 | 812 | ||
794 | } | 813 | } |
795 | 814 | ||
796 | void ServerApplication::screenClick(bool press) | 815 | void ServerApplication::screenClick(bool press) |
797 | { | 816 | { |
798 | if ( press && m_screentap_sound ) | 817 | if ( press && m_screentap_sound ) |
799 | ODevice::inst() -> touchSound(); | 818 | ODevice::inst() -> touchSound(); |
800 | } | 819 | } |
801 | 820 | ||
802 | void ServerApplication::soundAlarm() { | 821 | void ServerApplication::soundAlarm() { |
803 | if ( me ()->m_alarm_sound ) | 822 | if ( me ()->m_alarm_sound ) |
804 | ODevice::inst()->alarmSound(); | 823 | ODevice::inst()->alarmSound(); |
805 | } | 824 | } |
806 | 825 | ||
807 | ServerApplication *ServerApplication::me ( ) | 826 | ServerApplication *ServerApplication::me ( ) |
808 | { | 827 | { |
809 | return static_cast<ServerApplication*>( qApp ); | 828 | return static_cast<ServerApplication*>( qApp ); |
810 | } | 829 | } |
811 | 830 | ||
812 | 831 | ||
813 | #include "serverapp.moc" | 832 | #include "serverapp.moc" |
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index 64356ca..6122770 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp | |||
@@ -1,141 +1,149 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 <qtopia/qpeapplication.h> | 21 | #include <qtopia/qpeapplication.h> |
22 | #include <qtopia/qlibrary.h> | 22 | #include <qtopia/qlibrary.h> |
23 | #include <qtopia/config.h> | 23 | #include <qtopia/config.h> |
24 | 24 | ||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtranslator.h> | 28 | #include <qtranslator.h> |
29 | 29 | ||
30 | #include "systray.h" | 30 | #include "systray.h" |
31 | 31 | ||
32 | #include <stdlib.h> | 32 | #include <stdlib.h> |
33 | 33 | ||
34 | /* ### Single build floppies ### */ | 34 | /* ### Single build floppies ### */ |
35 | #if 0 | 35 | #if 0 |
36 | #ifdef QT_NO_COMPONENTS | 36 | #ifdef QT_NO_COMPONENTS |
37 | #include "../plugins/applets/clockapplet/clockappletimpl.h" | 37 | #include "../plugins/applets/clockapplet/clockappletimpl.h" |
38 | #endif | 38 | #endif |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) | 41 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) |
42 | { | 42 | { |
43 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 43 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
44 | loadApplets(); | 44 | loadApplets(); |
45 | } | 45 | } |
46 | 46 | ||
47 | SysTray::~SysTray() | 47 | SysTray::~SysTray() |
48 | { | 48 | { |
49 | clearApplets(); | 49 | clearApplets(); |
50 | } | 50 | } |
51 | 51 | ||
52 | static int compareAppletPositions(const void *a, const void *b) | 52 | static int compareAppletPositions(const void *a, const void *b) |
53 | { | 53 | { |
54 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; | 54 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; |
55 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; | 55 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; |
56 | int d = ab->iface->position() - aa->iface->position(); | 56 | int d = ab->iface->position() - aa->iface->position(); |
57 | if ( d ) return d; | 57 | if ( d ) return d; |
58 | return QString::compare(ab->name,aa->name); | 58 | return QString::compare(ab->name,aa->name); |
59 | } | 59 | } |
60 | 60 | ||
61 | void SysTray::loadApplets() | 61 | void SysTray::loadApplets() |
62 | { | 62 | { |
63 | hide(); | 63 | hide(); |
64 | clearApplets(); | 64 | clearApplets(); |
65 | addApplets(); | 65 | addApplets(); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SysTray::clearApplets() | 68 | void SysTray::clearApplets() |
69 | { | 69 | { |
70 | #ifndef QT_NO_COMPONENTS | 70 | #ifndef QT_NO_COMPONENTS |
71 | 71 | ||
72 | /* | ||
73 | * Note on clearing. SOme applets delete their | ||
74 | * applets themselves some don't do it | ||
75 | * and on restart this can crash. If we delete it | ||
76 | * here we might end up in a double deletion. We could | ||
77 | * use QGuardedPtr but that would be one QOBject | ||
78 | * for every applet more but only useful for restart | ||
79 | */ | ||
72 | QValueList<TaskbarApplet>::Iterator mit; | 80 | QValueList<TaskbarApplet>::Iterator mit; |
73 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { | 81 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { |
74 | (*mit).iface->release(); | 82 | (*mit).iface->release(); |
75 | (*mit).library->unload(); | 83 | (*mit).library->unload(); |
76 | delete (*mit).library; | 84 | delete (*mit).library; |
77 | } | 85 | } |
78 | 86 | ||
79 | #endif | 87 | #endif |
80 | appletList.clear(); | 88 | appletList.clear(); |
81 | if ( layout ) | 89 | if ( layout ) |
82 | delete layout; | 90 | delete layout; |
83 | layout = new QHBoxLayout( this, 0, 1 ); | 91 | layout = new QHBoxLayout( this, 0, 1 ); |
84 | layout->setAutoAdd(TRUE); | 92 | layout->setAutoAdd(TRUE); |
85 | } | 93 | } |
86 | 94 | ||
87 | void SysTray::addApplets() | 95 | void SysTray::addApplets() |
88 | { | 96 | { |
89 | hide(); | 97 | hide(); |
90 | #ifndef QT_NO_COMPONENTS | 98 | #ifndef QT_NO_COMPONENTS |
91 | Config cfg( "Taskbar" ); | 99 | Config cfg( "Taskbar" ); |
92 | cfg.setGroup( "Applets" ); | 100 | cfg.setGroup( "Applets" ); |
93 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 101 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
94 | 102 | ||
95 | QString lang = getenv( "LANG" ); | 103 | QString lang = getenv( "LANG" ); |
96 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 104 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; |
97 | QDir dir( path, "lib*.so" ); | 105 | QDir dir( path, "lib*.so" ); |
98 | QStringList list = dir.entryList(); | 106 | QStringList list = dir.entryList(); |
99 | QStringList::Iterator it; | 107 | QStringList::Iterator it; |
100 | int napplets=0; | 108 | int napplets=0; |
101 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; | 109 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; |
102 | for ( it = list.begin(); it != list.end(); ++it ) { | 110 | for ( it = list.begin(); it != list.end(); ++it ) { |
103 | if ( exclude.find( *it ) != exclude.end() ) | 111 | if ( exclude.find( *it ) != exclude.end() ) |
104 | continue; | 112 | continue; |
105 | TaskbarAppletInterface *iface = 0; | 113 | TaskbarAppletInterface *iface = 0; |
106 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 114 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
107 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 115 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
108 | TaskbarApplet *applet = new TaskbarApplet; | 116 | TaskbarApplet *applet = new TaskbarApplet; |
109 | applets[napplets++] = applet; | 117 | applets[napplets++] = applet; |
110 | applet->library = lib; | 118 | applet->library = lib; |
111 | applet->iface = iface; | 119 | applet->iface = iface; |
112 | 120 | ||
113 | QTranslator *trans = new QTranslator(qApp); | 121 | QTranslator *trans = new QTranslator(qApp); |
114 | QString type = (*it).left( (*it).find(".") ); | 122 | QString type = (*it).left( (*it).find(".") ); |
115 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 123 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
116 | if ( trans->load( tfn )) | 124 | if ( trans->load( tfn )) |
117 | qApp->installTranslator( trans ); | 125 | qApp->installTranslator( trans ); |
118 | else | 126 | else |
119 | delete trans; | 127 | delete trans; |
120 | } else { | 128 | } else { |
121 | exclude += *it; | 129 | exclude += *it; |
122 | delete lib; | 130 | delete lib; |
123 | } | 131 | } |
124 | } | 132 | } |
125 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 133 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
126 | qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); | 134 | qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); |
127 | while (napplets--) { | 135 | while (napplets--) { |
128 | TaskbarApplet *applet = applets[napplets]; | 136 | TaskbarApplet *applet = applets[napplets]; |
129 | applet->applet = applet->iface->applet( this ); | 137 | applet->applet = applet->iface->applet( this ); |
130 | appletList.append(*applet); | 138 | appletList.append(*applet); |
131 | } | 139 | } |
132 | delete [] applets; | 140 | delete [] applets; |
133 | #else /* ## FIXME single app */ | 141 | #else /* ## FIXME single app */ |
134 | TaskbarApplet * const applet = new TaskbarApplet(); | 142 | TaskbarApplet * const applet = new TaskbarApplet(); |
135 | applet->iface = new ClockAppletImpl(); | 143 | applet->iface = new ClockAppletImpl(); |
136 | applet->applet = applet->iface->applet( this ); | 144 | applet->applet = applet->iface->applet( this ); |
137 | appletList.append( applet ); | 145 | appletList.append( applet ); |
138 | #endif | 146 | #endif |
139 | show(); | 147 | show(); |
140 | } | 148 | } |
141 | 149 | ||
diff --git a/core/launcher/systray.h b/core/launcher/systray.h index 77c581f..b989d58 100644 --- a/core/launcher/systray.h +++ b/core/launcher/systray.h | |||
@@ -1,61 +1,62 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 __SYSTRAY_H__ | 21 | #ifndef __SYSTRAY_H__ |
22 | #define __SYSTRAY_H__ | 22 | #define __SYSTRAY_H__ |
23 | 23 | ||
24 | #ifndef QT_NO_COMPONENT | 24 | #ifndef QT_NO_COMPONENT |
25 | #include <qtopia/taskbarappletinterface.h> | 25 | #include <qtopia/taskbarappletinterface.h> |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qvaluelist.h> | 29 | #include <qvaluelist.h> |
30 | #include <qguardedptr.h> | ||
30 | 31 | ||
31 | class QHBoxLayout; | 32 | class QHBoxLayout; |
32 | class QLibrary; | 33 | class QLibrary; |
33 | 34 | ||
34 | struct TaskbarApplet | 35 | struct TaskbarApplet |
35 | { | 36 | { |
36 | #ifndef QT_NO_COMPONENT | 37 | #ifndef QT_NO_COMPONENT |
37 | QLibrary *library; | 38 | QLibrary *library; |
38 | TaskbarAppletInterface *iface; | 39 | TaskbarAppletInterface *iface; |
39 | #endif | 40 | #endif |
40 | QWidget *applet; | 41 | QWidget *applet; |
41 | QString name; | 42 | QString name; |
42 | }; | 43 | }; |
43 | 44 | ||
44 | class SysTray : public QFrame { | 45 | class SysTray : public QFrame { |
45 | Q_OBJECT | 46 | Q_OBJECT |
46 | public: | 47 | public: |
47 | SysTray( QWidget *parent ); | 48 | SysTray( QWidget *parent ); |
48 | ~SysTray(); | 49 | ~SysTray(); |
49 | 50 | ||
50 | void clearApplets(); | 51 | void clearApplets(); |
51 | void addApplets(); | 52 | void addApplets(); |
52 | 53 | ||
53 | private: | 54 | private: |
54 | void loadApplets(); | 55 | void loadApplets(); |
55 | QHBoxLayout *layout; | 56 | QHBoxLayout *layout; |
56 | QValueList<TaskbarApplet> appletList; | 57 | QValueList<TaskbarApplet> appletList; |
57 | }; | 58 | }; |
58 | 59 | ||
59 | 60 | ||
60 | #endif // __SYSTRAY_H__ | 61 | #endif // __SYSTRAY_H__ |
61 | 62 | ||