00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SERVERAPP_H
00022 #define SERVERAPP_H
00023
00024 #include <opie2/oapplication.h>
00025
00026 #include <qwidget.h>
00027 #ifdef QWS
00028 #include <qwindowsystem_qws.h>
00029 #endif
00030
00031 #include "shutdownimpl.h"
00032
00033 class PowerStatus;
00034 class DesktopPowerAlerter;
00035
00036 class OpieScreenSaver;
00037 namespace Opie {
00038 namespace Core {
00039 class ODeviceButton;
00040 }
00041 }
00042
00043 struct QCopKeyRegister {
00044 QCopKeyRegister();
00045 QCopKeyRegister( int k, const QCString&, const QCString& );
00046 int keyCode()const;
00047 QCString channel()const;
00048 QCString message()const;
00049 inline bool send();
00050
00051 private:
00052 int m_keyCode;
00053 QCString m_channel, m_message;
00054 };
00055
00056 typedef QMap<int, QCopKeyRegister> KeyRegisterList;
00057
00058 class KeyFilter : public QObject {
00059 Q_OBJECT
00060 public:
00061 KeyFilter(QObject* parent);
00062 void registerKey( const QCopKeyRegister& );
00063 void unregisterKey( const QCopKeyRegister& );
00064 bool checkButtonAction( bool, int, int, int );
00065
00066
00067
00068 protected:
00069 void timerEvent(QTimerEvent*);
00070
00071 signals:
00072 void launch();
00073 void power();
00074 void backlight();
00075 void symbol();
00076 void numLockStateToggle();
00077 void capsLockStateToggle();
00078 void activate(const Opie::Core::ODeviceButton*,bool);
00079
00080
00081 private:
00082 bool keyRegistered( int key );
00083 int held_tid;
00084 const Opie::Core::ODeviceButton* heldButton,*firedHeldButton;
00085 KeyRegisterList m_keys;
00086 };
00087
00088 class ServerApplication : public Opie::Core::OApplication
00089 {
00090 Q_OBJECT
00091 public:
00092 ServerApplication( int& argc, char **argv, Type t );
00093 ~ServerApplication();
00094
00095 static bool doRestart;
00096 static bool allowRestart;
00097 static bool screenLocked();
00098 static void login(bool at_poweron);
00099
00100 static bool isStarting();
00101
00102 static void switchLCD ( bool on );
00103 static void soundAlarm();
00104
00105 void restart();
00106 int exec();
00107
00108 signals:
00109 void menu();
00110 void home();
00111 void launch();
00112 void power();
00113 void backlight();
00114 void symbol();
00115 void numLockStateToggle();
00116 void capsLockStateToggle();
00117 void prepareForRestart();
00118 void activate(const Opie::Core::ODeviceButton*,bool);
00119
00120 public slots:
00121 virtual void systemMessage( const QCString& msg, const QByteArray& );
00122 virtual void launcherMessage( const QCString& msg, const QByteArray& );
00123 void rereadVolumes();
00124
00125 protected:
00126 bool eventFilter( QObject*, QEvent* );
00127 #ifdef Q_WS_QWS
00128 bool qwsEventFilter( QWSEvent * );
00129 #endif
00130 void shutdown();
00131 void checkMemory();
00132 bool recoverMemory();
00133 void keyClick(int keycode, bool press, bool repeat);
00134 void screenClick(bool press);
00135
00136 protected slots:
00137 void shutdown(ShutdownImpl::Type);
00138 void apmTimeout();
00139 void showSafeMode();
00140 void clearSafeMode();
00141 void togglePower();
00142 void toggleLight();
00143
00144 private:
00145 static ServerApplication *me ();
00146 void reloadPowerWarnSettings();
00147 KeyFilter *kf;
00148
00149
00150 private:
00151 DesktopPowerAlerter *pa;
00152 PowerStatus *m_ps, *m_ps_last;
00153 OpieScreenSaver *m_screensaver;
00154 QTimer *m_apm_timer;
00155 QDateTime m_suspendTime;
00156 int m_powerVeryLow;
00157 int m_powerCritical;
00158 int m_currentPowerLevel;
00159
00160 bool m_keyclick_sound : 1;
00161 bool m_screentap_sound : 1;
00162 bool m_alarm_sound : 1;
00163 static bool ms_is_starting;
00164
00165
00166 friend class KeyFilter;
00167 };
00168
00169
00170 #endif // SERVERAPP_H
00171