summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 56f305f..62bb68a 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,236 +1,238 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30 30
31#include "odevice_beagle.h" 31#include "odevice_beagle.h"
32#include "odevice_ipaq.h" 32#include "odevice_ipaq.h"
33#include "odevice_mypal.h"
33#include "odevice_jornada.h" 34#include "odevice_jornada.h"
34#include "odevice_ramses.h" 35#include "odevice_ramses.h"
35#include "odevice_simpad.h" 36#include "odevice_simpad.h"
36#include "odevice_yopy.h" 37#include "odevice_yopy.h"
37#include "odevice_zaurus.h" 38#include "odevice_zaurus.h"
38#include "odevice_genuineintel.h" 39#include "odevice_genuineintel.h"
39 40
40/* QT */ 41/* QT */
41#include <qapplication.h> 42#include <qapplication.h>
42#include <qfile.h> 43#include <qfile.h>
43#include <qtextstream.h> 44#include <qtextstream.h>
44#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
45 46
46/* OPIE */ 47/* OPIE */
47#include <qpe/config.h> 48#include <qpe/config.h>
48#include <qpe/sound.h> 49#include <qpe/sound.h>
49#include <qpe/qcopenvelope_qws.h> 50#include <qpe/qcopenvelope_qws.h>
50#include <qpe/sound.h> 51#include <qpe/sound.h>
51 52
52#include <opie2/okeyfilter.h> 53#include <opie2/okeyfilter.h>
53#include <opie2/oresource.h> 54#include <opie2/oresource.h>
54 55
55/* STD */ 56/* STD */
56#include <fcntl.h> 57#include <fcntl.h>
57#include <math.h> 58#include <math.h>
58#include <stdlib.h> 59#include <stdlib.h>
59#include <signal.h> 60#include <signal.h>
60#include <sys/ioctl.h> 61#include <sys/ioctl.h>
61#include <sys/time.h> 62#include <sys/time.h>
62#include <unistd.h> 63#include <unistd.h>
63#ifndef QT_NO_SOUND 64#ifndef QT_NO_SOUND
64#include <linux/soundcard.h> 65#include <linux/soundcard.h>
65#endif 66#endif
66 67
67namespace Opie { 68namespace Opie {
68namespace Core { 69namespace Core {
69 70
70static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 71static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
71 72
72 73
73/* STATIC and common implementation */ 74/* STATIC and common implementation */
74/* EXPORT */ ODistribution distributions[] = { 75/* EXPORT */ ODistribution distributions[] = {
75 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 76 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
76 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 77 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
77 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 78 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
78 { System_Unknown, "Linux", "/etc/issue" }, 79 { System_Unknown, "Linux", "/etc/issue" },
79}; 80};
80 81
81 82
82/* EXPORT */ bool isQWS(){ 83/* EXPORT */ bool isQWS(){
83 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 84 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
84} 85}
85 86
86/* EXPORT */ QCString makeChannel ( const char *str ){ 87/* EXPORT */ QCString makeChannel ( const char *str ){
87 if ( str && !::strchr ( str, '/' )) 88 if ( str && !::strchr ( str, '/' ))
88 return QCString ( "QPE/Application/" ) + str; 89 return QCString ( "QPE/Application/" ) + str;
89 else 90 else
90 return str; 91 return str;
91} 92}
92 93
93 94
94 95
95/* Now the default implementation of ODevice */ 96/* Now the default implementation of ODevice */
96 97
97struct default_button default_buttons [] = { 98struct default_button default_buttons [] = {
98 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 99 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
99 "devicebuttons/z_calendar", 100 "devicebuttons/z_calendar",
100 "datebook", "nextView()", 101 "datebook", "nextView()",
101 "today", "raise()" }, 102 "today", "raise()" },
102 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 103 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
103 "devicebuttons/z_contact", 104 "devicebuttons/z_contact",
104 "addressbook", "raise()", 105 "addressbook", "raise()",
105 "addressbook", "beamBusinessCard()" }, 106 "addressbook", "beamBusinessCard()" },
106 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 107 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
107 "devicebuttons/z_home", 108 "devicebuttons/z_home",
108 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
109 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
110 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 111 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
111 "devicebuttons/z_menu", 112 "devicebuttons/z_menu",
112 "QPE/TaskBar", "toggleMenu()", 113 "QPE/TaskBar", "toggleMenu()",
113 "QPE/TaskBar", "toggleStartMenu()" }, 114 "QPE/TaskBar", "toggleStartMenu()" },
114 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 115 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
115 "devicebuttons/z_mail", 116 "devicebuttons/z_mail",
116 "opiemail", "raise()", 117 "opiemail", "raise()",
117 "opiemail", "newMail()" }, 118 "opiemail", "newMail()" },
118}; 119};
119 120
120ODevice *ODevice::inst() 121ODevice *ODevice::inst()
121{ 122{
122 static ODevice *dev = 0; 123 static ODevice *dev = 0;
123 QString cpu_info; 124 QString cpu_info;
124 125
125 if ( !dev ) 126 if ( !dev )
126 { 127 {
127 QFile f( PATH_PROC_CPUINFO ); 128 QFile f( PATH_PROC_CPUINFO );
128 if ( f.open( IO_ReadOnly ) ) 129 if ( f.open( IO_ReadOnly ) )
129 { 130 {
130 QTextStream s( &f ); 131 QTextStream s( &f );
131 while ( !s.atEnd() ) 132 while ( !s.atEnd() )
132 { 133 {
133 QString line; 134 QString line;
134 line = s.readLine(); 135 line = s.readLine();
135 if ( line.startsWith( "Hardware" ) ) 136 if ( line.startsWith( "Hardware" ) )
136 { 137 {
137 qDebug( "ODevice() - found '%s'", (const char*) line ); 138 qDebug( "ODevice() - found '%s'", (const char*) line );
138 cpu_info = line; 139 cpu_info = line;
139 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 140 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
140 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 141 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
142 else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal();
141 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 143 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
142 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 144 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
143 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 145 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
144 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 146 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
145 else qWarning( "ODevice() - unknown hardware - using default." ); 147 else qWarning( "ODevice() - unknown hardware - using default." );
146 break; 148 break;
147 } else if ( line.startsWith( "vendor_id" ) ) { 149 } else if ( line.startsWith( "vendor_id" ) ) {
148 qDebug( "ODevice() - found '%s'", (const char*) line ); 150 qDebug( "ODevice() - found '%s'", (const char*) line );
149 cpu_info = line; 151 cpu_info = line;
150 if( line.contains( "genuineintel", false ) ) { 152 if( line.contains( "genuineintel", false ) ) {
151 dev = new Internal::GenuineIntel(); 153 dev = new Internal::GenuineIntel();
152 break; 154 break;
153 } 155 }
154 } 156 }
155 } 157 }
156 } 158 }
157 else 159 else
158 { 160 {
159 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 161 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
160 } 162 }
161 if ( !dev ) dev = new ODevice(); 163 if ( !dev ) dev = new ODevice();
162 dev->init(cpu_info); 164 dev->init(cpu_info);
163 } 165 }
164 return dev; 166 return dev;
165} 167}
166 168
167ODevice::ODevice() 169ODevice::ODevice()
168{ 170{
169 d = new ODeviceData; 171 d = new ODeviceData;
170 172
171 d->m_modelstr = "Unknown"; 173 d->m_modelstr = "Unknown";
172 d->m_model = Model_Unknown; 174 d->m_model = Model_Unknown;
173 d->m_vendorstr = "Unknown"; 175 d->m_vendorstr = "Unknown";
174 d->m_vendor = Vendor_Unknown; 176 d->m_vendor = Vendor_Unknown;
175 d->m_systemstr = "Unknown"; 177 d->m_systemstr = "Unknown";
176 d->m_system = System_Unknown; 178 d->m_system = System_Unknown;
177 d->m_sysverstr = "0.0"; 179 d->m_sysverstr = "0.0";
178 d->m_rotation = Rot0; 180 d->m_rotation = Rot0;
179 d->m_direction = CW; 181 d->m_direction = CW;
180 d->m_qteDriver = "Transformed"; 182 d->m_qteDriver = "Transformed";
181 183
182 d->m_holdtime = 1000; // 1000ms 184 d->m_holdtime = 1000; // 1000ms
183 d->m_buttons = 0; 185 d->m_buttons = 0;
184 d->m_cpu_frequencies = new QStrList; 186 d->m_cpu_frequencies = new QStrList;
185 187
186 188
187 /* mixer */ 189 /* mixer */
188 d->m_sound = d->m_vol = d->m_mixer = -1; 190 d->m_sound = d->m_vol = d->m_mixer = -1;
189 191
190 /* System QCopChannel created */ 192 /* System QCopChannel created */
191 d->m_initializedButtonQcop = false; 193 d->m_initializedButtonQcop = false;
192 194
193 // New distribution detection code first checks for legacy distributions, 195 // New distribution detection code first checks for legacy distributions,
194 // identified by /etc/familiar-version or /etc/oz_version. 196 // identified by /etc/familiar-version or /etc/oz_version.
195 // Then check for OpenEmbedded and lastly, read /etc/issue 197 // Then check for OpenEmbedded and lastly, read /etc/issue
196 198
197 for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) 199 for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i )
198 { 200 {
199 if ( QFile::exists( distributions[i].sysvfile ) ) 201 if ( QFile::exists( distributions[i].sysvfile ) )
200 { 202 {
201 d->m_systemstr = distributions[i].sysstr; 203 d->m_systemstr = distributions[i].sysstr;
202 d->m_system = distributions[i].system; 204 d->m_system = distributions[i].system;
203 d->m_sysverstr = "<Unknown>"; 205 d->m_sysverstr = "<Unknown>";
204 QFile f( distributions[i].sysvfile ); 206 QFile f( distributions[i].sysvfile );
205 if ( f.open( IO_ReadOnly ) ) 207 if ( f.open( IO_ReadOnly ) )
206 { 208 {
207 QTextStream ts( &f ); 209 QTextStream ts( &f );
208 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 210 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
209 } 211 }
210 break; 212 break;
211 } 213 }
212 } 214 }
213} 215}
214 216
215void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 217void ODevice::systemMessage( const QCString &msg, const QByteArray & )
216{ 218{
217 if ( msg == "deviceButtonMappingChanged()" ) { 219 if ( msg == "deviceButtonMappingChanged()" ) {
218 reloadButtonMapping(); 220 reloadButtonMapping();
219 } 221 }
220} 222}
221 223
222void ODevice::init(const QString&) 224void ODevice::init(const QString&)
223{ 225{
224} 226}
225 227
226/** 228/**
227* This method initialises the button mapping 229* This method initialises the button mapping
228*/ 230*/
229void ODevice::initButtons() 231void ODevice::initButtons()
230{ 232{
231 if ( d->m_buttons ) 233 if ( d->m_buttons )
232 return; 234 return;
233 235
234 qDebug ( "init Buttons" ); 236 qDebug ( "init Buttons" );
235 d->m_buttons = new QValueList <ODeviceButton>; 237 d->m_buttons = new QValueList <ODeviceButton>;
236 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 238 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {