summaryrefslogtreecommitdiff
path: root/core/applets/cardmon/cardmon.cpp
authorzecke <zecke>2002-06-23 14:19:13 (UTC)
committer zecke <zecke>2002-06-23 14:19:13 (UTC)
commitce9178fb13908eca5b7835e785fc0914a5022615 (patch) (side-by-side diff)
treed848ef07fb25ba6c21d3729140c4e3be9d69f6f6 /core/applets/cardmon/cardmon.cpp
parent3b02ead2254e59159db948d2a0980892eeb14ed8 (diff)
downloadopie-ce9178fb13908eca5b7835e785fc0914a5022615.zip
opie-ce9178fb13908eca5b7835e785fc0914a5022615.tar.gz
opie-ce9178fb13908eca5b7835e785fc0914a5022615.tar.bz2
Simon thanks for the patch. Some clean ups. Patch provided by tronical
OAOAOAOAOAOAOAOAOAOAOAOAOBOBCVS: noncore/tools/remote/dvdgroupconf.cpp
Diffstat (limited to 'core/applets/cardmon/cardmon.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp4
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 * ) {
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 & ) {
if ( msg == "stabChanged()" ) {
// qDebug("Pcmcia: stabchanged");
if ( getStatusPcmcia() ) {
repaint(FALSE);
}
} else if ( msg == "mtabChanged()" ) {
// qDebug("Pcmcia: mtabchanged");
if ( getStatusSd() ) {
repaint(FALSE);
}
}
}
-bool CardMonitor::getStatusPcmcia( int showPopUp = FALSE ) {
+bool CardMonitor::getStatusPcmcia( int showPopUp ) {
bool cardWas0 = cardInPcmcia0; // remember last state
bool cardWas1 = cardInPcmcia1;
QString fileName;
// one of these 3 files should exist
if (QFile::exists("/var/run/stab")) {
fileName = "/var/run/stab";
} else if (QFile::exists("/var/state/pcmcia/stab")) {
fileName="/var/state/pcmcia/stab";
} else {
fileName="/var/lib/pcmcia/stab";
}
QFile f(fileName);
if ( f.open(IO_ReadOnly) ) {
QStringList list;
QTextStream stream ( &f);
QString streamIn;
streamIn = stream.read();
list = QStringList::split("\n", streamIn);
for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) {
@@ -214,49 +214,49 @@ bool CardMonitor::getStatusPcmcia( int showPopUp = FALSE ) {
if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) {
QString text = "";
if(cardWas0 != cardInPcmcia0) {
if(cardInPcmcia0) { text += tr("New card: "); }
else { text += tr("Ejected: "); }
text += cardInPcmcia0Name;
}
if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) {
text += "\n";
}
if(cardWas1 != cardInPcmcia1) {
if(cardInPcmcia1) { text += tr("New card: "); }
else { text += tr("Ejected: "); }
text += cardInPcmcia1Name;
}
popUp( text );
}
f.close();
return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE);
}
-bool CardMonitor::getStatusSd( int showPopUp = FALSE ) {
+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;
if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) {
cardInSd=true;
}
}
endmntent( mntfp );
}
if(!showPopUp && cardWas != cardInSd) {
QString text = "";
if(cardInSd) { text += "SD Inserted"; }
else { text += "SD Removed"; }
popUp( text );
}