summaryrefslogtreecommitdiff
path: root/noncore/applets/pcmcia/configdialog.cpp
Unidiff
Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp42
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
@@ -37,13 +37,15 @@ using namespace Opie::Core;
37/* QT */ 37/* QT */
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qfile.h>
40#include <qlabel.h> 41#include <qlabel.h>
42#include <qtextstream.h>
41 43
42ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) 44ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent )
43 :ConfigDialogBase( parent, "pcmcia config dialog", true ) 45 :ConfigDialogBase( parent, "pcmcia config dialog", true )
44{ 46{
45 //setCaption( tr( "Configure %1" ).arg( cardname ) ); 47 //setCaption( tr( "Configure %1" ).arg( cardname ) );
46 textCardName->setText( cardname ); 48 txtCardName->setText( cardname );
47 49
48 OConfig cfg( "PCMCIA" ); 50 OConfig cfg( "PCMCIA" );
49 cfg.setGroup( "Global" ); 51 cfg.setGroup( "Global" );
@@ -70,15 +72,45 @@ ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent )
70 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); 72 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i );
71 } 73 }
72 74
73 // parse possible device and class names out of /etc/pcmcia/*.conf 75 // parse possible bind entries out of /etc/pcmcia/*.conf
74 QStringList deviceNames; 76 typedef QMap<QString,QString> StringMap;
75 QStringList classNames; 77 StringMap bindEntries;
76 78
77 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); 79 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" );
78 80
79 for ( int i = 0; i < pcmciaconfdir.count(); ++i ) 81 for ( int i = 0; i < pcmciaconfdir.count(); ++i )
80 odebug << "found conf file '" << pcmciaconfdir[i] << "'" << oendl; 82 {
83 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl;
84 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] );
85 QFile conffile( conffilename );
86 if ( conffile.open( IO_ReadOnly ) )
87 {
88 QTextStream ts( &conffile );
89 while ( !ts.atEnd() )
90 {
91 QString word;
92 ts >> word;
93 if ( word == "bind" )
94 {
95 word = ts.readLine();
96 bindEntries[ word.stripWhiteSpace() ] = conffilename;
97 continue;
98 }
99 ts.readLine();
100 }
101 }
102 else
103 {
104 owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl;
105 continue;
106 }
107 }
81 108
109 for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it )
110 {
111 odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl;
112 cbBindTo->insertItem( it.key() );
113 }
82} 114}
83 115
84ConfigDialog::~ConfigDialog() 116ConfigDialog::~ConfigDialog()