-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 74 | ||||
-rw-r--r-- | core/applets/cardmon/cardmon.pro | 2 |
2 files changed, 54 insertions, 22 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index e94f1dc..367ef3b 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp @@ -23,2 +23,4 @@ +#include <opie/odevice.h> + #include <qcopchannel_qws.h> @@ -55,2 +57,3 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), cardInPcmcia1 = FALSE; + cardInSd = FALSE; @@ -64,3 +67,5 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), CardMonitor::~CardMonitor() { - if( popupMenu ) { delete popupMenu; } + if( popupMenu ) { + delete popupMenu; + } } @@ -71,2 +76,3 @@ void CardMonitor::popUp( QString message, QString icon ) { } + popupMenu->clear(); @@ -75,4 +81,3 @@ void CardMonitor::popUp( QString message, QString icon ) { } else { - popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )), - message, 0 ); + popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 ); } @@ -118,3 +123,2 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { if ( opt == 1 ) { - cmd = "/sbin/cardctl eject 0"; @@ -126,2 +130,9 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { } else if ( opt == 0 ) { + if ( ODevice::inst()->system() == OSYSTEM_Familiar ) { + cmd = "umount /dev/mmc/part1"; + err = system( ( const char *) cmd ); + if ( ( err != 0 ) ) { + popUp( tr("SD/MMC card eject failed!") ); + } + } else { cmd = "/etc/sdcontrol compeject"; @@ -132,2 +143,3 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { } + } } else if ( opt == 2 ) { @@ -140,3 +152,2 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { } - delete menu; @@ -152,3 +163,3 @@ void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { } else if ( msg == "mtabChanged()" ) { - // qDebug("Pcmcia: mtabchanged"); + qDebug("CARDMONAPPLET: mtabchanged"); if ( getStatusSd() ) { @@ -196,4 +207,3 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { } - } - else if( (*line).startsWith("Socket 1:") ){ + } else if( (*line).startsWith( "Socket 1:" ) ){ if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ @@ -212,2 +222,3 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { f.close(); + if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { @@ -216,4 +227,9 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { if(cardWas0 != cardInPcmcia0) { - if(cardInPcmcia0) { text += tr("New card: "); what="on";} - else { text += tr("Ejected: "); what="off";} + if(cardInPcmcia0) { + text += tr( "New card: " ); + what="on"; + } else { + text += tr( "Ejected: " ); + what="off"; + } text += cardInPcmcia0Name; @@ -221,5 +237,11 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { } + if(cardWas1 != cardInPcmcia1) { - if(cardInPcmcia1) { text += tr("New card: "); what="on";} - else { text += tr("Ejected: "); what="off";} + if( cardInPcmcia1) { + text += tr( "New card: " ); + what = "on"; + } else { + text += tr( "Ejected: " ); + what = "off"; + } text += cardInPcmcia1Name; @@ -229,3 +251,2 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { } - } else { @@ -236,3 +257,2 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) { } - return ((cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1) ? FALSE : TRUE); @@ -244,3 +264,2 @@ bool CardMonitor::getStatusSd( int showPopUp ) { bool cardWas=cardInSd; // remember last state - cardInSd=false; @@ -253,4 +272,8 @@ bool CardMonitor::getStatusSd( int showPopUp ) { QString fs = me->mnt_fsname; - if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { - cardInSd=true; + 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; } @@ -259,9 +282,17 @@ bool CardMonitor::getStatusSd( int showPopUp ) { } + if(!showPopUp && cardWas != cardInSd) { QString text = QString::null; - if(cardInSd) { text += "SD Inserted"; } - else { text += "SD Removed"; } - popUp( text); // XX add SD pic + QString what = QString::null; + if( cardInSd ) { + text += "SD Inserted"; + what = "on"; + } else { + text += "SD Removed"; + what = "off"; + } + qDebug("TEXT: " + text ); + QSound::play( Resource::findSound( "cardmon/card" + what ) ); + popUp( text, "cardmon/ide" ); // XX add SD pic } - #else @@ -273,2 +304,3 @@ bool CardMonitor::getStatusSd( int showPopUp ) { void CardMonitor::paintEvent( QPaintEvent * ) { + QPainter p( this ); diff --git a/core/applets/cardmon/cardmon.pro b/core/applets/cardmon/cardmon.pro index aa34042..b2a2a4a 100644 --- a/core/applets/cardmon/cardmon.pro +++ b/core/applets/cardmon/cardmon.pro @@ -8,3 +8,3 @@ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include ../launcher -LIBS += -lqpe +LIBS += -lqpe -lopie VERSION = 1.0.0 |