-rw-r--r-- | core/launcher/serverapp.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index d38dd97..e4e16f2 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -34,48 +34,49 @@ | |||
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 | using namespace Opie::Core; | ||
58 | QCopKeyRegister::QCopKeyRegister() | 59 | QCopKeyRegister::QCopKeyRegister() |
59 | : m_keyCode( 0 ) { | 60 | : m_keyCode( 0 ) { |
60 | } | 61 | } |
61 | 62 | ||
62 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) | 63 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) |
63 | :m_keyCode( k ), m_channel( c ), m_message( m ) { | 64 | :m_keyCode( k ), m_channel( c ), m_message( m ) { |
64 | } | 65 | } |
65 | 66 | ||
66 | int QCopKeyRegister::keyCode()const { | 67 | int QCopKeyRegister::keyCode()const { |
67 | return m_keyCode; | 68 | return m_keyCode; |
68 | } | 69 | } |
69 | 70 | ||
70 | QCString QCopKeyRegister::channel()const { | 71 | QCString QCopKeyRegister::channel()const { |
71 | return m_channel; | 72 | return m_channel; |
72 | } | 73 | } |
73 | 74 | ||
74 | QCString QCopKeyRegister::message()const { | 75 | QCString QCopKeyRegister::message()const { |
75 | return m_message; | 76 | return m_message; |
76 | } | 77 | } |
77 | 78 | ||
78 | bool QCopKeyRegister::send() { | 79 | bool QCopKeyRegister::send() { |
79 | if (m_channel.isNull() ) | 80 | if (m_channel.isNull() ) |
80 | return false; | 81 | return false; |
81 | 82 | ||
@@ -176,49 +177,49 @@ bool KeyFilter::keyRegistered( int key ) { | |||
176 | 177 | ||
177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 178 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
178 | { | 179 | { |
179 | if ( !loggedin | 180 | if ( !loggedin |
180 | // Permitted keys | 181 | // Permitted keys |
181 | && keycode != Key_F34 // power | 182 | && keycode != Key_F34 // power |
182 | && keycode != Key_F30 // select | 183 | && keycode != Key_F30 // select |
183 | && keycode != Key_Enter | 184 | && keycode != Key_Enter |
184 | && keycode != Key_Return | 185 | && keycode != Key_Return |
185 | && keycode != Key_Space | 186 | && keycode != Key_Space |
186 | && keycode != Key_Left | 187 | && keycode != Key_Left |
187 | && keycode != Key_Right | 188 | && keycode != Key_Right |
188 | && keycode != Key_Up | 189 | && keycode != Key_Up |
189 | && keycode != Key_Down ) | 190 | && keycode != Key_Down ) |
190 | return TRUE; | 191 | return TRUE; |
191 | 192 | ||
192 | /* check if it was registered */ | 193 | /* check if it was registered */ |
193 | if (!db ) { | 194 | if (!db ) { |
194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 195 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
195 | return true; | 196 | return true; |
196 | }else { | 197 | }else { |
197 | 198 | ||
198 | 199 | ||
199 | // First check to see if DeviceButtonManager knows something about this button: | 200 | // First check to see if DeviceButtonManager knows something about this button: |
200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); | 201 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); |
201 | if (button && !autoRepeat) { | 202 | if (button && !autoRepeat) { |
202 | if ( held_tid ) { | 203 | if ( held_tid ) { |
203 | killTimer(held_tid); | 204 | killTimer(held_tid); |
204 | held_tid = 0; | 205 | held_tid = 0; |
205 | } | 206 | } |
206 | if ( button->heldAction().isNull() ) { | 207 | if ( button->heldAction().isNull() ) { |
207 | if ( press ) | 208 | if ( press ) |
208 | emit activate(button, FALSE); | 209 | emit activate(button, FALSE); |
209 | } else if ( press ) { | 210 | } else if ( press ) { |
210 | heldButton = button; | 211 | heldButton = button; |
211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 212 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
212 | } else if ( heldButton ) { | 213 | } else if ( heldButton ) { |
213 | heldButton = 0; | 214 | heldButton = 0; |
214 | emit activate(button, FALSE); | 215 | emit activate(button, FALSE); |
215 | } | 216 | } |
216 | QWSServer::screenSaverActivate(FALSE); | 217 | QWSServer::screenSaverActivate(FALSE); |
217 | return TRUE; | 218 | return TRUE; |
218 | } | 219 | } |
219 | return false; | 220 | return false; |
220 | } | 221 | } |
221 | if ( keycode == HardKey_Suspend ) { | 222 | if ( keycode == HardKey_Suspend ) { |
222 | if ( press ) emit power(); | 223 | if ( press ) emit power(); |
223 | return TRUE; | 224 | return TRUE; |
224 | } | 225 | } |
@@ -310,66 +311,66 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
310 | 311 | ||
311 | m_screensaver = new OpieScreenSaver(); | 312 | m_screensaver = new OpieScreenSaver(); |
312 | m_screensaver->setInterval( -1 ); | 313 | m_screensaver->setInterval( -1 ); |
313 | QWSServer::setScreenSaver( m_screensaver ); | 314 | QWSServer::setScreenSaver( m_screensaver ); |
314 | 315 | ||
315 | connect( qApp, SIGNAL( volumeChanged(bool) ), | 316 | connect( qApp, SIGNAL( volumeChanged(bool) ), |
316 | this, SLOT( rereadVolumes() ) ); | 317 | this, SLOT( rereadVolumes() ) ); |
317 | 318 | ||
318 | 319 | ||
319 | /* ### PluginLoader libqtopia SafeMode */ | 320 | /* ### PluginLoader libqtopia SafeMode */ |
320 | #if 0 | 321 | #if 0 |
321 | if ( PluginLoader::inSafeMode() ) | 322 | if ( PluginLoader::inSafeMode() ) |
322 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); | 323 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); |
323 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 324 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
324 | #endif | 325 | #endif |
325 | 326 | ||
326 | kf = new KeyFilter(this); | 327 | kf = new KeyFilter(this); |
327 | 328 | ||
328 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); | 329 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); |
329 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); | 330 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); |
330 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); | 331 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); |
331 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); | 332 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); |
332 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); | 333 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); |
333 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 334 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
334 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 335 | connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), |
335 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); | 336 | this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool))); |
336 | 337 | ||
337 | 338 | ||
338 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); | 339 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); |
339 | 340 | ||
340 | connect( this, SIGNAL(power() ), | 341 | connect( this, SIGNAL(power() ), |
341 | SLOT(togglePower() ) ); | 342 | SLOT(togglePower() ) ); |
342 | 343 | ||
343 | rereadVolumes(); | 344 | rereadVolumes(); |
344 | 345 | ||
345 | serverApp = this; | 346 | serverApp = this; |
346 | 347 | ||
347 | apmTimeout(); | 348 | apmTimeout(); |
348 | grabKeyboard(); | 349 | grabKeyboard(); |
349 | 350 | ||
350 | /* make sure the event filter is installed */ | 351 | /* make sure the event filter is installed */ |
351 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); | 352 | const ODeviceButton* but = ODevice::inst()->buttonForKeycode( -1 ); |
352 | } | 353 | } |
353 | 354 | ||
354 | 355 | ||
355 | ServerApplication::~ServerApplication() | 356 | ServerApplication::~ServerApplication() |
356 | { | 357 | { |
357 | ungrabKeyboard(); | 358 | ungrabKeyboard(); |
358 | 359 | ||
359 | 360 | ||
360 | delete pa; | 361 | delete pa; |
361 | delete m_ps; | 362 | delete m_ps; |
362 | delete m_ps_last; | 363 | delete m_ps_last; |
363 | } | 364 | } |
364 | 365 | ||
365 | void ServerApplication::apmTimeout() { | 366 | void ServerApplication::apmTimeout() { |
366 | serverApp-> checkMemory( ); // in case no events are generated | 367 | serverApp-> checkMemory( ); // in case no events are generated |
367 | *m_ps_last = *m_ps; | 368 | *m_ps_last = *m_ps; |
368 | *m_ps = PowerStatusManager::readStatus(); | 369 | *m_ps = PowerStatusManager::readStatus(); |
369 | 370 | ||
370 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | 371 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) |
371 | m_screensaver-> powerStatusChanged( *m_ps ); | 372 | m_screensaver-> powerStatusChanged( *m_ps ); |
372 | 373 | ||
373 | if ( m_ps->acStatus() == PowerStatus::Online ) { | 374 | if ( m_ps->acStatus() == PowerStatus::Online ) { |
374 | return; | 375 | return; |
375 | } | 376 | } |