summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-10-20 21:10:44 (UTC)
committer llornkcor <llornkcor>2002-10-20 21:10:44 (UTC)
commit5696ac7a408c826c1e62f2200f6209a2c3d95119 (patch) (side-by-side diff)
tree0b1f6e4b6e96331abf380ae371aa8021c6045f33 /core
parentd5433091ba9741f0fae104d038b906e353065e2d (diff)
downloadopie-5696ac7a408c826c1e62f2200f6209a2c3d95119.zip
opie-5696ac7a408c826c1e62f2200f6209a2c3d95119.tar.gz
opie-5696ac7a408c826c1e62f2200f6209a2c3d95119.tar.bz2
fix for sd/cf double whammy insert/eject on resume
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index c0a936f..74e8837 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -71,20 +71,20 @@ CardMonitor::~CardMonitor() {
delete popupMenu;
}
}
void CardMonitor::popUp( QString message, QString icon ) {
if ( ! popupMenu ) {
- popupMenu = new QPopupMenu();
+ popupMenu = new QPopupMenu();
}
popupMenu->clear();
if( icon.isEmpty() ) {
- popupMenu->insertItem( message, 0 );
+ popupMenu->insertItem( message, 0 );
} else {
- popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 );
+ popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 );
}
QPoint p = mapToGlobal ( QPoint ( 0, 0 ) );
QSize s = popupMenu->sizeHint ();
popupMenu->popup( QPoint (
p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
@@ -110,28 +110,28 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia0Type ) ),
tr( "Eject card 0: %1" ).arg(cardInPcmcia0Name ), 1 );
}
if ( cardInPcmcia1 ) {
menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type ) ),
- tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 );
+ tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 );
}
QPoint p = mapToGlobal ( QPoint ( 0, 0 ) );
QSize s = menu->sizeHint ();
int opt = menu->exec( QPoint (
- p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
- p. y ( ) - s. height ( ) ), 0);
+ p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
+ p. y ( ) - s. height ( ) ), 0);
if ( opt == 1 ) {
cmd = "/sbin/cardctl eject 0";
- err = system( ( const char * ) cmd );
- if ( ( err == 127 ) || ( err < 0 ) ) {
- qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", err );
- popUp( tr( "CF/PCMCIA card eject failed!" ) );
- }
+ err = system( ( const char * ) cmd );
+ if ( ( err == 127 ) || ( err < 0 ) ) {
+ qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", err );
+ popUp( tr( "CF/PCMCIA card eject failed!" ) );
+ }
} else if ( opt == 0 ) {
if ( ODevice::inst()->system() == System_Familiar ) {
cmd = "umount /dev/mmc/part1";
err = system( ( const char *) cmd );
if ( ( err != 0 ) ) {
popUp( tr("SD/MMC card eject failed!") );
@@ -144,16 +144,16 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
popUp( tr("SD/MMC card eject failed!") );
}
}
} else if ( opt == 2 ) {
cmd = "/sbin/cardctl eject 1";
err = system( ( const char *) cmd );
- if ( ( err == 127 ) || ( err < 0 ) ) {
- qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", err );
- popUp( tr( "CF/PCMCIA card eject failed!" ) );
- }
+ if ( ( err == 127 ) || ( err < 0 ) ) {
+ qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", err );
+ popUp( tr( "CF/PCMCIA card eject failed!" ) );
+ }
}
delete menu;
}
void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) {
@@ -201,26 +201,26 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
} else if ( !(*line).startsWith( "Socket 0: empty" ) && !cardInPcmcia0 ){
cardInPcmcia0Name = (*line).mid( ( (*line).find( ':' ) + 1 ), (*line).length() - 9 );
cardInPcmcia0Name.stripWhiteSpace();
cardInPcmcia0 = TRUE;
show();
line++;
- int pos=(*line).find('\t' ) + 1;
- cardInPcmcia0Type = (*line).mid( pos, (*line).find( "\t" , pos) - pos );
+ int pos=(*line).find('\t' ) + 1;
+ cardInPcmcia0Type = (*line).mid( pos, (*line).find( "\t" , pos) - pos );
}
} else if( (*line).startsWith( "Socket 1:" ) ){
if( (*line).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) {
cardInPcmcia1 = FALSE;
} else if ( !(*line).startsWith( "Socket 1: empty" ) && !cardInPcmcia1 ) {
cardInPcmcia1Name = (*line).mid(((*line).find(':') + 1), (*line).length() - 9 );
cardInPcmcia1Name.stripWhiteSpace();
cardInPcmcia1 = TRUE;
show();
line++;
- int pos=(*line).find('\t') + 1;
- cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos );
+ int pos=(*line).find('\t') + 1;
+ cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos );
}
}
}
f.close();
if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1) ) {
@@ -232,25 +232,25 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
what="on";
} else {
text += tr( "Ejected: " );
what="off";
}
text += cardInPcmcia0Name;
- popUp( text, "cardmon/" + cardInPcmcia0Type );
+ popUp( text, "cardmon/" + cardInPcmcia0Type );
}
if( cardWas1 != cardInPcmcia1) {
if( cardInPcmcia1) {
text += tr( "New card: " );
what = "on";
} else {
text += tr( "Ejected: " );
what = "off";
}
- text += cardInPcmcia1Name;
- popUp( text, "cardmon/" + cardInPcmcia1Type );
+ text += cardInPcmcia1Name;
+ popUp( text, "cardmon/" + cardInPcmcia1Type );
}
QSound::play( Resource::findSound( "cardmon/card" + what) );
}
} else {
// no file found
qDebug( "no file found" );
@@ -261,27 +261,29 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
}
bool CardMonitor::getStatusSd( int showPopUp ) {
bool cardWas = cardInSd; // remember last state
+ cardInSd = FALSE;
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
struct mntent *me;
FILE *mntfp = setmntent( "/etc/mtab", "r" );
if ( mntfp ) {
while ( ( me = getmntent( mntfp ) ) != 0 ) {
QString fs = me->mnt_fsname;
//qDebug( fs );
if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" || fs.left( 9 ) == "/dev/mmcd" ) {
cardInSd = TRUE;
show();
- } else {
- cardInSd = FALSE;
}
+// else {
+// cardInSd = FALSE;
+// }
}
endmntent( mntfp );
}
if( !showPopUp && cardWas != cardInSd ) {
QString text = QString::null;