author | mickeyl <mickeyl> | 2005-05-19 14:25:34 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-19 14:25:34 (UTC) |
commit | 7fcfce8388df1805327f21d4cc41d7f5f54c6e6a (patch) (unidiff) | |
tree | 80409a535f74f4d5c5131f2eeb9f064a492f0cb8 | |
parent | 77134583c00446fc74515889514571924e7471ed (diff) | |
download | opie-7fcfce8388df1805327f21d4cc41d7f5f54c6e6a.zip opie-7fcfce8388df1805327f21d4cc41d7f5f54c6e6a.tar.gz opie-7fcfce8388df1805327f21d4cc41d7f5f54c6e6a.tar.bz2 |
write card log
-rw-r--r-- | core/applets/cardmon/pcmcia.cpp | 284 | ||||
-rw-r--r-- | core/applets/cardmon/pcmcia.h | 35 |
2 files changed, 91 insertions, 228 deletions
diff --git a/core/applets/cardmon/pcmcia.cpp b/core/applets/cardmon/pcmcia.cpp index 2486f17..5183572 100644 --- a/core/applets/cardmon/pcmcia.cpp +++ b/core/applets/cardmon/pcmcia.cpp | |||
@@ -19,353 +19,231 @@ | |||
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "pcmcia.h" | 30 | #include "pcmcia.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | #include <opie2/odevice.h> | 34 | #include <opie2/odevice.h> |
35 | #include <opie2/oconfig.h> | ||
35 | #include <opie2/oprocess.h> | 36 | #include <opie2/oprocess.h> |
37 | #include <opie2/opcmciasystem.h> | ||
36 | #include <opie2/oresource.h> | 38 | #include <opie2/oresource.h> |
37 | #include <opie2/otaskbarapplet.h> | 39 | #include <opie2/otaskbarapplet.h> |
38 | #include <qpe/applnk.h> | 40 | #include <qpe/applnk.h> |
39 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
40 | using namespace Opie::Core; | 42 | using namespace Opie::Core; |
41 | using namespace Opie::Ui; | 43 | using namespace Opie::Ui; |
42 | 44 | ||
43 | /* QT */ | 45 | /* QT */ |
44 | #include <qcopchannel_qws.h> | 46 | #include <qcopchannel_qws.h> |
45 | #include <qpainter.h> | 47 | #include <qpainter.h> |
46 | #include <qfile.h> | 48 | #include <qfile.h> |
47 | #include <qtextstream.h> | 49 | #include <qtextstream.h> |
50 | #include <qmessagebox.h> | ||
48 | #include <qsound.h> | 51 | #include <qsound.h> |
49 | #include <qtimer.h> | 52 | #include <qtimer.h> |
50 | 53 | ||
51 | /* STD */ | 54 | /* STD */ |
52 | #include <stdio.h> | 55 | #include <stdio.h> |
53 | #include <unistd.h> | 56 | #include <unistd.h> |
54 | #include <stdlib.h> | 57 | #include <stdlib.h> |
55 | #include <string.h> | 58 | #include <string.h> |
56 | #include <fcntl.h> | 59 | #include <fcntl.h> |
57 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 60 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
58 | #include <sys/vfs.h> | 61 | #include <sys/vfs.h> |
59 | #include <mntent.h> | 62 | #include <mntent.h> |
60 | #endif | 63 | #endif |
61 | 64 | ||
62 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 65 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) |
63 | { | 66 | { |
64 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | ||
65 | #if 0 | ||
66 | QCopChannel *channel = new QCopChannel("QPE/System", this); | ||
67 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), | ||
68 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); | ||
69 | #endif | ||
70 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 67 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
71 | connect( pcmciaChannel, | 68 | connect( pcmciaChannel, |
72 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 69 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
73 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 70 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
74 | 71 | ||
75 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); | ||
76 | connect( sdChannel, | ||
77 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | ||
78 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | ||
79 | |||
80 | cardInPcmcia0 = FALSE; | ||
81 | cardInPcmcia1 = FALSE; | ||
82 | cardInSd = FALSE; | ||
83 | |||
84 | setFocusPolicy( NoFocus ); | 72 | setFocusPolicy( NoFocus ); |
85 | |||
86 | setFixedWidth ( AppLnk::smallIconSize() ); | 73 | setFixedWidth ( AppLnk::smallIconSize() ); |
87 | setFixedHeight ( AppLnk::smallIconSize() ); | 74 | setFixedHeight ( AppLnk::smallIconSize() ); |
88 | 75 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | |
89 | getStatusPcmcia( TRUE ); | ||
90 | getStatusSd( TRUE ); | ||
91 | repaint( FALSE ); | ||
92 | popupMenu = 0; | ||
93 | } | 76 | } |
94 | 77 | ||
95 | 78 | ||
96 | PcmciaManager::~PcmciaManager() | 79 | PcmciaManager::~PcmciaManager() |
97 | { | 80 | { |
98 | delete popupMenu; | ||
99 | } | 81 | } |
100 | 82 | ||
101 | 83 | ||
102 | void PcmciaManager::popUp( QString message, QString icon ) | 84 | void PcmciaManager::popUp( QString message, QString icon ) |
103 | { | 85 | { |
104 | if ( !popupMenu ) { | 86 | if ( !popupMenu ) { |
105 | popupMenu = new QPopupMenu( this ); | 87 | popupMenu = new QPopupMenu( this ); |
106 | } | 88 | } |
107 | 89 | ||
108 | popupMenu->clear(); | 90 | popupMenu->clear(); |
109 | if ( icon.isEmpty() ) { | 91 | if ( icon.isEmpty() ) { |
110 | popupMenu->insertItem( message, 0 ); | 92 | popupMenu->insertItem( message, 0 ); |
111 | } else { | 93 | } else { |
112 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), | 94 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), |
113 | message, 0 ); | 95 | message, 0 ); |
114 | } | 96 | } |
115 | 97 | ||
116 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 98 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
117 | QSize s = popupMenu->sizeHint(); | 99 | QSize s = popupMenu->sizeHint(); |
118 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 100 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
119 | p.y() - s.height() ), 0 ); | 101 | p.y() - s.height() ), 0 ); |
120 | 102 | ||
121 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 103 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
122 | } | 104 | } |
123 | 105 | ||
124 | 106 | ||
125 | void PcmciaManager::popupTimeout() | 107 | void PcmciaManager::popupTimeout() |
126 | { | 108 | { |
127 | popupMenu->hide(); | 109 | popupMenu->hide(); |
128 | } | 110 | } |
129 | 111 | ||
130 | 112 | ||
131 | void PcmciaManager::mousePressEvent( QMouseEvent * ) | 113 | void PcmciaManager::mousePressEvent( QMouseEvent* ) |
132 | { | 114 | { |
133 | QPopupMenu * menu = new QPopupMenu( this ); | 115 | QPopupMenu * menu = new QPopupMenu( this ); |
134 | QStringList cmd; | 116 | QStringList cmd; |
135 | bool execute = true; | 117 | bool execute = true; |
136 | 118 | ||
119 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | ||
120 | OPcmciaSystem::CardIterator it = sys->iterator(); | ||
121 | if ( !sys->count() ) return; | ||
122 | |||
123 | int i = 0; | ||
124 | while ( it.current() ) | ||
125 | { | ||
126 | menu->insertItem( tr( "Eject card %1: %2" ).arg( i++ ).arg( it.currentKey() ), 1 ); | ||
127 | ++it; | ||
128 | } | ||
129 | |||
130 | |||
131 | /* insert items depending on number of cards etc. | ||
132 | |||
137 | if ( cardInSd ) { | 133 | if ( cardInSd ) { |
138 | menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ), | 134 | menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ), |
139 | tr( "Eject SD/MMC card" ), 0 ); | 135 | tr( "Eject SD/MMC card" ), 0 ); |
140 | } | 136 | } |
141 | 137 | ||
138 | |||
139 | |||
142 | if ( cardInPcmcia0 ) { | 140 | if ( cardInPcmcia0 ) { |
143 | menu-> | 141 | menu-> |
144 | insertItem( QIconSet | 142 | insertItem( QIconSet |
145 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ), | 143 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ), |
146 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); | 144 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); |
147 | } | 145 | } |
148 | 146 | ||
149 | if ( cardInPcmcia1 ) { | 147 | if ( cardInPcmcia1 ) { |
150 | menu-> | 148 | menu-> |
151 | insertItem( QIconSet | 149 | insertItem( QIconSet |
152 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ), | 150 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ), |
153 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | 151 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); |
154 | } | 152 | } |
153 | */ | ||
155 | 154 | ||
156 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 155 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
157 | QSize s = menu->sizeHint(); | 156 | QSize s = menu->sizeHint(); |
158 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 157 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); |
159 | p.y() - s.height() ), 0 ); | 158 | qDebug( "pcmcia: menu result = %d", opt ); |
160 | |||
161 | if ( opt == 1 ) { | ||
162 | m_commandOrig = PCMCIA_Socket1; | ||
163 | cmd << "/sbin/cardctl" << "eject" << "0"; | ||
164 | } else if ( opt == 0 ) { | ||
165 | m_commandOrig = MMC_Socket; | ||
166 | cmd << "umount" << cardSdName; | ||
167 | } else if ( opt == 2 ) { | ||
168 | m_commandOrig = PCMCIA_Socket2; | ||
169 | cmd << "/sbin/cardctl" << "eject" << "1"; | ||
170 | }else | ||
171 | execute = false; | ||
172 | |||
173 | if ( execute ) | ||
174 | execCommand( cmd ); | ||
175 | |||
176 | delete menu; | 159 | delete menu; |
177 | } | 160 | } |
178 | 161 | ||
179 | 162 | ||
180 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | 163 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) |
181 | { | 164 | { |
182 | if ( msg == "stabChanged()" ) { | 165 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; |
183 | // odebug << "Pcmcia: stabchanged" << oendl; | 166 | if ( msg != "stabChanged()" ) return; |
184 | getStatusPcmcia(); | 167 | |
185 | } else if ( msg == "mtabChanged()" ) { | 168 | /* check if a previously unknown card has been inserted */ |
186 | // odebug << "CARDMONAPPLET: mtabchanged" << oendl; | 169 | OPcmciaSystem::instance()->synchronize(); |
187 | getStatusSd(); | 170 | |
188 | } | 171 | if ( !OPcmciaSystem::instance()->count() ) return; |
189 | } | 172 | |
190 | 173 | OConfig cfg( "PCMCIA" ); | |
191 | 174 | cfg.setGroup( "Global" ); | |
192 | bool PcmciaManager::getStatusPcmcia( int showPopUp ) { | 175 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
193 | 176 | ||
194 | bool cardWas0 = cardInPcmcia0; // remember last state | 177 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
195 | bool cardWas1 = cardInPcmcia1; | 178 | OPcmciaSystem::CardIterator it = sys->iterator(); |
196 | 179 | ||
197 | QString fileName; | 180 | bool newCard = true; |
198 | 181 | while ( it.current() && newCard ) | |
199 | if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } | 182 | { |
200 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } | 183 | QString name = it.currentKey(); |
201 | else { fileName = "/var/lib/pcmcia/stab"; } | 184 | for ( int i = 0; i < nCards; ++i ) |
202 | 185 | { | |
203 | QFile f( fileName ); | 186 | QString cardSection = QString( "Card_%1" ).arg( i ); |
204 | 187 | cfg.setGroup( cardSection ); | |
205 | if ( f.open( IO_ReadOnly ) ) { | 188 | QString cardName = cfg.readEntry( "name" ); |
206 | QStringList list; | 189 | odebug << "comparing card '" << name << "' with known card '" << cardName << "'" << oendl; |
207 | QTextStream stream( &f ); | 190 | if ( cardName == name ) |
208 | QString streamIn; | 191 | { |
209 | streamIn = stream.read(); | 192 | newCard = false; |
210 | list = QStringList::split( "\n", streamIn ); | 193 | break; |
211 | for ( QStringList::Iterator line = list.begin(); line != list.end(); | ||
212 | line++ ) { | ||
213 | if ( ( *line ).startsWith( "Socket 0:" ) ) { | ||
214 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) { | ||
215 | cardInPcmcia0 = FALSE; | ||
216 | } else if ( !( *line ).startsWith( "Socket 0: empty" ) | ||
217 | && !cardInPcmcia0 ) { | ||
218 | cardInPcmcia0Name = | ||
219 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | ||
220 | ( *line ).length() - 9 ); | ||
221 | cardInPcmcia0Name.stripWhiteSpace(); | ||
222 | cardInPcmcia0 = TRUE; | ||
223 | show(); | ||
224 | line++; | ||
225 | int pos = ( *line ).find( '\t' ) + 1; | ||
226 | cardInPcmcia0Type = | ||
227 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | ||
228 | } | ||
229 | } else if ( ( *line ).startsWith( "Socket 1:" ) ) { | ||
230 | if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { | ||
231 | cardInPcmcia1 = FALSE; | ||
232 | } else if ( !( *line ).startsWith( "Socket 1: empty" ) | ||
233 | && !cardInPcmcia1 ) { | ||
234 | cardInPcmcia1Name = | ||
235 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | ||
236 | ( *line ).length() - 9 ); | ||
237 | cardInPcmcia1Name.stripWhiteSpace(); | ||
238 | cardInPcmcia1 = TRUE; | ||
239 | show(); | ||
240 | line++; | ||
241 | int pos = ( *line ).find( '\t' ) + 1; | ||
242 | cardInPcmcia1Type = | ||
243 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | ||
244 | } | ||
245 | } | 194 | } |
246 | } | 195 | } |
247 | f.close(); | 196 | if ( !newCard ) ++it; else break; |
248 | |||
249 | if ( !showPopUp | ||
250 | && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) { | ||
251 | QString text = QString::null; | ||
252 | QString what = QString::null; | ||
253 | if ( cardWas0 != cardInPcmcia0 ) { | ||
254 | if ( cardInPcmcia0 ) { | ||
255 | text += tr( "New card: " ); | ||
256 | what = "on"; | ||
257 | } else { | ||
258 | text += tr( "Ejected: " ); | ||
259 | what = "off"; | ||
260 | } | ||
261 | text += cardInPcmcia0Name; | ||
262 | popUp( text, "cardmon/" + cardInPcmcia0Type ); | ||
263 | } | ||
264 | |||
265 | if ( cardWas1 != cardInPcmcia1 ) { | ||
266 | if ( cardInPcmcia1 ) { | ||
267 | text += tr( "New card: " ); | ||
268 | what = "on"; | ||
269 | } else { | ||
270 | text += tr( "Ejected: " ); | ||
271 | what = "off"; | ||
272 | } | ||
273 | text += cardInPcmcia1Name; | ||
274 | popUp( text, "cardmon/" + cardInPcmcia1Type ); | ||
275 | } | ||
276 | #ifndef QT_NO_SOUND | ||
277 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | ||
278 | #endif | ||
279 | |||
280 | } | ||
281 | } else { | ||
282 | // no file found | ||
283 | odebug << "no file found" << oendl; | ||
284 | cardInPcmcia0 = FALSE; | ||
285 | cardInPcmcia1 = FALSE; | ||
286 | } | 197 | } |
198 | QString newCardName = it.currentKey(); | ||
199 | |||
200 | if ( newCard ) | ||
201 | { | ||
202 | odebug << "pcmcia: new card detected" << oendl; | ||
203 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | ||
204 | cfg.writeEntry( "name", newCardName ); | ||
205 | cfg.setGroup( "Global" ); | ||
206 | cfg.writeEntry( "nCards", nCards+1 ); | ||
207 | cfg.write(); | ||
208 | |||
209 | int result = QMessageBox::information( qApp->desktop(), | ||
210 | tr( "PCMCIA/CF Subsystem" ), | ||
211 | tr( "You have inserted a new card\n%1\nDo you want to configure this card?" ).arg( newCardName ), | ||
212 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | ||
213 | odebug << "result = " << result << oendl; | ||
287 | 214 | ||
288 | repaint( FALSE ); | ||
289 | return ( ( cardWas0 == cardInPcmcia0 | ||
290 | && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); | ||
291 | |||
292 | } | ||
293 | |||
294 | |||
295 | bool PcmciaManager::getStatusSd( int showPopUp ) | ||
296 | { | ||
297 | |||
298 | bool cardWas = cardInSd; // remember last state | ||
299 | cardInSd = FALSE; | ||
300 | |||
301 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | ||
302 | |||
303 | struct mntent *me; | ||
304 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | ||
305 | |||
306 | if ( mntfp ) { | ||
307 | while ( ( me = getmntent( mntfp ) ) != 0 ) { | ||
308 | QString fs = QFile::decodeName( me->mnt_fsname ); | ||
309 | //odebug << fs << oendl; | ||
310 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" | ||
311 | || fs.left( 9 ) == "/dev/mmcd" || fs.left(11) == "/dev/mmcblk" ) { | ||
312 | cardInSd = TRUE; | ||
313 | cardSdName = fs; | ||
314 | show(); | ||
315 | } | ||
316 | // else { | ||
317 | // cardInSd = FALSE; | ||
318 | // } | ||
319 | } | ||
320 | endmntent( mntfp ); | ||
321 | } | 215 | } |
322 | 216 | else | |
323 | if ( !showPopUp && cardWas != cardInSd ) { | 217 | { |
324 | QString text = QString::null; | 218 | odebug << "pcmcia: card has been previously inserted" << oendl; |
325 | QString what = QString::null; | ||
326 | if ( cardInSd ) { | ||
327 | text += tr("New card: SD/MMC"); | ||
328 | what = "on"; | ||
329 | } else { | ||
330 | text += tr("Ejected: SD/MMC"); | ||
331 | what = "off"; | ||
332 | } | ||
333 | //odebug << "TEXT: " + text << oendl; | ||
334 | #ifndef QT_NO_SOUND | ||
335 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | ||
336 | #endif | ||
337 | |||
338 | popUp( text, "cardmon/ide" ); // XX add SD pic | ||
339 | } | 219 | } |
340 | #else | 220 | repaint( TRUE ); |
341 | #error "Not on Linux" | ||
342 | #endif | ||
343 | repaint( FALSE ); | ||
344 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); | ||
345 | } | 221 | } |
346 | 222 | ||
223 | |||
347 | void PcmciaManager::paintEvent( QPaintEvent * ) | 224 | void PcmciaManager::paintEvent( QPaintEvent * ) |
348 | { | 225 | { |
349 | |||
350 | QPainter p( this ); | 226 | QPainter p( this ); |
351 | 227 | qDebug( "count = %d", (OPcmciaSystem::instance()->count() ) ); | |
352 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 228 | if ( OPcmciaSystem::instance()->count() ) |
229 | { | ||
353 | p.drawPixmap( 0, 0, pm ); | 230 | p.drawPixmap( 0, 0, pm ); |
354 | show(); | 231 | show(); |
355 | } else { | 232 | } |
356 | //p.eraseRect(rect()); | 233 | else |
234 | { | ||
357 | hide(); | 235 | hide(); |
358 | } | 236 | } |
359 | } | 237 | } |
360 | 238 | ||
361 | int PcmciaManager::position() | 239 | int PcmciaManager::position() |
362 | { | 240 | { |
363 | return 7; | 241 | return 7; |
364 | } | 242 | } |
365 | 243 | ||
366 | void PcmciaManager::execCommand( const QStringList &strList ) | 244 | void PcmciaManager::execCommand( const QStringList &strList ) |
367 | { | 245 | { |
368 | } | 246 | } |
369 | 247 | ||
370 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 248 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) |
371 | 249 | ||
diff --git a/core/applets/cardmon/pcmcia.h b/core/applets/cardmon/pcmcia.h index 58a2d42..5c20433 100644 --- a/core/applets/cardmon/pcmcia.h +++ b/core/applets/cardmon/pcmcia.h | |||
@@ -24,57 +24,42 @@ | |||
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef PCMCIA_H | 30 | #ifndef PCMCIA_H |
31 | #define PCMCIA_H | 31 | #define PCMCIA_H |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | class PcmciaManager : public QWidget | 37 | class PcmciaManager : public QWidget |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | enum { | ||
42 | PCMCIA_Socket1, | ||
43 | PCMCIA_Socket2, | ||
44 | MMC_Socket | ||
45 | }; | ||
46 | |||
47 | PcmciaManager( QWidget *parent = 0 ); | 41 | PcmciaManager( QWidget *parent = 0 ); |
48 | ~PcmciaManager(); | 42 | ~PcmciaManager(); |
49 | bool getStatusPcmcia( int showPopUp = FALSE ); | ||
50 | bool getStatusSd( int showPopUp = FALSE ); | ||
51 | static int position(); | 43 | static int position(); |
52 | private slots: | 44 | |
53 | void cardMessage( const QCString &msg, const QByteArray & ); | 45 | private slots: |
46 | void cardMessage( const QCString& msg, const QByteArray& ); | ||
54 | void popupTimeout(); | 47 | void popupTimeout(); |
55 | 48 | ||
56 | protected: | 49 | protected: |
57 | void paintEvent( QPaintEvent* ); | 50 | void paintEvent( QPaintEvent* ); |
58 | void mousePressEvent( QMouseEvent * ); | 51 | void mousePressEvent( QMouseEvent * ); |
59 | 52 | ||
60 | private: | 53 | private: |
61 | void execCommand( const QStringList &command ); | 54 | void execCommand( const QStringList &command ); |
55 | void popUp(QString message, QString icon = QString::null ); | ||
56 | |||
57 | private: | ||
62 | int m_commandOrig; | 58 | int m_commandOrig; |
63 | QPixmap pm; | 59 | QPixmap pm; |
64 | // pcmcia socket 0 | ||
65 | bool cardInPcmcia0; | ||
66 | QString cardInPcmcia0Name; | ||
67 | QString cardInPcmcia0Type; | ||
68 | // pcmcia socket 1 | ||
69 | bool cardInPcmcia1; | ||
70 | QString cardInPcmcia1Name; | ||
71 | QString cardInPcmcia1Type; | ||
72 | bool cardInSd; | ||
73 | QString cardSdName; // the device which is mounted | ||
74 | void iconShow(); | ||
75 | QPopupMenu *popupMenu; | 60 | QPopupMenu *popupMenu; |
76 | void popUp(QString message, QString icon = QString::null ); | 61 | |
77 | }; | 62 | }; |
78 | 63 | ||
79 | #endif | 64 | #endif |
80 | 65 | ||