author | chicken <chicken> | 2004-03-01 15:44:36 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 15:44:36 (UTC) |
commit | c50e4c32d34a0550f167480b6306aac632fb201c (patch) (unidiff) | |
tree | a0795fa171d7410624717f120d1bd17f6c8f3224 /libopie/odevice.cpp | |
parent | 01abceaeb00bc35fa9bf5792eb51aa70b68f110d (diff) | |
download | opie-c50e4c32d34a0550f167480b6306aac632fb201c.zip opie-c50e4c32d34a0550f167480b6306aac632fb201c.tar.gz opie-c50e4c32d34a0550f167480b6306aac632fb201c.tar.bz2 |
fix includes
-rw-r--r-- | libopie/odevice.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index c5342e1..c0b6efa 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,799 +1,798 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #ifndef QT_NO_SOUND | 26 | #ifndef QT_NO_SOUND |
27 | #include <linux/soundcard.h> | 27 | #include <linux/soundcard.h> |
28 | #endif | 28 | #endif |
29 | #include <math.h> | 29 | #include <math.h> |
30 | 30 | ||
31 | #include <qapplication.h> | ||
32 | 31 | ||
33 | #include <qfile.h> | 32 | #include <qfile.h> |
34 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
35 | #include <qpe/sound.h> | 34 | #include <qpe/sound.h> |
36 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
37 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
39 | 38 | ||
40 | #include "odevice.h" | 39 | #include "odevice.h" |
41 | 40 | ||
42 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
43 | 42 | ||
44 | #ifndef ARRAY_SIZE | 43 | #ifndef ARRAY_SIZE |
45 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 44 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
46 | #endif | 45 | #endif |
47 | 46 | ||
48 | // _IO and friends are only defined in kernel headers ... | 47 | // _IO and friends are only defined in kernel headers ... |
49 | 48 | ||
50 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 49 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
51 | 50 | ||
52 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 51 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
53 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 52 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
54 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 53 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
55 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 54 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
56 | 55 | ||
57 | using namespace Opie; | 56 | using namespace Opie; |
58 | 57 | ||
59 | class ODeviceData { | 58 | class ODeviceData { |
60 | public: | 59 | public: |
61 | QString m_vendorstr; | 60 | QString m_vendorstr; |
62 | OVendor m_vendor; | 61 | OVendor m_vendor; |
63 | 62 | ||
64 | QString m_modelstr; | 63 | QString m_modelstr; |
65 | OModel m_model; | 64 | OModel m_model; |
66 | 65 | ||
67 | QString m_systemstr; | 66 | QString m_systemstr; |
68 | OSystem m_system; | 67 | OSystem m_system; |
69 | 68 | ||
70 | QString m_sysverstr; | 69 | QString m_sysverstr; |
71 | 70 | ||
72 | Transformation m_rotation; | 71 | Transformation m_rotation; |
73 | ODirection m_direction; | 72 | ODirection m_direction; |
74 | 73 | ||
75 | QValueList <ODeviceButton> *m_buttons; | 74 | QValueList <ODeviceButton> *m_buttons; |
76 | uint m_holdtime; | 75 | uint m_holdtime; |
77 | QStrList *m_cpu_frequencies; | 76 | QStrList *m_cpu_frequencies; |
78 | 77 | ||
79 | }; | 78 | }; |
80 | 79 | ||
81 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 80 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
82 | protected: | 81 | protected: |
83 | virtual void init ( ); | 82 | virtual void init ( ); |
84 | virtual void initButtons ( ); | 83 | virtual void initButtons ( ); |
85 | 84 | ||
86 | public: | 85 | public: |
87 | virtual bool setSoftSuspend ( bool soft ); | 86 | virtual bool setSoftSuspend ( bool soft ); |
88 | 87 | ||
89 | virtual bool setDisplayBrightness ( int b ); | 88 | virtual bool setDisplayBrightness ( int b ); |
90 | virtual int displayBrightnessResolution ( ) const; | 89 | virtual int displayBrightnessResolution ( ) const; |
91 | 90 | ||
92 | virtual void alarmSound ( ); | 91 | virtual void alarmSound ( ); |
93 | 92 | ||
94 | virtual QValueList <OLed> ledList ( ) const; | 93 | virtual QValueList <OLed> ledList ( ) const; |
95 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 94 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
96 | virtual OLedState ledState ( OLed led ) const; | 95 | virtual OLedState ledState ( OLed led ) const; |
97 | virtual bool setLedState ( OLed led, OLedState st ); | 96 | virtual bool setLedState ( OLed led, OLedState st ); |
98 | 97 | ||
99 | virtual bool hasLightSensor ( ) const; | 98 | virtual bool hasLightSensor ( ) const; |
100 | virtual int readLightSensor ( ); | 99 | virtual int readLightSensor ( ); |
101 | virtual int lightSensorResolution ( ) const; | 100 | virtual int lightSensorResolution ( ) const; |
102 | 101 | ||
103 | protected: | 102 | protected: |
104 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 103 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
105 | virtual void timerEvent ( QTimerEvent *te ); | 104 | virtual void timerEvent ( QTimerEvent *te ); |
106 | 105 | ||
107 | int m_power_timer; | 106 | int m_power_timer; |
108 | 107 | ||
109 | OLedState m_leds [2]; | 108 | OLedState m_leds [2]; |
110 | }; | 109 | }; |
111 | 110 | ||
112 | class Jornada : public ODevice { | 111 | class Jornada : public ODevice { |
113 | protected: | 112 | protected: |
114 | virtual void init ( ); | 113 | virtual void init ( ); |
115 | //virtual void initButtons ( ); | 114 | //virtual void initButtons ( ); |
116 | public: | 115 | public: |
117 | virtual bool setSoftSuspend ( bool soft ); | 116 | virtual bool setSoftSuspend ( bool soft ); |
118 | virtual bool setDisplayBrightness ( int b ); | 117 | virtual bool setDisplayBrightness ( int b ); |
119 | virtual int displayBrightnessResolution ( ) const; | 118 | virtual int displayBrightnessResolution ( ) const; |
120 | static bool isJornada(); | 119 | static bool isJornada(); |
121 | 120 | ||
122 | }; | 121 | }; |
123 | 122 | ||
124 | class Zaurus : public ODevice { | 123 | class Zaurus : public ODevice { |
125 | protected: | 124 | protected: |
126 | virtual void init ( ); | 125 | virtual void init ( ); |
127 | virtual void initButtons ( ); | 126 | virtual void initButtons ( ); |
128 | 127 | ||
129 | public: | 128 | public: |
130 | virtual bool setSoftSuspend ( bool soft ); | 129 | virtual bool setSoftSuspend ( bool soft ); |
131 | 130 | ||
132 | virtual bool setDisplayBrightness ( int b ); | 131 | virtual bool setDisplayBrightness ( int b ); |
133 | virtual int displayBrightnessResolution ( ) const; | 132 | virtual int displayBrightnessResolution ( ) const; |
134 | 133 | ||
135 | virtual void alarmSound ( ); | 134 | virtual void alarmSound ( ); |
136 | virtual void keySound ( ); | 135 | virtual void keySound ( ); |
137 | virtual void touchSound ( ); | 136 | virtual void touchSound ( ); |
138 | 137 | ||
139 | virtual QValueList <OLed> ledList ( ) const; | 138 | virtual QValueList <OLed> ledList ( ) const; |
140 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 139 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
141 | virtual OLedState ledState ( OLed led ) const; | 140 | virtual OLedState ledState ( OLed led ) const; |
142 | virtual bool setLedState ( OLed led, OLedState st ); | 141 | virtual bool setLedState ( OLed led, OLedState st ); |
143 | 142 | ||
144 | bool hasHingeSensor() const; | 143 | bool hasHingeSensor() const; |
145 | OHingeStatus readHingeSensor(); | 144 | OHingeStatus readHingeSensor(); |
146 | 145 | ||
147 | static bool isZaurus(); | 146 | static bool isZaurus(); |
148 | 147 | ||
149 | // Does this break BC? | 148 | // Does this break BC? |
150 | virtual bool suspend ( ); | 149 | virtual bool suspend ( ); |
151 | Transformation rotation ( ) const; | 150 | Transformation rotation ( ) const; |
152 | ODirection direction ( ) const; | 151 | ODirection direction ( ) const; |
153 | 152 | ||
154 | protected: | 153 | protected: |
155 | virtual void buzzer ( int snd ); | 154 | virtual void buzzer ( int snd ); |
156 | 155 | ||
157 | OLedState m_leds [1]; | 156 | OLedState m_leds [1]; |
158 | bool m_embedix; | 157 | bool m_embedix; |
159 | void virtual_hook( int id, void *data ); | 158 | void virtual_hook( int id, void *data ); |
160 | }; | 159 | }; |
161 | 160 | ||
162 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | 161 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { |
163 | protected: | 162 | protected: |
164 | virtual void init ( ); | 163 | virtual void init ( ); |
165 | virtual void initButtons ( ); | 164 | virtual void initButtons ( ); |
166 | 165 | ||
167 | public: | 166 | public: |
168 | virtual bool setSoftSuspend ( bool soft ); | 167 | virtual bool setSoftSuspend ( bool soft ); |
169 | virtual bool suspend(); | 168 | virtual bool suspend(); |
170 | 169 | ||
171 | virtual bool setDisplayStatus( bool on ); | 170 | virtual bool setDisplayStatus( bool on ); |
172 | virtual bool setDisplayBrightness ( int b ); | 171 | virtual bool setDisplayBrightness ( int b ); |
173 | virtual int displayBrightnessResolution ( ) const; | 172 | virtual int displayBrightnessResolution ( ) const; |
174 | 173 | ||
175 | virtual void alarmSound ( ); | 174 | virtual void alarmSound ( ); |
176 | 175 | ||
177 | virtual QValueList <OLed> ledList ( ) const; | 176 | virtual QValueList <OLed> ledList ( ) const; |
178 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 177 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
179 | virtual OLedState ledState ( OLed led ) const; | 178 | virtual OLedState ledState ( OLed led ) const; |
180 | virtual bool setLedState ( OLed led, OLedState st ); | 179 | virtual bool setLedState ( OLed led, OLedState st ); |
181 | 180 | ||
182 | protected: | 181 | protected: |
183 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 182 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
184 | virtual void timerEvent ( QTimerEvent *te ); | 183 | virtual void timerEvent ( QTimerEvent *te ); |
185 | 184 | ||
186 | int m_power_timer; | 185 | int m_power_timer; |
187 | 186 | ||
188 | OLedState m_leds [1]; //FIXME check if really only one | 187 | OLedState m_leds [1]; //FIXME check if really only one |
189 | }; | 188 | }; |
190 | 189 | ||
191 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { | 190 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { |
192 | protected: | 191 | protected: |
193 | virtual void init ( ); | 192 | virtual void init ( ); |
194 | 193 | ||
195 | public: | 194 | public: |
196 | virtual bool setSoftSuspend ( bool soft ); | 195 | virtual bool setSoftSuspend ( bool soft ); |
197 | virtual bool suspend ( ); | 196 | virtual bool suspend ( ); |
198 | 197 | ||
199 | virtual bool setDisplayStatus( bool on ); | 198 | virtual bool setDisplayStatus( bool on ); |
200 | virtual bool setDisplayBrightness ( int b ); | 199 | virtual bool setDisplayBrightness ( int b ); |
201 | virtual int displayBrightnessResolution ( ) const; | 200 | virtual int displayBrightnessResolution ( ) const; |
202 | virtual bool setDisplayContrast ( int b ); | 201 | virtual bool setDisplayContrast ( int b ); |
203 | virtual int displayContrastResolution ( ) const; | 202 | virtual int displayContrastResolution ( ) const; |
204 | 203 | ||
205 | protected: | 204 | protected: |
206 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 205 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
207 | virtual void timerEvent ( QTimerEvent *te ); | 206 | virtual void timerEvent ( QTimerEvent *te ); |
208 | 207 | ||
209 | int m_power_timer; | 208 | int m_power_timer; |
210 | }; | 209 | }; |
211 | 210 | ||
212 | struct i_button { | 211 | struct i_button { |
213 | uint model; | 212 | uint model; |
214 | Qt::Key code; | 213 | Qt::Key code; |
215 | char *utext; | 214 | char *utext; |
216 | char *pix; | 215 | char *pix; |
217 | char *fpressedservice; | 216 | char *fpressedservice; |
218 | char *fpressedaction; | 217 | char *fpressedaction; |
219 | char *fheldservice; | 218 | char *fheldservice; |
220 | char *fheldaction; | 219 | char *fheldaction; |
221 | } ipaq_buttons [] = { | 220 | } ipaq_buttons [] = { |
222 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 221 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
223 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 222 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
224 | "devicebuttons/ipaq_calendar", | 223 | "devicebuttons/ipaq_calendar", |
225 | "datebook", "nextView()", | 224 | "datebook", "nextView()", |
226 | "today", "raise()" }, | 225 | "today", "raise()" }, |
227 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 226 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
228 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 227 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
229 | "devicebuttons/ipaq_contact", | 228 | "devicebuttons/ipaq_contact", |
230 | "addressbook", "raise()", | 229 | "addressbook", "raise()", |
231 | "addressbook", "beamBusinessCard()" }, | 230 | "addressbook", "beamBusinessCard()" }, |
232 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 231 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
233 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 232 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
234 | "devicebuttons/ipaq_menu", | 233 | "devicebuttons/ipaq_menu", |
235 | "QPE/TaskBar", "toggleMenu()", | 234 | "QPE/TaskBar", "toggleMenu()", |
236 | "QPE/TaskBar", "toggleStartMenu()" }, | 235 | "QPE/TaskBar", "toggleStartMenu()" }, |
237 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 236 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
238 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 237 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
239 | "devicebuttons/ipaq_mail", | 238 | "devicebuttons/ipaq_mail", |
240 | "mail", "raise()", | 239 | "mail", "raise()", |
241 | "mail", "newMail()" }, | 240 | "mail", "newMail()" }, |
242 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 241 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
243 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 242 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
244 | "devicebuttons/ipaq_home", | 243 | "devicebuttons/ipaq_home", |
245 | "QPE/Launcher", "home()", | 244 | "QPE/Launcher", "home()", |
246 | "buttonsettings", "raise()" }, | 245 | "buttonsettings", "raise()" }, |
247 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 246 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
248 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 247 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
249 | "devicebuttons/ipaq_record", | 248 | "devicebuttons/ipaq_record", |
250 | "QPE/VMemo", "toggleRecord()", | 249 | "QPE/VMemo", "toggleRecord()", |
251 | "sound", "raise()" }, | 250 | "sound", "raise()" }, |
252 | }; | 251 | }; |
253 | 252 | ||
254 | struct z_button { | 253 | struct z_button { |
255 | Qt::Key code; | 254 | Qt::Key code; |
256 | char *utext; | 255 | char *utext; |
257 | char *pix; | 256 | char *pix; |
258 | char *fpressedservice; | 257 | char *fpressedservice; |
259 | char *fpressedaction; | 258 | char *fpressedaction; |
260 | char *fheldservice; | 259 | char *fheldservice; |
261 | char *fheldaction; | 260 | char *fheldaction; |
262 | } z_buttons [] = { | 261 | } z_buttons [] = { |
263 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 262 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
264 | "devicebuttons/z_calendar", | 263 | "devicebuttons/z_calendar", |
265 | "datebook", "nextView()", | 264 | "datebook", "nextView()", |
266 | "today", "raise()" }, | 265 | "today", "raise()" }, |
267 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 266 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
268 | "devicebuttons/z_contact", | 267 | "devicebuttons/z_contact", |
269 | "addressbook", "raise()", | 268 | "addressbook", "raise()", |
270 | "addressbook", "beamBusinessCard()" }, | 269 | "addressbook", "beamBusinessCard()" }, |
271 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 270 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
272 | "devicebuttons/z_home", | 271 | "devicebuttons/z_home", |
273 | "QPE/Launcher", "home()", | 272 | "QPE/Launcher", "home()", |
274 | "buttonsettings", "raise()" }, | 273 | "buttonsettings", "raise()" }, |
275 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 274 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
276 | "devicebuttons/z_menu", | 275 | "devicebuttons/z_menu", |
277 | "QPE/TaskBar", "toggleMenu()", | 276 | "QPE/TaskBar", "toggleMenu()", |
278 | "QPE/TaskBar", "toggleStartMenu()" }, | 277 | "QPE/TaskBar", "toggleStartMenu()" }, |
279 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 278 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
280 | "devicebuttons/z_mail", | 279 | "devicebuttons/z_mail", |
281 | "mail", "raise()", | 280 | "mail", "raise()", |
282 | "mail", "newMail()" }, | 281 | "mail", "newMail()" }, |
283 | }; | 282 | }; |
284 | 283 | ||
285 | struct z_button z_buttons_c700 [] = { | 284 | struct z_button z_buttons_c700 [] = { |
286 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 285 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
287 | "devicebuttons/z_calendar", | 286 | "devicebuttons/z_calendar", |
288 | "datebook", "nextView()", | 287 | "datebook", "nextView()", |
289 | "today", "raise()" }, | 288 | "today", "raise()" }, |
290 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 289 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
291 | "devicebuttons/z_contact", | 290 | "devicebuttons/z_contact", |
292 | "addressbook", "raise()", | 291 | "addressbook", "raise()", |
293 | "addressbook", "beamBusinessCard()" }, | 292 | "addressbook", "beamBusinessCard()" }, |
294 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 293 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
295 | "devicebuttons/z_home", | 294 | "devicebuttons/z_home", |
296 | "QPE/Launcher", "home()", | 295 | "QPE/Launcher", "home()", |
297 | "buttonsettings", "raise()" }, | 296 | "buttonsettings", "raise()" }, |
298 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 297 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
299 | "devicebuttons/z_menu", | 298 | "devicebuttons/z_menu", |
300 | "QPE/TaskBar", "toggleMenu()", | 299 | "QPE/TaskBar", "toggleMenu()", |
301 | "QPE/TaskBar", "toggleStartMenu()" }, | 300 | "QPE/TaskBar", "toggleStartMenu()" }, |
302 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 301 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
303 | "devicebuttons/z_hinge", | 302 | "devicebuttons/z_hinge", |
304 | "QPE/Rotation", "rotateDefault()", | 303 | "QPE/Rotation", "rotateDefault()", |
305 | "QPE/Dummy", "doNothing()" }, | 304 | "QPE/Dummy", "doNothing()" }, |
306 | }; | 305 | }; |
307 | 306 | ||
308 | struct s_button { | 307 | struct s_button { |
309 | uint model; | 308 | uint model; |
310 | Qt::Key code; | 309 | Qt::Key code; |
311 | char *utext; | 310 | char *utext; |
312 | char *pix; | 311 | char *pix; |
313 | char *fpressedservice; | 312 | char *fpressedservice; |
314 | char *fpressedaction; | 313 | char *fpressedaction; |
315 | char *fheldservice; | 314 | char *fheldservice; |
316 | char *fheldaction; | 315 | char *fheldaction; |
317 | } simpad_buttons [] = { | 316 | } simpad_buttons [] = { |
318 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 317 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
319 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 318 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
320 | "devicebuttons/simpad_lower_up", | 319 | "devicebuttons/simpad_lower_up", |
321 | "datebook", "nextView()", | 320 | "datebook", "nextView()", |
322 | "today", "raise()" }, | 321 | "today", "raise()" }, |
323 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 322 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
324 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 323 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
325 | "devicebuttons/simpad_lower_down", | 324 | "devicebuttons/simpad_lower_down", |
326 | "addressbook", "raise()", | 325 | "addressbook", "raise()", |
327 | "addressbook", "beamBusinessCard()" }, | 326 | "addressbook", "beamBusinessCard()" }, |
328 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 327 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
329 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 328 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
330 | "devicebuttons/simpad_lower_right", | 329 | "devicebuttons/simpad_lower_right", |
331 | "QPE/TaskBar", "toggleMenu()", | 330 | "QPE/TaskBar", "toggleMenu()", |
332 | "QPE/TaskBar", "toggleStartMenu()" }, | 331 | "QPE/TaskBar", "toggleStartMenu()" }, |
333 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 332 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
334 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 333 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
335 | "devicebuttons/simpad_lower_left", | 334 | "devicebuttons/simpad_lower_left", |
336 | "mail", "raise()", | 335 | "mail", "raise()", |
337 | "mail", "newMail()" }, | 336 | "mail", "newMail()" }, |
338 | 337 | ||
339 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 338 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
340 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 339 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
341 | "devicebuttons/simpad_upper_up", | 340 | "devicebuttons/simpad_upper_up", |
342 | "QPE/Launcher", "home()", | 341 | "QPE/Launcher", "home()", |
343 | "buttonsettings", "raise()" }, | 342 | "buttonsettings", "raise()" }, |
344 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 343 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
345 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 344 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
346 | "devicebuttons/simpad_upper_down", | 345 | "devicebuttons/simpad_upper_down", |
347 | "addressbook", "raise()", | 346 | "addressbook", "raise()", |
348 | "addressbook", "beamBusinessCard()" }, | 347 | "addressbook", "beamBusinessCard()" }, |
349 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 348 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
350 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 349 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
351 | "devicebuttons/simpad_upper_right", | 350 | "devicebuttons/simpad_upper_right", |
352 | "QPE/TaskBar", "toggleMenu()", | 351 | "QPE/TaskBar", "toggleMenu()", |
353 | "QPE/TaskBar", "toggleStartMenu()" }, | 352 | "QPE/TaskBar", "toggleStartMenu()" }, |
354 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 353 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
355 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 354 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
356 | "devicebuttons/simpad_upper_left", | 355 | "devicebuttons/simpad_upper_left", |
357 | "QPE/Rotation", "flip()", | 356 | "QPE/Rotation", "flip()", |
358 | "QPE/Rotation", "flip()" }, | 357 | "QPE/Rotation", "flip()" }, |
359 | /* | 358 | /* |
360 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 359 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
361 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 360 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
362 | "devicebuttons/simpad_lower_upper", | 361 | "devicebuttons/simpad_lower_upper", |
363 | "QPE/Launcher", "home()", | 362 | "QPE/Launcher", "home()", |
364 | "buttonsettings", "raise()" }, | 363 | "buttonsettings", "raise()" }, |
365 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 364 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
366 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
367 | "devicebuttons/simpad_upper_lower", | 366 | "devicebuttons/simpad_upper_lower", |
368 | "QPE/Launcher", "home()", | 367 | "QPE/Launcher", "home()", |
369 | "buttonsettings", "raise()" }, | 368 | "buttonsettings", "raise()" }, |
370 | */ | 369 | */ |
371 | }; | 370 | }; |
372 | 371 | ||
373 | struct r_button { | 372 | struct r_button { |
374 | uint model; | 373 | uint model; |
375 | Qt::Key code; | 374 | Qt::Key code; |
376 | char *utext; | 375 | char *utext; |
377 | char *pix; | 376 | char *pix; |
378 | char *fpressedservice; | 377 | char *fpressedservice; |
379 | char *fpressedaction; | 378 | char *fpressedaction; |
380 | char *fheldservice; | 379 | char *fheldservice; |
381 | char *fheldaction; | 380 | char *fheldaction; |
382 | } ramses_buttons [] = { | 381 | } ramses_buttons [] = { |
383 | { Model_Ramses_MNCI, | 382 | { Model_Ramses_MNCI, |
384 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 383 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
385 | "devicebuttons/z_menu", | 384 | "devicebuttons/z_menu", |
386 | "QPE/TaskBar", "toggleMenu()", | 385 | "QPE/TaskBar", "toggleMenu()", |
387 | "QPE/TaskBar", "toggleStartMenu()" }, | 386 | "QPE/TaskBar", "toggleStartMenu()" }, |
388 | { Model_Ramses_MNCI, | 387 | { Model_Ramses_MNCI, |
389 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 388 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
390 | "devicebuttons/ipaq_home", | 389 | "devicebuttons/ipaq_home", |
391 | "QPE/Launcher", "home()", | 390 | "QPE/Launcher", "home()", |
392 | "buttonsettings", "raise()" }, | 391 | "buttonsettings", "raise()" }, |
393 | }; | 392 | }; |
394 | 393 | ||
395 | class Yopy : public ODevice { | 394 | class Yopy : public ODevice { |
396 | protected: | 395 | protected: |
397 | virtual void init ( ); | 396 | virtual void init ( ); |
398 | virtual void initButtons ( ); | 397 | virtual void initButtons ( ); |
399 | 398 | ||
400 | public: | 399 | public: |
401 | virtual bool suspend ( ); | 400 | virtual bool suspend ( ); |
402 | 401 | ||
403 | virtual bool setDisplayBrightness ( int b ); | 402 | virtual bool setDisplayBrightness ( int b ); |
404 | virtual int displayBrightnessResolution ( ) const; | 403 | virtual int displayBrightnessResolution ( ) const; |
405 | 404 | ||
406 | static bool isYopy ( ); | 405 | static bool isYopy ( ); |
407 | }; | 406 | }; |
408 | 407 | ||
409 | struct yopy_button { | 408 | struct yopy_button { |
410 | Qt::Key code; | 409 | Qt::Key code; |
411 | char *utext; | 410 | char *utext; |
412 | char *pix; | 411 | char *pix; |
413 | char *fpressedservice; | 412 | char *fpressedservice; |
414 | char *fpressedaction; | 413 | char *fpressedaction; |
415 | char *fheldservice; | 414 | char *fheldservice; |
416 | char *fheldaction; | 415 | char *fheldaction; |
417 | } yopy_buttons [] = { | 416 | } yopy_buttons [] = { |
418 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | 417 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), |
419 | "devicebuttons/yopy_action", | 418 | "devicebuttons/yopy_action", |
420 | "datebook", "nextView()", | 419 | "datebook", "nextView()", |
421 | "today", "raise()" }, | 420 | "today", "raise()" }, |
422 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), | 421 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), |
423 | "devicebuttons/yopy_ok", | 422 | "devicebuttons/yopy_ok", |
424 | "addressbook", "raise()", | 423 | "addressbook", "raise()", |
425 | "addressbook", "beamBusinessCard()" }, | 424 | "addressbook", "beamBusinessCard()" }, |
426 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), | 425 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), |
427 | "devicebuttons/yopy_end", | 426 | "devicebuttons/yopy_end", |
428 | "QPE/Launcher", "home()", | 427 | "QPE/Launcher", "home()", |
429 | "buttonsettings", "raise()" }, | 428 | "buttonsettings", "raise()" }, |
430 | }; | 429 | }; |
431 | 430 | ||
432 | static QCString makeChannel ( const char *str ) | 431 | static QCString makeChannel ( const char *str ) |
433 | { | 432 | { |
434 | if ( str && !::strchr ( str, '/' )) | 433 | if ( str && !::strchr ( str, '/' )) |
435 | return QCString ( "QPE/Application/" ) + str; | 434 | return QCString ( "QPE/Application/" ) + str; |
436 | else | 435 | else |
437 | return str; | 436 | return str; |
438 | } | 437 | } |
439 | 438 | ||
440 | static inline bool isQWS() | 439 | static inline bool isQWS() |
441 | { | 440 | { |
442 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 441 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
443 | } | 442 | } |
444 | 443 | ||
445 | ODevice *ODevice::inst ( ) | 444 | ODevice *ODevice::inst ( ) |
446 | { | 445 | { |
447 | static ODevice *dev = 0; | 446 | static ODevice *dev = 0; |
448 | 447 | ||
449 | if ( !dev ) { | 448 | if ( !dev ) { |
450 | if ( QFile::exists ( "/proc/hal/model" )) | 449 | if ( QFile::exists ( "/proc/hal/model" )) |
451 | dev = new iPAQ ( ); | 450 | dev = new iPAQ ( ); |
452 | else if ( Zaurus::isZaurus() ) | 451 | else if ( Zaurus::isZaurus() ) |
453 | dev = new Zaurus ( ); | 452 | dev = new Zaurus ( ); |
454 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 453 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
455 | dev = new SIMpad ( ); | 454 | dev = new SIMpad ( ); |
456 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 455 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
457 | dev = new Ramses ( ); | 456 | dev = new Ramses ( ); |
458 | else if ( Yopy::isYopy() ) | 457 | else if ( Yopy::isYopy() ) |
459 | dev = new Yopy ( ); | 458 | dev = new Yopy ( ); |
460 | else if ( Jornada::isJornada() ) | 459 | else if ( Jornada::isJornada() ) |
461 | dev = new Jornada ( ); | 460 | dev = new Jornada ( ); |
462 | else | 461 | else |
463 | dev = new ODevice ( ); | 462 | dev = new ODevice ( ); |
464 | dev-> init ( ); | 463 | dev-> init ( ); |
465 | } | 464 | } |
466 | return dev; | 465 | return dev; |
467 | } | 466 | } |
468 | 467 | ||
469 | 468 | ||
470 | /************************************************** | 469 | /************************************************** |
471 | * | 470 | * |
472 | * common | 471 | * common |
473 | * | 472 | * |
474 | **************************************************/ | 473 | **************************************************/ |
475 | 474 | ||
476 | 475 | ||
477 | ODevice::ODevice ( ) | 476 | ODevice::ODevice ( ) |
478 | { | 477 | { |
479 | d = new ODeviceData; | 478 | d = new ODeviceData; |
480 | 479 | ||
481 | d-> m_modelstr = "Unknown"; | 480 | d-> m_modelstr = "Unknown"; |
482 | d-> m_model = Model_Unknown; | 481 | d-> m_model = Model_Unknown; |
483 | d-> m_vendorstr = "Unknown"; | 482 | d-> m_vendorstr = "Unknown"; |
484 | d-> m_vendor = Vendor_Unknown; | 483 | d-> m_vendor = Vendor_Unknown; |
485 | d-> m_systemstr = "Unknown"; | 484 | d-> m_systemstr = "Unknown"; |
486 | d-> m_system = System_Unknown; | 485 | d-> m_system = System_Unknown; |
487 | d-> m_sysverstr = "0.0"; | 486 | d-> m_sysverstr = "0.0"; |
488 | d-> m_rotation = Rot0; | 487 | d-> m_rotation = Rot0; |
489 | d-> m_direction = CW; | 488 | d-> m_direction = CW; |
490 | 489 | ||
491 | d-> m_holdtime = 1000; // 1000ms | 490 | d-> m_holdtime = 1000; // 1000ms |
492 | d-> m_buttons = 0; | 491 | d-> m_buttons = 0; |
493 | d-> m_cpu_frequencies = new QStrList; | 492 | d-> m_cpu_frequencies = new QStrList; |
494 | } | 493 | } |
495 | 494 | ||
496 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 495 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
497 | { | 496 | { |
498 | if ( msg == "deviceButtonMappingChanged()" ) { | 497 | if ( msg == "deviceButtonMappingChanged()" ) { |
499 | reloadButtonMapping ( ); | 498 | reloadButtonMapping ( ); |
500 | } | 499 | } |
501 | } | 500 | } |
502 | 501 | ||
503 | void ODevice::init ( ) | 502 | void ODevice::init ( ) |
504 | { | 503 | { |
505 | } | 504 | } |
506 | 505 | ||
507 | /** | 506 | /** |
508 | * This method initialises the button mapping | 507 | * This method initialises the button mapping |
509 | */ | 508 | */ |
510 | void ODevice::initButtons ( ) | 509 | void ODevice::initButtons ( ) |
511 | { | 510 | { |
512 | if ( d-> m_buttons ) | 511 | if ( d-> m_buttons ) |
513 | return; | 512 | return; |
514 | 513 | ||
515 | // Simulation uses iPAQ 3660 device buttons | 514 | // Simulation uses iPAQ 3660 device buttons |
516 | 515 | ||
517 | qDebug ( "init Buttons" ); | 516 | qDebug ( "init Buttons" ); |
518 | d-> m_buttons = new QValueList <ODeviceButton>; | 517 | d-> m_buttons = new QValueList <ODeviceButton>; |
519 | 518 | ||
520 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 519 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
521 | i_button *ib = ipaq_buttons + i; | 520 | i_button *ib = ipaq_buttons + i; |
522 | ODeviceButton b; | 521 | ODeviceButton b; |
523 | 522 | ||
524 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 523 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
525 | b. setKeycode ( ib-> code ); | 524 | b. setKeycode ( ib-> code ); |
526 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 525 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
527 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 526 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
528 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 527 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
529 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 528 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
530 | d-> m_buttons-> append ( b ); | 529 | d-> m_buttons-> append ( b ); |
531 | } | 530 | } |
532 | } | 531 | } |
533 | reloadButtonMapping ( ); | 532 | reloadButtonMapping ( ); |
534 | 533 | ||
535 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 534 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
536 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 535 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
537 | } | 536 | } |
538 | 537 | ||
539 | ODevice::~ODevice ( ) | 538 | ODevice::~ODevice ( ) |
540 | { | 539 | { |
541 | // we leak m_devicebuttons and m_cpu_frequency | 540 | // we leak m_devicebuttons and m_cpu_frequency |
542 | // but it's a singleton and it is not so importantant | 541 | // but it's a singleton and it is not so importantant |
543 | // -zecke | 542 | // -zecke |
544 | delete d; | 543 | delete d; |
545 | } | 544 | } |
546 | 545 | ||
547 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 546 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
548 | { | 547 | { |
549 | return false; | 548 | return false; |
550 | } | 549 | } |
551 | 550 | ||
552 | //#include <linux/apm_bios.h> | 551 | //#include <linux/apm_bios.h> |
553 | 552 | ||
554 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 553 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
555 | 554 | ||
556 | /** | 555 | /** |
557 | * This method will try to suspend the device | 556 | * This method will try to suspend the device |
558 | * It only works if the user is the QWS Server and the apm application | 557 | * It only works if the user is the QWS Server and the apm application |
559 | * is installed. | 558 | * is installed. |
560 | * It tries to suspend and then waits some time cause some distributions | 559 | * It tries to suspend and then waits some time cause some distributions |
561 | * do have asynchronus apm implementations. | 560 | * do have asynchronus apm implementations. |
562 | * This method will either fail and return false or it'll suspend the | 561 | * This method will either fail and return false or it'll suspend the |
563 | * device and return once the device got woken up | 562 | * device and return once the device got woken up |
564 | * | 563 | * |
565 | * @return if the device got suspended | 564 | * @return if the device got suspended |
566 | */ | 565 | */ |
567 | bool ODevice::suspend ( ) | 566 | bool ODevice::suspend ( ) |
568 | { | 567 | { |
569 | qDebug("ODevice::suspend"); | 568 | qDebug("ODevice::suspend"); |
570 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 569 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
571 | return false; | 570 | return false; |
572 | 571 | ||
573 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 572 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
574 | return false; | 573 | return false; |
575 | 574 | ||
576 | bool res = false; | 575 | bool res = false; |
577 | 576 | ||
578 | struct timeval tvs, tvn; | 577 | struct timeval tvs, tvn; |
579 | ::gettimeofday ( &tvs, 0 ); | 578 | ::gettimeofday ( &tvs, 0 ); |
580 | 579 | ||
581 | ::sync ( ); // flush fs caches | 580 | ::sync ( ); // flush fs caches |
582 | res = ( ::system ( "apm --suspend" ) == 0 ); | 581 | res = ( ::system ( "apm --suspend" ) == 0 ); |
583 | 582 | ||
584 | // This is needed because the iPAQ apm implementation is asynchronous and we | 583 | // This is needed because the iPAQ apm implementation is asynchronous and we |
585 | // can not be sure when exactly the device is really suspended | 584 | // can not be sure when exactly the device is really suspended |
586 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 585 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
587 | 586 | ||
588 | if ( res ) { | 587 | if ( res ) { |
589 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 588 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
590 | ::usleep ( 200 * 1000 ); | 589 | ::usleep ( 200 * 1000 ); |
591 | ::gettimeofday ( &tvn, 0 ); | 590 | ::gettimeofday ( &tvn, 0 ); |
592 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 591 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
593 | } | 592 | } |
594 | 593 | ||
595 | return res; | 594 | return res; |
596 | } | 595 | } |
597 | 596 | ||
598 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 597 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
599 | 598 | ||
600 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 599 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
601 | 600 | ||
602 | /* VESA Blanking Levels */ | 601 | /* VESA Blanking Levels */ |
603 | #define VESA_NO_BLANKING 0 | 602 | #define VESA_NO_BLANKING 0 |
604 | #define VESA_VSYNC_SUSPEND 1 | 603 | #define VESA_VSYNC_SUSPEND 1 |
605 | #define VESA_HSYNC_SUSPEND 2 | 604 | #define VESA_HSYNC_SUSPEND 2 |
606 | #define VESA_POWERDOWN 3 | 605 | #define VESA_POWERDOWN 3 |
607 | 606 | ||
608 | /** | 607 | /** |
609 | * This sets the display on or off | 608 | * This sets the display on or off |
610 | */ | 609 | */ |
611 | bool ODevice::setDisplayStatus ( bool on ) | 610 | bool ODevice::setDisplayStatus ( bool on ) |
612 | { | 611 | { |
613 | qDebug("ODevice::setDisplayStatus(%d)", on); | 612 | qDebug("ODevice::setDisplayStatus(%d)", on); |
614 | 613 | ||
615 | if ( d-> m_model == Model_Unknown ) | 614 | if ( d-> m_model == Model_Unknown ) |
616 | return false; | 615 | return false; |
617 | 616 | ||
618 | bool res = false; | 617 | bool res = false; |
619 | int fd; | 618 | int fd; |
620 | 619 | ||
621 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 620 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
622 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 621 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
623 | ::close ( fd ); | 622 | ::close ( fd ); |
624 | } | 623 | } |
625 | return res; | 624 | return res; |
626 | } | 625 | } |
627 | 626 | ||
628 | /** | 627 | /** |
629 | * This sets the display brightness | 628 | * This sets the display brightness |
630 | * | 629 | * |
631 | * @param p The brightness to be set on a scale from 0 to 255 | 630 | * @param p The brightness to be set on a scale from 0 to 255 |
632 | * @return success or failure | 631 | * @return success or failure |
633 | */ | 632 | */ |
634 | bool ODevice::setDisplayBrightness ( int p) | 633 | bool ODevice::setDisplayBrightness ( int p) |
635 | { | 634 | { |
636 | Q_UNUSED( p ) | 635 | Q_UNUSED( p ) |
637 | return false; | 636 | return false; |
638 | } | 637 | } |
639 | 638 | ||
640 | /** | 639 | /** |
641 | * @return returns the number of steppings on the brightness slider | 640 | * @return returns the number of steppings on the brightness slider |
642 | * in the Light-'n-Power settings. | 641 | * in the Light-'n-Power settings. |
643 | */ | 642 | */ |
644 | int ODevice::displayBrightnessResolution ( ) const | 643 | int ODevice::displayBrightnessResolution ( ) const |
645 | { | 644 | { |
646 | return 16; | 645 | return 16; |
647 | } | 646 | } |
648 | 647 | ||
649 | /** | 648 | /** |
650 | * This sets the display contrast | 649 | * This sets the display contrast |
651 | * @param p The contrast to be set on a scale from 0 to 255 | 650 | * @param p The contrast to be set on a scale from 0 to 255 |
652 | * @return success or failure | 651 | * @return success or failure |
653 | */ | 652 | */ |
654 | bool ODevice::setDisplayContrast ( int p) | 653 | bool ODevice::setDisplayContrast ( int p) |
655 | { | 654 | { |
656 | Q_UNUSED( p ) | 655 | Q_UNUSED( p ) |
657 | return false; | 656 | return false; |
658 | } | 657 | } |
659 | 658 | ||
660 | /** | 659 | /** |
661 | * @return return the max value for the brightness settings slider | 660 | * @return return the max value for the brightness settings slider |
662 | * or 0 if the device doesn't support setting of a contrast | 661 | * or 0 if the device doesn't support setting of a contrast |
663 | */ | 662 | */ |
664 | int ODevice::displayContrastResolution ( ) const | 663 | int ODevice::displayContrastResolution ( ) const |
665 | { | 664 | { |
666 | return 0; | 665 | return 0; |
667 | } | 666 | } |
668 | 667 | ||
669 | /** | 668 | /** |
670 | * This returns the vendor as string | 669 | * This returns the vendor as string |
671 | * @return Vendor as QString | 670 | * @return Vendor as QString |
672 | */ | 671 | */ |
673 | QString ODevice::vendorString ( ) const | 672 | QString ODevice::vendorString ( ) const |
674 | { | 673 | { |
675 | return d-> m_vendorstr; | 674 | return d-> m_vendorstr; |
676 | } | 675 | } |
677 | 676 | ||
678 | /** | 677 | /** |
679 | * This returns the vendor as one of the values of OVendor | 678 | * This returns the vendor as one of the values of OVendor |
680 | * @return OVendor | 679 | * @return OVendor |
681 | */ | 680 | */ |
682 | OVendor ODevice::vendor ( ) const | 681 | OVendor ODevice::vendor ( ) const |
683 | { | 682 | { |
684 | return d-> m_vendor; | 683 | return d-> m_vendor; |
685 | } | 684 | } |
686 | 685 | ||
687 | /** | 686 | /** |
688 | * This returns the model as a string | 687 | * This returns the model as a string |
689 | * @return A string representing the model | 688 | * @return A string representing the model |
690 | */ | 689 | */ |
691 | QString ODevice::modelString ( ) const | 690 | QString ODevice::modelString ( ) const |
692 | { | 691 | { |
693 | return d-> m_modelstr; | 692 | return d-> m_modelstr; |
694 | } | 693 | } |
695 | 694 | ||
696 | /** | 695 | /** |
697 | * This does return the OModel used | 696 | * This does return the OModel used |
698 | */ | 697 | */ |
699 | OModel ODevice::model ( ) const | 698 | OModel ODevice::model ( ) const |
700 | { | 699 | { |
701 | return d-> m_model; | 700 | return d-> m_model; |
702 | } | 701 | } |
703 | 702 | ||
704 | /** | 703 | /** |
705 | * This does return the systen name | 704 | * This does return the systen name |
706 | */ | 705 | */ |
707 | QString ODevice::systemString ( ) const | 706 | QString ODevice::systemString ( ) const |
708 | { | 707 | { |
709 | return d-> m_systemstr; | 708 | return d-> m_systemstr; |
710 | } | 709 | } |
711 | 710 | ||
712 | /** | 711 | /** |
713 | * Return System as OSystem value | 712 | * Return System as OSystem value |
714 | */ | 713 | */ |
715 | OSystem ODevice::system ( ) const | 714 | OSystem ODevice::system ( ) const |
716 | { | 715 | { |
717 | return d-> m_system; | 716 | return d-> m_system; |
718 | } | 717 | } |
719 | 718 | ||
720 | /** | 719 | /** |
721 | * @return the version string of the base system | 720 | * @return the version string of the base system |
722 | */ | 721 | */ |
723 | QString ODevice::systemVersionString ( ) const | 722 | QString ODevice::systemVersionString ( ) const |
724 | { | 723 | { |
725 | return d-> m_sysverstr; | 724 | return d-> m_sysverstr; |
726 | } | 725 | } |
727 | 726 | ||
728 | /** | 727 | /** |
729 | * @return the current Transformation | 728 | * @return the current Transformation |
730 | */ | 729 | */ |
731 | Transformation ODevice::rotation ( ) const | 730 | Transformation ODevice::rotation ( ) const |
732 | { | 731 | { |
733 | VirtRotation rot; | 732 | VirtRotation rot; |
734 | ODevice* that =(ODevice* )this; | 733 | ODevice* that =(ODevice* )this; |
735 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); | 734 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); |
736 | return rot.trans; | 735 | return rot.trans; |
737 | } | 736 | } |
738 | 737 | ||
739 | /** | 738 | /** |
740 | * @return the current rotation direction | 739 | * @return the current rotation direction |
741 | */ | 740 | */ |
742 | ODirection ODevice::direction ( ) const | 741 | ODirection ODevice::direction ( ) const |
743 | { | 742 | { |
744 | VirtDirection dir; | 743 | VirtDirection dir; |
745 | ODevice* that =(ODevice* )this; | 744 | ODevice* that =(ODevice* )this; |
746 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); | 745 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); |
747 | return dir.direct; | 746 | return dir.direct; |
748 | } | 747 | } |
749 | 748 | ||
750 | /** | 749 | /** |
751 | * This plays an alarmSound | 750 | * This plays an alarmSound |
752 | */ | 751 | */ |
753 | void ODevice::alarmSound ( ) | 752 | void ODevice::alarmSound ( ) |
754 | { | 753 | { |
755 | #ifndef QT_NO_SOUND | 754 | #ifndef QT_NO_SOUND |
756 | static Sound snd ( "alarm" ); | 755 | static Sound snd ( "alarm" ); |
757 | 756 | ||
758 | if ( snd. isFinished ( )) | 757 | if ( snd. isFinished ( )) |
759 | snd. play ( ); | 758 | snd. play ( ); |
760 | #endif | 759 | #endif |
761 | } | 760 | } |
762 | 761 | ||
763 | /** | 762 | /** |
764 | * This plays a key sound | 763 | * This plays a key sound |
765 | */ | 764 | */ |
766 | void ODevice::keySound ( ) | 765 | void ODevice::keySound ( ) |
767 | { | 766 | { |
768 | #ifndef QT_NO_SOUND | 767 | #ifndef QT_NO_SOUND |
769 | static Sound snd ( "keysound" ); | 768 | static Sound snd ( "keysound" ); |
770 | 769 | ||
771 | if ( snd. isFinished ( )) | 770 | if ( snd. isFinished ( )) |
772 | snd. play ( ); | 771 | snd. play ( ); |
773 | #endif | 772 | #endif |
774 | } | 773 | } |
775 | 774 | ||
776 | /** | 775 | /** |
777 | * This plays a touch sound | 776 | * This plays a touch sound |
778 | */ | 777 | */ |
779 | void ODevice::touchSound ( ) | 778 | void ODevice::touchSound ( ) |
780 | { | 779 | { |
781 | #ifndef QT_NO_SOUND | 780 | #ifndef QT_NO_SOUND |
782 | static Sound snd ( "touchsound" ); | 781 | static Sound snd ( "touchsound" ); |
783 | 782 | ||
784 | if ( snd. isFinished ( )) | 783 | if ( snd. isFinished ( )) |
785 | snd. play ( ); | 784 | snd. play ( ); |
786 | #endif | 785 | #endif |
787 | } | 786 | } |
788 | 787 | ||
789 | /** | 788 | /** |
790 | * This method will return a list of leds | 789 | * This method will return a list of leds |
791 | * available on this device | 790 | * available on this device |
792 | * @return a list of LEDs. | 791 | * @return a list of LEDs. |
793 | */ | 792 | */ |
794 | QValueList <OLed> ODevice::ledList ( ) const | 793 | QValueList <OLed> ODevice::ledList ( ) const |
795 | { | 794 | { |
796 | return QValueList <OLed> ( ); | 795 | return QValueList <OLed> ( ); |
797 | } | 796 | } |
798 | 797 | ||
799 | /** | 798 | /** |