author | llornkcor <llornkcor> | 2002-10-20 21:10:44 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-20 21:10:44 (UTC) |
commit | 5696ac7a408c826c1e62f2200f6209a2c3d95119 (patch) (unidiff) | |
tree | 0b1f6e4b6e96331abf380ae371aa8021c6045f33 | |
parent | d5433091ba9741f0fae104d038b906e353065e2d (diff) | |
download | opie-5696ac7a408c826c1e62f2200f6209a2c3d95119.zip opie-5696ac7a408c826c1e62f2200f6209a2c3d95119.tar.gz opie-5696ac7a408c826c1e62f2200f6209a2c3d95119.tar.bz2 |
fix for sd/cf double whammy insert/eject on resume
-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 50 |
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 | |||
@@ -73,16 +73,16 @@ CardMonitor::~CardMonitor() { | |||
73 | } | 73 | } |
74 | 74 | ||
75 | void CardMonitor::popUp( QString message, QString icon ) { | 75 | void 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 ) ); |
88 | QSize s = popupMenu->sizeHint (); | 88 | QSize s = popupMenu->sizeHint (); |
@@ -112,24 +112,24 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { | |||
112 | } | 112 | } |
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"; |
135 | err = system( ( const char *) cmd ); | 135 | err = system( ( const char *) cmd ); |
@@ -146,12 +146,12 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { | |||
146 | } | 146 | } |
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 | } |
157 | 157 | ||
@@ -203,10 +203,10 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { | |||
203 | cardInPcmcia0Name.stripWhiteSpace(); | 203 | cardInPcmcia0Name.stripWhiteSpace(); |
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 ) { |
212 | cardInPcmcia1 = FALSE; | 212 | cardInPcmcia1 = FALSE; |
@@ -215,10 +215,10 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { | |||
215 | cardInPcmcia1Name.stripWhiteSpace(); | 215 | cardInPcmcia1Name.stripWhiteSpace(); |
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 | } |
224 | f.close(); | 224 | f.close(); |
@@ -234,9 +234,9 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { | |||
234 | text += tr( "Ejected: " ); | 234 | text += tr( "Ejected: " ); |
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) { |
242 | if( cardInPcmcia1) { | 242 | if( cardInPcmcia1) { |
@@ -245,10 +245,10 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { | |||
245 | } else { | 245 | } else { |
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 | } |
254 | } else { | 254 | } else { |
@@ -263,8 +263,9 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { | |||
263 | 263 | ||
264 | bool CardMonitor::getStatusSd( int showPopUp ) { | 264 | bool 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; |
270 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 271 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
@@ -275,11 +276,12 @@ bool CardMonitor::getStatusSd( int showPopUp ) { | |||
275 | //qDebug( fs ); | 276 | //qDebug( fs ); |
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 | } |
285 | 287 | ||