summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/devicesinfo.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp
index b463e43..7e8aee8 100644
--- a/noncore/settings/sysinfo/devicesinfo.cpp
+++ b/noncore/settings/sysinfo/devicesinfo.cpp
@@ -1,351 +1,351 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 =. Copyright (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. Copyright (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org>
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 General Public 8:`=1 )Y*s>-.--   : the terms of the GNU 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..}^=.=       =       ; General Public License for more 18..}^=.=       =       ; 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 -_. . .   )=.  = General Public License along with 22 -_. . .   )=.  = General Public License along with
23   --        :-=` this application; see the file LICENSE.GPL. 23   --        :-=` this application; see the file LICENSE.GPL.
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#include "devicesinfo.h" 29#include "devicesinfo.h"
30/* OPIE */ 30/* OPIE */
31#include <opie2/odebug.h> 31#include <opie2/odebug.h>
32#include <opie2/oinputsystem.h> 32#include <opie2/oinputsystem.h>
33#include <opie2/olayout.h> 33#include <opie2/olayout.h>
34#include <opie2/olistview.h> 34#include <opie2/olistview.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36using namespace Opie::Core; 36using namespace Opie::Core;
37using namespace Opie::Ui; 37using namespace Opie::Ui;
38 38
39/* QT */ 39/* QT */
40#include <qobjectlist.h> 40#include <qobjectlist.h>
41#include <qlistview.h> 41#include <qlistview.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <qfile.h> 43#include <qfile.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46#include <qtextview.h> 46#include <qtextview.h>
47#include <qtimer.h> 47#include <qtimer.h>
48#include <qwhatsthis.h> 48#include <qwhatsthis.h>
49 49
50//================================================================================================= 50//=================================================================================================
51DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl ) 51DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl )
52 :Opie::Ui::OListView( parent, name, fl ) 52 :Opie::Ui::OListView( parent, name, fl )
53{ 53{
54 addColumn( tr( "My Computer" ) ); 54 addColumn( tr( "My Computer" ) );
55 setAllColumnsShowFocus( true ); 55 setAllColumnsShowFocus( true );
56 setRootIsDecorated( true ); 56 setRootIsDecorated( true );
57 QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) ); 57 QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) );
58 58
59 DevicesView* root = this; 59 DevicesView* root = this;
60 ( new CpuCategory( root ) )->populate(); 60 ( new CpuCategory( root ) )->populate();
61 ( new InputCategory( root ) )->populate(); 61 ( new InputCategory( root ) )->populate();
62 ( new CardsCategory( root ) )->populate(); 62 ( new CardsCategory( root ) )->populate();
63 ( new UsbCategory( root ) )->populate(); 63 ( new UsbCategory( root ) )->populate();
64 64
65 connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) ); 65 connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) );
66} 66}
67 67
68DevicesView::~DevicesView() 68DevicesView::~DevicesView()
69{ 69{
70} 70}
71 71
72 72
73void DevicesView::selectionChanged( QListViewItem* item ) 73void DevicesView::selectionChanged( QListViewItem* item )
74{ 74{
75 odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl; 75 odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl;
76 if ( item->parent() ) 76 if ( item->parent() )
77 { 77 {
78 QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); 78 QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget();
79 ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details ); 79 ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details );
80 } 80 }
81 else 81 else
82 { 82 {
83 odebug << "DevicesView::not a device node." << oendl; 83 odebug << "DevicesView::not a device node." << oendl;
84 } 84 }
85} 85}
86 86
87 87
88//================================================================================================= 88//=================================================================================================
89DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) 89DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl )
90 :QWidget( parent, name, fl ), details( 0 ) 90 :QWidget( parent, name, fl ), details( 0 )
91{ 91{
92 layout = new OAutoBoxLayout( this ); 92 layout = new OAutoBoxLayout( this );
93 layout->setSpacing( 2 ); 93 layout->setSpacing( 2 );
94 layout->setMargin( 2 ); 94 layout->setMargin( 2 );
95 view = new DevicesView( this ); 95 view = new DevicesView( this );
96 layout->addWidget( view, 100 ); 96 layout->addWidget( view, 100 );
97 stack = new QWidgetStack( this ); 97 stack = new QWidgetStack( this );
98 layout->addWidget( stack, 70 ); 98 layout->addWidget( stack, 70 );
99} 99}
100 100
101 101
102DevicesInfo::~DevicesInfo() 102DevicesInfo::~DevicesInfo()
103{ 103{
104} 104}
105 105
106 106
107void DevicesInfo::setDetailsWidget( QWidget* w ) 107void DevicesInfo::setDetailsWidget( QWidget* w )
108{ 108{
109 if ( details ) 109 if ( details )
110 { 110 {
111 qDebug( "hiding widget '%s' ('%s')", details->name(), details->className() ); 111 qDebug( "hiding widget '%s' ('%s')", details->name(), details->className() );
112 stack->removeWidget( w ); 112 stack->removeWidget( w );
113 } 113 }
114 114
115 stack->addWidget( details = w, 40 ); 115 stack->addWidget( details = w, 40 );
116 stack->raiseWidget( details ); 116 stack->raiseWidget( details );
117} 117}
118 118
119 119
120//================================================================================================= 120//=================================================================================================
121Category::Category( DevicesView* parent, const QString& name ) 121Category::Category( DevicesView* parent, const QString& name )
122 :OListViewItem( parent, name ) 122 :OListViewItem( parent, name )
123{ 123{
124 odebug << "Category '" << name << "' inserted. Scanning for devices..." << oendl; 124 odebug << "Category '" << name << "' inserted. Scanning for devices..." << oendl;
125} 125}
126 126
127Category::~Category() 127Category::~Category()
128{ 128{
129} 129}
130 130
131//================================================================================================= 131//=================================================================================================
132CpuCategory::CpuCategory( DevicesView* parent ) 132CpuCategory::CpuCategory( DevicesView* parent )
133 :Category( parent, "1. Central Processing Unit" ) 133 :Category( parent, "1. Central Processing Unit" )
134{ 134{
135} 135}
136 136
137CpuCategory::~CpuCategory() 137CpuCategory::~CpuCategory()
138{ 138{
139} 139}
140 140
141void CpuCategory::populate() 141void CpuCategory::populate()
142{ 142{
143 odebug << "CpuCategory::populate()" << oendl; 143 odebug << "CpuCategory::populate()" << oendl;
144 QFile cpuinfofile( "/proc/cpuinfo" ); 144 QFile cpuinfofile( "/proc/cpuinfo" );
145 if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) ) 145 if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) )
146 { 146 {
147 new CpuDevice( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); 147 new CpuDevice( this, "ERROR: /proc/cpuinfo not found or unaccessible" );
148 return; 148 return;
149 } 149 }
150 QTextStream cpuinfo( &cpuinfofile ); 150 QTextStream cpuinfo( &cpuinfofile );
151 151
152 int cpucount = 0; 152 int cpucount = 0;
153 CpuDevice* dev = 0; 153 CpuDevice* dev = 0;
154 154
155 while ( !cpuinfo.atEnd() ) 155 while ( !cpuinfo.atEnd() )
156 { 156 {
157 QString line = cpuinfo.readLine(); 157 QString line = cpuinfo.readLine();
158 odebug << "got line '" << line << "'" << oendl; 158 odebug << "got line '" << line << "'" << oendl;
159 if ( line.startsWith( "processor" ) ) 159 if ( line.lower().startsWith( "processor" ) )
160 { 160 {
161 dev = new CpuDevice( this, QString( "CPU #%1" ).arg( cpucount++ ) ); 161 dev = new CpuDevice( this, QString( "CPU #%1" ).arg( cpucount++ ) );
162 dev->addInfo( line ); 162 dev->addInfo( line );
163 } 163 }
164 else 164 else
165 { 165 {
166 if ( dev ) dev->addInfo( line ); 166 if ( dev ) dev->addInfo( line );
167 } 167 }
168 } 168 }
169} 169}
170 170
171//================================================================================================= 171//=================================================================================================
172InputCategory::InputCategory( DevicesView* parent ) 172InputCategory::InputCategory( DevicesView* parent )
173 :Category( parent, "2. Input Subsystem" ) 173 :Category( parent, "2. Input Subsystem" )
174{ 174{
175} 175}
176 176
177InputCategory::~InputCategory() 177InputCategory::~InputCategory()
178{ 178{
179} 179}
180 180
181void InputCategory::populate() 181void InputCategory::populate()
182{ 182{
183 odebug << "InputCategory::populate()" << oendl; 183 odebug << "InputCategory::populate()" << oendl;
184 OInputSystem* sys = OInputSystem::instance(); 184 OInputSystem* sys = OInputSystem::instance();
185 OInputSystem::DeviceIterator it = sys->iterator(); 185 OInputSystem::DeviceIterator it = sys->iterator();
186 while ( it.current() ) 186 while ( it.current() )
187 { 187 {
188 OInputDevice* dev = it.current(); 188 OInputDevice* dev = it.current();
189 new InputDevice( this, dev->identity() ); 189 new InputDevice( this, dev->identity() );
190 ++it; 190 ++it;
191 } 191 }
192} 192}
193 193
194//================================================================================================= 194//=================================================================================================
195CardsCategory::CardsCategory( DevicesView* parent ) 195CardsCategory::CardsCategory( DevicesView* parent )
196 :Category( parent, "3. Removable Cards" ) 196 :Category( parent, "3. Removable Cards" )
197{ 197{
198} 198}
199 199
200CardsCategory::~CardsCategory() 200CardsCategory::~CardsCategory()
201{ 201{
202} 202}
203 203
204void CardsCategory::populate() 204void CardsCategory::populate()
205{ 205{
206 odebug << "CardsCategory::populate()" << oendl; 206 odebug << "CardsCategory::populate()" << oendl;
207 QString fileName; 207 QString fileName;
208 if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } 208 if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; }
209 else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } 209 else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; }
210 else { fileName = "/var/lib/pcmcia/stab"; } 210 else { fileName = "/var/lib/pcmcia/stab"; }
211 QFile cardinfofile( fileName ); 211 QFile cardinfofile( fileName );
212 if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) ) 212 if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) )
213 { 213 {
214 new CardDevice( this, "ERROR: pcmcia info file not found or unaccessible" ); 214 new CardDevice( this, "ERROR: pcmcia info file not found or unaccessible" );
215 return; 215 return;
216 } 216 }
217 QTextStream cardinfo( &cardinfofile ); 217 QTextStream cardinfo( &cardinfofile );
218 while ( !cardinfo.atEnd() ) 218 while ( !cardinfo.atEnd() )
219 { 219 {
220 QString line = cardinfo.readLine(); 220 QString line = cardinfo.readLine();
221 odebug << "got line '" << line << "'" << oendl; 221 odebug << "got line '" << line << "'" << oendl;
222 if ( line.startsWith( "Socket" ) ) 222 if ( line.startsWith( "Socket" ) )
223 { 223 {
224 new CardDevice( this, line ); 224 new CardDevice( this, line );
225 } 225 }
226 else 226 else
227 { 227 {
228 continue; 228 continue;
229 } 229 }
230 } 230 }
231} 231}
232 232
233//================================================================================================= 233//=================================================================================================
234UsbCategory::UsbCategory( DevicesView* parent ) 234UsbCategory::UsbCategory( DevicesView* parent )
235 :Category( parent, "4. Universal Serial Bus" ) 235 :Category( parent, "4. Universal Serial Bus" )
236{ 236{
237} 237}
238 238
239UsbCategory::~UsbCategory() 239UsbCategory::~UsbCategory()
240{ 240{
241} 241}
242 242
243void UsbCategory::populate() 243void UsbCategory::populate()
244{ 244{
245 odebug << "UsbCategory::populate()" << oendl; 245 odebug << "UsbCategory::populate()" << oendl;
246 QFile usbinfofile( "/proc/bus/usb/devices" ); 246 QFile usbinfofile( "/proc/bus/usb/devices" );
247 if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) 247 if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) )
248 { 248 {
249 new UsbDevice( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" ); 249 new UsbDevice( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" );
250 return; 250 return;
251 } 251 }
252 QTextStream usbinfo( &usbinfofile ); 252 QTextStream usbinfo( &usbinfofile );
253 253
254 int _bus, _level, _parent, _port, _count, _device, _channels, _power; 254 int _bus, _level, _parent, _port, _count, _device, _channels, _power;
255 float _speed; 255 float _speed;
256 QString _manufacturer, _product, _serial; 256 QString _manufacturer, _product, _serial;
257 257
258 int usbcount = 0; 258 int usbcount = 0;
259 UsbDevice* lastDev = 0; 259 UsbDevice* lastDev = 0;
260 UsbDevice* dev = 0; 260 UsbDevice* dev = 0;
261 while ( !usbinfo.atEnd() ) 261 while ( !usbinfo.atEnd() )
262 { 262 {
263 QString line = usbinfo.readLine(); 263 QString line = usbinfo.readLine();
264 odebug << "got line '" << line << "'" << oendl; 264 odebug << "got line '" << line << "'" << oendl;
265 if ( line.startsWith( "T:" ) ) 265 if ( line.startsWith( "T:" ) )
266 { 266 {
267 sscanf(line.local8Bit().data(), "T: Bus=%2d Lev=%2d Prnt=%2d Port=%d Cnt=%2d Dev#=%3d Spd=%3f MxCh=%2d", &_bus, &_level, &_parent, &_port, &_count, &_device, &_speed, &_channels); 267 sscanf(line.local8Bit().data(), "T: Bus=%2d Lev=%2d Prnt=%2d Port=%d Cnt=%2d Dev#=%3d Spd=%3f MxCh=%2d", &_bus, &_level, &_parent, &_port, &_count, &_device, &_speed, &_channels);
268 268
269 if ( !_level ) 269 if ( !_level )
270 { 270 {
271 odebug << "adding new bus" << oendl; 271 odebug << "adding new bus" << oendl;
272 dev = new UsbDevice( this, QString( "Generic USB Hub Device" ) ); 272 dev = new UsbDevice( this, QString( "Generic USB Hub Device" ) );
273 lastDev = dev; 273 lastDev = dev;
274 } 274 }
275 else 275 else
276 { 276 {
277 odebug << "adding new dev" << oendl; 277 odebug << "adding new dev" << oendl;
278 dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) ); 278 dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) );
279 lastDev = dev; 279 lastDev = dev;
280 } 280 }
281 } 281 }
282 else if ( line.startsWith( "S: Product" ) ) 282 else if ( line.startsWith( "S: Product" ) )
283 { 283 {
284 int dp = line.find( '=' ); 284 int dp = line.find( '=' );
285 dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" ); 285 dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" );
286 } 286 }
287 else 287 else
288 { 288 {
289 continue; 289 continue;
290 } 290 }
291 } 291 }
292} 292}
293 293
294 294
295//================================================================================================= 295//=================================================================================================
296Device::Device( Category* parent, const QString& name ) 296Device::Device( Category* parent, const QString& name )
297 :OListViewItem( parent, name ) 297 :OListViewItem( parent, name )
298{ 298{
299 devinfo = static_cast<QWidget*>( listView()->parent() ); 299 devinfo = static_cast<QWidget*>( listView()->parent() );
300} 300}
301 301
302Device::Device( Device* parent, const QString& name ) 302Device::Device( Device* parent, const QString& name )
303 :OListViewItem( parent, name ) 303 :OListViewItem( parent, name )
304{ 304{
305 devinfo = static_cast<QWidget*>( listView()->parent() ); 305 devinfo = static_cast<QWidget*>( listView()->parent() );
306} 306}
307 307
308Device::~Device() 308Device::~Device()
309{ 309{
310} 310}
311 311
312 312
313QWidget* Device::detailsWidget() 313QWidget* Device::detailsWidget()
314{ 314{
315 return details; 315 return details;
316} 316}
317 317
318//================================================================================================= 318//=================================================================================================
319CpuDevice::CpuDevice( Category* parent, const QString& name ) 319CpuDevice::CpuDevice( Category* parent, const QString& name )
320 :Device( parent, name ) 320 :Device( parent, name )
321{ 321{
322 OListView* w = new OListView( devinfo ); 322 OListView* w = new OListView( devinfo );
323 details = w; 323 details = w;
324 w->addColumn( "Info" ); 324 w->addColumn( "Info" );
325 w->addColumn( "Value" ); 325 w->addColumn( "Value" );
326 w->hide(); 326 w->hide();
327} 327}
328 328
329CpuDevice::~CpuDevice() 329CpuDevice::~CpuDevice()
330{ 330{
331} 331}
332 332
333void CpuDevice::addInfo( const QString& info ) 333void CpuDevice::addInfo( const QString& info )
334{ 334{
335 int dp = info.find( ':' ); 335 int dp = info.find( ':' );
336 if ( dp != -1 ) 336 if ( dp != -1 )
337 { 337 {
338 new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) ); 338 new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) );
339 } 339 }
340} 340}
341 341
342//================================================================================================= 342//=================================================================================================
343CardDevice::CardDevice( Category* parent, const QString& name ) 343CardDevice::CardDevice( Category* parent, const QString& name )
344 :Device( parent, name ) 344 :Device( parent, name )
345{ 345{
346 details = new QPushButton( name, devinfo ); 346 details = new QPushButton( name, devinfo );
347 details->hide(); 347 details->hide();
348} 348}
349 349
350CardDevice::~CardDevice() 350CardDevice::~CardDevice()
351{ 351{