Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 62a2e03..cef7f63 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -45,157 +45,159 @@ _;:, .> :=|. This program is free software; you can | |||
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 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
62 | 62 | ||
63 | using namespace Opie::Core; | 63 | using namespace Opie::Core; |
64 | 64 | ||
65 | struct default_button default_buttons [] = { | 65 | struct default_button default_buttons [] = { |
66 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 66 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
67 | "devicebuttons/z_calendar", | 67 | "devicebuttons/z_calendar", |
68 | "datebook", "nextView()", | 68 | "datebook", "nextView()", |
69 | "today", "raise()" }, | 69 | "today", "raise()" }, |
70 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 70 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
71 | "devicebuttons/z_contact", | 71 | "devicebuttons/z_contact", |
72 | "addressbook", "raise()", | 72 | "addressbook", "raise()", |
73 | "addressbook", "beamBusinessCard()" }, | 73 | "addressbook", "beamBusinessCard()" }, |
74 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 74 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
75 | "devicebuttons/z_home", | 75 | "devicebuttons/z_home", |
76 | "QPE/Launcher", "home()", | 76 | "QPE/Launcher", "home()", |
77 | "buttonsettings", "raise()" }, | 77 | "buttonsettings", "raise()" }, |
78 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 78 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
79 | "devicebuttons/z_menu", | 79 | "devicebuttons/z_menu", |
80 | "QPE/TaskBar", "toggleMenu()", | 80 | "QPE/TaskBar", "toggleMenu()", |
81 | "QPE/TaskBar", "toggleStartMenu()" }, | 81 | "QPE/TaskBar", "toggleStartMenu()" }, |
82 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 82 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
83 | "devicebuttons/z_mail", | 83 | "devicebuttons/z_mail", |
84 | "opiemail", "raise()", | 84 | "opiemail", "raise()", |
85 | "opiemail", "newMail()" }, | 85 | "opiemail", "newMail()" }, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | ODevice *ODevice::inst() | 88 | ODevice *ODevice::inst() |
89 | { | 89 | { |
90 | static ODevice *dev = 0; | 90 | static ODevice *dev = 0; |
91 | 91 | ||
92 | // rewrite this to only use /proc/cpuinfo or so | 92 | // rewrite this to only use /proc/cpuinfo or so |
93 | QString cpu_info; | ||
93 | 94 | ||
94 | if ( !dev ) | 95 | if ( !dev ) |
95 | { | 96 | { |
96 | QFile f( PATH_PROC_CPUINFO ); | 97 | QFile f( PATH_PROC_CPUINFO ); |
97 | if ( f.open( IO_ReadOnly ) ) | 98 | if ( f.open( IO_ReadOnly ) ) |
98 | { | 99 | { |
99 | QTextStream s( &f ); | 100 | QTextStream s( &f ); |
100 | while ( !s.atEnd() ) | 101 | while ( !s.atEnd() ) |
101 | { | 102 | { |
102 | QString line; | 103 | QString line; |
103 | line = s.readLine(); | 104 | line = s.readLine(); |
104 | if ( line.startsWith( "Hardware" ) ) | 105 | if ( line.startsWith( "Hardware" ) ) |
105 | { | 106 | { |
106 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 107 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
108 | cpu_info = line; | ||
107 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 109 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
108 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 110 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
109 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 111 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
110 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 112 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
111 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 113 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
112 | else qWarning( "ODevice() - unknown hardware - using default." ); | 114 | else qWarning( "ODevice() - unknown hardware - using default." ); |
113 | break; | 115 | break; |
114 | } | 116 | } |
115 | } | 117 | } |
116 | } | 118 | } |
117 | else | 119 | else |
118 | { | 120 | { |
119 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 121 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
120 | } | 122 | } |
121 | if ( !dev ) dev = new ODevice(); | 123 | if ( !dev ) dev = new ODevice(); |
122 | dev->init(); | 124 | dev->init(cpu_info); |
123 | } | 125 | } |
124 | return dev; | 126 | return dev; |
125 | } | 127 | } |
126 | 128 | ||
127 | ODevice::ODevice() | 129 | ODevice::ODevice() |
128 | { | 130 | { |
129 | d = new ODeviceData; | 131 | d = new ODeviceData; |
130 | 132 | ||
131 | d->m_modelstr = "Unknown"; | 133 | d->m_modelstr = "Unknown"; |
132 | d->m_model = Model_Unknown; | 134 | d->m_model = Model_Unknown; |
133 | d->m_vendorstr = "Unknown"; | 135 | d->m_vendorstr = "Unknown"; |
134 | d->m_vendor = Vendor_Unknown; | 136 | d->m_vendor = Vendor_Unknown; |
135 | d->m_systemstr = "Unknown"; | 137 | d->m_systemstr = "Unknown"; |
136 | d->m_system = System_Unknown; | 138 | d->m_system = System_Unknown; |
137 | d->m_sysverstr = "0.0"; | 139 | d->m_sysverstr = "0.0"; |
138 | d->m_rotation = Rot0; | 140 | d->m_rotation = Rot0; |
139 | d->m_direction = CW; | 141 | d->m_direction = CW; |
140 | 142 | ||
141 | d->m_holdtime = 1000; // 1000ms | 143 | d->m_holdtime = 1000; // 1000ms |
142 | d->m_buttons = 0; | 144 | d->m_buttons = 0; |
143 | d->m_cpu_frequencies = new QStrList; | 145 | d->m_cpu_frequencies = new QStrList; |
144 | } | 146 | } |
145 | 147 | ||
146 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 148 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
147 | { | 149 | { |
148 | if ( msg == "deviceButtonMappingChanged()" ) { | 150 | if ( msg == "deviceButtonMappingChanged()" ) { |
149 | reloadButtonMapping(); | 151 | reloadButtonMapping(); |
150 | } | 152 | } |
151 | } | 153 | } |
152 | 154 | ||
153 | void ODevice::init() | 155 | void ODevice::init(const QString&) |
154 | { | 156 | { |
155 | } | 157 | } |
156 | 158 | ||
157 | /** | 159 | /** |
158 | * This method initialises the button mapping | 160 | * This method initialises the button mapping |
159 | */ | 161 | */ |
160 | void ODevice::initButtons() | 162 | void ODevice::initButtons() |
161 | { | 163 | { |
162 | if ( d->m_buttons ) | 164 | if ( d->m_buttons ) |
163 | return; | 165 | return; |
164 | 166 | ||
165 | qDebug ( "init Buttons" ); | 167 | qDebug ( "init Buttons" ); |
166 | d->m_buttons = new QValueList <ODeviceButton>; | 168 | d->m_buttons = new QValueList <ODeviceButton>; |
167 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 169 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
168 | default_button *db = default_buttons + i; | 170 | default_button *db = default_buttons + i; |
169 | ODeviceButton b; | 171 | ODeviceButton b; |
170 | b. setKeycode ( db->code ); | 172 | b. setKeycode ( db->code ); |
171 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 173 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
172 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 174 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
173 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 175 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
174 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 176 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
175 | d->m_buttons->append ( b ); | 177 | d->m_buttons->append ( b ); |
176 | } | 178 | } |
177 | 179 | ||
178 | reloadButtonMapping(); | 180 | reloadButtonMapping(); |
179 | 181 | ||
180 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 182 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
181 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 183 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
182 | } | 184 | } |
183 | 185 | ||
184 | ODevice::~ODevice() | 186 | ODevice::~ODevice() |
185 | { | 187 | { |
186 | // we leak m_devicebuttons and m_cpu_frequency | 188 | // we leak m_devicebuttons and m_cpu_frequency |
187 | // but it's a singleton and it is not so importantant | 189 | // but it's a singleton and it is not so importantant |
188 | // -zecke | 190 | // -zecke |
189 | delete d; | 191 | delete d; |
190 | } | 192 | } |
191 | 193 | ||
192 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 194 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
193 | { | 195 | { |
194 | return false; | 196 | return false; |
195 | } | 197 | } |
196 | 198 | ||
197 | //#include <linux/apm_bios.h> | 199 | //#include <linux/apm_bios.h> |
198 | 200 | ||
199 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 201 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
200 | 202 | ||
201 | /** | 203 | /** |