summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp10
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp90
-rw-r--r--noncore/applets/pcmcia/pcmcia.h3
3 files changed, 55 insertions, 48 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp
index f5812ba..f94edde 100644
--- a/noncore/applets/pcmcia/configdialog.cpp
+++ b/noncore/applets/pcmcia/configdialog.cpp
@@ -133,4 +133,5 @@ void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& k
cfg.setGroup( "Global" );
int nCards = cfg.readNumEntry( "nCards", 0 );
+ QString cardName = card->productIdentity().join( " " ).stripWhiteSpace();
QString action;
@@ -140,6 +141,6 @@ void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& k
cfg.setGroup( cardSection );
QString name = cfg.readEntry( "name" );
- odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl;
- if ( card->name() == name )
+ odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
+ if ( cardName == name )
{
cfg.writeEntry( key, value );
@@ -154,4 +155,5 @@ QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString&
cfg.setGroup( "Global" );
int nCards = cfg.readNumEntry( "nCards", 0 );
+ QString cardName = card->productIdentity().join( " " ).stripWhiteSpace();
QString value;
@@ -161,6 +163,6 @@ QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString&
cfg.setGroup( cardSection );
QString name = cfg.readEntry( "name" );
- odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl;
- if ( card->name() == name )
+ odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
+ if ( cardName == name )
{
value = cfg.readEntry( key, defaultValue );
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index e435f61..af23f58 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -67,5 +67,5 @@ using namespace Opie::Ui;
#endif
-PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent )
+PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ), popupMenu( 0 )
{
QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
@@ -97,11 +97,10 @@ void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& )
OPcmciaSystem* sys = OPcmciaSystem::instance();
OPcmciaSystem::CardIterator it = sys->iterator();
- OPcmciaSocket* theCard = 0;
while ( it.current() )
{
- if ( it.current()->isEmpty() )
+ if ( !it.current()->isEmpty() )
{
- executeResumeAction( theCard );
+ executeAction( it.current(), "resume" );
}
++it;
@@ -112,9 +111,11 @@ void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& )
void PcmciaManager::popUp( QString message, QString icon )
{
- if ( !popupMenu ) {
+ if ( !popupMenu)
+ {
popupMenu = new QPopupMenu( this );
+ popupMenu->setFocusPolicy( QWidget::NoFocus );
}
-
popupMenu->clear();
+
if ( icon.isEmpty() ) {
popupMenu->insertItem( message, 0 );
@@ -139,4 +140,5 @@ void PcmciaManager::popupTimeout()
enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE };
+static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur" };
void PcmciaManager::mousePressEvent( QMouseEvent* )
@@ -147,4 +149,5 @@ void PcmciaManager::mousePressEvent( QMouseEvent* )
OPcmciaSystem* sys = OPcmciaSystem::instance();
+ sys->synchronize();
OPcmciaSystem::CardIterator it = sys->iterator();
if ( !sys->count() ) return;
@@ -211,5 +214,5 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
{
theCard = it.current();
- QString cardName = theCard->productIdentity().join( " " );
+ QString cardName = theCard->productIdentity().join( " " ).stripWhiteSpace();
for ( int i = 0; i < nCards; ++i )
{
@@ -222,5 +225,5 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
newCard = false;
odebug << "pcmcia: we have seen this card before" << oendl;
- executeInsertAction( theCard );
+ executeAction( theCard, "insert" );
break;
}
@@ -254,5 +257,5 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
cfg.write();
- QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) );
+ QFile confFile( conf );
if ( confFile.open( IO_ReadWrite | IO_Append ) )
{
@@ -273,5 +276,5 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
else
{
- owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl;
+ owarn << "pcmcia: couldn't write binding to '" << conf << "' ( " << strerror( errno ) << " )." << oendl;
}
}
@@ -288,26 +291,12 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
else // it's an already configured card
{
- QString insertAction = ConfigDialog::preferredAction( theCard, "insert" );
- odebug << "pcmcia: card has been previously configured" << oendl;
- odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl;
+ odebug << "pcmcia: doing nothing... why do we come here?" << oendl;
}
- repaint( true );
}
-
void PcmciaManager::paintEvent( QPaintEvent * )
{
QPainter p( this );
- odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl;
-
- if ( OPcmciaSystem::instance()->cardCount() )
- {
p.drawPixmap( 0, 0, pm );
- show();
- }
- else
- {
- hide();
- }
}
@@ -334,21 +323,28 @@ void PcmciaManager::userCardAction( int action )
{
QString insertAction; QString resumeAction; QString driver; QString conf;
- bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf );
- success = true;
- break;
+ configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf );
+ return;
}
- case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break;
- case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break;
- case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break;
- case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break;
- case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break;
+ case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject();
+ break;
+ case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert();
+ break;
+ case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend();
+ break;
+ case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume();
+ break;
+ case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset();
+ break;
default: odebug << "pcmcia: not yet implemented" << oendl;
}
- if ( !success )
+ if ( success )
{
- owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl;
+ popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) );
+ }
+ else
+ {
+ popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) );
}
-
}
@@ -370,14 +366,24 @@ bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QStri
}
-void PcmciaManager::executeInsertAction( Opie::Core::OPcmciaSocket* card )
+void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QString& type )
+{
+ odebug << "pcmcia: performing " << type << " action ..." << oendl;
+ 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" )
{
- odebug << "pcmcia: execute insert action" << oendl;
+ odebug << "pcmcia: sorry, not 'prompt for' is not yet implemented!" << oendl;
+ return;
}
-
-void PcmciaManager::executeResumeAction( Opie::Core::OPcmciaSocket* card )
+ else
{
- odebug << "pcmcia: execute resume action" << oendl;
+ owarn << "pcmcia: action '" << theAction << "' not known. Huh?" << oendl;
+ return;
+ }
+ userCardAction( intAction );
}
-
EXPORT_OPIE_APPLET_v1( PcmciaManager )
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h
index 6567cd7..de7d6bf 100644
--- a/noncore/applets/pcmcia/pcmcia.h
+++ b/noncore/applets/pcmcia/pcmcia.h
@@ -58,6 +58,5 @@ class PcmciaManager : public QWidget
bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& );
void execCommand( const QStringList &command );
- void executeInsertAction( Opie::Core::OPcmciaSocket* );
- void executeResumeAction( Opie::Core::OPcmciaSocket* );
+ void executeAction( Opie::Core::OPcmciaSocket*, const QString& );
void popUp(QString message, QString icon = QString::null );