author | mickeyl <mickeyl> | 2004-01-13 15:21:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-13 15:21:40 (UTC) |
commit | af79bda4c7e51f46abe67124f9c06126eaebb59d (patch) (unidiff) | |
tree | 4e9ad77ec4b2bb3d66ac6553d0a225b0b18f2140 /libopie2/opiecore/device/odevice.h | |
parent | 24eb97ec5cda3d72c3541fd120568b8d937025f8 (diff) | |
download | opie-af79bda4c7e51f46abe67124f9c06126eaebb59d.zip opie-af79bda4c7e51f46abe67124f9c06126eaebb59d.tar.gz opie-af79bda4c7e51f46abe67124f9c06126eaebb59d.tar.bz2 |
- split odevice into dedicated files and classes, it has getting much too large
- merge odevice into libopie2
- merge oprocctrl and oprocess into libopie2
Diffstat (limited to 'libopie2/opiecore/device/odevice.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 329 |
1 files changed, 329 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h new file mode 100644 index 0000000..bde6411 --- a/dev/null +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -0,0 +1,329 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #ifndef ODEVICE_H_ | ||
31 | #define ODEVICE_H_ | ||
32 | |||
33 | #include <opie2/odevicebutton.h> | ||
34 | |||
35 | /* QT */ | ||
36 | #include <qnamespace.h> | ||
37 | #include <qobject.h> | ||
38 | #include <qstring.h> | ||
39 | #include <qstrlist.h> | ||
40 | |||
41 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | ||
42 | |||
43 | namespace Opie | ||
44 | { | ||
45 | class ODeviceData; | ||
46 | /** | ||
47 | * The available devices | ||
48 | */ | ||
49 | enum OModel { | ||
50 | Model_Unknown, // = 0 | ||
51 | |||
52 | Model_Series_Mask = 0xff000000, | ||
53 | |||
54 | Model_iPAQ = ( 1 << 24 ), | ||
55 | |||
56 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | ||
57 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | ||
58 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | ||
59 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | ||
60 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | ||
61 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | ||
62 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), | ||
63 | |||
64 | Model_Jornada = ( 6 << 24 ), | ||
65 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), | ||
66 | |||
67 | Model_Zaurus = ( 2 << 24 ), | ||
68 | |||
69 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | ||
70 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | ||
71 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | ||
72 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | ||
73 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), | ||
74 | |||
75 | Model_SIMpad = ( 3 << 24 ), | ||
76 | |||
77 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | ||
78 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | ||
79 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | ||
80 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | ||
81 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | ||
82 | |||
83 | Model_Ramses = ( 4 << 24 ), | ||
84 | |||
85 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | ||
86 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | ||
87 | |||
88 | Model_Yopy = ( 5 << 24 ), | ||
89 | |||
90 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), | ||
91 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), | ||
92 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), | ||
93 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), | ||
94 | |||
95 | }; | ||
96 | |||
97 | /** | ||
98 | * The vendor of the device | ||
99 | */ | ||
100 | enum OVendor { | ||
101 | Vendor_Unknown, | ||
102 | |||
103 | Vendor_HP, | ||
104 | Vendor_Sharp, | ||
105 | Vendor_SIEMENS, | ||
106 | Vendor_MundN, | ||
107 | Vendor_GMate, | ||
108 | }; | ||
109 | |||
110 | /** | ||
111 | * The System used | ||
112 | */ | ||
113 | enum OSystem { | ||
114 | System_Unknown, | ||
115 | |||
116 | System_Familiar, | ||
117 | System_Zaurus, | ||
118 | System_OpenZaurus, | ||
119 | System_Linupy, | ||
120 | }; | ||
121 | |||
122 | enum OLedState { | ||
123 | Led_Off, | ||
124 | Led_On, | ||
125 | Led_BlinkSlow, | ||
126 | Led_BlinkFast | ||
127 | }; | ||
128 | |||
129 | enum OLed { | ||
130 | Led_Mail, | ||
131 | Led_Power, | ||
132 | Led_BlueTooth | ||
133 | }; | ||
134 | |||
135 | enum OHardKey { | ||
136 | HardKey_Datebook = Qt::Key_F9, | ||
137 | HardKey_Contacts = Qt::Key_F10, | ||
138 | HardKey_Menu = Qt::Key_F11, | ||
139 | HardKey_Home = Qt::Key_F12, | ||
140 | HardKey_Mail = Qt::Key_F13, | ||
141 | HardKey_Record = Qt::Key_F24, | ||
142 | HardKey_Suspend = Qt::Key_F34, | ||
143 | HardKey_Backlight = Qt::Key_F35, | ||
144 | HardKey_Action = Qt::Key_F10, | ||
145 | HardKey_OK = Qt::Key_F11, | ||
146 | HardKey_End = Qt::Key_F12, | ||
147 | }; | ||
148 | |||
149 | enum ODirection { | ||
150 | CW = 0, | ||
151 | CCW = 1, | ||
152 | Flip = 2, | ||
153 | }; | ||
154 | |||
155 | enum OHingeStatus { | ||
156 | CASE_CLOSED = 3, | ||
157 | CASE_PORTRAIT = 2, | ||
158 | CASE_LANDSCAPE = 0, | ||
159 | CASE_UNKNOWN = 1, | ||
160 | }; | ||
161 | |||
162 | /** | ||
163 | * A singleton which gives informations about device specefic option | ||
164 | * like the Hardware used, LEDs, the Base Distribution and | ||
165 | * hardware key mappings. | ||
166 | * | ||
167 | * @short A small class for device specefic options | ||
168 | * @see QObject | ||
169 | * @author Robert Griebl | ||
170 | * @version 1.0 | ||
171 | */ | ||
172 | class ODevice : public QObject | ||
173 | { | ||
174 | Q_OBJECT | ||
175 | |||
176 | private: | ||
177 | /* disable copy */ | ||
178 | ODevice ( const ODevice & ); | ||
179 | |||
180 | protected: | ||
181 | ODevice(); | ||
182 | virtual void init(); | ||
183 | virtual void initButtons(); | ||
184 | |||
185 | ODeviceData *d; | ||
186 | |||
187 | public: | ||
188 | // sandman do we want to allow destructions? -zecke? | ||
189 | virtual ~ODevice(); | ||
190 | |||
191 | static ODevice *inst(); | ||
192 | |||
193 | // information | ||
194 | |||
195 | QString modelString() const; | ||
196 | OModel model() const; | ||
197 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } | ||
198 | |||
199 | QString vendorString() const; | ||
200 | OVendor vendor() const; | ||
201 | |||
202 | QString systemString() const; | ||
203 | OSystem system() const; | ||
204 | |||
205 | QString systemVersionString() const; | ||
206 | |||
207 | virtual Transformation rotation() const; | ||
208 | virtual ODirection direction() const; | ||
209 | |||
210 | // system | ||
211 | |||
212 | virtual bool setSoftSuspend ( bool on ); | ||
213 | virtual bool suspend(); | ||
214 | |||
215 | virtual bool setDisplayStatus ( bool on ); | ||
216 | virtual bool setDisplayBrightness ( int brightness ); | ||
217 | virtual int displayBrightnessResolution() const; | ||
218 | virtual bool setDisplayContrast ( int contrast ); | ||
219 | virtual int displayContrastResolution() const; | ||
220 | |||
221 | // don't add new virtual methods, use this: | ||
222 | ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; | ||
223 | // and in your subclass do do overwrite | ||
224 | //protected virtual int virtual_hook(int, void *) | ||
225 | // which is defined below | ||
226 | |||
227 | // input / output | ||
228 | //FIXME playAlarmSound and al might be better -zecke | ||
229 | virtual void alarmSound(); | ||
230 | virtual void keySound(); | ||
231 | virtual void touchSound(); | ||
232 | |||
233 | virtual QValueList <OLed> ledList() const; | ||
234 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | ||
235 | virtual OLedState ledState ( OLed led ) const; | ||
236 | virtual bool setLedState ( OLed led, OLedState st ); | ||
237 | |||
238 | virtual bool hasLightSensor() const; | ||
239 | virtual int readLightSensor(); | ||
240 | virtual int lightSensorResolution() const; | ||
241 | |||
242 | virtual bool hasHingeSensor() const; | ||
243 | virtual OHingeStatus readHingeSensor(); | ||
244 | |||
245 | const QStrList &allowedCpuFrequencies() const; | ||
246 | bool setCurrentCpuFrequency(uint index); | ||
247 | |||
248 | /** | ||
249 | * Returns the available buttons on this device. The number and location | ||
250 | * of buttons will vary depending on the device. Button numbers will be assigned | ||
251 | * by the device manufacturer and will be from most preferred button to least preffered | ||
252 | * button. Note that this list only contains "user mappable" buttons. | ||
253 | */ | ||
254 | const QValueList<ODeviceButton> &buttons() /* ### make const */; | ||
255 | |||
256 | /** | ||
257 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | ||
258 | * returns 0L | ||
259 | */ | ||
260 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | ||
261 | |||
262 | /** | ||
263 | * Reassigns the pressed action for \a button. To return to the factory | ||
264 | * default pass an empty string as \a qcopMessage. | ||
265 | */ | ||
266 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | ||
267 | |||
268 | /** | ||
269 | * Reassigns the held action for \a button. To return to the factory | ||
270 | * default pass an empty string as \a qcopMessage. | ||
271 | */ | ||
272 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | ||
273 | |||
274 | /** | ||
275 | * How long (in ms) you have to press a button for a "hold" action | ||
276 | */ | ||
277 | uint buttonHoldTime() const; | ||
278 | |||
279 | signals: | ||
280 | void buttonMappingChanged(); | ||
281 | |||
282 | private slots: | ||
283 | void systemMessage ( const QCString &, const QByteArray & ); | ||
284 | |||
285 | protected: | ||
286 | void reloadButtonMapping(); | ||
287 | /* ugly virtual hook */ | ||
288 | virtual void virtual_hook( int id, void* data ); | ||
289 | }; | ||
290 | |||
291 | class ODeviceData { | ||
292 | |||
293 | public: | ||
294 | QString m_vendorstr; | ||
295 | OVendor m_vendor; | ||
296 | |||
297 | QString m_modelstr; | ||
298 | OModel m_model; | ||
299 | |||
300 | QString m_systemstr; | ||
301 | OSystem m_system; | ||
302 | |||
303 | QString m_sysverstr; | ||
304 | |||
305 | Transformation m_rotation; | ||
306 | ODirection m_direction; | ||
307 | |||
308 | QValueList <ODeviceButton> *m_buttons; | ||
309 | uint m_holdtime; | ||
310 | QStrList *m_cpu_frequencies; | ||
311 | }; | ||
312 | |||
313 | } | ||
314 | |||
315 | static inline bool isQWS() | ||
316 | { | ||
317 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | ||
318 | } | ||
319 | |||
320 | static QCString makeChannel ( const char *str ) | ||
321 | { | ||
322 | if ( str && !::strchr ( str, '/' )) | ||
323 | return QCString ( "QPE/Application/" ) + str; | ||
324 | else | ||
325 | return str; | ||
326 | } | ||
327 | |||
328 | #endif | ||
329 | |||