-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 10 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 98 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 5 |
3 files changed, 60 insertions, 53 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 | |||
@@ -134,2 +134,3 @@ void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& k | |||
134 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 134 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
135 | QString cardName = card->productIdentity().join( " " ).stripWhiteSpace(); | ||
135 | QString action; | 136 | QString action; |
@@ -141,4 +142,4 @@ void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& k | |||
141 | QString name = cfg.readEntry( "name" ); | 142 | QString name = cfg.readEntry( "name" ); |
142 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 143 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
143 | if ( card->name() == name ) | 144 | if ( cardName == name ) |
144 | { | 145 | { |
@@ -155,2 +156,3 @@ QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& | |||
155 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 156 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
157 | QString cardName = card->productIdentity().join( " " ).stripWhiteSpace(); | ||
156 | QString value; | 158 | QString value; |
@@ -162,4 +164,4 @@ QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& | |||
162 | QString name = cfg.readEntry( "name" ); | 164 | QString name = cfg.readEntry( "name" ); |
163 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 165 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
164 | if ( card->name() == name ) | 166 | if ( cardName == name ) |
165 | { | 167 | { |
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 | |||
@@ -68,3 +68,3 @@ using namespace Opie::Ui; | |||
68 | 68 | ||
69 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 69 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ), popupMenu( 0 ) |
70 | { | 70 | { |
@@ -98,3 +98,2 @@ void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& ) | |||
98 | OPcmciaSystem::CardIterator it = sys->iterator(); | 98 | OPcmciaSystem::CardIterator it = sys->iterator(); |
99 | OPcmciaSocket* theCard = 0; | ||
100 | 99 | ||
@@ -102,5 +101,5 @@ void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& ) | |||
102 | { | 101 | { |
103 | if ( it.current()->isEmpty() ) | 102 | if ( !it.current()->isEmpty() ) |
104 | { | 103 | { |
105 | executeResumeAction( theCard ); | 104 | executeAction( it.current(), "resume" ); |
106 | } | 105 | } |
@@ -113,7 +112,9 @@ void PcmciaManager::popUp( QString message, QString icon ) | |||
113 | { | 112 | { |
114 | if ( !popupMenu ) { | 113 | if ( !popupMenu) |
114 | { | ||
115 | popupMenu = new QPopupMenu( this ); | 115 | popupMenu = new QPopupMenu( this ); |
116 | popupMenu->setFocusPolicy( QWidget::NoFocus ); | ||
116 | } | 117 | } |
117 | |||
118 | popupMenu->clear(); | 118 | popupMenu->clear(); |
119 | |||
119 | if ( icon.isEmpty() ) { | 120 | if ( icon.isEmpty() ) { |
@@ -140,2 +141,3 @@ void PcmciaManager::popupTimeout() | |||
140 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; | 141 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; |
142 | static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur" }; | ||
141 | 143 | ||
@@ -148,2 +150,3 @@ void PcmciaManager::mousePressEvent( QMouseEvent* ) | |||
148 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 150 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
151 | sys->synchronize(); | ||
149 | OPcmciaSystem::CardIterator it = sys->iterator(); | 152 | OPcmciaSystem::CardIterator it = sys->iterator(); |
@@ -212,3 +215,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
212 | theCard = it.current(); | 215 | theCard = it.current(); |
213 | QString cardName = theCard->productIdentity().join( " " ); | 216 | QString cardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); |
214 | for ( int i = 0; i < nCards; ++i ) | 217 | for ( int i = 0; i < nCards; ++i ) |
@@ -223,3 +226,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
223 | odebug << "pcmcia: we have seen this card before" << oendl; | 226 | odebug << "pcmcia: we have seen this card before" << oendl; |
224 | executeInsertAction( theCard ); | 227 | executeAction( theCard, "insert" ); |
225 | break; | 228 | break; |
@@ -255,3 +258,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
255 | 258 | ||
256 | QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) ); | 259 | QFile confFile( conf ); |
257 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | 260 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) |
@@ -274,3 +277,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
274 | { | 277 | { |
275 | owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl; | 278 | owarn << "pcmcia: couldn't write binding to '" << conf << "' ( " << strerror( errno ) << " )." << oendl; |
276 | } | 279 | } |
@@ -289,10 +292,6 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
289 | { | 292 | { |
290 | QString insertAction = ConfigDialog::preferredAction( theCard, "insert" ); | 293 | odebug << "pcmcia: doing nothing... why do we come here?" << oendl; |
291 | odebug << "pcmcia: card has been previously configured" << oendl; | ||
292 | odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl; | ||
293 | } | 294 | } |
294 | repaint( true ); | ||
295 | } | 295 | } |
296 | 296 | ||
297 | |||
298 | void PcmciaManager::paintEvent( QPaintEvent * ) | 297 | void PcmciaManager::paintEvent( QPaintEvent * ) |
@@ -300,13 +299,3 @@ void PcmciaManager::paintEvent( QPaintEvent * ) | |||
300 | QPainter p( this ); | 299 | QPainter p( this ); |
301 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; | 300 | p.drawPixmap( 0, 0, pm ); |
302 | |||
303 | if ( OPcmciaSystem::instance()->cardCount() ) | ||
304 | { | ||
305 | p.drawPixmap( 0, 0, pm ); | ||
306 | show(); | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | hide(); | ||
311 | } | ||
312 | } | 301 | } |
@@ -335,19 +324,26 @@ void PcmciaManager::userCardAction( int action ) | |||
335 | QString insertAction; QString resumeAction; QString driver; QString conf; | 324 | QString insertAction; QString resumeAction; QString driver; QString conf; |
336 | bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); | 325 | configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); |
337 | success = true; | 326 | return; |
338 | break; | ||
339 | } | 327 | } |
340 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; | 328 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); |
341 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; | 329 | break; |
342 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; | 330 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); |
343 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; | 331 | break; |
344 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; | 332 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); |
345 | default: odebug << "pcmcia: not yet implemented" << oendl; | 333 | break; |
334 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); | ||
335 | break; | ||
336 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); | ||
337 | break; | ||
338 | default: odebug << "pcmcia: not yet implemented" << oendl; | ||
346 | } | 339 | } |
347 | 340 | ||
348 | if ( !success ) | 341 | if ( success ) |
349 | { | 342 | { |
350 | owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl; | 343 | popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); |
344 | } | ||
345 | else | ||
346 | { | ||
347 | popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); | ||
351 | } | 348 | } |
352 | |||
353 | } | 349 | } |
@@ -371,13 +367,23 @@ bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QStri | |||
371 | 367 | ||
372 | void PcmciaManager::executeInsertAction( Opie::Core::OPcmciaSocket* card ) | 368 | void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QString& type ) |
373 | { | ||
374 | odebug << "pcmcia: execute insert action" << oendl; | ||
375 | } | ||
376 | |||
377 | void PcmciaManager::executeResumeAction( Opie::Core::OPcmciaSocket* card ) | ||
378 | { | 369 | { |
379 | odebug << "pcmcia: execute resume action" << oendl; | 370 | odebug << "pcmcia: performing " << type << " action ..." << oendl; |
371 | QString theAction = ConfigDialog::preferredAction( card, type ); | ||
372 | int intAction = card->number() * 100; | ||
373 | if ( theAction == "activate" ) ; | ||
374 | else if ( theAction == "eject" ) intAction += EJECT; | ||
375 | else if ( theAction == "suspend" ) intAction += SUSPEND; | ||
376 | else if ( theAction == "prompt for" ) | ||
377 | { | ||
378 | odebug << "pcmcia: sorry, not 'prompt for' is not yet implemented!" << oendl; | ||
379 | return; | ||
380 | } | ||
381 | else | ||
382 | { | ||
383 | owarn << "pcmcia: action '" << theAction << "' not known. Huh?" << oendl; | ||
384 | return; | ||
385 | } | ||
386 | userCardAction( intAction ); | ||
380 | } | 387 | } |
381 | 388 | ||
382 | |||
383 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 389 | 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 | |||
@@ -59,5 +59,4 @@ class PcmciaManager : public QWidget | |||
59 | void execCommand( const QStringList &command ); | 59 | void execCommand( const QStringList &command ); |
60 | void executeInsertAction( Opie::Core::OPcmciaSocket* ); | 60 | void executeAction( Opie::Core::OPcmciaSocket*, const QString& ); |
61 | void executeResumeAction( Opie::Core::OPcmciaSocket* ); | 61 | void popUp( QString message, QString icon = QString::null ); |
62 | void popUp(QString message, QString icon = QString::null ); | ||
63 | 62 | ||