summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-20 21:10:44 (UTC)
committer llornkcor <llornkcor>2002-10-20 21:10:44 (UTC)
commit5696ac7a408c826c1e62f2200f6209a2c3d95119 (patch) (unidiff)
tree0b1f6e4b6e96331abf380ae371aa8021c6045f33
parentd5433091ba9741f0fae104d038b906e353065e2d (diff)
downloadopie-5696ac7a408c826c1e62f2200f6209a2c3d95119.zip
opie-5696ac7a408c826c1e62f2200f6209a2c3d95119.tar.gz
opie-5696ac7a408c826c1e62f2200f6209a2c3d95119.tar.bz2
fix for sd/cf double whammy insert/eject on resume
Diffstat (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
@@ -74,14 +74,14 @@ CardMonitor::~CardMonitor() {
74 74
75void CardMonitor::popUp( QString message, QString icon ) { 75void CardMonitor::popUp( QString message, QString icon ) {
76 if ( ! popupMenu ) { 76 if ( ! popupMenu ) {
77 popupMenu = new QPopupMenu(); 77 popupMenu = new QPopupMenu();
78 } 78 }
79 79
80 popupMenu->clear(); 80 popupMenu->clear();
81 if( icon.isEmpty() ) { 81 if( icon.isEmpty() ) {
82 popupMenu->insertItem( message, 0 ); 82 popupMenu->insertItem( message, 0 );
83 } else { 83 } else {
84 popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 ); 84 popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 );
85 } 85 }
86 86
87 QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); 87 QPoint p = mapToGlobal ( QPoint ( 0, 0 ) );
@@ -113,22 +113,22 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
113 113
114 if ( cardInPcmcia1 ) { 114 if ( cardInPcmcia1 ) {
115 menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type ) ), 115 menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type ) ),
116 tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); 116 tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 );
117 } 117 }
118 118
119 QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); 119 QPoint p = mapToGlobal ( QPoint ( 0, 0 ) );
120 QSize s = menu->sizeHint (); 120 QSize s = menu->sizeHint ();
121 int opt = menu->exec( QPoint ( 121 int opt = menu->exec( QPoint (
122 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), 122 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
123 p. y ( ) - s. height ( ) ), 0); 123 p. y ( ) - s. height ( ) ), 0);
124 124
125 if ( opt == 1 ) { 125 if ( opt == 1 ) {
126 cmd = "/sbin/cardctl eject 0"; 126 cmd = "/sbin/cardctl eject 0";
127 err = system( ( const char * ) cmd ); 127 err = system( ( const char * ) cmd );
128 if ( ( err == 127 ) || ( err < 0 ) ) { 128 if ( ( err == 127 ) || ( err < 0 ) ) {
129 qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", err ); 129 qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", err );
130 popUp( tr( "CF/PCMCIA card eject failed!" ) ); 130 popUp( tr( "CF/PCMCIA card eject failed!" ) );
131 } 131 }
132 } else if ( opt == 0 ) { 132 } else if ( opt == 0 ) {
133 if ( ODevice::inst()->system() == System_Familiar ) { 133 if ( ODevice::inst()->system() == System_Familiar ) {
134 cmd = "umount /dev/mmc/part1"; 134 cmd = "umount /dev/mmc/part1";
@@ -147,10 +147,10 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
147 } else if ( opt == 2 ) { 147 } else if ( opt == 2 ) {
148 cmd = "/sbin/cardctl eject 1"; 148 cmd = "/sbin/cardctl eject 1";
149 err = system( ( const char *) cmd ); 149 err = system( ( const char *) cmd );
150 if ( ( err == 127 ) || ( err < 0 ) ) { 150 if ( ( err == 127 ) || ( err < 0 ) ) {
151 qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", err ); 151 qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", err );
152 popUp( tr( "CF/PCMCIA card eject failed!" ) ); 152 popUp( tr( "CF/PCMCIA card eject failed!" ) );
153 } 153 }
154 } 154 }
155 delete menu; 155 delete menu;
156} 156}
@@ -204,8 +204,8 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
204 cardInPcmcia0 = TRUE; 204 cardInPcmcia0 = TRUE;
205 show(); 205 show();
206 line++; 206 line++;
207 int pos=(*line).find('\t' ) + 1; 207 int pos=(*line).find('\t' ) + 1;
208 cardInPcmcia0Type = (*line).mid( pos, (*line).find( "\t" , pos) - pos ); 208 cardInPcmcia0Type = (*line).mid( pos, (*line).find( "\t" , pos) - pos );
209 } 209 }
210 } else if( (*line).startsWith( "Socket 1:" ) ){ 210 } else if( (*line).startsWith( "Socket 1:" ) ){
211 if( (*line).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { 211 if( (*line).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) {
@@ -216,8 +216,8 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
216 cardInPcmcia1 = TRUE; 216 cardInPcmcia1 = TRUE;
217 show(); 217 show();
218 line++; 218 line++;
219 int pos=(*line).find('\t') + 1; 219 int pos=(*line).find('\t') + 1;
220 cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos ); 220 cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos );
221 } 221 }
222 } 222 }
223 } 223 }
@@ -235,7 +235,7 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
235 what="off"; 235 what="off";
236 } 236 }
237 text += cardInPcmcia0Name; 237 text += cardInPcmcia0Name;
238 popUp( text, "cardmon/" + cardInPcmcia0Type ); 238 popUp( text, "cardmon/" + cardInPcmcia0Type );
239 } 239 }
240 240
241 if( cardWas1 != cardInPcmcia1) { 241 if( cardWas1 != cardInPcmcia1) {
@@ -246,8 +246,8 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
246 text += tr( "Ejected: " ); 246 text += tr( "Ejected: " );
247 what = "off"; 247 what = "off";
248 } 248 }
249 text += cardInPcmcia1Name; 249 text += cardInPcmcia1Name;
250 popUp( text, "cardmon/" + cardInPcmcia1Type ); 250 popUp( text, "cardmon/" + cardInPcmcia1Type );
251 } 251 }
252 QSound::play( Resource::findSound( "cardmon/card" + what) ); 252 QSound::play( Resource::findSound( "cardmon/card" + what) );
253 } 253 }
@@ -264,6 +264,7 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
264bool CardMonitor::getStatusSd( int showPopUp ) { 264bool CardMonitor::getStatusSd( int showPopUp ) {
265 265
266 bool cardWas = cardInSd; // remember last state 266 bool cardWas = cardInSd; // remember last state
267 cardInSd = FALSE;
267 268
268#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 269#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
269 struct mntent *me; 270 struct mntent *me;
@@ -276,9 +277,10 @@ bool CardMonitor::getStatusSd( int showPopUp ) {
276 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" || fs.left( 9 ) == "/dev/mmcd" ) { 277 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" || fs.left( 9 ) == "/dev/mmcd" ) {
277 cardInSd = TRUE; 278 cardInSd = TRUE;
278 show(); 279 show();
279 } else {
280 cardInSd = FALSE;
281 } 280 }
281// else {
282// cardInSd = FALSE;
283// }
282 } 284 }
283 endmntent( mntfp ); 285 endmntent( mntfp );
284 } 286 }