summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-09-08 21:05:17 (UTC)
committer mickeyl <mickeyl>2004-09-08 21:05:17 (UTC)
commit189f40847bbaaed928cb99d64f51f708c96a967b (patch) (unidiff)
treef0f1b7fac675e960be2472dcd7ea4b64034630a0
parentdbab81a4311ab27fd991a7f56f7804d2212d057d (diff)
downloadopie-189f40847bbaaed928cb99d64f51f708c96a967b.zip
opie-189f40847bbaaed928cb99d64f51f708c96a967b.tar.gz
opie-189f40847bbaaed928cb99d64f51f708c96a967b.tar.bz2
remove things like \n and \l from the system version string
Diffstat (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 129215b..280b0c5 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -98,193 +98,193 @@ struct default_button default_buttons [] = {
98 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 98 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
99 "devicebuttons/z_contact", 99 "devicebuttons/z_contact",
100 "addressbook", "raise()", 100 "addressbook", "raise()",
101 "addressbook", "beamBusinessCard()" }, 101 "addressbook", "beamBusinessCard()" },
102 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 102 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
103 "devicebuttons/z_home", 103 "devicebuttons/z_home",
104 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
105 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
106 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 106 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
107 "devicebuttons/z_menu", 107 "devicebuttons/z_menu",
108 "QPE/TaskBar", "toggleMenu()", 108 "QPE/TaskBar", "toggleMenu()",
109 "QPE/TaskBar", "toggleStartMenu()" }, 109 "QPE/TaskBar", "toggleStartMenu()" },
110 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 110 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
111 "devicebuttons/z_mail", 111 "devicebuttons/z_mail",
112 "opiemail", "raise()", 112 "opiemail", "raise()",
113 "opiemail", "newMail()" }, 113 "opiemail", "newMail()" },
114}; 114};
115 115
116ODevice *ODevice::inst() 116ODevice *ODevice::inst()
117{ 117{
118 static ODevice *dev = 0; 118 static ODevice *dev = 0;
119 119
120 // rewrite this to only use /proc/cpuinfo or so 120 // rewrite this to only use /proc/cpuinfo or so
121 QString cpu_info; 121 QString cpu_info;
122 122
123 if ( !dev ) 123 if ( !dev )
124 { 124 {
125 QFile f( PATH_PROC_CPUINFO ); 125 QFile f( PATH_PROC_CPUINFO );
126 if ( f.open( IO_ReadOnly ) ) 126 if ( f.open( IO_ReadOnly ) )
127 { 127 {
128 QTextStream s( &f ); 128 QTextStream s( &f );
129 while ( !s.atEnd() ) 129 while ( !s.atEnd() )
130 { 130 {
131 QString line; 131 QString line;
132 line = s.readLine(); 132 line = s.readLine();
133 if ( line.startsWith( "Hardware" ) ) 133 if ( line.startsWith( "Hardware" ) )
134 { 134 {
135 qDebug( "ODevice() - found '%s'", (const char*) line ); 135 qDebug( "ODevice() - found '%s'", (const char*) line );
136 cpu_info = line; 136 cpu_info = line;
137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
142 else qWarning( "ODevice() - unknown hardware - using default." ); 142 else qWarning( "ODevice() - unknown hardware - using default." );
143 break; 143 break;
144 } 144 }
145 } 145 }
146 } 146 }
147 else 147 else
148 { 148 {
149 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 149 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
150 } 150 }
151 if ( !dev ) dev = new ODevice(); 151 if ( !dev ) dev = new ODevice();
152 dev->init(cpu_info); 152 dev->init(cpu_info);
153 } 153 }
154 return dev; 154 return dev;
155} 155}
156 156
157ODevice::ODevice() 157ODevice::ODevice()
158{ 158{
159 d = new ODeviceData; 159 d = new ODeviceData;
160 160
161 d->m_modelstr = "Unknown"; 161 d->m_modelstr = "Unknown";
162 d->m_model = Model_Unknown; 162 d->m_model = Model_Unknown;
163 d->m_vendorstr = "Unknown"; 163 d->m_vendorstr = "Unknown";
164 d->m_vendor = Vendor_Unknown; 164 d->m_vendor = Vendor_Unknown;
165 d->m_systemstr = "Unknown"; 165 d->m_systemstr = "Unknown";
166 d->m_system = System_Unknown; 166 d->m_system = System_Unknown;
167 d->m_sysverstr = "0.0"; 167 d->m_sysverstr = "0.0";
168 d->m_rotation = Rot0; 168 d->m_rotation = Rot0;
169 d->m_direction = CW; 169 d->m_direction = CW;
170 170
171 d->m_holdtime = 1000; // 1000ms 171 d->m_holdtime = 1000; // 1000ms
172 d->m_buttons = 0; 172 d->m_buttons = 0;
173 d->m_cpu_frequencies = new QStrList; 173 d->m_cpu_frequencies = new QStrList;
174 174
175 175
176 /* mixer */ 176 /* mixer */
177 d->m_sound = d->m_vol = d->m_mixer = -1; 177 d->m_sound = d->m_vol = d->m_mixer = -1;
178 178
179 // New distribution detection code first checks for legacy distributions, 179 // New distribution detection code first checks for legacy distributions,
180 // identified by /etc/familiar-version or /etc/oz_version. 180 // identified by /etc/familiar-version or /etc/oz_version.
181 // Then check for OpenEmbedded and lastly, read /etc/issue 181 // Then check for OpenEmbedded and lastly, read /etc/issue
182 182
183 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 183 for ( unsigned int i = 0; i < sizeof distributions; ++i )
184 { 184 {
185 if ( QFile::exists( distributions[i].sysvfile ) ) 185 if ( QFile::exists( distributions[i].sysvfile ) )
186 { 186 {
187 d->m_systemstr = distributions[i].sysstr; 187 d->m_systemstr = distributions[i].sysstr;
188 d->m_system = distributions[i].system; 188 d->m_system = distributions[i].system;
189 d->m_sysverstr = "<Unknown>"; 189 d->m_sysverstr = "<Unknown>";
190 QFile f( distributions[i].sysvfile ); 190 QFile f( distributions[i].sysvfile );
191 if ( f.open( IO_ReadOnly ) ) 191 if ( f.open( IO_ReadOnly ) )
192 { 192 {
193 QTextStream ts( &f ); 193 QTextStream ts( &f );
194 d->m_sysverstr = ts.readLine(); 194 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
195 } 195 }
196 break; 196 break;
197 } 197 }
198 } 198 }
199} 199}
200 200
201void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 201void ODevice::systemMessage( const QCString &msg, const QByteArray & )
202{ 202{
203 if ( msg == "deviceButtonMappingChanged()" ) { 203 if ( msg == "deviceButtonMappingChanged()" ) {
204 reloadButtonMapping(); 204 reloadButtonMapping();
205 } 205 }
206} 206}
207 207
208void ODevice::init(const QString&) 208void ODevice::init(const QString&)
209{ 209{
210} 210}
211 211
212/** 212/**
213* This method initialises the button mapping 213* This method initialises the button mapping
214*/ 214*/
215void ODevice::initButtons() 215void ODevice::initButtons()
216{ 216{
217 if ( d->m_buttons ) 217 if ( d->m_buttons )
218 return; 218 return;
219 219
220 qDebug ( "init Buttons" ); 220 qDebug ( "init Buttons" );
221 d->m_buttons = new QValueList <ODeviceButton>; 221 d->m_buttons = new QValueList <ODeviceButton>;
222 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 222 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
223 default_button *db = default_buttons + i; 223 default_button *db = default_buttons + i;
224 ODeviceButton b; 224 ODeviceButton b;
225 b. setKeycode ( db->code ); 225 b. setKeycode ( db->code );
226 b. setUserText ( QObject::tr ( "Button", db->utext )); 226 b. setUserText ( QObject::tr ( "Button", db->utext ));
227 b. setPixmap ( Resource::loadPixmap ( db->pix )); 227 b. setPixmap ( Resource::loadPixmap ( db->pix ));
228 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 228 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
229 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 229 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
230 d->m_buttons->append ( b ); 230 d->m_buttons->append ( b );
231 } 231 }
232 232
233 reloadButtonMapping(); 233 reloadButtonMapping();
234 234
235 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 235 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
236 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 236 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
237} 237}
238 238
239ODevice::~ODevice() 239ODevice::~ODevice()
240{ 240{
241// we leak m_devicebuttons and m_cpu_frequency 241// we leak m_devicebuttons and m_cpu_frequency
242// but it's a singleton and it is not so importantant 242// but it's a singleton and it is not so importantant
243// -zecke 243// -zecke
244 delete d; 244 delete d;
245} 245}
246 246
247bool ODevice::setSoftSuspend ( bool /*soft*/ ) 247bool ODevice::setSoftSuspend ( bool /*soft*/ )
248{ 248{
249 return false; 249 return false;
250} 250}
251 251
252//#include <linux/apm_bios.h> 252//#include <linux/apm_bios.h>
253 253
254#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 254#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
255 255
256/** 256/**
257* This method will try to suspend the device 257* This method will try to suspend the device
258* It only works if the user is the QWS Server and the apm application 258* It only works if the user is the QWS Server and the apm application
259* is installed. 259* is installed.
260* It tries to suspend and then waits some time cause some distributions 260* It tries to suspend and then waits some time cause some distributions
261* do have asynchronus apm implementations. 261* do have asynchronus apm implementations.
262* This method will either fail and return false or it'll suspend the 262* This method will either fail and return false or it'll suspend the
263* device and return once the device got woken up 263* device and return once the device got woken up
264* 264*
265* @return if the device got suspended 265* @return if the device got suspended
266*/ 266*/
267bool ODevice::suspend() 267bool ODevice::suspend()
268{ 268{
269 qDebug("ODevice::suspend"); 269 qDebug("ODevice::suspend");
270 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 270 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
271 return false; 271 return false;
272 272
273 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 273 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
274 return false; 274 return false;
275 275
276 bool res = false; 276 bool res = false;
277 ODevice::sendSuspendmsg(); 277 ODevice::sendSuspendmsg();
278 278
279 struct timeval tvs, tvn; 279 struct timeval tvs, tvn;
280 ::gettimeofday ( &tvs, 0 ); 280 ::gettimeofday ( &tvs, 0 );
281 281
282 ::sync(); // flush fs caches 282 ::sync(); // flush fs caches
283 res = ( ::system ( "apm --suspend" ) == 0 ); 283 res = ( ::system ( "apm --suspend" ) == 0 );
284 284
285 // This is needed because the iPAQ apm implementation is asynchronous and we 285 // This is needed because the iPAQ apm implementation is asynchronous and we
286 // can not be sure when exactly the device is really suspended 286 // can not be sure when exactly the device is really suspended
287 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 287 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
288 288
289 if ( res ) { 289 if ( res ) {
290 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 290 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed