author | harlekin <harlekin> | 2002-08-30 15:18:25 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-30 15:18:25 (UTC) |
commit | 2e1362616524463697dfe2693178a698ccc713ec (patch) (unidiff) | |
tree | fd7d05256716b33de05705451105336dfcc29571 | |
parent | a4ad4c4ec7227d7ac0e62da71972f35672a6692f (diff) | |
download | opie-2e1362616524463697dfe2693178a698ccc713ec.zip opie-2e1362616524463697dfe2693178a698ccc713ec.tar.gz opie-2e1362616524463697dfe2693178a698ccc713ec.tar.bz2 |
some more debug stuff out
-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 367ef3b..583f2da 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,315 +1,315 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.cpp | 2 | * cardmon.cpp |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * copyright : (c) 2002 by Maximilian Reiss | 6 | * copyright : (c) 2002 by Maximilian Reiss |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * based on two apps by Devin Butterfield | 8 | * based on two apps by Devin Butterfield |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | 19 | ||
20 | #include "cardmon.h" | 20 | #include "cardmon.h" |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | 23 | ||
24 | #include <opie/odevice.h> | 24 | #include <opie/odevice.h> |
25 | 25 | ||
26 | #include <qcopchannel_qws.h> | 26 | #include <qcopchannel_qws.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | 32 | ||
33 | #include <stdio.h> | 33 | #include <stdio.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <string.h> | 36 | #include <string.h> |
37 | #include <fcntl.h> | 37 | #include <fcntl.h> |
38 | #include <qsound.h> | 38 | #include <qsound.h> |
39 | 39 | ||
40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
41 | #include <sys/vfs.h> | 41 | #include <sys/vfs.h> |
42 | #include <mntent.h> | 42 | #include <mntent.h> |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), | 45 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), |
46 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { | 46 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { |
47 | 47 | ||
48 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 48 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
49 | connect( pcmciaChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 49 | connect( pcmciaChannel, SIGNAL( received( const QCString &, const QByteArray &) ), |
50 | this, SLOT( cardMessage( const QCString &, const QByteArray &) ) ); | 50 | this, SLOT( cardMessage( const QCString &, const QByteArray &) ) ); |
51 | 51 | ||
52 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); | 52 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); |
53 | connect( sdChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 53 | connect( sdChannel, SIGNAL( received( const QCString &, const QByteArray &) ), |
54 | this, SLOT( cardMessage( const QCString &, const QByteArray &) ) ); | 54 | this, SLOT( cardMessage( const QCString &, const QByteArray &) ) ); |
55 | 55 | ||
56 | cardInPcmcia0 = FALSE; | 56 | cardInPcmcia0 = FALSE; |
57 | cardInPcmcia1 = FALSE; | 57 | cardInPcmcia1 = FALSE; |
58 | cardInSd = FALSE; | 58 | cardInSd = FALSE; |
59 | 59 | ||
60 | setFixedSize( pm.size() ); | 60 | setFixedSize( pm.size() ); |
61 | getStatusPcmcia( TRUE ); | 61 | getStatusPcmcia( TRUE ); |
62 | getStatusSd( TRUE ); | 62 | getStatusSd( TRUE ); |
63 | repaint( FALSE ); | 63 | repaint( FALSE ); |
64 | popupMenu = 0; | 64 | popupMenu = 0; |
65 | } | 65 | } |
66 | 66 | ||
67 | CardMonitor::~CardMonitor() { | 67 | CardMonitor::~CardMonitor() { |
68 | if( popupMenu ) { | 68 | if( popupMenu ) { |
69 | delete popupMenu; | 69 | delete popupMenu; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | void CardMonitor::popUp( QString message, QString icon ) { | 73 | void CardMonitor::popUp( QString message, QString icon ) { |
74 | if ( ! popupMenu ) { | 74 | if ( ! popupMenu ) { |
75 | popupMenu = new QPopupMenu(); | 75 | popupMenu = new QPopupMenu(); |
76 | } | 76 | } |
77 | 77 | ||
78 | popupMenu->clear(); | 78 | popupMenu->clear(); |
79 | if( icon.isEmpty() ) { | 79 | if( icon.isEmpty() ) { |
80 | popupMenu->insertItem( message, 0 ); | 80 | popupMenu->insertItem( message, 0 ); |
81 | } else { | 81 | } else { |
82 | popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 ); | 82 | popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon ) ), message, 0 ); |
83 | } | 83 | } |
84 | 84 | ||
85 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); | 85 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); |
86 | QSize s = popupMenu->sizeHint (); | 86 | QSize s = popupMenu->sizeHint (); |
87 | popupMenu->popup( QPoint ( | 87 | popupMenu->popup( QPoint ( |
88 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 88 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
89 | p. y ( ) - s. height ( ) ), 0); | 89 | p. y ( ) - s. height ( ) ), 0); |
90 | 90 | ||
91 | QTimer::singleShot( 2000, this, SLOT(popupTimeout() ) ); | 91 | QTimer::singleShot( 2000, this, SLOT(popupTimeout() ) ); |
92 | } | 92 | } |
93 | 93 | ||
94 | void CardMonitor::popupTimeout() { | 94 | void CardMonitor::popupTimeout() { |
95 | popupMenu->hide(); | 95 | popupMenu->hide(); |
96 | } | 96 | } |
97 | 97 | ||
98 | void CardMonitor::mousePressEvent( QMouseEvent * ) { | 98 | void CardMonitor::mousePressEvent( QMouseEvent * ) { |
99 | QPopupMenu *menu = new QPopupMenu(); | 99 | QPopupMenu *menu = new QPopupMenu(); |
100 | QString cmd; | 100 | QString cmd; |
101 | int err=0; | 101 | int err=0; |
102 | 102 | ||
103 | if ( cardInSd ) { | 103 | if ( cardInSd ) { |
104 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); | 104 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); |
105 | } | 105 | } |
106 | 106 | ||
107 | if ( cardInPcmcia0 ) { | 107 | if ( cardInPcmcia0 ) { |
108 | menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia0Type ) ), | 108 | menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia0Type ) ), |
109 | tr( "Eject card 0: %1" ).arg(cardInPcmcia0Name ), 1 ); | 109 | tr( "Eject card 0: %1" ).arg(cardInPcmcia0Name ), 1 ); |
110 | } | 110 | } |
111 | 111 | ||
112 | if ( cardInPcmcia1 ) { | 112 | if ( cardInPcmcia1 ) { |
113 | menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type ) ), | 113 | menu->insertItem( QIconSet ( Resource::loadPixmap ( "cardmon/" + cardInPcmcia1Type ) ), |
114 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | 114 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); |
115 | } | 115 | } |
116 | 116 | ||
117 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); | 117 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); |
118 | QSize s = menu->sizeHint (); | 118 | QSize s = menu->sizeHint (); |
119 | int opt = menu->exec( QPoint ( | 119 | int opt = menu->exec( QPoint ( |
120 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 120 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
121 | p. y ( ) - s. height ( ) ), 0); | 121 | p. y ( ) - s. height ( ) ), 0); |
122 | 122 | ||
123 | if ( opt == 1 ) { | 123 | if ( opt == 1 ) { |
124 | cmd = "/sbin/cardctl eject 0"; | 124 | cmd = "/sbin/cardctl eject 0"; |
125 | err = system( ( const char * ) cmd ); | 125 | err = system( ( const char * ) cmd ); |
126 | if ( ( err == 127 ) || ( err < 0 ) ) { | 126 | if ( ( err == 127 ) || ( err < 0 ) ) { |
127 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", err ); | 127 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", err ); |
128 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 128 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
129 | } | 129 | } |
130 | } else if ( opt == 0 ) { | 130 | } else if ( opt == 0 ) { |
131 | if ( ODevice::inst()->system() == OSYSTEM_Familiar ) { | 131 | if ( ODevice::inst()->system() == OSYSTEM_Familiar ) { |
132 | cmd = "umount /dev/mmc/part1"; | 132 | cmd = "umount /dev/mmc/part1"; |
133 | err = system( ( const char *) cmd ); | 133 | err = system( ( const char *) cmd ); |
134 | if ( ( err != 0 ) ) { | 134 | if ( ( err != 0 ) ) { |
135 | popUp( tr("SD/MMC card eject failed!") ); | 135 | popUp( tr("SD/MMC card eject failed!") ); |
136 | } | 136 | } |
137 | } else { | 137 | } else { |
138 | cmd = "/etc/sdcontrol compeject"; | 138 | cmd = "/etc/sdcontrol compeject"; |
139 | err = system( ( const char *) cmd ); | 139 | err = system( ( const char *) cmd ); |
140 | if ( ( err != 0 ) ) { | 140 | if ( ( err != 0 ) ) { |
141 | qDebug( "Could not execute `/etc/sdcontrol comeject'! err=%d", err ); | 141 | qDebug( "Could not execute `/etc/sdcontrol comeject'! err=%d", err ); |
142 | popUp( tr("SD/MMC card eject failed!") ); | 142 | popUp( tr("SD/MMC card eject failed!") ); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | } else if ( opt == 2 ) { | 145 | } else if ( opt == 2 ) { |
146 | cmd = "/sbin/cardctl eject 1"; | 146 | cmd = "/sbin/cardctl eject 1"; |
147 | err = system( ( const char *) cmd ); | 147 | err = system( ( const char *) cmd ); |
148 | if ( ( err == 127 ) || ( err < 0 ) ) { | 148 | if ( ( err == 127 ) || ( err < 0 ) ) { |
149 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", err ); | 149 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", err ); |
150 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 150 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | delete menu; | 153 | delete menu; |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { | 157 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { |
158 | if ( msg == "stabChanged()" ) { | 158 | if ( msg == "stabChanged()" ) { |
159 | // qDebug("Pcmcia: stabchanged"); | 159 | // qDebug("Pcmcia: stabchanged"); |
160 | if ( getStatusPcmcia() ) { | 160 | if ( getStatusPcmcia() ) { |
161 | repaint( FALSE ); | 161 | repaint( FALSE ); |
162 | } | 162 | } |
163 | } else if ( msg == "mtabChanged()" ) { | 163 | } else if ( msg == "mtabChanged()" ) { |
164 | qDebug("CARDMONAPPLET: mtabchanged"); | 164 | qDebug("CARDMONAPPLET: mtabchanged"); |
165 | if ( getStatusSd() ) { | 165 | if ( getStatusSd() ) { |
166 | repaint( FALSE ); | 166 | repaint( FALSE ); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { | 171 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { |
172 | 172 | ||
173 | bool cardWas0 = cardInPcmcia0; // remember last state | 173 | bool cardWas0 = cardInPcmcia0; // remember last state |
174 | bool cardWas1 = cardInPcmcia1; | 174 | bool cardWas1 = cardInPcmcia1; |
175 | 175 | ||
176 | QString fileName; | 176 | QString fileName; |
177 | 177 | ||
178 | // one of these 3 files should exist | 178 | // one of these 3 files should exist |
179 | if ( QFile::exists( "/var/run/stab" ) ) { | 179 | if ( QFile::exists( "/var/run/stab" ) ) { |
180 | fileName = "/var/run/stab"; | 180 | fileName = "/var/run/stab"; |
181 | } else if (QFile::exists( "/var/state/pcmcia/stab" ) ) { | 181 | } else if (QFile::exists( "/var/state/pcmcia/stab" ) ) { |
182 | fileName = "/var/state/pcmcia/stab"; | 182 | fileName = "/var/state/pcmcia/stab"; |
183 | } else { | 183 | } else { |
184 | fileName = "/var/lib/pcmcia/stab"; | 184 | fileName = "/var/lib/pcmcia/stab"; |
185 | } | 185 | } |
186 | 186 | ||
187 | QFile f( fileName ); | 187 | QFile f( fileName ); |
188 | 188 | ||
189 | if ( f.open( IO_ReadOnly ) ) { | 189 | if ( f.open( IO_ReadOnly ) ) { |
190 | QStringList list; | 190 | QStringList list; |
191 | QTextStream stream ( &f ); | 191 | QTextStream stream ( &f ); |
192 | QString streamIn; | 192 | QString streamIn; |
193 | streamIn = stream.read(); | 193 | streamIn = stream.read(); |
194 | list = QStringList::split( "\n", streamIn ); | 194 | list = QStringList::split( "\n", streamIn ); |
195 | for( QStringList::Iterator line=list.begin(); line!=list.end(); line++ ) { | 195 | for( QStringList::Iterator line=list.begin(); line!=list.end(); line++ ) { |
196 | if( (*line).startsWith( "Socket 0:" ) ){ | 196 | if( (*line).startsWith( "Socket 0:" ) ){ |
197 | if( (*line).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ){ | 197 | if( (*line).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ){ |
198 | cardInPcmcia0 = FALSE; | 198 | cardInPcmcia0 = FALSE; |
199 | } else if ( !(*line).startsWith( "Socket 0: empty" ) && !cardInPcmcia0 ){ | 199 | } else if ( !(*line).startsWith( "Socket 0: empty" ) && !cardInPcmcia0 ){ |
200 | cardInPcmcia0Name = (*line).mid( ( (*line).find( ':' ) + 1 ), (*line).length() - 9 ); | 200 | cardInPcmcia0Name = (*line).mid( ( (*line).find( ':' ) + 1 ), (*line).length() - 9 ); |
201 | cardInPcmcia0Name.stripWhiteSpace(); | 201 | cardInPcmcia0Name.stripWhiteSpace(); |
202 | cardInPcmcia0 = TRUE; | 202 | cardInPcmcia0 = TRUE; |
203 | show(); | 203 | show(); |
204 | line++; | 204 | line++; |
205 | int pos=(*line).find('\t' ) + 1; | 205 | int pos=(*line).find('\t' ) + 1; |
206 | cardInPcmcia0Type = (*line).mid( pos, (*line).find( "\t" , pos) - pos ); | 206 | cardInPcmcia0Type = (*line).mid( pos, (*line).find( "\t" , pos) - pos ); |
207 | } | 207 | } |
208 | } else if( (*line).startsWith( "Socket 1:" ) ){ | 208 | } else if( (*line).startsWith( "Socket 1:" ) ){ |
209 | if( (*line).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { | 209 | if( (*line).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { |
210 | cardInPcmcia1 = FALSE; | 210 | cardInPcmcia1 = FALSE; |
211 | } else if ( !(*line).startsWith( "Socket 1: empty" ) && !cardInPcmcia1 ) { | 211 | } else if ( !(*line).startsWith( "Socket 1: empty" ) && !cardInPcmcia1 ) { |
212 | cardInPcmcia1Name = (*line).mid(((*line).find(':') + 1), (*line).length() - 9 ); | 212 | cardInPcmcia1Name = (*line).mid(((*line).find(':') + 1), (*line).length() - 9 ); |
213 | cardInPcmcia1Name.stripWhiteSpace(); | 213 | cardInPcmcia1Name.stripWhiteSpace(); |
214 | cardInPcmcia1 = TRUE; | 214 | cardInPcmcia1 = TRUE; |
215 | show(); | 215 | show(); |
216 | line++; | 216 | line++; |
217 | int pos=(*line).find('\t') + 1; | 217 | int pos=(*line).find('\t') + 1; |
218 | cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos ); | 218 | cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos ); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | f.close(); | 222 | f.close(); |
223 | 223 | ||
224 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1) ) { | 224 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1) ) { |
225 | QString text = QString::null; | 225 | QString text = QString::null; |
226 | QString what = QString::null; | 226 | QString what = QString::null; |
227 | if(cardWas0 != cardInPcmcia0) { | 227 | if(cardWas0 != cardInPcmcia0) { |
228 | if(cardInPcmcia0) { | 228 | if(cardInPcmcia0) { |
229 | text += tr( "New card: " ); | 229 | text += tr( "New card: " ); |
230 | what="on"; | 230 | what="on"; |
231 | } else { | 231 | } else { |
232 | text += tr( "Ejected: " ); | 232 | text += tr( "Ejected: " ); |
233 | what="off"; | 233 | what="off"; |
234 | } | 234 | } |
235 | text += cardInPcmcia0Name; | 235 | text += cardInPcmcia0Name; |
236 | popUp( text, "cardmon/" + cardInPcmcia0Type ); | 236 | popUp( text, "cardmon/" + cardInPcmcia0Type ); |
237 | } | 237 | } |
238 | 238 | ||
239 | if( cardWas1 != cardInPcmcia1) { | 239 | if( cardWas1 != cardInPcmcia1) { |
240 | if( cardInPcmcia1) { | 240 | if( cardInPcmcia1) { |
241 | text += tr( "New card: " ); | 241 | text += tr( "New card: " ); |
242 | what = "on"; | 242 | what = "on"; |
243 | } else { | 243 | } else { |
244 | text += tr( "Ejected: " ); | 244 | text += tr( "Ejected: " ); |
245 | what = "off"; | 245 | what = "off"; |
246 | } | 246 | } |
247 | text += cardInPcmcia1Name; | 247 | text += cardInPcmcia1Name; |
248 | popUp( text, "cardmon/" + cardInPcmcia1Type ); | 248 | popUp( text, "cardmon/" + cardInPcmcia1Type ); |
249 | } | 249 | } |
250 | QSound::play( Resource::findSound( "cardmon/card" + what) ); | 250 | QSound::play( Resource::findSound( "cardmon/card" + what) ); |
251 | } | 251 | } |
252 | } else { | 252 | } else { |
253 | // no file found | 253 | // no file found |
254 | qDebug("no file found"); | 254 | qDebug( "no file found" ); |
255 | cardInPcmcia0 = FALSE; | 255 | cardInPcmcia0 = FALSE; |
256 | cardInPcmcia1 = FALSE; | 256 | cardInPcmcia1 = FALSE; |
257 | } | 257 | } |
258 | return ( (cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); | 258 | return ( (cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
262 | bool CardMonitor::getStatusSd( int showPopUp ) { | 262 | bool CardMonitor::getStatusSd( int showPopUp ) { |
263 | 263 | ||
264 | bool cardWas = cardInSd; // remember last state | 264 | bool cardWas = cardInSd; // remember last state |
265 | 265 | ||
266 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 266 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
267 | struct mntent *me; | 267 | struct mntent *me; |
268 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 268 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
269 | 269 | ||
270 | if ( mntfp ) { | 270 | if ( mntfp ) { |
271 | while ( ( me = getmntent( mntfp ) ) != 0 ) { | 271 | while ( ( me = getmntent( mntfp ) ) != 0 ) { |
272 | QString fs = me->mnt_fsname; | 272 | QString fs = me->mnt_fsname; |
273 | qDebug( fs ); | 273 | //qDebug( fs ); |
274 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" || fs.left( 9 ) == "/dev/mmcd" ) { | 274 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" || fs.left( 9 ) == "/dev/mmcd" ) { |
275 | cardInSd = TRUE; | 275 | cardInSd = TRUE; |
276 | show(); | 276 | show(); |
277 | } else { | 277 | } else { |
278 | cardInSd = FALSE; | 278 | cardInSd = FALSE; |
279 | } | 279 | } |
280 | } | 280 | } |
281 | endmntent( mntfp ); | 281 | endmntent( mntfp ); |
282 | } | 282 | } |
283 | 283 | ||
284 | if( !showPopUp && cardWas != cardInSd ) { | 284 | if( !showPopUp && cardWas != cardInSd ) { |
285 | QString text = QString::null; | 285 | QString text = QString::null; |
286 | QString what = QString::null; | 286 | QString what = QString::null; |
287 | if( cardInSd ) { | 287 | if( cardInSd ) { |
288 | text += "SD Inserted"; | 288 | text += "SD Inserted"; |
289 | what = "on"; | 289 | what = "on"; |
290 | } else { | 290 | } else { |
291 | text += "SD Removed"; | 291 | text += "SD Removed"; |
292 | what = "off"; | 292 | what = "off"; |
293 | } | 293 | } |
294 | qDebug("TEXT: " + text ); | 294 | //qDebug("TEXT: " + text ); |
295 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | 295 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); |
296 | popUp( text, "cardmon/ide" ); // XX add SD pic | 296 | popUp( text, "cardmon/ide" ); // XX add SD pic |
297 | } | 297 | } |
298 | #else | 298 | #else |
299 | #error "Not on Linux" | 299 | #error "Not on Linux" |
300 | #endif | 300 | #endif |
301 | return ( ( cardWas == cardInSd) ? FALSE : TRUE ); | 301 | return ( ( cardWas == cardInSd) ? FALSE : TRUE ); |
302 | } | 302 | } |
303 | 303 | ||
304 | void CardMonitor::paintEvent( QPaintEvent * ) { | 304 | void CardMonitor::paintEvent( QPaintEvent * ) { |
305 | 305 | ||
306 | QPainter p( this ); | 306 | QPainter p( this ); |
307 | 307 | ||
308 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 308 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { |
309 | p.drawPixmap( 0, 0, pm ); | 309 | p.drawPixmap( 0, 0, pm ); |
310 | show(); | 310 | show(); |
311 | } else { | 311 | } else { |
312 | p.eraseRect( rect() ); | 312 | p.eraseRect( rect() ); |
313 | hide(); | 313 | hide(); |
314 | } | 314 | } |
315 | } | 315 | } |