summaryrefslogtreecommitdiff
path: root/noncore/applets/pcmcia/pcmcia.cpp
Side-by-side diff
Diffstat (limited to 'noncore/applets/pcmcia/pcmcia.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp88
1 files changed, 31 insertions, 57 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
@@ -30,4 +30,5 @@
#include "pcmcia.h"
#include "configdialog.h"
+#include "promptactiondialog.h"
/* OPIE */
@@ -139,6 +140,6 @@ void PcmciaManager::popupTimeout()
}
-enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE };
-static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur" };
+enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE, ACTIVATE };
+static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur", "activat" };
void PcmciaManager::mousePressEvent( QMouseEvent* )
@@ -247,44 +248,5 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
if ( result == 0 )
{
- QString insertAction; QString resumeAction; QString driver; QString conf;
- bool configured = configure( theCard, insertAction, resumeAction, driver, conf );
-
- if ( configured )
- {
- odebug << "pcmcia: card has been configured. writing out to database" << oendl;
- cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
- cfg.writeEntry( "name", newCardName );
- cfg.writeEntry( "insertAction", insertAction );
- cfg.writeEntry( "resumeAction", resumeAction );
- cfg.setGroup( "Global" );
- cfg.writeEntry( "nCards", nCards+1 );
- cfg.write();
-
- QFile confFile( conf );
- if ( confFile.open( IO_ReadWrite | IO_Append ) )
- {
- QString entryCard = QString( "card \"%1\"" ).arg( newCardName );
- QString entryVersion( " version " );
- for ( QStringList::Iterator it = theCard->productIdentityVector().begin(); it != theCard->productIdentityVector().end(); ++it )
- {
- entryVersion += QString( "\"%1\", " ).arg( *it );
- }
- QString entryBind = QString( " bind %1" ).arg( driver );
- QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind );
- odebug << "pcmcia: writing entry...:" << entry << oendl;
-
- confFile.writeBlock( (const char*) entry, entry.length() );
- Global::statusMessage( "restarting pcmcia services..." );
- ::system( "/etc/init.d/pcmcia restart" );
- }
- else
- {
- owarn << "pcmcia: couldn't write binding to '" << conf << "' ( " << strerror( errno ) << " )." << oendl;
- }
- }
- else
- {
- odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl;
- }
+ configure( theCard );
}
else
@@ -327,5 +289,5 @@ void PcmciaManager::userCardAction( int action )
{
QString insertAction; QString resumeAction; QString driver; QString conf;
- configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf );
+ configure( OPcmciaSystem::instance()->socket( socket ) );
return;
}
@@ -340,4 +302,6 @@ void PcmciaManager::userCardAction( int action )
case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset();
break;
+ case ACTIVATE: success = true;
+ break;
default: odebug << "pcmcia: not yet implemented" << oendl;
}
@@ -345,27 +309,25 @@ void PcmciaManager::userCardAction( int action )
if ( success )
{
+ odebug << tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl;
popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) );
}
else
{
+ odebug << tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl;
popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) );
}
}
-bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf )
+void PcmciaManager::configure( OPcmciaSocket* card )
{
configuring = true;
ConfigDialog dialog( card, qApp->desktop() );
- int configresult = QPEApplication::execDialog( &dialog, false );
+ int result = QPEApplication::execDialog( &dialog, false );
configuring = false;
- odebug << "pcmcia: configresult = " << configresult << oendl;
- if ( configresult )
+ odebug << "pcmcia: configresult = " << result << oendl;
+ if ( result )
{
- insertAction = dialog.cbInsertAction->currentText();
- resumeAction = dialog.cbResumeAction->currentText();
- driver = dialog.cbBindTo->currentText();
- conf = dialog.bindEntries[driver];
+ dialog.writeConfiguration( card );
}
- return configresult;
}
@@ -375,12 +337,24 @@ void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QStrin
QString theAction = ConfigDialog::preferredAction( card, type );
int intAction = card->number() * 100;
- if ( theAction == "activate" ) ;
- else if ( theAction == "eject" ) intAction += EJECT;
- else if ( theAction == "suspend" ) intAction += SUSPEND;
- else if ( theAction == "prompt for" )
+
+ if ( theAction == "prompt for" )
{
- odebug << "pcmcia: sorry, not 'prompt for' is not yet implemented!" << oendl;
+ PromptActionDialog dialog( qApp->desktop(), "promptfor", true );
+ dialog.setCaption( QString( "Choose action for card #%1" ).arg( card->number() ) );
+ int result = QPEApplication::execDialog( &dialog, true );
+ odebug << "pcmcia: configresult = " << result << oendl;
+ if ( result )
+ {
+ theAction = dialog.cbAction->currentText();
+ }
+ else
+ {
+ odebug << "pcmcia: prompted to do nothing" << oendl;
return;
}
+ }
+ if ( theAction == "activate" ) intAction += ACTIVATE;
+ else if ( theAction == "eject" ) intAction += EJECT;
+ else if ( theAction == "suspend" ) intAction += SUSPEND;
else
{