-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 3dd9f54..93bc97a 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -131,49 +131,49 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { | |||
131 | if ( ( err == 127 ) || ( err < 0 ) ) { | 131 | if ( ( err == 127 ) || ( err < 0 ) ) { |
132 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); | 132 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); |
133 | popUp( tr("CF/PCMCIA card eject failed!")); | 133 | popUp( tr("CF/PCMCIA card eject failed!")); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | delete menu; | 137 | delete menu; |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { | 141 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { |
142 | if ( msg == "stabChanged()" ) { | 142 | if ( msg == "stabChanged()" ) { |
143 | // qDebug("Pcmcia: stabchanged"); | 143 | // qDebug("Pcmcia: stabchanged"); |
144 | if ( getStatusPcmcia() ) { | 144 | if ( getStatusPcmcia() ) { |
145 | repaint(FALSE); | 145 | repaint(FALSE); |
146 | } | 146 | } |
147 | } else if ( msg == "mtabChanged()" ) { | 147 | } else if ( msg == "mtabChanged()" ) { |
148 | // qDebug("Pcmcia: mtabchanged"); | 148 | // qDebug("Pcmcia: mtabchanged"); |
149 | if ( getStatusSd() ) { | 149 | if ( getStatusSd() ) { |
150 | repaint(FALSE); | 150 | repaint(FALSE); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | bool CardMonitor::getStatusPcmcia( int showPopUp = FALSE ) { | 155 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { |
156 | 156 | ||
157 | bool cardWas0 = cardInPcmcia0; // remember last state | 157 | bool cardWas0 = cardInPcmcia0; // remember last state |
158 | bool cardWas1 = cardInPcmcia1; | 158 | bool cardWas1 = cardInPcmcia1; |
159 | 159 | ||
160 | QString fileName; | 160 | QString fileName; |
161 | 161 | ||
162 | // one of these 3 files should exist | 162 | // one of these 3 files should exist |
163 | if (QFile::exists("/var/run/stab")) { | 163 | if (QFile::exists("/var/run/stab")) { |
164 | fileName = "/var/run/stab"; | 164 | fileName = "/var/run/stab"; |
165 | } else if (QFile::exists("/var/state/pcmcia/stab")) { | 165 | } else if (QFile::exists("/var/state/pcmcia/stab")) { |
166 | fileName="/var/state/pcmcia/stab"; | 166 | fileName="/var/state/pcmcia/stab"; |
167 | } else { | 167 | } else { |
168 | fileName="/var/lib/pcmcia/stab"; | 168 | fileName="/var/lib/pcmcia/stab"; |
169 | } | 169 | } |
170 | 170 | ||
171 | QFile f(fileName); | 171 | QFile f(fileName); |
172 | 172 | ||
173 | if ( f.open(IO_ReadOnly) ) { | 173 | if ( f.open(IO_ReadOnly) ) { |
174 | QStringList list; | 174 | QStringList list; |
175 | QTextStream stream ( &f); | 175 | QTextStream stream ( &f); |
176 | QString streamIn; | 176 | QString streamIn; |
177 | streamIn = stream.read(); | 177 | streamIn = stream.read(); |
178 | list = QStringList::split("\n", streamIn); | 178 | list = QStringList::split("\n", streamIn); |
179 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 179 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
@@ -214,49 +214,49 @@ bool CardMonitor::getStatusPcmcia( int showPopUp = FALSE ) { | |||
214 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { | 214 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { |
215 | QString text = ""; | 215 | QString text = ""; |
216 | if(cardWas0 != cardInPcmcia0) { | 216 | if(cardWas0 != cardInPcmcia0) { |
217 | if(cardInPcmcia0) { text += tr("New card: "); } | 217 | if(cardInPcmcia0) { text += tr("New card: "); } |
218 | else { text += tr("Ejected: "); } | 218 | else { text += tr("Ejected: "); } |
219 | text += cardInPcmcia0Name; | 219 | text += cardInPcmcia0Name; |
220 | } | 220 | } |
221 | if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) { | 221 | if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) { |
222 | text += "\n"; | 222 | text += "\n"; |
223 | } | 223 | } |
224 | if(cardWas1 != cardInPcmcia1) { | 224 | if(cardWas1 != cardInPcmcia1) { |
225 | if(cardInPcmcia1) { text += tr("New card: "); } | 225 | if(cardInPcmcia1) { text += tr("New card: "); } |
226 | else { text += tr("Ejected: "); } | 226 | else { text += tr("Ejected: "); } |
227 | text += cardInPcmcia1Name; | 227 | text += cardInPcmcia1Name; |
228 | } | 228 | } |
229 | popUp( text ); | 229 | popUp( text ); |
230 | } | 230 | } |
231 | 231 | ||
232 | f.close(); | 232 | f.close(); |
233 | 233 | ||
234 | return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); | 234 | return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | bool CardMonitor::getStatusSd( int showPopUp = FALSE ) { | 238 | bool CardMonitor::getStatusSd( int showPopUp ) { |
239 | 239 | ||
240 | bool cardWas=cardInSd; // remember last state | 240 | bool cardWas=cardInSd; // remember last state |
241 | cardInSd=false; | 241 | cardInSd=false; |
242 | 242 | ||
243 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 243 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
244 | struct mntent *me; | 244 | struct mntent *me; |
245 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 245 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
246 | 246 | ||
247 | if ( mntfp ) { | 247 | if ( mntfp ) { |
248 | while ( (me = getmntent( mntfp )) != 0 ) { | 248 | while ( (me = getmntent( mntfp )) != 0 ) { |
249 | QString fs = me->mnt_fsname; | 249 | QString fs = me->mnt_fsname; |
250 | if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { | 250 | if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { |
251 | cardInSd=true; | 251 | cardInSd=true; |
252 | } | 252 | } |
253 | } | 253 | } |
254 | endmntent( mntfp ); | 254 | endmntent( mntfp ); |
255 | } | 255 | } |
256 | if(!showPopUp && cardWas != cardInSd) { | 256 | if(!showPopUp && cardWas != cardInSd) { |
257 | QString text = ""; | 257 | QString text = ""; |
258 | if(cardInSd) { text += "SD Inserted"; } | 258 | if(cardInSd) { text += "SD Inserted"; } |
259 | else { text += "SD Removed"; } | 259 | else { text += "SD Removed"; } |
260 | popUp( text ); | 260 | popUp( text ); |
261 | } | 261 | } |
262 | 262 | ||