Diffstat (limited to 'noncore/applets/pcmcia/pcmcia.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 114 |
1 files changed, 44 insertions, 70 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index c6386cb..187adc6 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -2,3 +2,3 @@ | |||
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
@@ -31,2 +31,3 @@ | |||
31 | #include "configdialog.h" | 31 | #include "configdialog.h" |
32 | #include "promptactiondialog.h" | ||
32 | 33 | ||
@@ -140,4 +141,4 @@ void PcmciaManager::popupTimeout() | |||
140 | 141 | ||
141 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; | 142 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE, ACTIVATE }; |
142 | static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur" }; | 143 | static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur", "activat" }; |
143 | 144 | ||
@@ -248,42 +249,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
248 | { | 249 | { |
249 | QString insertAction; QString resumeAction; QString driver; QString conf; | 250 | configure( theCard ); |
250 | bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); | ||
251 | |||
252 | if ( configured ) | ||
253 | { | ||
254 | odebug << "pcmcia: card has been configured. writing out to database" << oendl; | ||
255 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | ||
256 | cfg.writeEntry( "name", newCardName ); | ||
257 | cfg.writeEntry( "insertAction", insertAction ); | ||
258 | cfg.writeEntry( "resumeAction", resumeAction ); | ||
259 | cfg.setGroup( "Global" ); | ||
260 | cfg.writeEntry( "nCards", nCards+1 ); | ||
261 | cfg.write(); | ||
262 | |||
263 | QFile confFile( conf ); | ||
264 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | ||
265 | { | ||
266 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); | ||
267 | QString entryVersion( " version " ); | ||
268 | for ( QStringList::Iterator it = theCard->productIdentityVector().begin(); it != theCard->productIdentityVector().end(); ++it ) | ||
269 | { | ||
270 | entryVersion += QString( "\"%1\", " ).arg( *it ); | ||
271 | } | ||
272 | QString entryBind = QString( " bind %1" ).arg( driver ); | ||
273 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); | ||
274 | odebug << "pcmcia: writing entry...:" << entry << oendl; | ||
275 | |||
276 | confFile.writeBlock( (const char*) entry, entry.length() ); | ||
277 | Global::statusMessage( "restarting pcmcia services..." ); | ||
278 | ::system( "/etc/init.d/pcmcia restart" ); | ||
279 | } | ||
280 | else | ||
281 | { | ||
282 | owarn << "pcmcia: couldn't write binding to '" << conf << "' ( " << strerror( errno ) << " )." << oendl; | ||
283 | } | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl; | ||
288 | } | ||
289 | } | 251 | } |
@@ -328,16 +290,18 @@ void PcmciaManager::userCardAction( int action ) | |||
328 | QString insertAction; QString resumeAction; QString driver; QString conf; | 290 | QString insertAction; QString resumeAction; QString driver; QString conf; |
329 | configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); | 291 | configure( OPcmciaSystem::instance()->socket( socket ) ); |
330 | return; | 292 | return; |
331 | } | 293 | } |
332 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); | 294 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); |
333 | break; | 295 | break; |
334 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); | 296 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); |
335 | break; | 297 | break; |
336 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); | 298 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); |
337 | break; | 299 | break; |
338 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); | 300 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); |
339 | break; | 301 | break; |
340 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); | 302 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); |
341 | break; | 303 | break; |
342 | default: odebug << "pcmcia: not yet implemented" << oendl; | 304 | case ACTIVATE: success = true; |
305 | break; | ||
306 | default: odebug << "pcmcia: not yet implemented" << oendl; | ||
343 | } | 307 | } |
@@ -346,2 +310,3 @@ void PcmciaManager::userCardAction( int action ) | |||
346 | { | 310 | { |
311 | odebug << tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl; | ||
347 | popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); | 312 | popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); |
@@ -350,2 +315,3 @@ void PcmciaManager::userCardAction( int action ) | |||
350 | { | 315 | { |
316 | odebug << tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl; | ||
351 | popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); | 317 | popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); |
@@ -354,3 +320,3 @@ void PcmciaManager::userCardAction( int action ) | |||
354 | 320 | ||
355 | bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) | 321 | void PcmciaManager::configure( OPcmciaSocket* card ) |
356 | { | 322 | { |
@@ -358,13 +324,9 @@ bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QStri | |||
358 | ConfigDialog dialog( card, qApp->desktop() ); | 324 | ConfigDialog dialog( card, qApp->desktop() ); |
359 | int configresult = QPEApplication::execDialog( &dialog, false ); | 325 | int result = QPEApplication::execDialog( &dialog, false ); |
360 | configuring = false; | 326 | configuring = false; |
361 | odebug << "pcmcia: configresult = " << configresult << oendl; | 327 | odebug << "pcmcia: configresult = " << result << oendl; |
362 | if ( configresult ) | 328 | if ( result ) |
363 | { | 329 | { |
364 | insertAction = dialog.cbInsertAction->currentText(); | 330 | dialog.writeConfiguration( card ); |
365 | resumeAction = dialog.cbResumeAction->currentText(); | ||
366 | driver = dialog.cbBindTo->currentText(); | ||
367 | conf = dialog.bindEntries[driver]; | ||
368 | } | 331 | } |
369 | return configresult; | ||
370 | } | 332 | } |
@@ -376,10 +338,22 @@ void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QStrin | |||
376 | int intAction = card->number() * 100; | 338 | int intAction = card->number() * 100; |
377 | if ( theAction == "activate" ) ; | 339 | |
378 | else if ( theAction == "eject" ) intAction += EJECT; | 340 | if ( theAction == "prompt for" ) |
379 | else if ( theAction == "suspend" ) intAction += SUSPEND; | ||
380 | else if ( theAction == "prompt for" ) | ||
381 | { | 341 | { |
382 | odebug << "pcmcia: sorry, not 'prompt for' is not yet implemented!" << oendl; | 342 | PromptActionDialog dialog( qApp->desktop(), "promptfor", true ); |
383 | return; | 343 | dialog.setCaption( QString( "Choose action for card #%1" ).arg( card->number() ) ); |
344 | int result = QPEApplication::execDialog( &dialog, true ); | ||
345 | odebug << "pcmcia: configresult = " << result << oendl; | ||
346 | if ( result ) | ||
347 | { | ||
348 | theAction = dialog.cbAction->currentText(); | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | odebug << "pcmcia: prompted to do nothing" << oendl; | ||
353 | return; | ||
354 | } | ||
384 | } | 355 | } |
356 | if ( theAction == "activate" ) intAction += ACTIVATE; | ||
357 | else if ( theAction == "eject" ) intAction += EJECT; | ||
358 | else if ( theAction == "suspend" ) intAction += SUSPEND; | ||
385 | else | 359 | else |