summaryrefslogtreecommitdiff
path: root/noncore/applets/pcmcia/configdialog.cpp
Unidiff
Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp55
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
@@ -48,25 +48,33 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
48{ 48{
49 gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); 49 gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) );
50 txtCardName->setText( card->productIdentity().join( " " ) ); 50 txtCardName->setText( card->productIdentity().join( " " ) );
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();
70 return; 78 return;
71 } 79 }
72 else 80 else
@@ -75,15 +83,12 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
75 textInfo->show(); 83 textInfo->show();
76 textBindTo->show(); 84 textBindTo->show();
77 cbBindTo->show(); 85 cbBindTo->show();
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 )
87 { 92 {
88 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; 93 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl;
89 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); 94 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] );
@@ -119,13 +124,13 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
119} 124}
120 125
121ConfigDialog::~ConfigDialog() 126ConfigDialog::~ConfigDialog()
122{ 127{
123} 128}
124 129
125QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) 130void 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" );
129 int nCards = cfg.readNumEntry( "nCards", 0 ); 134 int nCards = cfg.readNumEntry( "nCards", 0 );
130 QString action; 135 QString action;
131 136
@@ -134,13 +139,39 @@ QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
134 QString cardSection = QString( "Card_%1" ).arg( i ); 139 QString cardSection = QString( "Card_%1" ).arg( i );
135 cfg.setGroup( cardSection ); 140 cfg.setGroup( cardSection );
136 QString name = cfg.readEntry( "name" ); 141 QString name = cfg.readEntry( "name" );
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; 151QString 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
174QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type )
175{
176 return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" );
146} 177}