summaryrefslogtreecommitdiff
path: root/noncore/applets/pcmcia/pcmcia.cpp
Unidiff
Diffstat (limited to 'noncore/applets/pcmcia/pcmcia.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp69
1 files changed, 54 insertions, 15 deletions
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;