Diffstat (limited to 'noncore/settings/sysinfo/devicesinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.cpp | 79 |
1 files changed, 72 insertions, 7 deletions
diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp index 4940286..76c9b79 100644 --- a/noncore/settings/sysinfo/devicesinfo.cpp +++ b/noncore/settings/sysinfo/devicesinfo.cpp | |||
@@ -22,48 +22,49 @@ _;:, .> :=|. This program is free software; you can | |||
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/opcmciasystem.h> | 33 | #include <opie2/opcmciasystem.h> |
34 | #include <opie2/olayout.h> | 34 | #include <opie2/olayout.h> |
35 | #include <opie2/olistview.h> | 35 | #include <opie2/olistview.h> |
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | using namespace Opie::Core; | 37 | using namespace Opie::Core; |
38 | using namespace Opie::Ui; | 38 | using namespace Opie::Ui; |
39 | 39 | ||
40 | /* QT */ | 40 | /* QT */ |
41 | #include <qobjectlist.h> | 41 | #include <qobjectlist.h> |
42 | #include <qlistview.h> | 42 | #include <qlistview.h> |
43 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
44 | #include <qfile.h> | 44 | #include <qfile.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #include <qstringlist.h> | ||
46 | #include <qtextstream.h> | 47 | #include <qtextstream.h> |
47 | #include <qtextview.h> | 48 | #include <qtextview.h> |
48 | #include <qtimer.h> | 49 | #include <qtimer.h> |
49 | #include <qwhatsthis.h> | 50 | #include <qwhatsthis.h> |
50 | 51 | ||
51 | //================================================================================================= | 52 | //================================================================================================= |
52 | DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl ) | 53 | DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl ) |
53 | :Opie::Ui::OListView( parent, name, fl ) | 54 | :Opie::Ui::OListView( parent, name, fl ) |
54 | { | 55 | { |
55 | addColumn( tr( "My Computer" ) ); | 56 | addColumn( tr( "My Computer" ) ); |
56 | setAllColumnsShowFocus( true ); | 57 | setAllColumnsShowFocus( true ); |
57 | setRootIsDecorated( true ); | 58 | setRootIsDecorated( true ); |
58 | QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) ); | 59 | QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) ); |
59 | 60 | ||
60 | DevicesView* root = this; | 61 | DevicesView* root = this; |
61 | ( new CpuCategory( root ) )->populate(); | 62 | ( new CpuCategory( root ) )->populate(); |
62 | ( new InputCategory( root ) )->populate(); | 63 | ( new InputCategory( root ) )->populate(); |
63 | ( new CardsCategory( root ) )->populate(); | 64 | ( new CardsCategory( root ) )->populate(); |
64 | ( new UsbCategory( root ) )->populate(); | 65 | ( new UsbCategory( root ) )->populate(); |
65 | 66 | ||
66 | connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) ); | 67 | connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) ); |
67 | } | 68 | } |
68 | 69 | ||
69 | DevicesView::~DevicesView() | 70 | DevicesView::~DevicesView() |
@@ -75,49 +76,49 @@ void DevicesView::selectionChanged( QListViewItem* item ) | |||
75 | { | 76 | { |
76 | odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl; | 77 | odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl; |
77 | if ( item->parent() ) | 78 | if ( item->parent() ) |
78 | { | 79 | { |
79 | QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); | 80 | QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); |
80 | ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details ); | 81 | ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details ); |
81 | } | 82 | } |
82 | else | 83 | else |
83 | { | 84 | { |
84 | odebug << "DevicesView::not a device node." << oendl; | 85 | odebug << "DevicesView::not a device node." << oendl; |
85 | } | 86 | } |
86 | } | 87 | } |
87 | 88 | ||
88 | 89 | ||
89 | //================================================================================================= | 90 | //================================================================================================= |
90 | DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) | 91 | DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) |
91 | :QWidget( parent, name, fl ), details( 0 ) | 92 | :QWidget( parent, name, fl ), details( 0 ) |
92 | { | 93 | { |
93 | layout = new OAutoBoxLayout( this ); | 94 | layout = new OAutoBoxLayout( this ); |
94 | layout->setSpacing( 2 ); | 95 | layout->setSpacing( 2 ); |
95 | layout->setMargin( 2 ); | 96 | layout->setMargin( 2 ); |
96 | view = new DevicesView( this ); | 97 | view = new DevicesView( this ); |
97 | layout->addWidget( view, 100 ); | 98 | layout->addWidget( view, 100 ); |
98 | stack = new QWidgetStack( this ); | 99 | stack = new QWidgetStack( this ); |
99 | layout->addWidget( stack, 70 ); | 100 | layout->addWidget( stack, 80 ); |
100 | } | 101 | } |
101 | 102 | ||
102 | 103 | ||
103 | DevicesInfo::~DevicesInfo() | 104 | DevicesInfo::~DevicesInfo() |
104 | { | 105 | { |
105 | } | 106 | } |
106 | 107 | ||
107 | 108 | ||
108 | void DevicesInfo::setDetailsWidget( QWidget* w ) | 109 | void DevicesInfo::setDetailsWidget( QWidget* w ) |
109 | { | 110 | { |
110 | if ( details ) | 111 | if ( details ) |
111 | { | 112 | { |
112 | qDebug( "hiding widget '%s' ('%s')", details->name(), details->className() ); | 113 | qDebug( "hiding widget '%s' ('%s')", details->name(), details->className() ); |
113 | stack->removeWidget( w ); | 114 | stack->removeWidget( w ); |
114 | } | 115 | } |
115 | 116 | ||
116 | stack->addWidget( details = w, 40 ); | 117 | stack->addWidget( details = w, 40 ); |
117 | stack->raiseWidget( details ); | 118 | stack->raiseWidget( details ); |
118 | } | 119 | } |
119 | 120 | ||
120 | 121 | ||
121 | //================================================================================================= | 122 | //================================================================================================= |
122 | Category::Category( DevicesView* parent, const QString& name ) | 123 | Category::Category( DevicesView* parent, const QString& name ) |
123 | :OListViewItem( parent, name ) | 124 | :OListViewItem( parent, name ) |
@@ -165,71 +166,73 @@ void CpuCategory::populate() | |||
165 | else | 166 | else |
166 | { | 167 | { |
167 | if ( dev ) dev->addInfo( line ); | 168 | if ( dev ) dev->addInfo( line ); |
168 | } | 169 | } |
169 | } | 170 | } |
170 | } | 171 | } |
171 | 172 | ||
172 | //================================================================================================= | 173 | //================================================================================================= |
173 | InputCategory::InputCategory( DevicesView* parent ) | 174 | InputCategory::InputCategory( DevicesView* parent ) |
174 | :Category( parent, "2. Input Subsystem" ) | 175 | :Category( parent, "2. Input Subsystem" ) |
175 | { | 176 | { |
176 | } | 177 | } |
177 | 178 | ||
178 | InputCategory::~InputCategory() | 179 | InputCategory::~InputCategory() |
179 | { | 180 | { |
180 | } | 181 | } |
181 | 182 | ||
182 | void InputCategory::populate() | 183 | void InputCategory::populate() |
183 | { | 184 | { |
184 | odebug << "InputCategory::populate()" << oendl; | 185 | odebug << "InputCategory::populate()" << oendl; |
185 | OInputSystem* sys = OInputSystem::instance(); | 186 | OInputSystem* sys = OInputSystem::instance(); |
186 | OInputSystem::DeviceIterator it = sys->iterator(); | 187 | OInputSystem::DeviceIterator it = sys->iterator(); |
187 | while ( it.current() ) | 188 | while ( it.current() ) |
188 | { | 189 | { |
189 | new InputDevice( this, it.current()->identity() ); | 190 | InputDevice* dev = new InputDevice( this, it.current()->identity() ); |
191 | dev->setInfo( it.current() ); | ||
190 | ++it; | 192 | ++it; |
191 | } | 193 | } |
192 | } | 194 | } |
193 | 195 | ||
194 | //================================================================================================= | 196 | //================================================================================================= |
195 | CardsCategory::CardsCategory( DevicesView* parent ) | 197 | CardsCategory::CardsCategory( DevicesView* parent ) |
196 | :Category( parent, "3. Removable Cards" ) | 198 | :Category( parent, "3. Removable Cards" ) |
197 | { | 199 | { |
198 | } | 200 | } |
199 | 201 | ||
200 | CardsCategory::~CardsCategory() | 202 | CardsCategory::~CardsCategory() |
201 | { | 203 | { |
202 | } | 204 | } |
203 | 205 | ||
204 | void CardsCategory::populate() | 206 | void CardsCategory::populate() |
205 | { | 207 | { |
206 | odebug << "CardsCategory::populate()" << oendl; | 208 | odebug << "CardsCategory::populate()" << oendl; |
207 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 209 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
208 | OPcmciaSystem::CardIterator it = sys->iterator(); | 210 | OPcmciaSystem::CardIterator it = sys->iterator(); |
209 | while ( it.current() ) | 211 | while ( it.current() ) |
210 | { | 212 | { |
211 | new CardDevice( this, it.current()->identity() ); | 213 | CardDevice *dev = new CardDevice( this, it.current()->identity() ); |
214 | dev->setInfo( it.current() ); | ||
212 | ++it; | 215 | ++it; |
213 | } | 216 | } |
214 | } | 217 | } |
215 | 218 | ||
216 | //================================================================================================= | 219 | //================================================================================================= |
217 | UsbCategory::UsbCategory( DevicesView* parent ) | 220 | UsbCategory::UsbCategory( DevicesView* parent ) |
218 | :Category( parent, "4. Universal Serial Bus" ) | 221 | :Category( parent, "4. Universal Serial Bus" ) |
219 | { | 222 | { |
220 | } | 223 | } |
221 | 224 | ||
222 | UsbCategory::~UsbCategory() | 225 | UsbCategory::~UsbCategory() |
223 | { | 226 | { |
224 | } | 227 | } |
225 | 228 | ||
226 | void UsbCategory::populate() | 229 | void UsbCategory::populate() |
227 | { | 230 | { |
228 | odebug << "UsbCategory::populate()" << oendl; | 231 | odebug << "UsbCategory::populate()" << oendl; |
229 | QFile usbinfofile( "/proc/bus/usb/devices" ); | 232 | QFile usbinfofile( "/proc/bus/usb/devices" ); |
230 | if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) | 233 | if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) |
231 | { | 234 | { |
232 | new UsbDevice( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" ); | 235 | new UsbDevice( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" ); |
233 | return; | 236 | return; |
234 | } | 237 | } |
235 | QTextStream usbinfo( &usbinfofile ); | 238 | QTextStream usbinfo( &usbinfofile ); |
@@ -305,62 +308,124 @@ CpuDevice::CpuDevice( Category* parent, const QString& name ) | |||
305 | OListView* w = new OListView( devinfo ); | 308 | OListView* w = new OListView( devinfo ); |
306 | details = w; | 309 | details = w; |
307 | w->addColumn( "Info" ); | 310 | w->addColumn( "Info" ); |
308 | w->addColumn( "Value" ); | 311 | w->addColumn( "Value" ); |
309 | w->hide(); | 312 | w->hide(); |
310 | } | 313 | } |
311 | 314 | ||
312 | CpuDevice::~CpuDevice() | 315 | CpuDevice::~CpuDevice() |
313 | { | 316 | { |
314 | } | 317 | } |
315 | 318 | ||
316 | void CpuDevice::addInfo( const QString& info ) | 319 | void CpuDevice::addInfo( const QString& info ) |
317 | { | 320 | { |
318 | int dp = info.find( ':' ); | 321 | int dp = info.find( ':' ); |
319 | if ( dp != -1 ) | 322 | if ( dp != -1 ) |
320 | { | 323 | { |
321 | new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) ); | 324 | new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) ); |
322 | } | 325 | } |
323 | } | 326 | } |
324 | 327 | ||
325 | //================================================================================================= | 328 | //================================================================================================= |
326 | CardDevice::CardDevice( Category* parent, const QString& name ) | 329 | CardDevice::CardDevice( Category* parent, const QString& name ) |
327 | :Device( parent, name ) | 330 | :Device( parent, name ) |
328 | { | 331 | { |
329 | details = new QPushButton( name, devinfo ); | 332 | OListView* w = new OListView( devinfo ); |
330 | details->hide(); | 333 | details = w; |
334 | w->addColumn( "Info" ); | ||
335 | w->addColumn( "Value" ); | ||
336 | w->hide(); | ||
337 | } | ||
338 | |||
339 | void CardDevice::setInfo( const OPcmciaSocket* card ) | ||
340 | { | ||
341 | QStringList vendorlst = card->productIdentityVector(); | ||
342 | for( QStringList::Iterator it = vendorlst.begin(); it != vendorlst.end(); ++it ) | ||
343 | { | ||
344 | new OListViewItem( (OListView*) details, "VendorID", *it ); | ||
345 | } | ||
346 | new OListViewItem( (OListView*) details, "Manufacturer", card->manufacturerIdentity() ); | ||
347 | new OListViewItem( (OListView*) details, "Function", card->function() ); | ||
348 | |||
349 | QStringList text; | ||
350 | OPcmciaSocket::OPcmciaSocketCardStatus status = card->status(); | ||
351 | if ( status ) | ||
352 | { | ||
353 | if ( status & OPcmciaSocket::Occupied ) text += "Occupied"; | ||
354 | if ( status & OPcmciaSocket::OccupiedCardBus ) text += "CardBus"; | ||
355 | if ( status & OPcmciaSocket::WriteProtected ) text += "WriteProtected"; | ||
356 | if ( status & OPcmciaSocket::BatteryLow ) text += "BatteryLow"; | ||
357 | if ( status & OPcmciaSocket::BatteryDead ) text += "BatteryDead"; | ||
358 | if ( status & OPcmciaSocket::Ready ) text += "Ready"; | ||
359 | if ( status & OPcmciaSocket::Suspended ) text += "Suspended"; | ||
360 | if ( status & OPcmciaSocket::Attention ) text += "Attention"; | ||
361 | if ( status & OPcmciaSocket::InsertionInProgress ) text += "InsertionInProgress"; | ||
362 | if ( status & OPcmciaSocket::RemovalInProgress ) text += "RemovalInProgress"; | ||
363 | if ( status & OPcmciaSocket::ThreeVolts ) text += "3V"; | ||
364 | if ( status & OPcmciaSocket::SupportsVoltage ) text += "SupportsVoltage"; | ||
365 | } | ||
366 | else | ||
367 | { | ||
368 | text += "<unknown>"; | ||
369 | } | ||
370 | new OListViewItem( (OListView*) details, "Status", text.join( ", " ) ); | ||
331 | } | 371 | } |
332 | 372 | ||
333 | CardDevice::~CardDevice() | 373 | CardDevice::~CardDevice() |
334 | { | 374 | { |
335 | } | 375 | } |
336 | 376 | ||
337 | //================================================================================================= | 377 | //================================================================================================= |
338 | InputDevice::InputDevice( Category* parent, const QString& name ) | 378 | InputDevice::InputDevice( Category* parent, const QString& name ) |
339 | :Device( parent, name ) | 379 | :Device( parent, name ) |
340 | { | 380 | { |
341 | details = new QPushButton( name, devinfo ); | 381 | OListView* w = new OListView( devinfo ); |
342 | details->hide(); | 382 | details = w; |
383 | w->addColumn( "Info" ); | ||
384 | w->addColumn( "Value" ); | ||
385 | w->hide(); | ||
386 | } | ||
387 | |||
388 | void InputDevice::setInfo( const OInputDevice* dev ) | ||
389 | { | ||
390 | new OListViewItem( (OListView*) details, "Identity", dev->identity() ); | ||
391 | new OListViewItem( (OListView*) details, "Path", dev->path() ); | ||
392 | new OListViewItem( (OListView*) details, "Unique", dev->uniq() ); | ||
393 | |||
394 | QStringList text; | ||
395 | if ( dev->hasFeature( OInputDevice::Synchronous ) ) text += "Synchronous"; | ||
396 | if ( dev->hasFeature( OInputDevice::Keys ) ) text += "Keys"; | ||
397 | if ( dev->hasFeature( OInputDevice::Relative ) ) text += "Relative"; | ||
398 | if ( dev->hasFeature( OInputDevice::Absolute ) ) text += "Absolute"; | ||
399 | if ( dev->hasFeature( OInputDevice::Miscellaneous ) ) text += "Miscellaneous"; | ||
400 | if ( dev->hasFeature( OInputDevice::Leds ) ) text += "Leds"; | ||
401 | if ( dev->hasFeature( OInputDevice::Sound ) ) text += "Sound"; | ||
402 | if ( dev->hasFeature( OInputDevice::AutoRepeat ) ) text += "AutoRepeat"; | ||
403 | if ( dev->hasFeature( OInputDevice::ForceFeedback ) ) text += "ForceFeedback"; | ||
404 | if ( dev->hasFeature( OInputDevice::PowerManagement ) ) text += "PowerManagement"; | ||
405 | if ( dev->hasFeature( OInputDevice::ForceFeedbackStatus ) ) text += "ForceFeedbackStatus"; | ||
406 | new OListViewItem( (OListView*) details, "Features", text.join( ", " ) ); | ||
407 | |||
343 | } | 408 | } |
344 | 409 | ||
345 | InputDevice::~InputDevice() | 410 | InputDevice::~InputDevice() |
346 | { | 411 | { |
347 | } | 412 | } |
348 | 413 | ||
349 | //================================================================================================= | 414 | //================================================================================================= |
350 | UsbDevice::UsbDevice( Category* parent, const QString& name ) | 415 | UsbDevice::UsbDevice( Category* parent, const QString& name ) |
351 | :Device( parent, name ) | 416 | :Device( parent, name ) |
352 | { | 417 | { |
353 | details = new QPushButton( name, devinfo ); | 418 | details = new QPushButton( name, devinfo ); |
354 | details->hide(); | 419 | details->hide(); |
355 | } | 420 | } |
356 | 421 | ||
357 | //================================================================================================= | 422 | //================================================================================================= |
358 | UsbDevice::UsbDevice( UsbDevice* parent, const QString& name ) | 423 | UsbDevice::UsbDevice( UsbDevice* parent, const QString& name ) |
359 | :Device( parent, name ) | 424 | :Device( parent, name ) |
360 | { | 425 | { |
361 | details = new QPushButton( name, devinfo ); | 426 | details = new QPushButton( name, devinfo ); |
362 | details->hide(); | 427 | details->hide(); |
363 | } | 428 | } |
364 | 429 | ||
365 | UsbDevice::~UsbDevice() | 430 | UsbDevice::~UsbDevice() |
366 | { | 431 | { |