summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-07-31 13:30:45 (UTC)
committer harlekin <harlekin>2002-07-31 13:30:45 (UTC)
commit3cd137ee5784ac9552650e4f8edb1696880ced28 (patch) (unidiff)
treef1668f52a53583843c68c51a8e636b8967b19064
parent012abe9b9c667d24052a9f078030bfa7874b404e (diff)
downloadopie-3cd137ee5784ac9552650e4f8edb1696880ced28.zip
opie-3cd137ee5784ac9552650e4f8edb1696880ced28.tar.gz
opie-3cd137ee5784ac9552650e4f8edb1696880ced28.tar.bz2
try to make gcc3.x happy
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp22
-rw-r--r--core/applets/cardmon/cardmon.h2
2 files changed, 12 insertions, 12 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index 0bd1ed3..ffead4d 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -44,120 +44,120 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ),
44 pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { 44 pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) {
45 45
46 QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); 46 QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this );
47 connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), 47 connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)),
48 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 48 this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
49 49
50 QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); 50 QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this );
51 connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), 51 connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)),
52 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 52 this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
53 53
54 cardInPcmcia0 = FALSE; 54 cardInPcmcia0 = FALSE;
55 cardInPcmcia1 = FALSE; 55 cardInPcmcia1 = FALSE;
56 56
57 setFixedSize( pm.size() ); 57 setFixedSize( pm.size() );
58 getStatusPcmcia(TRUE); 58 getStatusPcmcia(TRUE);
59 getStatusSd(TRUE); 59 getStatusSd(TRUE);
60 repaint(FALSE); 60 repaint(FALSE);
61 popupMenu = 0; 61 popupMenu = 0;
62} 62}
63 63
64CardMonitor::~CardMonitor() { 64CardMonitor::~CardMonitor() {
65 if( popupMenu ) { delete popupMenu; } 65 if( popupMenu ) { delete popupMenu; }
66} 66}
67 67
68void CardMonitor::popUp(QString message, QString icon="") { 68void CardMonitor::popUp( QString message, QString icon = QString::null ) {
69 if ( ! popupMenu ) { 69 if ( ! popupMenu ) {
70 popupMenu = new QPopupMenu(); 70 popupMenu = new QPopupMenu();
71 } 71 }
72 popupMenu->clear(); 72 popupMenu->clear();
73 if( icon == "" ) { 73 if( icon.isEmpty() ) {
74 popupMenu->insertItem( message, 0 ); 74 popupMenu->insertItem( message, 0 );
75 } else { 75 } else {
76 popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )), 76 popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )),
77 message, 0 ); 77 message, 0 );
78 } 78 }
79 79
80 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 80 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
81 QSize s = popupMenu->sizeHint ( ); 81 QSize s = popupMenu->sizeHint ( );
82 popupMenu->popup( QPoint ( 82 popupMenu->popup( QPoint (
83 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), 83 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
84 p. y ( ) - s. height ( ) ), 0); 84 p. y ( ) - s. height ( ) ), 0);
85 85
86 QTimer::singleShot( 2000, this, SLOT(popupTimeout()) ); 86 QTimer::singleShot( 2000, this, SLOT(popupTimeout()) );
87} 87}
88 88
89void CardMonitor::popupTimeout() { 89void CardMonitor::popupTimeout() {
90 popupMenu->hide(); 90 popupMenu->hide();
91} 91}
92 92
93void CardMonitor::mousePressEvent( QMouseEvent * ) { 93void CardMonitor::mousePressEvent( QMouseEvent * ) {
94 QPopupMenu *menu = new QPopupMenu(); 94 QPopupMenu *menu = new QPopupMenu();
95 QString cmd; 95 QString cmd;
96 int err=0; 96 int err=0;
97 97
98 if ( cardInSd ) { 98 if ( cardInSd ) {
99 menu->insertItem( tr("Eject SD/MMC card"), 0 ); 99 menu->insertItem( tr("Eject SD/MMC card"), 0 );
100 } 100 }
101 101
102 if ( cardInPcmcia0 ) { 102 if ( cardInPcmcia0 ) {
103 menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia0Type )), 103 menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia0Type )),
104 tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); 104 tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 );
105 } 105 }
106 106
107 if ( cardInPcmcia1 ) { 107 if ( cardInPcmcia1 ) {
108 menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type )), 108 menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type )),
109 tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); 109 tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 );
110 } 110 }
111 111
112 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 112 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
113 QSize s = menu->sizeHint ( ); 113 QSize s = menu->sizeHint ( );
114 int opt = menu->exec( QPoint ( 114 int opt = menu->exec( QPoint (
115 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), 115 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
116 p. y ( ) - s. height ( ) ), 0); 116 p. y ( ) - s. height ( ) ), 0);
117 117
118 if ( opt == 1 ) { 118 if ( opt == 1 ) {
119 119
120 cmd = "/sbin/cardctl eject 0"; 120 cmd = "/sbin/cardctl eject 0";
121 err = system( (const char *) cmd ); 121 err = system( (const char *) cmd );
122 if ( ( err == 127 ) || ( err < 0 ) ) { 122 if ( ( err == 127 ) || ( err < 0 ) ) {
123 qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); 123 qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err);
124 popUp( tr("CF/PCMCIA card eject failed!")); 124 popUp( tr("CF/PCMCIA card eject failed!"));
125 } 125 }
126 } else if ( opt == 0 ) { 126 } else if ( opt == 0 ) {
127 cmd = "/etc/sdcontrol compeject"; 127 cmd = "/etc/sdcontrol compeject";
128 err = system( (const char *) cmd ); 128 err = system( (const char *) cmd );
129 if ( ( err != 0 ) ) { 129 if ( ( err != 0 ) ) {
130 qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); 130 qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err);
131 popUp( tr("SD/MMC card eject failed!")); 131 popUp( tr("SD/MMC card eject failed!"));
132 } 132 }
133 } else if ( opt == 2 ) { 133 } else if ( opt == 2 ) {
134 cmd = "/sbin/cardctl eject 1"; 134 cmd = "/sbin/cardctl eject 1";
135 err = system( (const char *) cmd ); 135 err = system( (const char *) cmd );
136 if ( ( err == 127 ) || ( err < 0 ) ) { 136 if ( ( err == 127 ) || ( err < 0 ) ) {
137 qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); 137 qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err);
138 popUp( tr("CF/PCMCIA card eject failed!")); 138 popUp( tr("CF/PCMCIA card eject failed!"));
139 } 139 }
140 } 140 }
141 141
142 delete menu; 142 delete menu;
143} 143}
144 144
145 145
146void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { 146void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) {
147 if ( msg == "stabChanged()" ) { 147 if ( msg == "stabChanged()" ) {
148 // qDebug("Pcmcia: stabchanged"); 148 // qDebug("Pcmcia: stabchanged");
149 if ( getStatusPcmcia() ) { 149 if ( getStatusPcmcia() ) {
150 repaint(FALSE); 150 repaint(FALSE);
151 } 151 }
152 } else if ( msg == "mtabChanged()" ) { 152 } else if ( msg == "mtabChanged()" ) {
153 // qDebug("Pcmcia: mtabchanged"); 153 // qDebug("Pcmcia: mtabchanged");
154 if ( getStatusSd() ) { 154 if ( getStatusSd() ) {
155 repaint(FALSE); 155 repaint(FALSE);
156 } 156 }
157 } 157 }
158} 158}
159 159
160bool CardMonitor::getStatusPcmcia( int showPopUp ) { 160bool CardMonitor::getStatusPcmcia( int showPopUp ) {
161 161
162 bool cardWas0 = cardInPcmcia0; // remember last state 162 bool cardWas0 = cardInPcmcia0; // remember last state
163 bool cardWas1 = cardInPcmcia1; 163 bool cardWas1 = cardInPcmcia1;
@@ -190,94 +190,94 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) {
190 cardInPcmcia0Name.stripWhiteSpace(); 190 cardInPcmcia0Name.stripWhiteSpace();
191 cardInPcmcia0 = TRUE; 191 cardInPcmcia0 = TRUE;
192 show(); 192 show();
193 line++; 193 line++;
194 int pos=(*line).find('\t')+1; 194 int pos=(*line).find('\t')+1;
195 cardInPcmcia0Type = (*line).mid( pos, (*line).find("\t", pos) - pos); 195 cardInPcmcia0Type = (*line).mid( pos, (*line).find("\t", pos) - pos);
196 } 196 }
197 } 197 }
198 else if( (*line).startsWith("Socket 1:") ){ 198 else if( (*line).startsWith("Socket 1:") ){
199 if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ 199 if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){
200 cardInPcmcia1 = FALSE; 200 cardInPcmcia1 = FALSE;
201 } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){ 201 } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){
202 cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); 202 cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 );
203 cardInPcmcia1Name.stripWhiteSpace(); 203 cardInPcmcia1Name.stripWhiteSpace();
204 cardInPcmcia1 = TRUE; 204 cardInPcmcia1 = TRUE;
205 show(); 205 show();
206 line++; 206 line++;
207 int pos=(*line).find('\t')+1; 207 int pos=(*line).find('\t')+1;
208 cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos); 208 cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos);
209 } 209 }
210 } 210 }
211 } 211 }
212 f.close(); 212 f.close();
213 if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { 213 if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) {
214 QString text = ""; 214 QString text = QString::null;
215 QString what = ""; 215 QString what = QString::null;
216 if(cardWas0 != cardInPcmcia0) { 216 if(cardWas0 != cardInPcmcia0) {
217 if(cardInPcmcia0) { text += tr("New card: "); what="on";} 217 if(cardInPcmcia0) { text += tr("New card: "); what="on";}
218 else { text += tr("Ejected: "); what="off";} 218 else { text += tr("Ejected: "); what="off";}
219 text += cardInPcmcia0Name; 219 text += cardInPcmcia0Name;
220 popUp( text, "cardmon/" + cardInPcmcia0Type ); 220 popUp( text, "cardmon/" + cardInPcmcia0Type );
221 } 221 }
222 if(cardWas1 != cardInPcmcia1) { 222 if(cardWas1 != cardInPcmcia1) {
223 if(cardInPcmcia1) { text += tr("New card: "); what="on";} 223 if(cardInPcmcia1) { text += tr("New card: "); what="on";}
224 else { text += tr("Ejected: "); what="off";} 224 else { text += tr("Ejected: "); what="off";}
225 text += cardInPcmcia1Name; 225 text += cardInPcmcia1Name;
226 popUp( text, "cardmon/" + cardInPcmcia1Type ); 226 popUp( text, "cardmon/" + cardInPcmcia1Type );
227 } 227 }
228 QSound::play(Resource::findSound("cardmon/card" + what)); 228 QSound::play(Resource::findSound("cardmon/card" + what));
229 } 229 }
230 230
231 } else { 231 } else {
232 // no file found 232 // no file found
233 qDebug("no file found"); 233 qDebug("no file found");
234 cardInPcmcia0 = FALSE; 234 cardInPcmcia0 = FALSE;
235 cardInPcmcia1 = FALSE; 235 cardInPcmcia1 = FALSE;
236 } 236 }
237 237
238 return ((cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1) ? FALSE : TRUE); 238 return ((cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1) ? FALSE : TRUE);
239} 239}
240 240
241 241
242bool CardMonitor::getStatusSd( int showPopUp ) { 242bool CardMonitor::getStatusSd( int showPopUp ) {
243 243
244 bool cardWas=cardInSd; // remember last state 244 bool cardWas=cardInSd; // remember last state
245 cardInSd=false; 245 cardInSd=false;
246 246
247#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 247#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
248 struct mntent *me; 248 struct mntent *me;
249 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 249 FILE *mntfp = setmntent( "/etc/mtab", "r" );
250 250
251 if ( mntfp ) { 251 if ( mntfp ) {
252 while ( (me = getmntent( mntfp )) != 0 ) { 252 while ( (me = getmntent( mntfp )) != 0 ) {
253 QString fs = me->mnt_fsname; 253 QString fs = me->mnt_fsname;
254 if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { 254 if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) {
255 cardInSd=true; 255 cardInSd=true;
256 } 256 }
257 } 257 }
258 endmntent( mntfp ); 258 endmntent( mntfp );
259 } 259 }
260 if(!showPopUp && cardWas != cardInSd) { 260 if(!showPopUp && cardWas != cardInSd) {
261 QString text = ""; 261 QString text = QString::null;
262 if(cardInSd) { text += "SD Inserted"; } 262 if(cardInSd) { text += "SD Inserted"; }
263 else { text += "SD Removed"; } 263 else { text += "SD Removed"; }
264 popUp( text); // XX add SD pic 264 popUp( text); // XX add SD pic
265 } 265 }
266 266
267#else 267#else
268#error "Not on Linux" 268#error "Not on Linux"
269#endif 269#endif
270 return ((cardWas == cardInSd) ? FALSE : TRUE); 270 return ((cardWas == cardInSd) ? FALSE : TRUE);
271} 271}
272 272
273void CardMonitor::paintEvent( QPaintEvent * ) { 273void CardMonitor::paintEvent( QPaintEvent * ) {
274 QPainter p( this ); 274 QPainter p( this );
275 275
276 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { 276 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) {
277 p.drawPixmap( 0, 0, pm ); 277 p.drawPixmap( 0, 0, pm );
278 show(); 278 show();
279 } else { 279 } else {
280 p.eraseRect( rect() ); 280 p.eraseRect( rect() );
281 hide(); 281 hide();
282 } 282 }
283} 283}
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h
index 9651783..49bcae8 100644
--- a/core/applets/cardmon/cardmon.h
+++ b/core/applets/cardmon/cardmon.h
@@ -30,29 +30,29 @@ public:
30 ~CardMonitor(); 30 ~CardMonitor();
31 bool getStatusPcmcia( int showPopUp = FALSE ); 31 bool getStatusPcmcia( int showPopUp = FALSE );
32 bool getStatusSd( int showPopUp = FALSE ); 32 bool getStatusSd( int showPopUp = FALSE );
33 33
34private slots: 34private slots:
35 void cardMessage( const QCString &msg, const QByteArray & ); 35 void cardMessage( const QCString &msg, const QByteArray & );
36 void popupTimeout(); 36 void popupTimeout();
37 37
38protected: 38protected:
39 void paintEvent( QPaintEvent* ); 39 void paintEvent( QPaintEvent* );
40 void mousePressEvent( QMouseEvent * ); 40 void mousePressEvent( QMouseEvent * );
41private: 41private:
42 QPixmap pm; 42 QPixmap pm;
43 // pcmcia socket 0 43 // pcmcia socket 0
44 bool cardInPcmcia0; 44 bool cardInPcmcia0;
45 QString cardInPcmcia0Name; 45 QString cardInPcmcia0Name;
46 QString cardInPcmcia0Type; 46 QString cardInPcmcia0Type;
47 // pcmcia socket 1 47 // pcmcia socket 1
48 bool cardInPcmcia1; 48 bool cardInPcmcia1;
49 QString cardInPcmcia1Name; 49 QString cardInPcmcia1Name;
50 QString cardInPcmcia1Type; 50 QString cardInPcmcia1Type;
51 bool cardInSd; 51 bool cardInSd;
52 void iconShow(); 52 void iconShow();
53 QPopupMenu *popupMenu; 53 QPopupMenu *popupMenu;
54 void popUp(QString message, QString icon=""); 54 void popUp(QString message, QString icon = QString::null );
55 }; 55 };
56 56
57#endif 57#endif
58 58