summaryrefslogtreecommitdiff
path: root/libopie2
authorhrw <hrw>2006-01-23 13:33:31 (UTC)
committer hrw <hrw>2006-01-23 13:33:31 (UTC)
commitdccddc207399669495ec0f5b4c6faa0d5159dc87 (patch) (unidiff)
treefa9cfb30b34d67a20bf11dd6d88c01596b3e4aeb /libopie2
parentd5a4ddcb27db77d41de3f6a66bef4227c33d925e (diff)
downloadopie-dccddc207399669495ec0f5b4c6faa0d5159dc87.zip
opie-dccddc207399669495ec0f5b4c6faa0d5159dc87.tar.gz
opie-dccddc207399669495ec0f5b4c6faa0d5159dc87.tar.bz2
libopiecore: /etc/oz_version renamed to /etc/openzaurus-version
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 62bb68a..7b99eb4 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,269 +1,269 @@
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_mypal.h"
34#include "odevice_jornada.h" 34#include "odevice_jornada.h"
35#include "odevice_ramses.h" 35#include "odevice_ramses.h"
36#include "odevice_simpad.h" 36#include "odevice_simpad.h"
37#include "odevice_yopy.h" 37#include "odevice_yopy.h"
38#include "odevice_zaurus.h" 38#include "odevice_zaurus.h"
39#include "odevice_genuineintel.h" 39#include "odevice_genuineintel.h"
40 40
41/* QT */ 41/* QT */
42#include <qapplication.h> 42#include <qapplication.h>
43#include <qfile.h> 43#include <qfile.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
46 46
47/* OPIE */ 47/* OPIE */
48#include <qpe/config.h> 48#include <qpe/config.h>
49#include <qpe/sound.h> 49#include <qpe/sound.h>
50#include <qpe/qcopenvelope_qws.h> 50#include <qpe/qcopenvelope_qws.h>
51#include <qpe/sound.h> 51#include <qpe/sound.h>
52 52
53#include <opie2/okeyfilter.h> 53#include <opie2/okeyfilter.h>
54#include <opie2/oresource.h> 54#include <opie2/oresource.h>
55 55
56/* STD */ 56/* STD */
57#include <fcntl.h> 57#include <fcntl.h>
58#include <math.h> 58#include <math.h>
59#include <stdlib.h> 59#include <stdlib.h>
60#include <signal.h> 60#include <signal.h>
61#include <sys/ioctl.h> 61#include <sys/ioctl.h>
62#include <sys/time.h> 62#include <sys/time.h>
63#include <unistd.h> 63#include <unistd.h>
64#ifndef QT_NO_SOUND 64#ifndef QT_NO_SOUND
65#include <linux/soundcard.h> 65#include <linux/soundcard.h>
66#endif 66#endif
67 67
68namespace Opie { 68namespace Opie {
69namespace Core { 69namespace Core {
70 70
71static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 71static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
72 72
73 73
74/* STATIC and common implementation */ 74/* STATIC and common implementation */
75/* EXPORT */ ODistribution distributions[] = { 75/* EXPORT */ ODistribution distributions[] = {
76 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 76 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
77 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 77 { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" },
78 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 78 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
79 { System_Unknown, "Linux", "/etc/issue" }, 79 { System_Unknown, "Linux", "/etc/issue" },
80}; 80};
81 81
82 82
83/* EXPORT */ bool isQWS(){ 83/* EXPORT */ bool isQWS(){
84 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 84 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
85} 85}
86 86
87/* EXPORT */ QCString makeChannel ( const char *str ){ 87/* EXPORT */ QCString makeChannel ( const char *str ){
88 if ( str && !::strchr ( str, '/' )) 88 if ( str && !::strchr ( str, '/' ))
89 return QCString ( "QPE/Application/" ) + str; 89 return QCString ( "QPE/Application/" ) + str;
90 else 90 else
91 return str; 91 return str;
92} 92}
93 93
94 94
95 95
96/* Now the default implementation of ODevice */ 96/* Now the default implementation of ODevice */
97 97
98struct default_button default_buttons [] = { 98struct default_button default_buttons [] = {
99 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 99 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
100 "devicebuttons/z_calendar", 100 "devicebuttons/z_calendar",
101 "datebook", "nextView()", 101 "datebook", "nextView()",
102 "today", "raise()" }, 102 "today", "raise()" },
103 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 103 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
104 "devicebuttons/z_contact", 104 "devicebuttons/z_contact",
105 "addressbook", "raise()", 105 "addressbook", "raise()",
106 "addressbook", "beamBusinessCard()" }, 106 "addressbook", "beamBusinessCard()" },
107 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 107 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
108 "devicebuttons/z_home", 108 "devicebuttons/z_home",
109 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
110 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
111 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 111 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
112 "devicebuttons/z_menu", 112 "devicebuttons/z_menu",
113 "QPE/TaskBar", "toggleMenu()", 113 "QPE/TaskBar", "toggleMenu()",
114 "QPE/TaskBar", "toggleStartMenu()" }, 114 "QPE/TaskBar", "toggleStartMenu()" },
115 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 115 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
116 "devicebuttons/z_mail", 116 "devicebuttons/z_mail",
117 "opiemail", "raise()", 117 "opiemail", "raise()",
118 "opiemail", "newMail()" }, 118 "opiemail", "newMail()" },
119}; 119};
120 120
121ODevice *ODevice::inst() 121ODevice *ODevice::inst()
122{ 122{
123 static ODevice *dev = 0; 123 static ODevice *dev = 0;
124 QString cpu_info; 124 QString cpu_info;
125 125
126 if ( !dev ) 126 if ( !dev )
127 { 127 {
128 QFile f( PATH_PROC_CPUINFO ); 128 QFile f( PATH_PROC_CPUINFO );
129 if ( f.open( IO_ReadOnly ) ) 129 if ( f.open( IO_ReadOnly ) )
130 { 130 {
131 QTextStream s( &f ); 131 QTextStream s( &f );
132 while ( !s.atEnd() ) 132 while ( !s.atEnd() )
133 { 133 {
134 QString line; 134 QString line;
135 line = s.readLine(); 135 line = s.readLine();
136 if ( line.startsWith( "Hardware" ) ) 136 if ( line.startsWith( "Hardware" ) )
137 { 137 {
138 qDebug( "ODevice() - found '%s'", (const char*) line ); 138 qDebug( "ODevice() - found '%s'", (const char*) line );
139 cpu_info = line; 139 cpu_info = line;
140 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 140 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
141 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(); 142 else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal();
143 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 143 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
144 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 144 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
145 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 145 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
146 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 146 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
147 else qWarning( "ODevice() - unknown hardware - using default." ); 147 else qWarning( "ODevice() - unknown hardware - using default." );
148 break; 148 break;
149 } else if ( line.startsWith( "vendor_id" ) ) { 149 } else if ( line.startsWith( "vendor_id" ) ) {
150 qDebug( "ODevice() - found '%s'", (const char*) line ); 150 qDebug( "ODevice() - found '%s'", (const char*) line );
151 cpu_info = line; 151 cpu_info = line;
152 if( line.contains( "genuineintel", false ) ) { 152 if( line.contains( "genuineintel", false ) ) {
153 dev = new Internal::GenuineIntel(); 153 dev = new Internal::GenuineIntel();
154 break; 154 break;
155 } 155 }
156 } 156 }
157 } 157 }
158 } 158 }
159 else 159 else
160 { 160 {
161 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 );
162 } 162 }
163 if ( !dev ) dev = new ODevice(); 163 if ( !dev ) dev = new ODevice();
164 dev->init(cpu_info); 164 dev->init(cpu_info);
165 } 165 }
166 return dev; 166 return dev;
167} 167}
168 168
169ODevice::ODevice() 169ODevice::ODevice()
170{ 170{
171 d = new ODeviceData; 171 d = new ODeviceData;
172 172
173 d->m_modelstr = "Unknown"; 173 d->m_modelstr = "Unknown";
174 d->m_model = Model_Unknown; 174 d->m_model = Model_Unknown;
175 d->m_vendorstr = "Unknown"; 175 d->m_vendorstr = "Unknown";
176 d->m_vendor = Vendor_Unknown; 176 d->m_vendor = Vendor_Unknown;
177 d->m_systemstr = "Unknown"; 177 d->m_systemstr = "Unknown";
178 d->m_system = System_Unknown; 178 d->m_system = System_Unknown;
179 d->m_sysverstr = "0.0"; 179 d->m_sysverstr = "0.0";
180 d->m_rotation = Rot0; 180 d->m_rotation = Rot0;
181 d->m_direction = CW; 181 d->m_direction = CW;
182 d->m_qteDriver = "Transformed"; 182 d->m_qteDriver = "Transformed";
183 183
184 d->m_holdtime = 1000; // 1000ms 184 d->m_holdtime = 1000; // 1000ms
185 d->m_buttons = 0; 185 d->m_buttons = 0;
186 d->m_cpu_frequencies = new QStrList; 186 d->m_cpu_frequencies = new QStrList;
187 187
188 188
189 /* mixer */ 189 /* mixer */
190 d->m_sound = d->m_vol = d->m_mixer = -1; 190 d->m_sound = d->m_vol = d->m_mixer = -1;
191 191
192 /* System QCopChannel created */ 192 /* System QCopChannel created */
193 d->m_initializedButtonQcop = false; 193 d->m_initializedButtonQcop = false;
194 194
195 // New distribution detection code first checks for legacy distributions, 195 // New distribution detection code first checks for legacy distributions,
196 // identified by /etc/familiar-version or /etc/oz_version. 196 // identified by /etc/familiar-version or /etc/oz_version.
197 // Then check for OpenEmbedded and lastly, read /etc/issue 197 // Then check for OpenEmbedded and lastly, read /etc/issue
198 198
199 for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) 199 for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i )
200 { 200 {
201 if ( QFile::exists( distributions[i].sysvfile ) ) 201 if ( QFile::exists( distributions[i].sysvfile ) )
202 { 202 {
203 d->m_systemstr = distributions[i].sysstr; 203 d->m_systemstr = distributions[i].sysstr;
204 d->m_system = distributions[i].system; 204 d->m_system = distributions[i].system;
205 d->m_sysverstr = "<Unknown>"; 205 d->m_sysverstr = "<Unknown>";
206 QFile f( distributions[i].sysvfile ); 206 QFile f( distributions[i].sysvfile );
207 if ( f.open( IO_ReadOnly ) ) 207 if ( f.open( IO_ReadOnly ) )
208 { 208 {
209 QTextStream ts( &f ); 209 QTextStream ts( &f );
210 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 210 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
211 } 211 }
212 break; 212 break;
213 } 213 }
214 } 214 }
215} 215}
216 216
217void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 217void ODevice::systemMessage( const QCString &msg, const QByteArray & )
218{ 218{
219 if ( msg == "deviceButtonMappingChanged()" ) { 219 if ( msg == "deviceButtonMappingChanged()" ) {
220 reloadButtonMapping(); 220 reloadButtonMapping();
221 } 221 }
222} 222}
223 223
224void ODevice::init(const QString&) 224void ODevice::init(const QString&)
225{ 225{
226} 226}
227 227
228/** 228/**
229* This method initialises the button mapping 229* This method initialises the button mapping
230*/ 230*/
231void ODevice::initButtons() 231void ODevice::initButtons()
232{ 232{
233 if ( d->m_buttons ) 233 if ( d->m_buttons )
234 return; 234 return;
235 235
236 qDebug ( "init Buttons" ); 236 qDebug ( "init Buttons" );
237 d->m_buttons = new QValueList <ODeviceButton>; 237 d->m_buttons = new QValueList <ODeviceButton>;
238 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++ ) {
239 default_button *db = default_buttons + i; 239 default_button *db = default_buttons + i;
240 ODeviceButton b; 240 ODeviceButton b;
241 b. setKeycode ( db->code ); 241 b. setKeycode ( db->code );
242 b. setUserText ( QObject::tr ( "Button", db->utext )); 242 b. setUserText ( QObject::tr ( "Button", db->utext ));
243 b. setPixmap ( OResource::loadPixmap ( db->pix )); 243 b. setPixmap ( OResource::loadPixmap ( db->pix ));
244 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 244 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
245 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 245 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
246 d->m_buttons->append ( b ); 246 d->m_buttons->append ( b );
247 } 247 }
248 248
249 reloadButtonMapping(); 249 reloadButtonMapping();
250} 250}
251 251
252ODevice::~ODevice() 252ODevice::~ODevice()
253{ 253{
254// we leak m_devicebuttons and m_cpu_frequency 254// we leak m_devicebuttons and m_cpu_frequency
255// but it's a singleton and it is not so importantant 255// but it's a singleton and it is not so importantant
256// -zecke 256// -zecke
257 delete d; 257 delete d;
258} 258}
259 259
260/** 260/**
261* This method will try to suspend the device 261* This method will try to suspend the device
262* It only works if the user is the QWS Server and the apm application 262* It only works if the user is the QWS Server and the apm application
263* is installed. 263* is installed.
264* It tries to suspend and then waits some time cause some distributions 264* It tries to suspend and then waits some time cause some distributions
265* do have asynchronus apm implementations. 265* do have asynchronus apm implementations.
266* This method will either fail and return false or it'll suspend the 266* This method will either fail and return false or it'll suspend the
267* device and return once the device got woken up 267* device and return once the device got woken up
268* 268*
269* @return if the device got suspended 269* @return if the device got suspended