summaryrefslogtreecommitdiff
path: root/core/applets/cardmon/cardmon.cpp
Unidiff
Diffstat (limited to 'core/applets/cardmon/cardmon.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp74
1 files changed, 53 insertions, 21 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 @@
23 23
24#include <opie/odevice.h>
25
24#include <qcopchannel_qws.h> 26#include <qcopchannel_qws.h>
@@ -55,2 +57,3 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ),
55 cardInPcmcia1 = FALSE; 57 cardInPcmcia1 = FALSE;
58 cardInSd = FALSE;
56 59
@@ -64,3 +67,5 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ),
64CardMonitor::~CardMonitor() { 67CardMonitor::~CardMonitor() {
65 if( popupMenu ) { delete popupMenu; } 68 if( popupMenu ) {
69 delete popupMenu;
70 }
66} 71}
@@ -71,2 +76,3 @@ void CardMonitor::popUp( QString message, QString icon ) {
71 } 76 }
77
72 popupMenu->clear(); 78 popupMenu->clear();
@@ -75,4 +81,3 @@ void CardMonitor::popUp( QString message, QString icon ) {
75 } else { 81 } else {
76 popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )), 82 popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 );
77 message, 0 );
78 } 83 }
@@ -118,3 +123,2 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
118 if ( opt == 1 ) { 123 if ( opt == 1 ) {
119
120 cmd = "/sbin/cardctl eject 0"; 124 cmd = "/sbin/cardctl eject 0";
@@ -126,2 +130,9 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
126 } else if ( opt == 0 ) { 130 } else if ( opt == 0 ) {
131 if ( ODevice::inst()->system() == OSYSTEM_Familiar ) {
132 cmd = "umount /dev/mmc/part1";
133 err = system( ( const char *) cmd );
134 if ( ( err != 0 ) ) {
135 popUp( tr("SD/MMC card eject failed!") );
136 }
137 } else {
127 cmd = "/etc/sdcontrol compeject"; 138 cmd = "/etc/sdcontrol compeject";
@@ -132,2 +143,3 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
132 } 143 }
144 }
133 } else if ( opt == 2 ) { 145 } else if ( opt == 2 ) {
@@ -140,3 +152,2 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) {
140 } 152 }
141
142 delete menu; 153 delete menu;
@@ -152,3 +163,3 @@ void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) {
152 } else if ( msg == "mtabChanged()" ) { 163 } else if ( msg == "mtabChanged()" ) {
153 // qDebug("Pcmcia: mtabchanged"); 164 qDebug("CARDMONAPPLET: mtabchanged");
154 if ( getStatusSd() ) { 165 if ( getStatusSd() ) {
@@ -196,4 +207,3 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
196 } 207 }
197 } 208 } else if( (*line).startsWith( "Socket 1:" ) ){
198 else if( (*line).startsWith("Socket 1:") ){
199 if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ 209 if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){
@@ -212,2 +222,3 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
212 f.close(); 222 f.close();
223
213 if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { 224 if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) {
@@ -216,4 +227,9 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
216 if(cardWas0 != cardInPcmcia0) { 227 if(cardWas0 != cardInPcmcia0) {
217 if(cardInPcmcia0) { text += tr("New card: "); what="on";} 228 if(cardInPcmcia0) {
218 else { text += tr("Ejected: "); what="off";} 229 text += tr( "New card: " );
230 what="on";
231 } else {
232 text += tr( "Ejected: " );
233 what="off";
234 }
219 text += cardInPcmcia0Name; 235 text += cardInPcmcia0Name;
@@ -221,5 +237,11 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
221 } 237 }
238
222 if(cardWas1 != cardInPcmcia1) { 239 if(cardWas1 != cardInPcmcia1) {
223 if(cardInPcmcia1) { text += tr("New card: "); what="on";} 240 if( cardInPcmcia1) {
224 else { text += tr("Ejected: "); what="off";} 241 text += tr( "New card: " );
242 what = "on";
243 } else {
244 text += tr( "Ejected: " );
245 what = "off";
246 }
225 text += cardInPcmcia1Name; 247 text += cardInPcmcia1Name;
@@ -229,3 +251,2 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
229 } 251 }
230
231 } else { 252 } else {
@@ -236,3 +257,2 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
236 } 257 }
237
238 return ((cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1) ? FALSE : TRUE); 258 return ((cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1) ? FALSE : TRUE);
@@ -244,3 +264,2 @@ bool CardMonitor::getStatusSd( int showPopUp ) {
244 bool cardWas=cardInSd; // remember last state 264 bool cardWas=cardInSd; // remember last state
245 cardInSd=false;
246 265
@@ -253,4 +272,8 @@ bool CardMonitor::getStatusSd( int showPopUp ) {
253 QString fs = me->mnt_fsname; 272 QString fs = me->mnt_fsname;
254 if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { 273 qDebug( fs );
255 cardInSd=true; 274 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" || fs.left( 9 ) == "/dev/mmcd" ) {
275 cardInSd = TRUE;
276 show();
277 } else {
278 cardInSd = FALSE;
256 } 279 }
@@ -259,9 +282,17 @@ bool CardMonitor::getStatusSd( int showPopUp ) {
259 } 282 }
283
260 if(!showPopUp && cardWas != cardInSd) { 284 if(!showPopUp && cardWas != cardInSd) {
261 QString text = QString::null; 285 QString text = QString::null;
262 if(cardInSd) { text += "SD Inserted"; } 286 QString what = QString::null;
263 else { text += "SD Removed"; } 287 if( cardInSd ) {
264 popUp( text); // XX add SD pic 288 text += "SD Inserted";
289 what = "on";
290 } else {
291 text += "SD Removed";
292 what = "off";
293 }
294 qDebug("TEXT: " + text );
295 QSound::play( Resource::findSound( "cardmon/card" + what ) );
296 popUp( text, "cardmon/ide" ); // XX add SD pic
265 } 297 }
266
267#else 298#else
@@ -273,2 +304,3 @@ bool CardMonitor::getStatusSd( int showPopUp ) {
273void CardMonitor::paintEvent( QPaintEvent * ) { 304void CardMonitor::paintEvent( QPaintEvent * ) {
305
274 QPainter p( this ); 306 QPainter p( this );