Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index f961069..f5812ba 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -51,19 +51,27 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | |||
51 | txtManfid->setText( card->manufacturerIdentity() ); | 51 | txtManfid->setText( card->manufacturerIdentity() ); |
52 | txtFunction->setText( card->function() ); | 52 | txtFunction->setText( card->function() ); |
53 | 53 | ||
54 | QString action = preferredAction( card ); | 54 | QString insertAction = preferredAction( card, "insert" ); |
55 | QString resumeAction = preferredAction( card, "resume" ); | ||
55 | 56 | ||
56 | odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl; | 57 | odebug << "pcmcia: preferred insertion action for card '" << card->name() << "' seems to be '" << insertAction << "'" << oendl; |
58 | odebug << "pcmcia: preferred resume action for card '" << card->name() << "' seems to be '" << resumeAction << "'" << oendl; | ||
57 | 59 | ||
58 | if ( !action.isEmpty() ) | 60 | if ( !insertAction.isEmpty() ) |
59 | { | 61 | { |
60 | for ( int i; i < cbAction->count(); ++i ) | 62 | for ( int i; i < cbInsertAction->count(); ++i ) |
61 | if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i ); | 63 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); |
64 | } | ||
65 | |||
66 | if ( !resumeAction.isEmpty() ) | ||
67 | { | ||
68 | for ( int i; i < cbResumeAction->count(); ++i ) | ||
69 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); | ||
62 | } | 70 | } |
63 | 71 | ||
64 | if ( !card->isUnsupported() ) | 72 | if ( !card->isUnsupported() ) |
65 | { | 73 | { |
66 | odebug << "card is recognized - hiding bindings" << oendl; | 74 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; |
67 | textInfo->hide(); | 75 | textInfo->hide(); |
68 | textBindTo->hide(); | 76 | textBindTo->hide(); |
69 | cbBindTo->hide(); | 77 | cbBindTo->hide(); |
@@ -78,9 +86,6 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | |||
78 | } | 86 | } |
79 | 87 | ||
80 | // parse possible bind entries out of /etc/pcmcia/*.conf | 88 | // parse possible bind entries out of /etc/pcmcia/*.conf |
81 | typedef QMap<QString,QString> StringMap; | ||
82 | StringMap bindEntries; | ||
83 | |||
84 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | 89 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); |
85 | 90 | ||
86 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) | 91 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) |
@@ -122,7 +127,7 @@ ConfigDialog::~ConfigDialog() | |||
122 | { | 127 | { |
123 | } | 128 | } |
124 | 129 | ||
125 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) | 130 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) |
126 | { | 131 | { |
127 | OConfig cfg( "PCMCIA" ); | 132 | OConfig cfg( "PCMCIA" ); |
128 | cfg.setGroup( "Global" ); | 133 | cfg.setGroup( "Global" ); |
@@ -137,10 +142,36 @@ QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) | |||
137 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 142 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; |
138 | if ( card->name() == name ) | 143 | if ( card->name() == name ) |
139 | { | 144 | { |
140 | action = cfg.readEntry( "action" ); | 145 | cfg.writeEntry( key, value ); |
141 | break; | 146 | break; |
142 | } | 147 | } |
143 | } | 148 | } |
149 | } | ||
144 | 150 | ||
145 | return action; | 151 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) |
152 | { | ||
153 | OConfig cfg( "PCMCIA" ); | ||
154 | cfg.setGroup( "Global" ); | ||
155 | int nCards = cfg.readNumEntry( "nCards", 0 ); | ||
156 | QString value; | ||
157 | |||
158 | for ( int i = 0; i < nCards; ++i ) | ||
159 | { | ||
160 | QString cardSection = QString( "Card_%1" ).arg( i ); | ||
161 | cfg.setGroup( cardSection ); | ||
162 | QString name = cfg.readEntry( "name" ); | ||
163 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | ||
164 | if ( card->name() == name ) | ||
165 | { | ||
166 | value = cfg.readEntry( key, defaultValue ); | ||
167 | break; | ||
168 | } | ||
169 | } | ||
170 | return value; | ||
171 | } | ||
172 | |||
173 | |||
174 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) | ||
175 | { | ||
176 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); | ||
146 | } | 177 | } |