Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index e7c97c1..e161d18 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp @@ -28,31 +28,33 @@ */ #include "configdialog.h" /* OPIE */ #include <opie2/oconfig.h> #include <opie2/odebug.h> using namespace Opie::Core; /* QT */ #include <qcombobox.h> #include <qdir.h> +#include <qfile.h> #include <qlabel.h> +#include <qtextstream.h> ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) :ConfigDialogBase( parent, "pcmcia config dialog", true ) { //setCaption( tr( "Configure %1" ).arg( cardname ) ); - textCardName->setText( cardname ); + txtCardName->setText( cardname ); OConfig cfg( "PCMCIA" ); cfg.setGroup( "Global" ); int nCards = cfg.readNumEntry( "nCards", 0 ); QString insert; for ( int i = 0; i < nCards; ++i ) { QString cardSection = QString( "Card_%1" ).arg( i ); cfg.setGroup( cardSection ); QString name = cfg.readEntry( "name" ); odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; @@ -61,26 +63,56 @@ ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) insert = cfg.readEntry( "insert" ); break; } } odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl; if ( !insert.isEmpty() ) { for ( int i; i < cbAction->count(); ++i ) if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); } - // parse possible device and class names out of /etc/pcmcia/*.conf - QStringList deviceNames; - QStringList classNames; + // parse possible bind entries out of /etc/pcmcia/*.conf + typedef QMap<QString,QString> StringMap; + StringMap bindEntries; QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); for ( int i = 0; i < pcmciaconfdir.count(); ++i ) - odebug << "found conf file '" << pcmciaconfdir[i] << "'" << oendl; + { + odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; + QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); + QFile conffile( conffilename ); + if ( conffile.open( IO_ReadOnly ) ) + { + QTextStream ts( &conffile ); + while ( !ts.atEnd() ) + { + QString word; + ts >> word; + if ( word == "bind" ) + { + word = ts.readLine(); + bindEntries[ word.stripWhiteSpace() ] = conffilename; + continue; + } + ts.readLine(); + } + } + else + { + owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; + continue; + } + } + for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) + { + odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; + cbBindTo->insertItem( it.key() ); + } } ConfigDialog::~ConfigDialog() { } |