-rw-r--r-- | core/launcher/serverapp.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index fac52a6..64c97d4 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -1,298 +1,298 @@ | |||
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 | #include "screensaver.h" | 22 | #include "screensaver.h" |
23 | 23 | ||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <opie2/odevice.h> | 26 | #include <opie2/odevice.h> |
27 | #include <opie2/multiauthpassword.h> | 27 | #include <opie2/multiauthpassword.h> |
28 | 28 | ||
29 | #include <qtopia/config.h> | 29 | #include <qtopia/config.h> |
30 | #include <qtopia/power.h> | 30 | #include <qtopia/power.h> |
31 | 31 | ||
32 | #ifdef Q_WS_QWS | 32 | #ifdef Q_WS_QWS |
33 | #include <qtopia/qcopenvelope_qws.h> | 33 | #include <qtopia/qcopenvelope_qws.h> |
34 | #endif | 34 | #endif |
35 | #include <qtopia/global.h> | 35 | #include <qtopia/global.h> |
36 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #ifdef Q_WS_QWS | 39 | #ifdef Q_WS_QWS |
40 | #include <qgfx_qws.h> | 40 | #include <qgfx_qws.h> |
41 | #endif | 41 | #endif |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qpainter.h> | 44 | #include <qpainter.h> |
45 | #include <qfile.h> | 45 | #include <qfile.h> |
46 | #include <qpixmapcache.h> | 46 | #include <qpixmapcache.h> |
47 | 47 | ||
48 | /* STD */ | 48 | /* STD */ |
49 | #ifdef Q_OS_WIN32 | 49 | #ifdef Q_OS_WIN32 |
50 | #include <io.h> | 50 | #include <io.h> |
51 | #include <process.h> | 51 | #include <process.h> |
52 | #else | 52 | #else |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #endif | 54 | #endif |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | 56 | ||
57 | static ServerApplication *serverApp = 0; | 57 | static ServerApplication *serverApp = 0; |
58 | static int loggedin=0; | 58 | static int loggedin=0; |
59 | 59 | ||
60 | QCopKeyRegister::QCopKeyRegister() | 60 | QCopKeyRegister::QCopKeyRegister() |
61 | : m_keyCode( 0 ) | 61 | : m_keyCode( 0 ) |
62 | { | 62 | { |
63 | odebug << "KeyRegister1 " << m_keyCode << oendl; | 63 | |
64 | } | 64 | } |
65 | 65 | ||
66 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) | 66 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) |
67 | :m_keyCode( k ), m_channel( c ), m_message( m ) | 67 | :m_keyCode( k ), m_channel( c ), m_message( m ) |
68 | { | 68 | { |
69 | odebug << "keyRegister2 " << m_keyCode << c << m << oendl; | 69 | |
70 | } | 70 | } |
71 | 71 | ||
72 | int QCopKeyRegister::keyCode() const | 72 | int QCopKeyRegister::keyCode() const |
73 | { | 73 | { |
74 | return m_keyCode; | 74 | return m_keyCode; |
75 | } | 75 | } |
76 | 76 | ||
77 | QCString QCopKeyRegister::channel() const | 77 | QCString QCopKeyRegister::channel() const |
78 | { | 78 | { |
79 | return m_channel; | 79 | return m_channel; |
80 | } | 80 | } |
81 | 81 | ||
82 | QCString QCopKeyRegister::message() const | 82 | QCString QCopKeyRegister::message() const |
83 | { | 83 | { |
84 | return m_message; | 84 | return m_message; |
85 | } | 85 | } |
86 | 86 | ||
87 | bool QCopKeyRegister::send() | 87 | bool QCopKeyRegister::send() |
88 | { | 88 | { |
89 | if (m_channel.isNull() ) | 89 | if (m_channel.isNull() ) |
90 | return false; | 90 | return false; |
91 | qDebug("Send Message: "+m_channel+" "+m_message); | 91 | qDebug("Send Message: "+m_channel+" "+m_message); |
92 | QCopEnvelope e( m_channel, m_message ); | 92 | QCopEnvelope e( m_channel, m_message ); |
93 | 93 | ||
94 | return true; | 94 | return true; |
95 | } | 95 | } |
96 | 96 | ||
97 | //--------------------------------------------------------------------------- | 97 | //--------------------------------------------------------------------------- |
98 | 98 | ||
99 | /* | 99 | /* |
100 | Priority is number of alerts that are needed to pop up | 100 | Priority is number of alerts that are needed to pop up |
101 | alert. | 101 | alert. |
102 | */ | 102 | */ |
103 | class DesktopPowerAlerter : public QMessageBox | 103 | class DesktopPowerAlerter : public QMessageBox |
104 | { | 104 | { |
105 | Q_OBJECT | 105 | Q_OBJECT |
106 | public: | 106 | public: |
107 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 107 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
108 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), | 108 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), |
109 | QMessageBox::Critical, | 109 | QMessageBox::Critical, |
110 | QMessageBox::Ok | QMessageBox::Default, | 110 | QMessageBox::Ok | QMessageBox::Default, |
111 | QMessageBox::NoButton, QMessageBox::NoButton, | 111 | QMessageBox::NoButton, QMessageBox::NoButton, |
112 | parent, name, FALSE ) | 112 | parent, name, FALSE ) |
113 | { | 113 | { |
114 | currentPriority = INT_MAX; | 114 | currentPriority = INT_MAX; |
115 | alertCount = 0; | 115 | alertCount = 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | void alert( const QString &text, int priority ); | 118 | void alert( const QString &text, int priority ); |
119 | void hideEvent( QHideEvent * ); | 119 | void hideEvent( QHideEvent * ); |
120 | private: | 120 | private: |
121 | int currentPriority; | 121 | int currentPriority; |
122 | int alertCount; | 122 | int alertCount; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 125 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
126 | { | 126 | { |
127 | alertCount++; | 127 | alertCount++; |
128 | if ( alertCount < priority ) | 128 | if ( alertCount < priority ) |
129 | return; | 129 | return; |
130 | if ( priority > currentPriority ) | 130 | if ( priority > currentPriority ) |
131 | return; | 131 | return; |
132 | currentPriority = priority; | 132 | currentPriority = priority; |
133 | setText( text ); | 133 | setText( text ); |
134 | show(); | 134 | show(); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 138 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
139 | { | 139 | { |
140 | QMessageBox::hideEvent( e ); | 140 | QMessageBox::hideEvent( e ); |
141 | alertCount = 0; | 141 | alertCount = 0; |
142 | currentPriority = INT_MAX; | 142 | currentPriority = INT_MAX; |
143 | } | 143 | } |
144 | 144 | ||
145 | //--------------------------------------------------------------------------- | 145 | //--------------------------------------------------------------------------- |
146 | 146 | ||
147 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) | 147 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) |
148 | { | 148 | { |
149 | /* We don't do this cause it would interfere with ODevice */ | 149 | /* We don't do this cause it would interfere with ODevice */ |
150 | #if 0 | 150 | #if 0 |
151 | qwsServer->setKeyboardFilter(this); | 151 | qwsServer->setKeyboardFilter(this); |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | 154 | ||
155 | void KeyFilter::timerEvent(QTimerEvent* e) | 155 | void KeyFilter::timerEvent(QTimerEvent* e) |
156 | { | 156 | { |
157 | if ( e->timerId() == held_tid ) { | 157 | if ( e->timerId() == held_tid ) { |
158 | killTimer(held_tid); | 158 | killTimer(held_tid); |
159 | // button held | 159 | // button held |
160 | if ( heldButton ) { | 160 | if ( heldButton ) { |
161 | emit activate(heldButton, TRUE); | 161 | emit activate(heldButton, TRUE); |
162 | heldButton = 0; | 162 | heldButton = 0; |
163 | } | 163 | } |
164 | held_tid = 0; | 164 | held_tid = 0; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | void KeyFilter::registerKey( const QCopKeyRegister& key ) | 168 | void KeyFilter::registerKey( const QCopKeyRegister& key ) |
169 | { | 169 | { |
170 | odebug << "KeyFilter::registerKey " << key.keyCode() << key.channel() << key.message() << oendl; | 170 | |
171 | m_keys.insert( key.keyCode(), key ); | 171 | m_keys.insert( key.keyCode(), key ); |
172 | } | 172 | } |
173 | 173 | ||
174 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) | 174 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) |
175 | { | 175 | { |
176 | m_keys.remove( key.keyCode() ); | 176 | m_keys.remove( key.keyCode() ); |
177 | } | 177 | } |
178 | 178 | ||
179 | bool KeyFilter::keyRegistered( int key ) | 179 | bool KeyFilter::keyRegistered( int key ) |
180 | { | 180 | { |
181 | /* | 181 | /* |
182 | * Check if we've a key registered | 182 | * Check if we've a key registered |
183 | */ | 183 | */ |
184 | if ( !m_keys[key].send()) | 184 | if ( !m_keys[key].send()) |
185 | return false; | 185 | return false; |
186 | else | 186 | else |
187 | return true; | 187 | return true; |
188 | } | 188 | } |
189 | 189 | ||
190 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 190 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
191 | { | 191 | { |
192 | if ( !loggedin | 192 | if ( !loggedin |
193 | // Permitted keys | 193 | // Permitted keys |
194 | && keycode != Key_F34 // power | 194 | && keycode != Key_F34 // power |
195 | && keycode != Key_F30 // select | 195 | && keycode != Key_F30 // select |
196 | && keycode != Key_Enter | 196 | && keycode != Key_Enter |
197 | && keycode != Key_Return | 197 | && keycode != Key_Return |
198 | && keycode != Key_Space | 198 | && keycode != Key_Space |
199 | && keycode != Key_Left | 199 | && keycode != Key_Left |
200 | && keycode != Key_Right | 200 | && keycode != Key_Right |
201 | && keycode != Key_Up | 201 | && keycode != Key_Up |
202 | && keycode != Key_Down ) | 202 | && keycode != Key_Down ) |
203 | return TRUE; | 203 | return TRUE; |
204 | 204 | ||
205 | /* check if it was registered */ | 205 | /* check if it was registered */ |
206 | if (!db ) { | 206 | if (!db ) { |
207 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 207 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
208 | return true; | 208 | return true; |
209 | } else { | 209 | } else { |
210 | 210 | ||
211 | // First check to see if DeviceButtonManager knows something about this button: | 211 | // First check to see if DeviceButtonManager knows something about this button: |
212 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); | 212 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); |
213 | if (button && !autoRepeat) { | 213 | if (button && !autoRepeat) { |
214 | if ( held_tid ) { | 214 | if ( held_tid ) { |
215 | killTimer(held_tid); | 215 | killTimer(held_tid); |
216 | held_tid = 0; | 216 | held_tid = 0; |
217 | } | 217 | } |
218 | if ( button->heldAction().isNull() ) { | 218 | if ( button->heldAction().isNull() ) { |
219 | if ( press ) | 219 | if ( press ) |
220 | emit activate(button, FALSE); | 220 | emit activate(button, FALSE); |
221 | } else if ( press ) { | 221 | } else if ( press ) { |
222 | heldButton = button; | 222 | heldButton = button; |
223 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 223 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
224 | } else if ( heldButton ) { | 224 | } else if ( heldButton ) { |
225 | heldButton = 0; | 225 | heldButton = 0; |
226 | emit activate(button, FALSE); | 226 | emit activate(button, FALSE); |
227 | } | 227 | } |
228 | QWSServer::screenSaverActivate(FALSE); | 228 | QWSServer::screenSaverActivate(FALSE); |
229 | return TRUE; | 229 | return TRUE; |
230 | } | 230 | } |
231 | return false; | 231 | return false; |
232 | } | 232 | } |
233 | if ( keycode == HardKey_Suspend ) { | 233 | if ( keycode == HardKey_Suspend ) { |
234 | if ( press ) emit power(); | 234 | if ( press ) emit power(); |
235 | return TRUE; | 235 | return TRUE; |
236 | } | 236 | } |
237 | if ( keycode == HardKey_Backlight ) { | 237 | if ( keycode == HardKey_Backlight ) { |
238 | if ( press ) emit backlight(); | 238 | if ( press ) emit backlight(); |
239 | return TRUE; | 239 | return TRUE; |
240 | } | 240 | } |
241 | if ( keycode == Key_F32 ) { | 241 | if ( keycode == Key_F32 ) { |
242 | #ifndef QT_NO_COP | 242 | #ifndef QT_NO_COP |
243 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 243 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
244 | #endif | 244 | #endif |
245 | return TRUE; | 245 | return TRUE; |
246 | } | 246 | } |
247 | if ( keycode == Key_F31 ) { | 247 | if ( keycode == Key_F31 ) { |
248 | if ( press ) emit symbol(); | 248 | if ( press ) emit symbol(); |
249 | QWSServer::screenSaverActivate(FALSE); | 249 | QWSServer::screenSaverActivate(FALSE); |
250 | return TRUE; | 250 | return TRUE; |
251 | } | 251 | } |
252 | 252 | ||
253 | if ( keycode == Key_NumLock ) | 253 | if ( keycode == Key_NumLock ) |
254 | if ( press ) emit numLockStateToggle(); | 254 | if ( press ) emit numLockStateToggle(); |
255 | 255 | ||
256 | if ( keycode == Key_CapsLock ) | 256 | if ( keycode == Key_CapsLock ) |
257 | if ( press ) emit capsLockStateToggle(); | 257 | if ( press ) emit capsLockStateToggle(); |
258 | 258 | ||
259 | if ( serverApp ) | 259 | if ( serverApp ) |
260 | serverApp->keyClick(keycode,press,autoRepeat); | 260 | serverApp->keyClick(keycode,press,autoRepeat); |
261 | 261 | ||
262 | return FALSE; | 262 | return FALSE; |
263 | } | 263 | } |
264 | 264 | ||
265 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 265 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
266 | 266 | ||
267 | #if defined(QPE_HAVE_MEMALERTER) | 267 | #if defined(QPE_HAVE_MEMALERTER) |
268 | QPE_MEMALERTER_IMPL | 268 | QPE_MEMALERTER_IMPL |
269 | #endif | 269 | #endif |
270 | 270 | ||
271 | 271 | ||
272 | 272 | ||
273 | //--------------------------------------------------------------------------- | 273 | //--------------------------------------------------------------------------- |
274 | 274 | ||
275 | bool ServerApplication::doRestart = FALSE; | 275 | bool ServerApplication::doRestart = FALSE; |
276 | bool ServerApplication::allowRestart = TRUE; | 276 | bool ServerApplication::allowRestart = TRUE; |
277 | bool ServerApplication::ms_is_starting = TRUE; | 277 | bool ServerApplication::ms_is_starting = TRUE; |
278 | 278 | ||
279 | void ServerApplication::switchLCD( bool on ) | 279 | void ServerApplication::switchLCD( bool on ) |
280 | { | 280 | { |
281 | if ( !qApp ) | 281 | if ( !qApp ) |
282 | return; | 282 | return; |
283 | 283 | ||
284 | ServerApplication *dapp = ServerApplication::me() ; | 284 | ServerApplication *dapp = ServerApplication::me() ; |
285 | 285 | ||
286 | if ( !dapp-> m_screensaver ) | 286 | if ( !dapp-> m_screensaver ) |
287 | return; | 287 | return; |
288 | 288 | ||
289 | if ( on ) { | 289 | if ( on ) { |
290 | dapp-> m_screensaver-> setDisplayState ( true ); | 290 | dapp-> m_screensaver-> setDisplayState ( true ); |
291 | dapp-> m_screensaver-> setBacklight ( -3 ); | 291 | dapp-> m_screensaver-> setBacklight ( -3 ); |
292 | } else | 292 | } else |
293 | dapp-> m_screensaver-> setDisplayState ( false ); | 293 | dapp-> m_screensaver-> setDisplayState ( false ); |
294 | 294 | ||
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 298 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |