Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (show 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 | |||
@@ -34,19 +34,21 @@ | |||
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | using namespace Opie::Core; | 35 | using namespace Opie::Core; |
36 | 36 | ||
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 | ||
42 | ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) | 44 | ConfigDialog::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" ); |
50 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 52 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
51 | QString insert; | 53 | QString insert; |
52 | 54 | ||
@@ -67,20 +69,50 @@ ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) | |||
67 | if ( !insert.isEmpty() ) | 69 | if ( !insert.isEmpty() ) |
68 | { | 70 | { |
69 | for ( int i; i < cbAction->count(); ++i ) | 71 | for ( int i; i < cbAction->count(); ++i ) |
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 | ||
84 | ConfigDialog::~ConfigDialog() | 116 | ConfigDialog::~ConfigDialog() |
85 | { | 117 | { |
86 | } | 118 | } |