-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 34 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 21 |
2 files changed, 35 insertions, 20 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 5b73e59..0068d88 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -29,67 +29,93 @@ | |||
29 | 29 | ||
30 | #include "odevice_ipaq.h" | 30 | #include "odevice_ipaq.h" |
31 | #include "odevice_jornada.h" | 31 | #include "odevice_jornada.h" |
32 | #include "odevice_ramses.h" | 32 | #include "odevice_ramses.h" |
33 | #include "odevice_simpad.h" | 33 | #include "odevice_simpad.h" |
34 | #include "odevice_yopy.h" | 34 | #include "odevice_yopy.h" |
35 | #include "odevice_zaurus.h" | 35 | #include "odevice_zaurus.h" |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
42 | 42 | ||
43 | /* OPIE */ | 43 | /* OPIE */ |
44 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
45 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
46 | #include <qpe/sound.h> | 46 | #include <qpe/sound.h> |
47 | #include <qpe/qcopenvelope_qws.h> | 47 | #include <qpe/qcopenvelope_qws.h> |
48 | 48 | ||
49 | /* STD */ | 49 | /* STD */ |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> |
51 | #include <math.h> | 51 | #include <math.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | #include <signal.h> | 53 | #include <signal.h> |
54 | #include <sys/ioctl.h> | 54 | #include <sys/ioctl.h> |
55 | #include <sys/time.h> | 55 | #include <sys/time.h> |
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #ifndef QT_NO_SOUND | 57 | #ifndef QT_NO_SOUND |
58 | #include <linux/soundcard.h> | 58 | #include <linux/soundcard.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 61 | namespace Opie { |
62 | namespace Core { | ||
62 | 63 | ||
63 | using namespace Opie::Core; | 64 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
65 | |||
66 | |||
67 | /* STATIC and common implementation */ | ||
68 | /* EXPORT */ ODistribution distributions[] = { | ||
69 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | ||
70 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | ||
71 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | ||
72 | { System_Unknown, "Linux", "/etc/issue" }, | ||
73 | }; | ||
74 | |||
75 | |||
76 | /* EXPORT */ bool isQWS(){ | ||
77 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | ||
78 | } | ||
79 | |||
80 | /* EXPORT */ QCString makeChannel ( const char *str ){ | ||
81 | if ( str && !::strchr ( str, '/' )) | ||
82 | return QCString ( "QPE/Application/" ) + str; | ||
83 | else | ||
84 | return str; | ||
85 | } | ||
86 | |||
87 | |||
88 | |||
89 | /* Now the default implementation of ODevice */ | ||
64 | 90 | ||
65 | struct default_button default_buttons [] = { | 91 | struct default_button default_buttons [] = { |
66 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 92 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
67 | "devicebuttons/z_calendar", | 93 | "devicebuttons/z_calendar", |
68 | "datebook", "nextView()", | 94 | "datebook", "nextView()", |
69 | "today", "raise()" }, | 95 | "today", "raise()" }, |
70 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 96 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
71 | "devicebuttons/z_contact", | 97 | "devicebuttons/z_contact", |
72 | "addressbook", "raise()", | 98 | "addressbook", "raise()", |
73 | "addressbook", "beamBusinessCard()" }, | 99 | "addressbook", "beamBusinessCard()" }, |
74 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 100 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
75 | "devicebuttons/z_home", | 101 | "devicebuttons/z_home", |
76 | "QPE/Launcher", "home()", | 102 | "QPE/Launcher", "home()", |
77 | "buttonsettings", "raise()" }, | 103 | "buttonsettings", "raise()" }, |
78 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 104 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
79 | "devicebuttons/z_menu", | 105 | "devicebuttons/z_menu", |
80 | "QPE/TaskBar", "toggleMenu()", | 106 | "QPE/TaskBar", "toggleMenu()", |
81 | "QPE/TaskBar", "toggleStartMenu()" }, | 107 | "QPE/TaskBar", "toggleStartMenu()" }, |
82 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 108 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
83 | "devicebuttons/z_mail", | 109 | "devicebuttons/z_mail", |
84 | "opiemail", "raise()", | 110 | "opiemail", "raise()", |
85 | "opiemail", "newMail()" }, | 111 | "opiemail", "newMail()" }, |
86 | }; | 112 | }; |
87 | 113 | ||
88 | ODevice *ODevice::inst() | 114 | ODevice *ODevice::inst() |
89 | { | 115 | { |
90 | static ODevice *dev = 0; | 116 | static ODevice *dev = 0; |
91 | 117 | ||
92 | // rewrite this to only use /proc/cpuinfo or so | 118 | // rewrite this to only use /proc/cpuinfo or so |
93 | QString cpu_info; | 119 | QString cpu_info; |
94 | 120 | ||
95 | if ( !dev ) | 121 | if ( !dev ) |
@@ -656,32 +682,36 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | |||
656 | } | 682 | } |
657 | 683 | ||
658 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 684 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
659 | { | 685 | { |
660 | initButtons(); | 686 | initButtons(); |
661 | 687 | ||
662 | if ( button >= (int) d->m_buttons->count()) | 688 | if ( button >= (int) d->m_buttons->count()) |
663 | return; | 689 | return; |
664 | 690 | ||
665 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 691 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
666 | b. setHeldAction ( action ); | 692 | b. setHeldAction ( action ); |
667 | 693 | ||
668 | Config buttonFile ( "ButtonSettings" ); | 694 | Config buttonFile ( "ButtonSettings" ); |
669 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 695 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
670 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 696 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
671 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 697 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
672 | 698 | ||
673 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 699 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
674 | 700 | ||
675 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 701 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
676 | } | 702 | } |
677 | void ODevice::virtual_hook(int, void* ){ | 703 | void ODevice::virtual_hook(int, void* ){ |
678 | 704 | ||
679 | } | 705 | } |
680 | 706 | ||
681 | void ODevice::sendSuspendmsg() | 707 | void ODevice::sendSuspendmsg() |
682 | { | 708 | { |
683 | if ( isQWS() ) | 709 | if ( isQWS() ) |
684 | return; | 710 | return; |
685 | 711 | ||
686 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 712 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
687 | } | 713 | } |
714 | |||
715 | |||
716 | } | ||
717 | } | ||
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 474d792..0465d7e 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -105,72 +105,66 @@ enum OModel { | |||
105 | * The vendor of the device | 105 | * The vendor of the device |
106 | */ | 106 | */ |
107 | enum OVendor { | 107 | enum OVendor { |
108 | Vendor_Unknown, | 108 | Vendor_Unknown, |
109 | 109 | ||
110 | Vendor_HP, | 110 | Vendor_HP, |
111 | Vendor_Sharp, | 111 | Vendor_Sharp, |
112 | Vendor_SIEMENS, | 112 | Vendor_SIEMENS, |
113 | Vendor_MundN, | 113 | Vendor_MundN, |
114 | Vendor_GMate, | 114 | Vendor_GMate, |
115 | Vendor_MasterIA, | 115 | Vendor_MasterIA, |
116 | }; | 116 | }; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * The System used | 119 | * The System used |
120 | */ | 120 | */ |
121 | enum OSystem { | 121 | enum OSystem { |
122 | System_Unknown, | 122 | System_Unknown, |
123 | 123 | ||
124 | System_Familiar, | 124 | System_Familiar, |
125 | System_Zaurus, | 125 | System_Zaurus, |
126 | System_OpenZaurus, | 126 | System_OpenZaurus, |
127 | System_Linupy, | 127 | System_Linupy, |
128 | System_OpenEmbedded, | 128 | System_OpenEmbedded, |
129 | }; | 129 | }; |
130 | 130 | ||
131 | typedef struct { | 131 | typedef struct { |
132 | OSystem system; | 132 | OSystem system; |
133 | char* sysstr; | 133 | char* sysstr; |
134 | char* sysvfile; | 134 | char* sysvfile; |
135 | } ODistribution; | 135 | } ODistribution; |
136 | 136 | ||
137 | static ODistribution distributions[] = | 137 | extern ODistribution distributions[]; |
138 | { | ||
139 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | ||
140 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | ||
141 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | ||
142 | { System_Unknown, "Linux", "/etc/issue" }, | ||
143 | 138 | ||
144 | }; | ||
145 | 139 | ||
146 | enum OLedState { | 140 | enum OLedState { |
147 | Led_Off, | 141 | Led_Off, |
148 | Led_On, | 142 | Led_On, |
149 | Led_BlinkSlow, | 143 | Led_BlinkSlow, |
150 | Led_BlinkFast | 144 | Led_BlinkFast |
151 | }; | 145 | }; |
152 | 146 | ||
153 | enum OLed { | 147 | enum OLed { |
154 | Led_Mail, | 148 | Led_Mail, |
155 | Led_Power, | 149 | Led_Power, |
156 | Led_BlueTooth | 150 | Led_BlueTooth |
157 | }; | 151 | }; |
158 | 152 | ||
159 | enum OHardKey { | 153 | enum OHardKey { |
160 | HardKey_Datebook = Qt::Key_F9, | 154 | HardKey_Datebook = Qt::Key_F9, |
161 | HardKey_Contacts = Qt::Key_F10, | 155 | HardKey_Contacts = Qt::Key_F10, |
162 | HardKey_Menu = Qt::Key_F11, | 156 | HardKey_Menu = Qt::Key_F11, |
163 | HardKey_Home = Qt::Key_F12, | 157 | HardKey_Home = Qt::Key_F12, |
164 | HardKey_Mail = Qt::Key_F13, | 158 | HardKey_Mail = Qt::Key_F13, |
165 | HardKey_Record = Qt::Key_F24, | 159 | HardKey_Record = Qt::Key_F24, |
166 | HardKey_Suspend = Qt::Key_F34, | 160 | HardKey_Suspend = Qt::Key_F34, |
167 | HardKey_Backlight = Qt::Key_F35, | 161 | HardKey_Backlight = Qt::Key_F35, |
168 | HardKey_Action = Qt::Key_F10, | 162 | HardKey_Action = Qt::Key_F10, |
169 | HardKey_OK = Qt::Key_F11, | 163 | HardKey_OK = Qt::Key_F11, |
170 | HardKey_End = Qt::Key_F12, | 164 | HardKey_End = Qt::Key_F12, |
171 | }; | 165 | }; |
172 | 166 | ||
173 | enum ODirection { | 167 | enum ODirection { |
174 | CW = 0, | 168 | CW = 0, |
175 | CCW = 1, | 169 | CCW = 1, |
176 | Flip = 2, | 170 | Flip = 2, |
@@ -323,51 +317,42 @@ signals: | |||
323 | 317 | ||
324 | private slots: | 318 | private slots: |
325 | void systemMessage ( const QCString &, const QByteArray & ); | 319 | void systemMessage ( const QCString &, const QByteArray & ); |
326 | 320 | ||
327 | protected: | 321 | protected: |
328 | void reloadButtonMapping(); | 322 | void reloadButtonMapping(); |
329 | /* ugly virtual hook */ | 323 | /* ugly virtual hook */ |
330 | virtual void virtual_hook( int id, void* data ); | 324 | virtual void virtual_hook( int id, void* data ); |
331 | }; | 325 | }; |
332 | 326 | ||
333 | class ODeviceData { | 327 | class ODeviceData { |
334 | 328 | ||
335 | public: | 329 | public: |
336 | QString m_vendorstr; | 330 | QString m_vendorstr; |
337 | OVendor m_vendor; | 331 | OVendor m_vendor; |
338 | 332 | ||
339 | QString m_modelstr; | 333 | QString m_modelstr; |
340 | OModel m_model; | 334 | OModel m_model; |
341 | 335 | ||
342 | QString m_systemstr; | 336 | QString m_systemstr; |
343 | OSystem m_system; | 337 | OSystem m_system; |
344 | 338 | ||
345 | QString m_sysverstr; | 339 | QString m_sysverstr; |
346 | 340 | ||
347 | Transformation m_rotation; | 341 | Transformation m_rotation; |
348 | ODirection m_direction; | 342 | ODirection m_direction; |
349 | 343 | ||
350 | QValueList <ODeviceButton> *m_buttons; | 344 | QValueList <ODeviceButton> *m_buttons; |
351 | uint m_holdtime; | 345 | uint m_holdtime; |
352 | QStrList *m_cpu_frequencies; | 346 | QStrList *m_cpu_frequencies; |
353 | }; | 347 | }; |
354 | 348 | ||
349 | extern bool isQWS(); | ||
350 | extern QCString makeChannel ( const char *str ); | ||
355 | } | 351 | } |
356 | } | 352 | } |
357 | 353 | ||
358 | static inline bool isQWS() | ||
359 | { | ||
360 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | ||
361 | } | ||
362 | 354 | ||
363 | static QCString makeChannel ( const char *str ) | ||
364 | { | ||
365 | if ( str && !::strchr ( str, '/' )) | ||
366 | return QCString ( "QPE/Application/" ) + str; | ||
367 | else | ||
368 | return str; | ||
369 | } | ||
370 | 355 | ||
371 | 356 | ||
372 | #endif | 357 | #endif |
373 | 358 | ||