summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index 53497df..452339c 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -162,220 +162,220 @@ void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) {
162 } else if ( msg == "mtabChanged()" ) { 162 } else if ( msg == "mtabChanged()" ) {
163 // odebug << "CARDMONAPPLET: mtabchanged" << oendl; 163 // odebug << "CARDMONAPPLET: mtabchanged" << oendl;
164 getStatusSd(); 164 getStatusSd();
165 } 165 }
166} 166}
167 167
168bool CardMonitor::getStatusPcmcia( int showPopUp ) { 168bool CardMonitor::getStatusPcmcia( int showPopUp ) {
169 169
170 bool cardWas0 = cardInPcmcia0; // remember last state 170 bool cardWas0 = cardInPcmcia0; // remember last state
171 bool cardWas1 = cardInPcmcia1; 171 bool cardWas1 = cardInPcmcia1;
172 172
173 QString fileName; 173 QString fileName;
174 174
175 // one of these 3 files should exist 175 // one of these 3 files should exist
176 if ( QFile::exists( "/var/run/stab" ) ) { 176 if ( QFile::exists( "/var/run/stab" ) ) {
177 fileName = "/var/run/stab"; 177 fileName = "/var/run/stab";
178 } else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { 178 } else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) {
179 fileName = "/var/state/pcmcia/stab"; 179 fileName = "/var/state/pcmcia/stab";
180 } else { 180 } else {
181 fileName = "/var/lib/pcmcia/stab"; 181 fileName = "/var/lib/pcmcia/stab";
182 } 182 }
183 183
184 QFile f( fileName ); 184 QFile f( fileName );
185 185
186 if ( f.open( IO_ReadOnly ) ) { 186 if ( f.open( IO_ReadOnly ) ) {
187 QStringList list; 187 QStringList list;
188 QTextStream stream( &f ); 188 QTextStream stream( &f );
189 QString streamIn; 189 QString streamIn;
190 streamIn = stream.read(); 190 streamIn = stream.read();
191 list = QStringList::split( "\n", streamIn ); 191 list = QStringList::split( "\n", streamIn );
192 for ( QStringList::Iterator line = list.begin(); line != list.end(); 192 for ( QStringList::Iterator line = list.begin(); line != list.end();
193 line++ ) { 193 line++ ) {
194 if ( ( *line ).startsWith( "Socket 0:" ) ) { 194 if ( ( *line ).startsWith( "Socket 0:" ) ) {
195 if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) { 195 if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) {
196 cardInPcmcia0 = FALSE; 196 cardInPcmcia0 = FALSE;
197 } else if ( !( *line ).startsWith( "Socket 0: empty" ) 197 } else if ( !( *line ).startsWith( "Socket 0: empty" )
198 && !cardInPcmcia0 ) { 198 && !cardInPcmcia0 ) {
199 cardInPcmcia0Name = 199 cardInPcmcia0Name =
200 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), 200 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ),
201 ( *line ).length() - 9 ); 201 ( *line ).length() - 9 );
202 cardInPcmcia0Name.stripWhiteSpace(); 202 cardInPcmcia0Name.stripWhiteSpace();
203 cardInPcmcia0 = TRUE; 203 cardInPcmcia0 = TRUE;
204 show(); 204 show();
205 line++; 205 line++;
206 int pos = ( *line ).find( '\t' ) + 1; 206 int pos = ( *line ).find( '\t' ) + 1;
207 cardInPcmcia0Type = 207 cardInPcmcia0Type =
208 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); 208 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos );
209 } 209 }
210 } else if ( ( *line ).startsWith( "Socket 1:" ) ) { 210 } else if ( ( *line ).startsWith( "Socket 1:" ) ) {
211 if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { 211 if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) {
212 cardInPcmcia1 = FALSE; 212 cardInPcmcia1 = FALSE;
213 } else if ( !( *line ).startsWith( "Socket 1: empty" ) 213 } else if ( !( *line ).startsWith( "Socket 1: empty" )
214 && !cardInPcmcia1 ) { 214 && !cardInPcmcia1 ) {
215 cardInPcmcia1Name = 215 cardInPcmcia1Name =
216 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), 216 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ),
217 ( *line ).length() - 9 ); 217 ( *line ).length() - 9 );
218 cardInPcmcia1Name.stripWhiteSpace(); 218 cardInPcmcia1Name.stripWhiteSpace();
219 cardInPcmcia1 = TRUE; 219 cardInPcmcia1 = TRUE;
220 show(); 220 show();
221 line++; 221 line++;
222 int pos = ( *line ).find( '\t' ) + 1; 222 int pos = ( *line ).find( '\t' ) + 1;
223 cardInPcmcia1Type = 223 cardInPcmcia1Type =
224 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); 224 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos );
225 } 225 }
226 } 226 }
227 } 227 }
228 f.close(); 228 f.close();
229 229
230 if ( !showPopUp 230 if ( !showPopUp
231 && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) { 231 && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) {
232 QString text = QString::null; 232 QString text = QString::null;
233 QString what = QString::null; 233 QString what = QString::null;
234 if ( cardWas0 != cardInPcmcia0 ) { 234 if ( cardWas0 != cardInPcmcia0 ) {
235 if ( cardInPcmcia0 ) { 235 if ( cardInPcmcia0 ) {
236 text += tr( "New card: " ); 236 text += tr( "New card: " );
237 what = "on"; 237 what = "on";
238 } else { 238 } else {
239 text += tr( "Ejected: " ); 239 text += tr( "Ejected: " );
240 what = "off"; 240 what = "off";
241 } 241 }
242 text += cardInPcmcia0Name; 242 text += cardInPcmcia0Name;
243 popUp( text, "cardmon/" + cardInPcmcia0Type ); 243 popUp( text, "cardmon/" + cardInPcmcia0Type );
244 } 244 }
245 245
246 if ( cardWas1 != cardInPcmcia1 ) { 246 if ( cardWas1 != cardInPcmcia1 ) {
247 if ( cardInPcmcia1 ) { 247 if ( cardInPcmcia1 ) {
248 text += tr( "New card: " ); 248 text += tr( "New card: " );
249 what = "on"; 249 what = "on";
250 } else { 250 } else {
251 text += tr( "Ejected: " ); 251 text += tr( "Ejected: " );
252 what = "off"; 252 what = "off";
253 } 253 }
254 text += cardInPcmcia1Name; 254 text += cardInPcmcia1Name;
255 popUp( text, "cardmon/" + cardInPcmcia1Type ); 255 popUp( text, "cardmon/" + cardInPcmcia1Type );
256 } 256 }
257 #ifndef QT_NO_SOUND 257 #ifndef QT_NO_SOUND
258 QSound::play( Resource::findSound( "cardmon/card" + what ) ); 258 QSound::play( Resource::findSound( "cardmon/card" + what ) );
259 #endif 259 #endif
260 260
261 } 261 }
262 } else { 262 } else {
263 // no file found 263 // no file found
264 odebug << "no file found" << oendl; 264 odebug << "no file found" << oendl;
265 cardInPcmcia0 = FALSE; 265 cardInPcmcia0 = FALSE;
266 cardInPcmcia1 = FALSE; 266 cardInPcmcia1 = FALSE;
267 } 267 }
268 repaint( FALSE ); 268 repaint( FALSE );
269 return ( ( cardWas0 == cardInPcmcia0 269 return ( ( cardWas0 == cardInPcmcia0
270 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); 270 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE );
271 271
272} 272}
273 273
274 274
275bool CardMonitor::getStatusSd( int showPopUp ) { 275bool CardMonitor::getStatusSd( int showPopUp ) {
276 276
277 bool cardWas = cardInSd; // remember last state 277 bool cardWas = cardInSd; // remember last state
278 cardInSd = FALSE; 278 cardInSd = FALSE;
279 279
280 #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 280 #if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
281 281
282 struct mntent *me; 282 struct mntent *me;
283 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 283 FILE *mntfp = setmntent( "/etc/mtab", "r" );
284 284
285 if ( mntfp ) { 285 if ( mntfp ) {
286 while ( ( me = getmntent( mntfp ) ) != 0 ) { 286 while ( ( me = getmntent( mntfp ) ) != 0 ) {
287 QString fs = QFile::decodeName( me->mnt_fsname ); 287 QString fs = QFile::decodeName( me->mnt_fsname );
288 //odebug << fs << oendl; 288 //odebug << fs << oendl;
289 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" 289 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd"
290 || fs.left( 9 ) == "/dev/mmcd" ) { 290 || fs.left( 9 ) == "/dev/mmcd" || fs.left(11) == "/dev/mmcblk" ) {
291 cardInSd = TRUE; 291 cardInSd = TRUE;
292 cardSdName = fs; 292 cardSdName = fs;
293 show(); 293 show();
294 } 294 }
295 // else { 295 // else {
296 // cardInSd = FALSE; 296 // cardInSd = FALSE;
297 // } 297 // }
298 } 298 }
299 endmntent( mntfp ); 299 endmntent( mntfp );
300 } 300 }
301 301
302 if ( !showPopUp && cardWas != cardInSd ) { 302 if ( !showPopUp && cardWas != cardInSd ) {
303 QString text = QString::null; 303 QString text = QString::null;
304 QString what = QString::null; 304 QString what = QString::null;
305 if ( cardInSd ) { 305 if ( cardInSd ) {
306 text += tr("New card: SD/MMC"); 306 text += tr("New card: SD/MMC");
307 what = "on"; 307 what = "on";
308 } else { 308 } else {
309 text += tr("Ejected: SD/MMC"); 309 text += tr("Ejected: SD/MMC");
310 what = "off"; 310 what = "off";
311 } 311 }
312 //odebug << "TEXT: " + text << oendl; 312 //odebug << "TEXT: " + text << oendl;
313 #ifndef QT_NO_SOUND 313 #ifndef QT_NO_SOUND
314 QSound::play( Resource::findSound( "cardmon/card" + what ) ); 314 QSound::play( Resource::findSound( "cardmon/card" + what ) );
315 #endif 315 #endif
316 316
317 popUp( text, "cardmon/ide" ); // XX add SD pic 317 popUp( text, "cardmon/ide" ); // XX add SD pic
318 } 318 }
319 #else 319 #else
320 #error "Not on Linux" 320 #error "Not on Linux"
321 #endif 321 #endif
322 repaint( FALSE ); 322 repaint( FALSE );
323 return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); 323 return ( ( cardWas == cardInSd ) ? FALSE : TRUE );
324} 324}
325 325
326void CardMonitor::paintEvent( QPaintEvent * ) { 326void CardMonitor::paintEvent( QPaintEvent * ) {
327 327
328 QPainter p( this ); 328 QPainter p( this );
329 329
330 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { 330 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) {
331 p.drawPixmap( 0, 0, pm ); 331 p.drawPixmap( 0, 0, pm );
332 show(); 332 show();
333 } else { 333 } else {
334 //p.eraseRect(rect()); 334 //p.eraseRect(rect());
335 hide(); 335 hide();
336 } 336 }
337} 337}
338 338
339int CardMonitor::position() { 339int CardMonitor::position() {
340 return 7; 340 return 7;
341} 341}
342 342
343void CardMonitor::execCommand( const QStringList &strList ) { 343void CardMonitor::execCommand( const QStringList &strList ) {
344 delete m_process; 344 delete m_process;
345 m_process = 0; 345 m_process = 0;
346 346
347 if ( m_process == 0 ) { 347 if ( m_process == 0 ) {
348 m_process = new OProcess(); 348 m_process = new OProcess();
349 349
350 350
351 for ( QStringList::ConstIterator it = strList.begin(); it != strList.end(); ++it ) { 351 for ( QStringList::ConstIterator it = strList.begin(); it != strList.end(); ++it ) {
352 *m_process << *it; 352 *m_process << *it;
353 } 353 }
354 354
355 connect(m_process, SIGNAL(processExited(Opie::Core::OProcess*)), 355 connect(m_process, SIGNAL(processExited(Opie::Core::OProcess*)),
356 this, SLOT( slotExited(Opie::Core::OProcess*))); 356 this, SLOT( slotExited(Opie::Core::OProcess*)));
357 357
358 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ) { 358 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ) {
359 delete m_process; 359 delete m_process;
360 m_process = 0; 360 m_process = 0;
361 } 361 }
362 } 362 }
363} 363}
364 364
365void CardMonitor::slotExited( OProcess* ) { 365void CardMonitor::slotExited( OProcess* ) {
366 366
367 if( m_process->normalExit() ) { 367 if( m_process->normalExit() ) {
368 int ret = m_process->exitStatus(); 368 int ret = m_process->exitStatus();
369 if( ret != 0 ) { 369 if( ret != 0 ) {
370 if ( m_commandOrig == PCMCIA_Socket1 || 370 if ( m_commandOrig == PCMCIA_Socket1 ||
371 m_commandOrig == PCMCIA_Socket2 ) { 371 m_commandOrig == PCMCIA_Socket2 ) {
372 popUp( tr( "CF/PCMCIA card eject failed!" ) ); 372 popUp( tr( "CF/PCMCIA card eject failed!" ) );
373 } else if ( m_commandOrig == MMC_Socket ) { 373 } else if ( m_commandOrig == MMC_Socket ) {
374 popUp( tr( "SD/MMC card eject failed!" ) ); 374 popUp( tr( "SD/MMC card eject failed!" ) );
375 } 375 }
376 } 376 }
377 } 377 }
378} 378}
379 379
380EXPORT_OPIE_APPLET_v1( CardMonitor ) 380EXPORT_OPIE_APPLET_v1( CardMonitor )
381 381