summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-05-21 15:43:07 (UTC)
committer mickeyl <mickeyl>2005-05-21 15:43:07 (UTC)
commite570da2879fb3220a46f1a19bb797512fca144c6 (patch) (unidiff)
tree9ba374f101078fb5ba2e77ad9ab3beefa0a05415
parentc5cb180e37514584fd0015d7713fe07c041f3815 (diff)
downloadopie-e570da2879fb3220a46f1a19bb797512fca144c6.zip
opie-e570da2879fb3220a46f1a19bb797512fca144c6.tar.gz
opie-e570da2879fb3220a46f1a19bb797512fca144c6.tar.bz2
catch up with pcmcia changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp24
-rw-r--r--noncore/settings/sysinfo/devicesinfo.cpp2
2 files changed, 18 insertions, 8 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 5183572..7f24371 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -1,249 +1,259 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
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; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
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#include "pcmcia.h" 30#include "pcmcia.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34#include <opie2/odevice.h> 34#include <opie2/odevice.h>
35#include <opie2/oconfig.h> 35#include <opie2/oconfig.h>
36#include <opie2/oprocess.h> 36#include <opie2/oprocess.h>
37#include <opie2/opcmciasystem.h> 37#include <opie2/opcmciasystem.h>
38#include <opie2/oresource.h> 38#include <opie2/oresource.h>
39#include <opie2/otaskbarapplet.h> 39#include <opie2/otaskbarapplet.h>
40#include <qpe/applnk.h> 40#include <qpe/applnk.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42using namespace Opie::Core; 42using namespace Opie::Core;
43using namespace Opie::Ui; 43using namespace Opie::Ui;
44 44
45/* QT */ 45/* QT */
46#include <qcopchannel_qws.h> 46#include <qcopchannel_qws.h>
47#include <qpainter.h> 47#include <qpainter.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qtextstream.h> 49#include <qtextstream.h>
50#include <qmessagebox.h> 50#include <qmessagebox.h>
51#include <qsound.h> 51#include <qsound.h>
52#include <qtimer.h> 52#include <qtimer.h>
53 53
54/* STD */ 54/* STD */
55#include <stdio.h> 55#include <stdio.h>
56#include <unistd.h> 56#include <unistd.h>
57#include <stdlib.h> 57#include <stdlib.h>
58#include <string.h> 58#include <string.h>
59#include <fcntl.h> 59#include <fcntl.h>
60#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 60#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
61#include <sys/vfs.h> 61#include <sys/vfs.h>
62#include <mntent.h> 62#include <mntent.h>
63#endif 63#endif
64 64
65PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) 65PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent )
66{ 66{
67 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); 67 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
68 connect( pcmciaChannel, 68 connect( pcmciaChannel,
69 SIGNAL( received(const QCString&,const QByteArray&) ), this, 69 SIGNAL( received(const QCString&,const QByteArray&) ), this,
70 SLOT( cardMessage(const QCString&,const QByteArray&) ) ); 70 SLOT( cardMessage(const QCString&,const QByteArray&) ) );
71 71
72 setFocusPolicy( NoFocus ); 72 setFocusPolicy( NoFocus );
73 setFixedWidth ( AppLnk::smallIconSize() ); 73 setFixedWidth ( AppLnk::smallIconSize() );
74 setFixedHeight ( AppLnk::smallIconSize() ); 74 setFixedHeight ( AppLnk::smallIconSize() );
75 pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); 75 pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon );
76} 76}
77 77
78 78
79PcmciaManager::~PcmciaManager() 79PcmciaManager::~PcmciaManager()
80{ 80{
81} 81}
82 82
83 83
84void PcmciaManager::popUp( QString message, QString icon ) 84void PcmciaManager::popUp( QString message, QString icon )
85{ 85{
86 if ( !popupMenu ) { 86 if ( !popupMenu ) {
87 popupMenu = new QPopupMenu( this ); 87 popupMenu = new QPopupMenu( this );
88 } 88 }
89 89
90 popupMenu->clear(); 90 popupMenu->clear();
91 if ( icon.isEmpty() ) { 91 if ( icon.isEmpty() ) {
92 popupMenu->insertItem( message, 0 ); 92 popupMenu->insertItem( message, 0 );
93 } else { 93 } else {
94 popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), 94 popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ),
95 message, 0 ); 95 message, 0 );
96 } 96 }
97 97
98 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 98 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
99 QSize s = popupMenu->sizeHint(); 99 QSize s = popupMenu->sizeHint();
100 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), 100 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
101 p.y() - s.height() ), 0 ); 101 p.y() - s.height() ), 0 );
102 102
103 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); 103 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
104} 104}
105 105
106 106
107void PcmciaManager::popupTimeout() 107void PcmciaManager::popupTimeout()
108{ 108{
109 popupMenu->hide(); 109 popupMenu->hide();
110} 110}
111 111
112 112
113void PcmciaManager::mousePressEvent( QMouseEvent* ) 113void PcmciaManager::mousePressEvent( QMouseEvent* )
114{ 114{
115 QPopupMenu * menu = new QPopupMenu( this ); 115 QPopupMenu* menu = new QPopupMenu( this );
116 QStringList cmd; 116 QStringList cmd;
117 bool execute = true; 117 bool execute = true;
118 118
119 OPcmciaSystem* sys = OPcmciaSystem::instance(); 119 OPcmciaSystem* sys = OPcmciaSystem::instance();
120 OPcmciaSystem::CardIterator it = sys->iterator(); 120 OPcmciaSystem::CardIterator it = sys->iterator();
121 if ( !sys->count() ) return; 121 if ( !sys->count() ) return;
122 122
123 int i = 0; 123 int i = 0;
124 while ( it.current() ) 124 while ( it.current() )
125 { 125 {
126 menu->insertItem( tr( "Eject card %1: %2" ).arg( i++ ).arg( it.currentKey() ), 1 ); 126
127 QPopupMenu* submenu = new QPopupMenu( menu );
128 submenu->insertItem( "Eject" );
129 submenu->insertItem( "Insert" );
130 submenu->insertItem( "Suspend" );
131 submenu->insertItem( "Resume" );
132 submenu->insertItem( "Configure" );
133
134 menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 );
127 ++it; 135 ++it;
128 } 136 }
129 137
130 138
139
131 /* insert items depending on number of cards etc. 140 /* insert items depending on number of cards etc.
132 141
133 if ( cardInSd ) { 142 if ( cardInSd ) {
134 menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ), 143 menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ),
135 tr( "Eject SD/MMC card" ), 0 ); 144 tr( "Eject SD/MMC card" ), 0 );
136 } 145 }
137 146
138 147
139 148
140 if ( cardInPcmcia0 ) { 149 if ( cardInPcmcia0 ) {
141 menu-> 150 menu->
142 insertItem( QIconSet 151 insertItem( QIconSet
143 ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ), 152 ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ),
144 tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); 153 tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 );
145 } 154 }
146 155
147 if ( cardInPcmcia1 ) { 156 if ( cardInPcmcia1 ) {
148 menu-> 157 menu->
149 insertItem( QIconSet 158 insertItem( QIconSet
150 ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ), 159 ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ),
151 tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); 160 tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 );
152 } 161 }
153 */ 162 */
154 163
155 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 164 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
156 QSize s = menu->sizeHint(); 165 QSize s = menu->sizeHint();
157 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); 166 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 );
158 qDebug( "pcmcia: menu result = %d", opt ); 167 qDebug( "pcmcia: menu result = %d", opt );
159 delete menu; 168 delete menu;
160} 169}
161 170
162 171
163void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) 172void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
164{ 173{
165 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; 174 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl;
166 if ( msg != "stabChanged()" ) return; 175 if ( msg != "stabChanged()" ) return;
167 176
168 /* check if a previously unknown card has been inserted */ 177 /* check if a previously unknown card has been inserted */
169 OPcmciaSystem::instance()->synchronize(); 178 OPcmciaSystem::instance()->synchronize();
170 179
171 if ( !OPcmciaSystem::instance()->count() ) return; 180 if ( !OPcmciaSystem::instance()->cardCount() ) return;
172 181
173 OConfig cfg( "PCMCIA" ); 182 OConfig cfg( "PCMCIA" );
174 cfg.setGroup( "Global" ); 183 cfg.setGroup( "Global" );
175 int nCards = cfg.readNumEntry( "nCards", 0 ); 184 int nCards = cfg.readNumEntry( "nCards", 0 );
176 185
177 OPcmciaSystem* sys = OPcmciaSystem::instance(); 186 OPcmciaSystem* sys = OPcmciaSystem::instance();
178 OPcmciaSystem::CardIterator it = sys->iterator(); 187 OPcmciaSystem::CardIterator it = sys->iterator();
179 188
180 bool newCard = true; 189 bool newCard = true;
181 while ( it.current() && newCard ) 190
191 while ( it.current() && !it.current()->isEmpty() && newCard )
182 { 192 {
183 QString name = it.currentKey(); 193 QString name = it.current()->identity();
184 for ( int i = 0; i < nCards; ++i ) 194 for ( int i = 0; i < nCards; ++i )
185 { 195 {
186 QString cardSection = QString( "Card_%1" ).arg( i ); 196 QString cardSection = QString( "Card_%1" ).arg( i );
187 cfg.setGroup( cardSection ); 197 cfg.setGroup( cardSection );
188 QString cardName = cfg.readEntry( "name" ); 198 QString cardName = cfg.readEntry( "name" );
189 odebug << "comparing card '" << name << "' with known card '" << cardName << "'" << oendl; 199 odebug << "comparing card '" << name << "' with known card '" << cardName << "'" << oendl;
190 if ( cardName == name ) 200 if ( cardName == name )
191 { 201 {
192 newCard = false; 202 newCard = false;
193 break; 203 break;
194 } 204 }
195 } 205 }
196 if ( !newCard ) ++it; else break; 206 if ( !newCard ) ++it; else break;
197 } 207 }
198 QString newCardName = it.currentKey();
199 208
200 if ( newCard ) 209 if ( newCard )
201 { 210 {
211 QString newCardName = it.current()->identity();
202 odebug << "pcmcia: new card detected" << oendl; 212 odebug << "pcmcia: new card detected" << oendl;
203 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); 213 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
204 cfg.writeEntry( "name", newCardName ); 214 cfg.writeEntry( "name", newCardName );
205 cfg.setGroup( "Global" ); 215 cfg.setGroup( "Global" );
206 cfg.writeEntry( "nCards", nCards+1 ); 216 cfg.writeEntry( "nCards", nCards+1 );
207 cfg.write(); 217 cfg.write();
208 218
209 int result = QMessageBox::information( qApp->desktop(), 219 int result = QMessageBox::information( qApp->desktop(),
210 tr( "PCMCIA/CF Subsystem" ), 220 tr( "PCMCIA/CF Subsystem" ),
211 tr( "You have inserted a new card\n%1\nDo you want to configure this card?" ).arg( newCardName ), 221 tr( "You have inserted a new card\n%1\nDo you want to configure this card?" ).arg( newCardName ),
212 tr( "Yes" ), tr( "No" ), 0, 0, 1 ); 222 tr( "Yes" ), tr( "No" ), 0, 0, 1 );
213 odebug << "result = " << result << oendl; 223 odebug << "result = " << result << oendl;
214 224
215 } 225 }
216 else 226 else
217 { 227 {
218 odebug << "pcmcia: card has been previously inserted" << oendl; 228 odebug << "pcmcia: card has been previously inserted" << oendl;
219 } 229 }
220 repaint( TRUE ); 230 repaint( TRUE );
221} 231}
222 232
223 233
224void PcmciaManager::paintEvent( QPaintEvent * ) 234void PcmciaManager::paintEvent( QPaintEvent * )
225{ 235{
226 QPainter p( this ); 236 QPainter p( this );
227 qDebug( "count = %d", (OPcmciaSystem::instance()->count() ) ); 237 qDebug( "count = %d", (OPcmciaSystem::instance()->count() ) );
228 if ( OPcmciaSystem::instance()->count() ) 238 if ( OPcmciaSystem::instance()->count() )
229 { 239 {
230 p.drawPixmap( 0, 0, pm ); 240 p.drawPixmap( 0, 0, pm );
231 show(); 241 show();
232 } 242 }
233 else 243 else
234 { 244 {
235 hide(); 245 hide();
236 } 246 }
237} 247}
238 248
239int PcmciaManager::position() 249int PcmciaManager::position()
240{ 250{
241 return 7; 251 return 7;
242} 252}
243 253
244void PcmciaManager::execCommand( const QStringList &strList ) 254void PcmciaManager::execCommand( const QStringList &strList )
245{ 255{
246} 256}
247 257
248EXPORT_OPIE_APPLET_v1( PcmciaManager ) 258EXPORT_OPIE_APPLET_v1( PcmciaManager )
249 259
diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp
index 945edea..4940286 100644
--- a/noncore/settings/sysinfo/devicesinfo.cpp
+++ b/noncore/settings/sysinfo/devicesinfo.cpp
@@ -1,367 +1,367 @@
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/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>
37using namespace Opie::Core; 37using namespace Opie::Core;
38using namespace Opie::Ui; 38using 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 <qtextstream.h> 46#include <qtextstream.h>
47#include <qtextview.h> 47#include <qtextview.h>
48#include <qtimer.h> 48#include <qtimer.h>
49#include <qwhatsthis.h> 49#include <qwhatsthis.h>
50 50
51//================================================================================================= 51//=================================================================================================
52DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl ) 52DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl )
53 :Opie::Ui::OListView( parent, name, fl ) 53 :Opie::Ui::OListView( parent, name, fl )
54{ 54{
55 addColumn( tr( "My Computer" ) ); 55 addColumn( tr( "My Computer" ) );
56 setAllColumnsShowFocus( true ); 56 setAllColumnsShowFocus( true );
57 setRootIsDecorated( true ); 57 setRootIsDecorated( true );
58 QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) ); 58 QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) );
59 59
60 DevicesView* root = this; 60 DevicesView* root = this;
61 ( new CpuCategory( root ) )->populate(); 61 ( new CpuCategory( root ) )->populate();
62 ( new InputCategory( root ) )->populate(); 62 ( new InputCategory( root ) )->populate();
63 ( new CardsCategory( root ) )->populate(); 63 ( new CardsCategory( root ) )->populate();
64 ( new UsbCategory( root ) )->populate(); 64 ( new UsbCategory( root ) )->populate();
65 65
66 connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) ); 66 connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) );
67} 67}
68 68
69DevicesView::~DevicesView() 69DevicesView::~DevicesView()
70{ 70{
71} 71}
72 72
73 73
74void DevicesView::selectionChanged( QListViewItem* item ) 74void DevicesView::selectionChanged( QListViewItem* item )
75{ 75{
76 odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl; 76 odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl;
77 if ( item->parent() ) 77 if ( item->parent() )
78 { 78 {
79 QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); 79 QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget();
80 ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details ); 80 ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details );
81 } 81 }
82 else 82 else
83 { 83 {
84 odebug << "DevicesView::not a device node." << oendl; 84 odebug << "DevicesView::not a device node." << oendl;
85 } 85 }
86} 86}
87 87
88 88
89//================================================================================================= 89//=================================================================================================
90DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) 90DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl )
91 :QWidget( parent, name, fl ), details( 0 ) 91 :QWidget( parent, name, fl ), details( 0 )
92{ 92{
93 layout = new OAutoBoxLayout( this ); 93 layout = new OAutoBoxLayout( this );
94 layout->setSpacing( 2 ); 94 layout->setSpacing( 2 );
95 layout->setMargin( 2 ); 95 layout->setMargin( 2 );
96 view = new DevicesView( this ); 96 view = new DevicesView( this );
97 layout->addWidget( view, 100 ); 97 layout->addWidget( view, 100 );
98 stack = new QWidgetStack( this ); 98 stack = new QWidgetStack( this );
99 layout->addWidget( stack, 70 ); 99 layout->addWidget( stack, 70 );
100} 100}
101 101
102 102
103DevicesInfo::~DevicesInfo() 103DevicesInfo::~DevicesInfo()
104{ 104{
105} 105}
106 106
107 107
108void DevicesInfo::setDetailsWidget( QWidget* w ) 108void DevicesInfo::setDetailsWidget( QWidget* w )
109{ 109{
110 if ( details ) 110 if ( details )
111 { 111 {
112 qDebug( "hiding widget '%s' ('%s')", details->name(), details->className() ); 112 qDebug( "hiding widget '%s' ('%s')", details->name(), details->className() );
113 stack->removeWidget( w ); 113 stack->removeWidget( w );
114 } 114 }
115 115
116 stack->addWidget( details = w, 40 ); 116 stack->addWidget( details = w, 40 );
117 stack->raiseWidget( details ); 117 stack->raiseWidget( details );
118} 118}
119 119
120 120
121//================================================================================================= 121//=================================================================================================
122Category::Category( DevicesView* parent, const QString& name ) 122Category::Category( DevicesView* parent, const QString& name )
123 :OListViewItem( parent, name ) 123 :OListViewItem( parent, name )
124{ 124{
125 odebug << "Category '" << name << "' inserted. Scanning for devices..." << oendl; 125 odebug << "Category '" << name << "' inserted. Scanning for devices..." << oendl;
126} 126}
127 127
128Category::~Category() 128Category::~Category()
129{ 129{
130} 130}
131 131
132//================================================================================================= 132//=================================================================================================
133CpuCategory::CpuCategory( DevicesView* parent ) 133CpuCategory::CpuCategory( DevicesView* parent )
134 :Category( parent, "1. Central Processing Unit" ) 134 :Category( parent, "1. Central Processing Unit" )
135{ 135{
136} 136}
137 137
138CpuCategory::~CpuCategory() 138CpuCategory::~CpuCategory()
139{ 139{
140} 140}
141 141
142void CpuCategory::populate() 142void CpuCategory::populate()
143{ 143{
144 odebug << "CpuCategory::populate()" << oendl; 144 odebug << "CpuCategory::populate()" << oendl;
145 QFile cpuinfofile( "/proc/cpuinfo" ); 145 QFile cpuinfofile( "/proc/cpuinfo" );
146 if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) ) 146 if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) )
147 { 147 {
148 new CpuDevice( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); 148 new CpuDevice( this, "ERROR: /proc/cpuinfo not found or unaccessible" );
149 return; 149 return;
150 } 150 }
151 QTextStream cpuinfo( &cpuinfofile ); 151 QTextStream cpuinfo( &cpuinfofile );
152 152
153 int cpucount = 0; 153 int cpucount = 0;
154 CpuDevice* dev = 0; 154 CpuDevice* dev = 0;
155 155
156 while ( !cpuinfo.atEnd() ) 156 while ( !cpuinfo.atEnd() )
157 { 157 {
158 QString line = cpuinfo.readLine(); 158 QString line = cpuinfo.readLine();
159 odebug << "got line '" << line << "'" << oendl; 159 odebug << "got line '" << line << "'" << oendl;
160 if ( line.lower().startsWith( "processor" ) ) 160 if ( line.lower().startsWith( "processor" ) )
161 { 161 {
162 dev = new CpuDevice( this, QString( "CPU #%1" ).arg( cpucount++ ) ); 162 dev = new CpuDevice( this, QString( "CPU #%1" ).arg( cpucount++ ) );
163 dev->addInfo( line ); 163 dev->addInfo( line );
164 } 164 }
165 else 165 else
166 { 166 {
167 if ( dev ) dev->addInfo( line ); 167 if ( dev ) dev->addInfo( line );
168 } 168 }
169 } 169 }
170} 170}
171 171
172//================================================================================================= 172//=================================================================================================
173InputCategory::InputCategory( DevicesView* parent ) 173InputCategory::InputCategory( DevicesView* parent )
174 :Category( parent, "2. Input Subsystem" ) 174 :Category( parent, "2. Input Subsystem" )
175{ 175{
176} 176}
177 177
178InputCategory::~InputCategory() 178InputCategory::~InputCategory()
179{ 179{
180} 180}
181 181
182void InputCategory::populate() 182void InputCategory::populate()
183{ 183{
184 odebug << "InputCategory::populate()" << oendl; 184 odebug << "InputCategory::populate()" << oendl;
185 OInputSystem* sys = OInputSystem::instance(); 185 OInputSystem* sys = OInputSystem::instance();
186 OInputSystem::DeviceIterator it = sys->iterator(); 186 OInputSystem::DeviceIterator it = sys->iterator();
187 while ( it.current() ) 187 while ( it.current() )
188 { 188 {
189 new InputDevice( this, it.current()->identity() ); 189 new InputDevice( this, it.current()->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 OPcmciaSystem* sys = OPcmciaSystem::instance(); 207 OPcmciaSystem* sys = OPcmciaSystem::instance();
208 OPcmciaSystem::CardIterator it = sys->iterator(); 208 OPcmciaSystem::CardIterator it = sys->iterator();
209 while ( it.current() ) 209 while ( it.current() )
210 { 210 {
211 new CardDevice( this, (const char*) it.currentKey() ); 211 new CardDevice( this, it.current()->identity() );
212 ++it; 212 ++it;
213 } 213 }
214} 214}
215 215
216//================================================================================================= 216//=================================================================================================
217UsbCategory::UsbCategory( DevicesView* parent ) 217UsbCategory::UsbCategory( DevicesView* parent )
218 :Category( parent, "4. Universal Serial Bus" ) 218 :Category( parent, "4. Universal Serial Bus" )
219{ 219{
220} 220}
221 221
222UsbCategory::~UsbCategory() 222UsbCategory::~UsbCategory()
223{ 223{
224} 224}
225 225
226void UsbCategory::populate() 226void UsbCategory::populate()
227{ 227{
228 odebug << "UsbCategory::populate()" << oendl; 228 odebug << "UsbCategory::populate()" << oendl;
229 QFile usbinfofile( "/proc/bus/usb/devices" ); 229 QFile usbinfofile( "/proc/bus/usb/devices" );
230 if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) 230 if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) )
231 { 231 {
232 new UsbDevice( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" ); 232 new UsbDevice( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" );
233 return; 233 return;
234 } 234 }
235 QTextStream usbinfo( &usbinfofile ); 235 QTextStream usbinfo( &usbinfofile );
236 236
237 int _bus, _level, _parent, _port, _count, _device, _channels, _power; 237 int _bus, _level, _parent, _port, _count, _device, _channels, _power;
238 float _speed; 238 float _speed;
239 QString _manufacturer, _product, _serial; 239 QString _manufacturer, _product, _serial;
240 240
241 int usbcount = 0; 241 int usbcount = 0;
242 UsbDevice* lastDev = 0; 242 UsbDevice* lastDev = 0;
243 UsbDevice* dev = 0; 243 UsbDevice* dev = 0;
244 while ( !usbinfo.atEnd() ) 244 while ( !usbinfo.atEnd() )
245 { 245 {
246 QString line = usbinfo.readLine(); 246 QString line = usbinfo.readLine();
247 odebug << "got line '" << line << "'" << oendl; 247 odebug << "got line '" << line << "'" << oendl;
248 if ( line.startsWith( "T:" ) ) 248 if ( line.startsWith( "T:" ) )
249 { 249 {
250 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); 250 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);
251 251
252 if ( !_level ) 252 if ( !_level )
253 { 253 {
254 odebug << "adding new bus" << oendl; 254 odebug << "adding new bus" << oendl;
255 dev = new UsbDevice( this, QString( "Generic USB Hub Device" ) ); 255 dev = new UsbDevice( this, QString( "Generic USB Hub Device" ) );
256 lastDev = dev; 256 lastDev = dev;
257 } 257 }
258 else 258 else
259 { 259 {
260 odebug << "adding new dev" << oendl; 260 odebug << "adding new dev" << oendl;
261 dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) ); 261 dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) );
262 lastDev = dev; 262 lastDev = dev;
263 } 263 }
264 } 264 }
265 else if ( line.startsWith( "S: Product" ) ) 265 else if ( line.startsWith( "S: Product" ) )
266 { 266 {
267 int dp = line.find( '=' ); 267 int dp = line.find( '=' );
268 dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" ); 268 dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" );
269 } 269 }
270 else 270 else
271 { 271 {
272 continue; 272 continue;
273 } 273 }
274 } 274 }
275} 275}
276 276
277 277
278//================================================================================================= 278//=================================================================================================
279Device::Device( Category* parent, const QString& name ) 279Device::Device( Category* parent, const QString& name )
280 :OListViewItem( parent, name ) 280 :OListViewItem( parent, name )
281{ 281{
282 devinfo = static_cast<QWidget*>( listView()->parent() ); 282 devinfo = static_cast<QWidget*>( listView()->parent() );
283} 283}
284 284
285Device::Device( Device* parent, const QString& name ) 285Device::Device( Device* parent, const QString& name )
286 :OListViewItem( parent, name ) 286 :OListViewItem( parent, name )
287{ 287{
288 devinfo = static_cast<QWidget*>( listView()->parent() ); 288 devinfo = static_cast<QWidget*>( listView()->parent() );
289} 289}
290 290
291Device::~Device() 291Device::~Device()
292{ 292{
293} 293}
294 294
295 295
296QWidget* Device::detailsWidget() 296QWidget* Device::detailsWidget()
297{ 297{
298 return details; 298 return details;
299} 299}
300 300
301//================================================================================================= 301//=================================================================================================
302CpuDevice::CpuDevice( Category* parent, const QString& name ) 302CpuDevice::CpuDevice( Category* parent, const QString& name )
303 :Device( parent, name ) 303 :Device( parent, name )
304{ 304{
305 OListView* w = new OListView( devinfo ); 305 OListView* w = new OListView( devinfo );
306 details = w; 306 details = w;
307 w->addColumn( "Info" ); 307 w->addColumn( "Info" );
308 w->addColumn( "Value" ); 308 w->addColumn( "Value" );
309 w->hide(); 309 w->hide();
310} 310}
311 311
312CpuDevice::~CpuDevice() 312CpuDevice::~CpuDevice()
313{ 313{
314} 314}
315 315
316void CpuDevice::addInfo( const QString& info ) 316void CpuDevice::addInfo( const QString& info )
317{ 317{
318 int dp = info.find( ':' ); 318 int dp = info.find( ':' );
319 if ( dp != -1 ) 319 if ( dp != -1 )
320 { 320 {
321 new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) ); 321 new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) );
322 } 322 }
323} 323}
324 324
325//================================================================================================= 325//=================================================================================================
326CardDevice::CardDevice( Category* parent, const QString& name ) 326CardDevice::CardDevice( Category* parent, const QString& name )
327 :Device( parent, name ) 327 :Device( parent, name )
328{ 328{
329 details = new QPushButton( name, devinfo ); 329 details = new QPushButton( name, devinfo );
330 details->hide(); 330 details->hide();
331} 331}
332 332
333CardDevice::~CardDevice() 333CardDevice::~CardDevice()
334{ 334{
335} 335}
336 336
337//================================================================================================= 337//=================================================================================================
338InputDevice::InputDevice( Category* parent, const QString& name ) 338InputDevice::InputDevice( Category* parent, const QString& name )
339 :Device( parent, name ) 339 :Device( parent, name )
340{ 340{
341 details = new QPushButton( name, devinfo ); 341 details = new QPushButton( name, devinfo );
342 details->hide(); 342 details->hide();
343} 343}
344 344
345InputDevice::~InputDevice() 345InputDevice::~InputDevice()
346{ 346{
347} 347}
348 348
349//================================================================================================= 349//=================================================================================================
350UsbDevice::UsbDevice( Category* parent, const QString& name ) 350UsbDevice::UsbDevice( Category* parent, const QString& name )
351 :Device( parent, name ) 351 :Device( parent, name )
352{ 352{
353 details = new QPushButton( name, devinfo ); 353 details = new QPushButton( name, devinfo );
354 details->hide(); 354 details->hide();
355} 355}
356 356
357//================================================================================================= 357//=================================================================================================
358UsbDevice::UsbDevice( UsbDevice* parent, const QString& name ) 358UsbDevice::UsbDevice( UsbDevice* parent, const QString& name )
359 :Device( parent, name ) 359 :Device( parent, name )
360{ 360{
361 details = new QPushButton( name, devinfo ); 361 details = new QPushButton( name, devinfo );
362 details->hide(); 362 details->hide();
363} 363}
364 364
365UsbDevice::~UsbDevice() 365UsbDevice::~UsbDevice()
366{ 366{
367} 367}