summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/serverapp.cpp14
-rw-r--r--core/launcher/serverapp.h4
2 files changed, 17 insertions, 1 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index 11381e6..f7c2341 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -201,151 +201,152 @@ bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepe
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
253enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; 253enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown;
254 254
255#if defined(QPE_HAVE_MEMALERTER) 255#if defined(QPE_HAVE_MEMALERTER)
256QPE_MEMALERTER_IMPL 256QPE_MEMALERTER_IMPL
257#endif 257#endif
258 258
259 259
260 260
261//--------------------------------------------------------------------------- 261//---------------------------------------------------------------------------
262 262
263bool ServerApplication::doRestart = FALSE; 263bool ServerApplication::doRestart = FALSE;
264bool ServerApplication::allowRestart = TRUE; 264bool ServerApplication::allowRestart = TRUE;
265bool ServerApplication::ms_is_starting = TRUE;
265 266
266void ServerApplication::switchLCD( bool on ) { 267void ServerApplication::switchLCD( bool on ) {
267 if ( !qApp ) 268 if ( !qApp )
268 return; 269 return;
269 270
270 ServerApplication *dapp = ServerApplication::me() ; 271 ServerApplication *dapp = ServerApplication::me() ;
271 272
272 if ( !dapp-> m_screensaver ) 273 if ( !dapp-> m_screensaver )
273 return; 274 return;
274 275
275 if ( on ) { 276 if ( on ) {
276 dapp-> m_screensaver-> setDisplayState ( true ); 277 dapp-> m_screensaver-> setDisplayState ( true );
277 dapp-> m_screensaver-> setBacklight ( -3 ); 278 dapp-> m_screensaver-> setBacklight ( -3 );
278 }else 279 }else
279 dapp-> m_screensaver-> setDisplayState ( false ); 280 dapp-> m_screensaver-> setDisplayState ( false );
280 281
281 282
282} 283}
283 284
284ServerApplication::ServerApplication( int& argc, char **argv, Type t ) 285ServerApplication::ServerApplication( int& argc, char **argv, Type t )
285 : QPEApplication( argc, argv, t ) 286 : QPEApplication( argc, argv, t )
286{ 287{
287 288 ms_is_starting = true;
288 289
289 // We know we'll have lots of cached pixmaps due to App/DocLnks 290 // We know we'll have lots of cached pixmaps due to App/DocLnks
290 QPixmapCache::setCacheLimit(512); 291 QPixmapCache::setCacheLimit(512);
291 292
292 m_ps = new PowerStatus; 293 m_ps = new PowerStatus;
293 m_ps_last = new PowerStatus; 294 m_ps_last = new PowerStatus;
294 pa = new DesktopPowerAlerter( 0 ); 295 pa = new DesktopPowerAlerter( 0 );
295 296
296 m_apm_timer = new QTimer( this ); 297 m_apm_timer = new QTimer( this );
297 connect(m_apm_timer, SIGNAL( timeout() ), 298 connect(m_apm_timer, SIGNAL( timeout() ),
298 this, SLOT( apmTimeout() ) ); 299 this, SLOT( apmTimeout() ) );
299 300
300 reloadPowerWarnSettings(); 301 reloadPowerWarnSettings();
301 302
302 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 303 QCopChannel *channel = new QCopChannel( "QPE/System", this );
303 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), 304 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ),
304 this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); 305 this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) );
305 306
306 channel = new QCopChannel("QPE/Launcher", this ); 307 channel = new QCopChannel("QPE/Launcher", this );
307 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), 308 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ),
308 this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); 309 this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) );
309 310
310 m_screensaver = new OpieScreenSaver(); 311 m_screensaver = new OpieScreenSaver();
311 m_screensaver->setInterval( -1 ); 312 m_screensaver->setInterval( -1 );
312 QWSServer::setScreenSaver( m_screensaver ); 313 QWSServer::setScreenSaver( m_screensaver );
313 314
314 connect( qApp, SIGNAL( volumeChanged( bool ) ), 315 connect( qApp, SIGNAL( volumeChanged( bool ) ),
315 this, SLOT( rereadVolumes() ) ); 316 this, SLOT( rereadVolumes() ) );
316 317
317 318
318 /* ### PluginLoader libqtopia SafeMode */ 319 /* ### PluginLoader libqtopia SafeMode */
319#if 0 320#if 0
320 if ( PluginLoader::inSafeMode() ) 321 if ( PluginLoader::inSafeMode() )
321 QTimer::singleShot(500, this, SLOT(showSafeMode()) ); 322 QTimer::singleShot(500, this, SLOT(showSafeMode()) );
322 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); 323 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) );
323#endif 324#endif
324 325
325 kf = new KeyFilter(this); 326 kf = new KeyFilter(this);
326 327
327 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); 328 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) );
328 connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); 329 connect( kf, SIGNAL(power()), this, SIGNAL(power()) );
329 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); 330 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) );
330 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); 331 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol()));
331 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); 332 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle()));
332 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); 333 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle()));
333 connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), 334 connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)),
334 this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); 335 this,SIGNAL(activate(const Opie::ODeviceButton*,bool)));
335 336
336 337
337 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); 338 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) );
338 339
339 connect( this, SIGNAL(power() ), 340 connect( this, SIGNAL(power() ),
340 SLOT(togglePower() ) ); 341 SLOT(togglePower() ) );
341 342
342 rereadVolumes(); 343 rereadVolumes();
343 344
344 serverApp = this; 345 serverApp = this;
345 346
346 apmTimeout(); 347 apmTimeout();
347 grabKeyboard(); 348 grabKeyboard();
348 349
349 /* make sure the event filter is installed */ 350 /* make sure the event filter is installed */
350 const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); 351 const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 );
351} 352}
@@ -785,66 +786,77 @@ void ServerApplication::checkMemory()
785 786
786 if(existingMessage) 787 if(existingMessage)
787 return; // don't show a second message while still on first 788 return; // don't show a second message while still on first
788 789
789 existingMessage = TRUE; 790 existingMessage = TRUE;
790 switch ( memstate ) { 791 switch ( memstate ) {
791 case MemUnknown: 792 case MemUnknown:
792 break; 793 break;
793 case MemLow: 794 case MemLow:
794 memstate = MemUnknown; 795 memstate = MemUnknown;
795 if ( !recoverMemory() ) { 796 if ( !recoverMemory() ) {
796 QMessageBox::warning( 0 , tr("Memory Status"), 797 QMessageBox::warning( 0 , tr("Memory Status"),
797 tr("Memory Low\nPlease save data.") ); 798 tr("Memory Low\nPlease save data.") );
798 ignoreNormal = FALSE; 799 ignoreNormal = FALSE;
799 } 800 }
800 break; 801 break;
801 case MemNormal: 802 case MemNormal:
802 memstate = MemUnknown; 803 memstate = MemUnknown;
803 if ( !ignoreNormal ) { 804 if ( !ignoreNormal ) {
804 ignoreNormal = TRUE; 805 ignoreNormal = TRUE;
805 QMessageBox::information ( 0 , tr("Memory Status"), 806 QMessageBox::information ( 0 , tr("Memory Status"),
806 "Memory OK" ); 807 "Memory OK" );
807 } 808 }
808 break; 809 break;
809 case MemVeryLow: 810 case MemVeryLow:
810 memstate = MemUnknown; 811 memstate = MemUnknown;
811 QMessageBox::critical( 0 , tr("Memory Status"), 812 QMessageBox::critical( 0 , tr("Memory Status"),
812 tr("Critical Memory Shortage\n" 813 tr("Critical Memory Shortage\n"
813 "Please end this application\n" 814 "Please end this application\n"
814 "immediately.") ); 815 "immediately.") );
815 recoverMemory(); 816 recoverMemory();
816 } 817 }
817 existingMessage = FALSE; 818 existingMessage = FALSE;
818#endif 819#endif
819} 820}
820 821
821bool ServerApplication::recoverMemory() 822bool ServerApplication::recoverMemory()
822{ 823{
823 return FALSE; 824 return FALSE;
824} 825}
825 826
826void ServerApplication::keyClick(int , bool press, bool ) 827void ServerApplication::keyClick(int , bool press, bool )
827{ 828{
828 if ( press && m_keyclick_sound ) 829 if ( press && m_keyclick_sound )
829 ODevice::inst() -> playKeySound(); 830 ODevice::inst() -> playKeySound();
830 831
831} 832}
832 833
833void ServerApplication::screenClick(bool press) 834void ServerApplication::screenClick(bool press)
834{ 835{
835 if ( press && m_screentap_sound ) 836 if ( press && m_screentap_sound )
836 ODevice::inst() -> playTouchSound(); 837 ODevice::inst() -> playTouchSound();
837} 838}
838 839
839void ServerApplication::soundAlarm() { 840void ServerApplication::soundAlarm() {
840 if ( me ()->m_alarm_sound ) 841 if ( me ()->m_alarm_sound )
841 ODevice::inst()->playAlarmSound(); 842 ODevice::inst()->playAlarmSound();
842} 843}
843 844
844ServerApplication *ServerApplication::me ( ) 845ServerApplication *ServerApplication::me ( )
845{ 846{
846 return static_cast<ServerApplication*>( qApp ); 847 return static_cast<ServerApplication*>( qApp );
847} 848}
848 849
850bool ServerApplication::isStarting()
851{
852 return ms_is_starting;
853}
854
855int ServerApplication::exec()
856{
857 ms_is_starting = true;
858 qDebug("Serverapp - exec");
859 return QPEApplication::exec();
860}
849 861
850#include "serverapp.moc" 862#include "serverapp.moc"
diff --git a/core/launcher/serverapp.h b/core/launcher/serverapp.h
index fe3f24a..4d9f808 100644
--- a/core/launcher/serverapp.h
+++ b/core/launcher/serverapp.h
@@ -33,133 +33,137 @@
33class PowerStatus; 33class PowerStatus;
34class DesktopPowerAlerter; 34class DesktopPowerAlerter;
35 35
36class OpieScreenSaver; 36class OpieScreenSaver;
37namespace Opie { 37namespace Opie {
38 class ODeviceButton; 38 class ODeviceButton;
39} 39}
40 40
41struct QCopKeyRegister { 41struct QCopKeyRegister {
42 QCopKeyRegister(); 42 QCopKeyRegister();
43 QCopKeyRegister( int k, const QCString&, const QCString& ); 43 QCopKeyRegister( int k, const QCString&, const QCString& );
44 int keyCode()const; 44 int keyCode()const;
45 QCString channel()const; 45 QCString channel()const;
46 QCString message()const; 46 QCString message()const;
47 inline bool send(); 47 inline bool send();
48 48
49private: 49private:
50 int m_keyCode; 50 int m_keyCode;
51 QCString m_channel, m_message; 51 QCString m_channel, m_message;
52}; 52};
53 53
54typedef QMap<int, QCopKeyRegister> KeyRegisterList; 54typedef QMap<int, QCopKeyRegister> KeyRegisterList;
55 55
56class KeyFilter : public QObject { 56class KeyFilter : public QObject {
57 Q_OBJECT 57 Q_OBJECT
58public: 58public:
59 KeyFilter(QObject* parent); 59 KeyFilter(QObject* parent);
60 void registerKey( const QCopKeyRegister& ); 60 void registerKey( const QCopKeyRegister& );
61 void unregisterKey( const QCopKeyRegister& ); 61 void unregisterKey( const QCopKeyRegister& );
62 bool checkButtonAction( bool, int, int, int ); 62 bool checkButtonAction( bool, int, int, int );
63 63
64 64
65 65
66protected: 66protected:
67 void timerEvent(QTimerEvent*); 67 void timerEvent(QTimerEvent*);
68 68
69signals: 69signals:
70 void launch(); 70 void launch();
71 void power(); 71 void power();
72 void backlight(); 72 void backlight();
73 void symbol(); 73 void symbol();
74 void numLockStateToggle(); 74 void numLockStateToggle();
75 void capsLockStateToggle(); 75 void capsLockStateToggle();
76 void activate(const Opie::ODeviceButton*,bool); 76 void activate(const Opie::ODeviceButton*,bool);
77 77
78 78
79private: 79private:
80 bool keyRegistered( int key ); 80 bool keyRegistered( int key );
81 int held_tid; 81 int held_tid;
82 const Opie::ODeviceButton* heldButton; 82 const Opie::ODeviceButton* heldButton;
83 KeyRegisterList m_keys; 83 KeyRegisterList m_keys;
84}; 84};
85 85
86class ServerApplication : public QPEApplication 86class ServerApplication : public QPEApplication
87{ 87{
88 Q_OBJECT 88 Q_OBJECT
89public: 89public:
90 ServerApplication( int& argc, char **argv, Type t ); 90 ServerApplication( int& argc, char **argv, Type t );
91 ~ServerApplication(); 91 ~ServerApplication();
92 92
93 static bool doRestart; 93 static bool doRestart;
94 static bool allowRestart; 94 static bool allowRestart;
95 static bool screenLocked(); 95 static bool screenLocked();
96 static void login(bool at_poweron); 96 static void login(bool at_poweron);
97
98 static bool isStarting();
97 99
98 static void switchLCD ( bool on ); // only for togglePower in Desktop 100 static void switchLCD ( bool on ); // only for togglePower in Desktop
99 static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar 101 static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar
100 102
101 void restart(); 103 void restart();
104 int exec();
102 105
103signals: 106signals:
104 void menu(); 107 void menu();
105 void home(); 108 void home();
106 void launch(); 109 void launch();
107 void power(); 110 void power();
108 void backlight(); 111 void backlight();
109 void symbol(); 112 void symbol();
110 void numLockStateToggle(); 113 void numLockStateToggle();
111 void capsLockStateToggle(); 114 void capsLockStateToggle();
112 void prepareForRestart(); 115 void prepareForRestart();
113 void activate(const Opie::ODeviceButton*,bool); 116 void activate(const Opie::ODeviceButton*,bool);
114 117
115public slots: 118public slots:
116 virtual void systemMessage( const QCString& msg, const QByteArray& ); 119 virtual void systemMessage( const QCString& msg, const QByteArray& );
117 virtual void launcherMessage( const QCString& msg, const QByteArray& ); 120 virtual void launcherMessage( const QCString& msg, const QByteArray& );
118 void rereadVolumes(); 121 void rereadVolumes();
119 122
120protected: 123protected:
121 bool eventFilter( QObject*, QEvent* ); 124 bool eventFilter( QObject*, QEvent* );
122#ifdef Q_WS_QWS 125#ifdef Q_WS_QWS
123 bool qwsEventFilter( QWSEvent * ); 126 bool qwsEventFilter( QWSEvent * );
124#endif 127#endif
125 void shutdown(); 128 void shutdown();
126 void checkMemory(); 129 void checkMemory();
127 bool recoverMemory(); 130 bool recoverMemory();
128 void keyClick(int keycode, bool press, bool repeat); 131 void keyClick(int keycode, bool press, bool repeat);
129 void screenClick(bool press); 132 void screenClick(bool press);
130 133
131protected slots: 134protected slots:
132 void shutdown(ShutdownImpl::Type); 135 void shutdown(ShutdownImpl::Type);
133 void apmTimeout(); 136 void apmTimeout();
134 void showSafeMode(); 137 void showSafeMode();
135 void clearSafeMode(); 138 void clearSafeMode();
136 void togglePower(); 139 void togglePower();
137 void toggleLight(); 140 void toggleLight();
138 141
139private: 142private:
140 static ServerApplication *me (); 143 static ServerApplication *me ();
141 void reloadPowerWarnSettings(); 144 void reloadPowerWarnSettings();
142 KeyFilter *kf; 145 KeyFilter *kf;
143 146
144 147
145private: 148private:
146 DesktopPowerAlerter *pa; 149 DesktopPowerAlerter *pa;
147 PowerStatus *m_ps, *m_ps_last; 150 PowerStatus *m_ps, *m_ps_last;
148 OpieScreenSaver *m_screensaver; 151 OpieScreenSaver *m_screensaver;
149 QTimer *m_apm_timer; 152 QTimer *m_apm_timer;
150 QDateTime m_suspendTime; 153 QDateTime m_suspendTime;
151 int m_powerVeryLow; 154 int m_powerVeryLow;
152 int m_powerCritical; 155 int m_powerCritical;
153 int m_currentPowerLevel; 156 int m_currentPowerLevel;
154 157
155 bool m_keyclick_sound : 1; 158 bool m_keyclick_sound : 1;
156 bool m_screentap_sound : 1; 159 bool m_screentap_sound : 1;
157 bool m_alarm_sound : 1; 160 bool m_alarm_sound : 1;
161 static bool ms_is_starting;
158 162
159 163
160 friend class KeyFilter; 164 friend class KeyFilter;
161}; 165};
162 166
163 167
164#endif // SERVERAPP_H 168#endif // SERVERAPP_H
165 169