summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-06-20 12:46:33 (UTC)
committer mickeyl <mickeyl>2005-06-20 12:46:33 (UTC)
commit3b02e2a868535628090567ed612d9fdb5b247f61 (patch) (unidiff)
tree6bc0281825b61316c594747b111b479f68115f37
parent1a3c172bd98026a555d65e802647f0511e80d3a6 (diff)
downloadopie-3b02e2a868535628090567ed612d9fdb5b247f61.zip
opie-3b02e2a868535628090567ed612d9fdb5b247f61.tar.gz
opie-3b02e2a868535628090567ed612d9fdb5b247f61.tar.bz2
miscellaneous work towards completon of this applet - still some way to go though
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp55
-rw-r--r--noncore/applets/pcmcia/configdialog.h7
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui171
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp69
-rw-r--r--noncore/applets/pcmcia/pcmcia.h2
5 files changed, 216 insertions, 88 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
@@ -53,10 +53,18 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
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 }
@@ -65,3 +73,3 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
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();
@@ -80,5 +88,2 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
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" );
@@ -124,3 +129,3 @@ ConfigDialog::~ConfigDialog()
124 129
125QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) 130void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value )
126{ 131{
@@ -139,3 +144,3 @@ QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
139 { 144 {
140 action = cfg.readEntry( "action" ); 145 cfg.writeEntry( key, value );
141 break; 146 break;
@@ -143,4 +148,30 @@ QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
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}
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h
index 321180d..169dadb 100644
--- a/noncore/applets/pcmcia/configdialog.h
+++ b/noncore/applets/pcmcia/configdialog.h
@@ -36,2 +36,4 @@ namespace Opie { namespace Core { class OPcmciaSocket; }; };
36 36
37typedef QMap<QString,QString> StringMap;
38
37class ConfigDialog : public ConfigDialogBase 39class ConfigDialog : public ConfigDialogBase
@@ -42,3 +44,6 @@ class ConfigDialog : public ConfigDialogBase
42 ~ConfigDialog(); 44 ~ConfigDialog();
43 static QString preferredAction( const Opie::Core::OPcmciaSocket* card ); 45 static QString preferredAction( const Opie::Core::OPcmciaSocket* card, const QString& type );
46 static QString readConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& defaultValue );
47 static void writeConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& value );
48 StringMap bindEntries;
44}; 49};
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui
index 829b71a..97d9a50 100644
--- a/noncore/applets/pcmcia/configdialogbase.ui
+++ b/noncore/applets/pcmcia/configdialogbase.ui
@@ -13,3 +13,3 @@
13 <y>0</y> 13 <y>0</y>
14 <width>215</width> 14 <width>211</width>
15 <height>329</height> 15 <height>329</height>
@@ -30,3 +30,3 @@
30 <name>margin</name> 30 <name>margin</name>
31 <number>5</number> 31 <number>6</number>
32 </property> 32 </property>
@@ -150,56 +150,3 @@
150 </widget> 150 </widget>
151 <widget row="1" column="0" > 151 <widget row="5" column="0" >
152 <class>QLabel</class>
153 <property stdset="1">
154 <name>name</name>
155 <cstring>TextLabel2</cstring>
156 </property>
157 <property stdset="1">
158 <name>text</name>
159 <string>On insertion,</string>
160 </property>
161 </widget>
162 <widget row="1" column="1" >
163 <class>QComboBox</class>
164 <item>
165 <property>
166 <name>text</name>
167 <string>suspend</string>
168 </property>
169 </item>
170 <item>
171 <property>
172 <name>text</name>
173 <string>activate</string>
174 </property>
175 </item>
176 <item>
177 <property>
178 <name>text</name>
179 <string>eject</string>
180 </property>
181 </item>
182 <item>
183 <property>
184 <name>text</name>
185 <string>prompt for</string>
186 </property>
187 </item>
188 <property stdset="1">
189 <name>name</name>
190 <cstring>cbAction</cstring>
191 </property>
192 </widget>
193 <widget row="1" column="2" >
194 <class>QLabel</class>
195 <property stdset="1">
196 <name>name</name>
197 <cstring>TextLabel3</cstring>
198 </property>
199 <property stdset="1">
200 <name>text</name>
201 <string>card</string>
202 </property>
203 </widget>
204 <widget row="4" column="0" >
205 <class>QLabel</class> 152 <class>QLabel</class>
@@ -214,3 +161,3 @@
214 </widget> 161 </widget>
215 <widget row="4" column="1" rowspan="1" colspan="2" > 162 <widget row="5" column="1" rowspan="1" colspan="2" >
216 <class>QComboBox</class> 163 <class>QComboBox</class>
@@ -246,3 +193,3 @@
246 </widget> 193 </widget>
247 <widget row="3" column="0" rowspan="1" colspan="3" > 194 <widget row="4" column="0" rowspan="1" colspan="3" >
248 <class>QLabel</class> 195 <class>QLabel</class>
@@ -273,3 +220,47 @@
273 </widget> 220 </widget>
274 <spacer row="2" column="1" > 221 <widget row="1" column="0" >
222 <class>QLabel</class>
223 <property stdset="1">
224 <name>name</name>
225 <cstring>TextLabel2</cstring>
226 </property>
227 <property stdset="1">
228 <name>text</name>
229 <string>On insertion,</string>
230 </property>
231 </widget>
232 <widget row="1" column="2" >
233 <class>QLabel</class>
234 <property stdset="1">
235 <name>name</name>
236 <cstring>TextLabel3</cstring>
237 </property>
238 <property stdset="1">
239 <name>text</name>
240 <string>card</string>
241 </property>
242 </widget>
243 <widget row="2" column="0" >
244 <class>QLabel</class>
245 <property stdset="1">
246 <name>name</name>
247 <cstring>TextLabel2_2</cstring>
248 </property>
249 <property stdset="1">
250 <name>text</name>
251 <string>On resume,</string>
252 </property>
253 </widget>
254 <widget row="2" column="2" >
255 <class>QLabel</class>
256 <property stdset="1">
257 <name>name</name>
258 <cstring>TextLabel3_2</cstring>
259 </property>
260 <property stdset="1">
261 <name>text</name>
262 <string>card</string>
263 </property>
264 </widget>
265 <spacer row="3" column="1" >
275 <property> 266 <property>
@@ -294,2 +285,64 @@
294 </spacer> 285 </spacer>
286 <widget row="1" column="1" >
287 <class>QComboBox</class>
288 <item>
289 <property>
290 <name>text</name>
291 <string>suspend</string>
292 </property>
293 </item>
294 <item>
295 <property>
296 <name>text</name>
297 <string>activate</string>
298 </property>
299 </item>
300 <item>
301 <property>
302 <name>text</name>
303 <string>eject</string>
304 </property>
305 </item>
306 <item>
307 <property>
308 <name>text</name>
309 <string>prompt for</string>
310 </property>
311 </item>
312 <property stdset="1">
313 <name>name</name>
314 <cstring>cbInsertAction</cstring>
315 </property>
316 </widget>
317 <widget row="2" column="1" >
318 <class>QComboBox</class>
319 <item>
320 <property>
321 <name>text</name>
322 <string>suspend</string>
323 </property>
324 </item>
325 <item>
326 <property>
327 <name>text</name>
328 <string>activate</string>
329 </property>
330 </item>
331 <item>
332 <property>
333 <name>text</name>
334 <string>eject</string>
335 </property>
336 </item>
337 <item>
338 <property>
339 <name>text</name>
340 <string>prompt for</string>
341 </property>
342 </item>
343 <property stdset="1">
344 <name>name</name>
345 <cstring>cbResumeAction</cstring>
346 </property>
347 </widget>
295 </grid> 348 </grid>
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 1a2b619..186dfea 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -41,2 +41,3 @@
41#include <qpe/applnk.h> 41#include <qpe/applnk.h>
42#include <qpe/global.h>
42#include <qpe/resource.h> 43#include <qpe/resource.h>
@@ -46,2 +47,3 @@ using namespace Opie::Ui;
46/* QT */ 47/* QT */
48#include <qcombobox.h>
47#include <qcopchannel_qws.h> 49#include <qcopchannel_qws.h>
@@ -180,3 +182,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
180 { 182 {
181 odebug << "skipping empty card in socket " << it.current()->number() << oendl; 183 odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl;
182 ++it; 184 ++it;
@@ -193,3 +195,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
193 QString name = cfg.readEntry( "name" ); 195 QString name = cfg.readEntry( "name" );
194 odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; 196 odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
195 if ( cardName == name ) 197 if ( cardName == name )
@@ -209,8 +211,9 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
209 tr( "PCMCIA/CF Subsystem" ), 211 tr( "PCMCIA/CF Subsystem" ),
210 tr( "<qt>You have inserted the card '%1'. This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ), 212 tr( "<qt>You have inserted the card<br/><b>%1</b><br/>This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ),
211 tr( "Yes" ), tr( "No" ), 0, 0, 1 ); 213 tr( "Yes" ), tr( "No" ), 0, 0, 1 );
212 odebug << "result = " << result << oendl; 214 odebug << "pcmcia: result = " << result << oendl;
213 if ( result == 0 ) 215 if ( result == 0 )
214 { 216 {
215 bool configured = configure( theCard ); 217 QString insertAction; QString resumeAction; QString driver; QString conf;
218 bool configured = configure( theCard, insertAction, resumeAction, driver, conf );
216 219
@@ -218,6 +221,7 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
218 { 221 {
219 odebug << "card has been configured. writing out to dabase" << oendl; 222 odebug << "pcmcia: card has been configured. writing out to database" << oendl;
220 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); 223 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
221 cfg.writeEntry( "name", newCardName ); 224 cfg.writeEntry( "name", newCardName );
222 cfg.writeEntry( "insert", "suspend" ); 225 cfg.writeEntry( "insertAction", insertAction );
226 cfg.writeEntry( "resumeAction", resumeAction );
223 cfg.setGroup( "Global" ); 227 cfg.setGroup( "Global" );
@@ -225,2 +229,24 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
225 cfg.write(); 229 cfg.write();
230
231 QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) );
232 if ( confFile.open( IO_ReadWrite | IO_Append ) )
233 {
234 QString entryCard = QString( "card \"%1\"" ).arg( newCardName );
235 QString entryVersion( " version " );
236 for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it )
237 {
238 entryVersion += QString( "\"%1\", " ).arg( *it );
239 }
240 QString entryBind = QString( " bind %1" ).arg( driver );
241 QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind );
242 odebug << "pcmcia: writing entry...:" << entry << oendl;
243
244 confFile.writeBlock( (const char*) entry, entry.length() );
245 Global::statusMessage( "restarting pcmcia services..." );
246 ::system( "/etc/init.d/pcmcia restart" );
247 }
248 else
249 {
250 owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl;
251 }
226 } 252 }
@@ -228,3 +254,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
228 { 254 {
229 odebug << "card has not been configured this time. leaving as unknown card" << oendl; 255 odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl;
230 } 256 }
@@ -238,5 +264,5 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
238 { 264 {
239 QString action = ConfigDialog::preferredAction( theCard ); 265 QString insertAction = ConfigDialog::preferredAction( theCard, "insert" );
240 odebug << "pcmcia: card has been previously configured" << oendl; 266 odebug << "pcmcia: card has been previously configured" << oendl;
241 odebug << "pcmcia: need to perform action'" << action << "' now... sorry, not yet implemented..." << oendl; 267 odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl;
242 } 268 }
@@ -273,3 +299,3 @@ void PcmciaManager::userCardAction( int action )
273{ 299{
274 odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl; 300 odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl;
275 301
@@ -281,3 +307,9 @@ void PcmciaManager::userCardAction( int action )
281 { 307 {
282 case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break; 308 case CONFIGURE:
309 {
310 QString insertAction; QString resumeAction; QString driver; QString conf;
311 bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf );
312 success = true;
313 break;
314 }
283 case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; 315 case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break;
@@ -287,3 +319,3 @@ void PcmciaManager::userCardAction( int action )
287 case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; 319 case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break;
288 default: odebug << "not yet implemented" << oendl; 320 default: odebug << "pcmcia: not yet implemented" << oendl;
289 } 321 }
@@ -292,3 +324,3 @@ void PcmciaManager::userCardAction( int action )
292 { 324 {
293 owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl; 325 owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl;
294 } 326 }
@@ -297,3 +329,3 @@ void PcmciaManager::userCardAction( int action )
297 329
298bool PcmciaManager::configure( OPcmciaSocket* card ) 330bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf )
299{ 331{
@@ -304,2 +336,9 @@ bool PcmciaManager::configure( OPcmciaSocket* card )
304 odebug << "pcmcia: configresult = " << configresult << oendl; 336 odebug << "pcmcia: configresult = " << configresult << oendl;
337 if ( configresult )
338 {
339 insertAction = dialog.cbInsertAction->currentText();
340 resumeAction = dialog.cbResumeAction->currentText();
341 driver = dialog.cbBindTo->currentText();
342 conf = dialog.bindEntries[driver];
343 }
305 return configresult; 344 return configresult;
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h
index eb9c513..94203d3 100644
--- a/noncore/applets/pcmcia/pcmcia.h
+++ b/noncore/applets/pcmcia/pcmcia.h
@@ -56,3 +56,3 @@ class PcmciaManager : public QWidget
56 private: 56 private:
57 bool configure( Opie::Core::OPcmciaSocket* ); 57 bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& );
58 void execCommand( const QStringList &command ); 58 void execCommand( const QStringList &command );