summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index 452339c..11ce880 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -1,381 +1,382 @@
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#include "cardmon.h" 19#include "cardmon.h"
20 20
21/* OPIE */ 21/* OPIE */
22#include <opie2/odebug.h> 22#include <opie2/odebug.h>
23#include <opie2/odevice.h> 23#include <opie2/odevice.h>
24#include <opie2/otaskbarapplet.h>
25#include <opie2/oprocess.h> 24#include <opie2/oprocess.h>
25#include <opie2/oresource.h>
26#include <opie2/otaskbarapplet.h>
26 27
27#include <qpe/applnk.h> 28#include <qpe/applnk.h>
28#include <qpe/resource.h> 29#include <qpe/resource.h>
29using namespace Opie::Core; 30using namespace Opie::Core;
30using namespace Opie::Ui; 31using namespace Opie::Ui;
31 32
32/* QT */ 33/* QT */
33#include <qcopchannel_qws.h> 34#include <qcopchannel_qws.h>
34#include <qpainter.h> 35#include <qpainter.h>
35#include <qfile.h> 36#include <qfile.h>
36#include <qtextstream.h> 37#include <qtextstream.h>
37#include <qsound.h> 38#include <qsound.h>
38#include <qtimer.h> 39#include <qtimer.h>
39 40
40/* STD */ 41/* STD */
41#include <stdio.h> 42#include <stdio.h>
42#include <unistd.h> 43#include <unistd.h>
43#include <stdlib.h> 44#include <stdlib.h>
44#include <string.h> 45#include <string.h>
45#include <fcntl.h> 46#include <fcntl.h>
46#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 47#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
47#include <sys/vfs.h> 48#include <sys/vfs.h>
48#include <mntent.h> 49#include <mntent.h>
49#endif 50#endif
50 51
51CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ) 52CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent )
52{ 53{
53 pm = Resource::loadImage( "cardmon/pcmcia").smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); 54 pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon );
54 55
55 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); 56 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
56 connect( pcmciaChannel, 57 connect( pcmciaChannel,
57 SIGNAL( received(const QCString&,const QByteArray&) ), this, 58 SIGNAL( received(const QCString&,const QByteArray&) ), this,
58 SLOT( cardMessage(const QCString&,const QByteArray&) ) ); 59 SLOT( cardMessage(const QCString&,const QByteArray&) ) );
59 60
60 QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); 61 QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this );
61 connect( sdChannel, 62 connect( sdChannel,
62 SIGNAL( received(const QCString&,const QByteArray&) ), this, 63 SIGNAL( received(const QCString&,const QByteArray&) ), this,
63 SLOT( cardMessage(const QCString&,const QByteArray&) ) ); 64 SLOT( cardMessage(const QCString&,const QByteArray&) ) );
64 65
65 cardInPcmcia0 = FALSE; 66 cardInPcmcia0 = FALSE;
66 cardInPcmcia1 = FALSE; 67 cardInPcmcia1 = FALSE;
67 cardInSd = FALSE; 68 cardInSd = FALSE;
68 m_process = 0; 69 m_process = 0;
69 70
70 setFocusPolicy( NoFocus ); 71 setFocusPolicy( NoFocus );
71 72
72 setFixedWidth ( AppLnk::smallIconSize() ); 73 setFixedWidth ( AppLnk::smallIconSize() );
73 setFixedHeight ( AppLnk::smallIconSize() ); 74 setFixedHeight ( AppLnk::smallIconSize() );
74 75
75 getStatusPcmcia( TRUE ); 76 getStatusPcmcia( TRUE );
76 getStatusSd( TRUE ); 77 getStatusSd( TRUE );
77 repaint( FALSE ); 78 repaint( FALSE );
78 popupMenu = 0; 79 popupMenu = 0;
79} 80}
80 81
81CardMonitor::~CardMonitor() { 82CardMonitor::~CardMonitor() {
82 delete popupMenu; 83 delete popupMenu;
83} 84}
84 85
85void CardMonitor::popUp( QString message, QString icon ) { 86void CardMonitor::popUp( QString message, QString icon ) {
86 if ( !popupMenu ) { 87 if ( !popupMenu ) {
87 popupMenu = new QPopupMenu( this ); 88 popupMenu = new QPopupMenu( this );
88 } 89 }
89 90
90 popupMenu->clear(); 91 popupMenu->clear();
91 if ( icon.isEmpty() ) { 92 if ( icon.isEmpty() ) {
92 popupMenu->insertItem( message, 0 ); 93 popupMenu->insertItem( message, 0 );
93 } else { 94 } else {
94 popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), 95 popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ),
95 message, 0 ); 96 message, 0 );
96 } 97 }
97 98
98 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 99 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
99 QSize s = popupMenu->sizeHint(); 100 QSize s = popupMenu->sizeHint();
100 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), 101 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
101 p.y() - s.height() ), 0 ); 102 p.y() - s.height() ), 0 );
102 103
103 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); 104 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
104} 105}
105 106
106void CardMonitor::popupTimeout() { 107void CardMonitor::popupTimeout() {
107 popupMenu->hide(); 108 popupMenu->hide();
108} 109}
109 110
110void CardMonitor::mousePressEvent( QMouseEvent * ) { 111void CardMonitor::mousePressEvent( QMouseEvent * ) {
111 QPopupMenu * menu = new QPopupMenu( this ); 112 QPopupMenu * menu = new QPopupMenu( this );
112 QStringList cmd; 113 QStringList cmd;
113 bool execute = true; 114 bool execute = true;
114 115
115 if ( cardInSd ) { 116 if ( cardInSd ) {
116 menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ), 117 menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ),
117 tr( "Eject SD/MMC card" ), 0 ); 118 tr( "Eject SD/MMC card" ), 0 );
118 } 119 }
119 120
120 if ( cardInPcmcia0 ) { 121 if ( cardInPcmcia0 ) {
121 menu-> 122 menu->
122 insertItem( QIconSet 123 insertItem( QIconSet
123 ( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ), 124 ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ),
124 tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); 125 tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 );
125 } 126 }
126 127
127 if ( cardInPcmcia1 ) { 128 if ( cardInPcmcia1 ) {
128 menu-> 129 menu->
129 insertItem( QIconSet 130 insertItem( QIconSet
130 ( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ), 131 ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ),
131 tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); 132 tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 );
132 } 133 }
133 134
134 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 135 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
135 QSize s = menu->sizeHint(); 136 QSize s = menu->sizeHint();
136 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), 137 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
137 p.y() - s.height() ), 0 ); 138 p.y() - s.height() ), 0 );
138 139
139 if ( opt == 1 ) { 140 if ( opt == 1 ) {
140 m_commandOrig = PCMCIA_Socket1; 141 m_commandOrig = PCMCIA_Socket1;
141 cmd << "/sbin/cardctl" << "eject" << "0"; 142 cmd << "/sbin/cardctl" << "eject" << "0";
142 } else if ( opt == 0 ) { 143 } else if ( opt == 0 ) {
143 m_commandOrig = MMC_Socket; 144 m_commandOrig = MMC_Socket;
144 cmd << "umount" << cardSdName; 145 cmd << "umount" << cardSdName;
145 } else if ( opt == 2 ) { 146 } else if ( opt == 2 ) {
146 m_commandOrig = PCMCIA_Socket2; 147 m_commandOrig = PCMCIA_Socket2;
147 cmd << "/sbin/cardctl" << "eject" << "1"; 148 cmd << "/sbin/cardctl" << "eject" << "1";
148 }else 149 }else
149 execute = false; 150 execute = false;
150 151
151 if ( execute ) 152 if ( execute )
152 execCommand( cmd ); 153 execCommand( cmd );
153 154
154 delete menu; 155 delete menu;
155} 156}
156 157
157 158
158void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) { 159void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) {
159 if ( msg == "stabChanged()" ) { 160 if ( msg == "stabChanged()" ) {
160 // odebug << "Pcmcia: stabchanged" << oendl; 161 // odebug << "Pcmcia: stabchanged" << oendl;
161 getStatusPcmcia(); 162 getStatusPcmcia();
162 } else if ( msg == "mtabChanged()" ) { 163 } else if ( msg == "mtabChanged()" ) {
163 // odebug << "CARDMONAPPLET: mtabchanged" << oendl; 164 // odebug << "CARDMONAPPLET: mtabchanged" << oendl;
164 getStatusSd(); 165 getStatusSd();
165 } 166 }
166} 167}
167 168
168bool CardMonitor::getStatusPcmcia( int showPopUp ) { 169bool CardMonitor::getStatusPcmcia( int showPopUp ) {
169 170
170 bool cardWas0 = cardInPcmcia0; // remember last state 171 bool cardWas0 = cardInPcmcia0; // remember last state
171 bool cardWas1 = cardInPcmcia1; 172 bool cardWas1 = cardInPcmcia1;
172 173
173 QString fileName; 174 QString fileName;
174 175
175 // one of these 3 files should exist 176 // one of these 3 files should exist
176 if ( QFile::exists( "/var/run/stab" ) ) { 177 if ( QFile::exists( "/var/run/stab" ) ) {
177 fileName = "/var/run/stab"; 178 fileName = "/var/run/stab";
178 } else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { 179 } else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) {
179 fileName = "/var/state/pcmcia/stab"; 180 fileName = "/var/state/pcmcia/stab";
180 } else { 181 } else {
181 fileName = "/var/lib/pcmcia/stab"; 182 fileName = "/var/lib/pcmcia/stab";
182 } 183 }
183 184
184 QFile f( fileName ); 185 QFile f( fileName );
185 186
186 if ( f.open( IO_ReadOnly ) ) { 187 if ( f.open( IO_ReadOnly ) ) {
187 QStringList list; 188 QStringList list;
188 QTextStream stream( &f ); 189 QTextStream stream( &f );
189 QString streamIn; 190 QString streamIn;
190 streamIn = stream.read(); 191 streamIn = stream.read();
191 list = QStringList::split( "\n", streamIn ); 192 list = QStringList::split( "\n", streamIn );
192 for ( QStringList::Iterator line = list.begin(); line != list.end(); 193 for ( QStringList::Iterator line = list.begin(); line != list.end();
193 line++ ) { 194 line++ ) {
194 if ( ( *line ).startsWith( "Socket 0:" ) ) { 195 if ( ( *line ).startsWith( "Socket 0:" ) ) {
195 if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) { 196 if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) {
196 cardInPcmcia0 = FALSE; 197 cardInPcmcia0 = FALSE;
197 } else if ( !( *line ).startsWith( "Socket 0: empty" ) 198 } else if ( !( *line ).startsWith( "Socket 0: empty" )
198 && !cardInPcmcia0 ) { 199 && !cardInPcmcia0 ) {
199 cardInPcmcia0Name = 200 cardInPcmcia0Name =
200 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), 201 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ),
201 ( *line ).length() - 9 ); 202 ( *line ).length() - 9 );
202 cardInPcmcia0Name.stripWhiteSpace(); 203 cardInPcmcia0Name.stripWhiteSpace();
203 cardInPcmcia0 = TRUE; 204 cardInPcmcia0 = TRUE;
204 show(); 205 show();
205 line++; 206 line++;
206 int pos = ( *line ).find( '\t' ) + 1; 207 int pos = ( *line ).find( '\t' ) + 1;
207 cardInPcmcia0Type = 208 cardInPcmcia0Type =
208 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); 209 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos );
209 } 210 }
210 } else if ( ( *line ).startsWith( "Socket 1:" ) ) { 211 } else if ( ( *line ).startsWith( "Socket 1:" ) ) {
211 if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { 212 if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) {
212 cardInPcmcia1 = FALSE; 213 cardInPcmcia1 = FALSE;
213 } else if ( !( *line ).startsWith( "Socket 1: empty" ) 214 } else if ( !( *line ).startsWith( "Socket 1: empty" )
214 && !cardInPcmcia1 ) { 215 && !cardInPcmcia1 ) {
215 cardInPcmcia1Name = 216 cardInPcmcia1Name =
216 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), 217 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ),
217 ( *line ).length() - 9 ); 218 ( *line ).length() - 9 );
218 cardInPcmcia1Name.stripWhiteSpace(); 219 cardInPcmcia1Name.stripWhiteSpace();
219 cardInPcmcia1 = TRUE; 220 cardInPcmcia1 = TRUE;
220 show(); 221 show();
221 line++; 222 line++;
222 int pos = ( *line ).find( '\t' ) + 1; 223 int pos = ( *line ).find( '\t' ) + 1;
223 cardInPcmcia1Type = 224 cardInPcmcia1Type =
224 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); 225 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos );
225 } 226 }
226 } 227 }
227 } 228 }
228 f.close(); 229 f.close();
229 230
230 if ( !showPopUp 231 if ( !showPopUp
231 && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) { 232 && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) {
232 QString text = QString::null; 233 QString text = QString::null;
233 QString what = QString::null; 234 QString what = QString::null;
234 if ( cardWas0 != cardInPcmcia0 ) { 235 if ( cardWas0 != cardInPcmcia0 ) {
235 if ( cardInPcmcia0 ) { 236 if ( cardInPcmcia0 ) {
236 text += tr( "New card: " ); 237 text += tr( "New card: " );
237 what = "on"; 238 what = "on";
238 } else { 239 } else {
239 text += tr( "Ejected: " ); 240 text += tr( "Ejected: " );
240 what = "off"; 241 what = "off";
241 } 242 }
242 text += cardInPcmcia0Name; 243 text += cardInPcmcia0Name;
243 popUp( text, "cardmon/" + cardInPcmcia0Type ); 244 popUp( text, "cardmon/" + cardInPcmcia0Type );
244 } 245 }
245 246
246 if ( cardWas1 != cardInPcmcia1 ) { 247 if ( cardWas1 != cardInPcmcia1 ) {
247 if ( cardInPcmcia1 ) { 248 if ( cardInPcmcia1 ) {
248 text += tr( "New card: " ); 249 text += tr( "New card: " );
249 what = "on"; 250 what = "on";
250 } else { 251 } else {
251 text += tr( "Ejected: " ); 252 text += tr( "Ejected: " );
252 what = "off"; 253 what = "off";
253 } 254 }
254 text += cardInPcmcia1Name; 255 text += cardInPcmcia1Name;
255 popUp( text, "cardmon/" + cardInPcmcia1Type ); 256 popUp( text, "cardmon/" + cardInPcmcia1Type );
256 } 257 }
257 #ifndef QT_NO_SOUND 258 #ifndef QT_NO_SOUND
258 QSound::play( Resource::findSound( "cardmon/card" + what ) ); 259 QSound::play( Resource::findSound( "cardmon/card" + what ) );
259 #endif 260 #endif
260 261
261 } 262 }
262 } else { 263 } else {
263 // no file found 264 // no file found
264 odebug << "no file found" << oendl; 265 odebug << "no file found" << oendl;
265 cardInPcmcia0 = FALSE; 266 cardInPcmcia0 = FALSE;
266 cardInPcmcia1 = FALSE; 267 cardInPcmcia1 = FALSE;
267 } 268 }
268 repaint( FALSE ); 269 repaint( FALSE );
269 return ( ( cardWas0 == cardInPcmcia0 270 return ( ( cardWas0 == cardInPcmcia0
270 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); 271 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE );
271 272
272} 273}
273 274
274 275
275bool CardMonitor::getStatusSd( int showPopUp ) { 276bool CardMonitor::getStatusSd( int showPopUp ) {
276 277
277 bool cardWas = cardInSd; // remember last state 278 bool cardWas = cardInSd; // remember last state
278 cardInSd = FALSE; 279 cardInSd = FALSE;
279 280
280 #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 281 #if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
281 282
282 struct mntent *me; 283 struct mntent *me;
283 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 284 FILE *mntfp = setmntent( "/etc/mtab", "r" );
284 285
285 if ( mntfp ) { 286 if ( mntfp ) {
286 while ( ( me = getmntent( mntfp ) ) != 0 ) { 287 while ( ( me = getmntent( mntfp ) ) != 0 ) {
287 QString fs = QFile::decodeName( me->mnt_fsname ); 288 QString fs = QFile::decodeName( me->mnt_fsname );
288 //odebug << fs << oendl; 289 //odebug << fs << oendl;
289 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" 290 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd"
290 || fs.left( 9 ) == "/dev/mmcd" || fs.left(11) == "/dev/mmcblk" ) { 291 || fs.left( 9 ) == "/dev/mmcd" || fs.left(11) == "/dev/mmcblk" ) {
291 cardInSd = TRUE; 292 cardInSd = TRUE;
292 cardSdName = fs; 293 cardSdName = fs;
293 show(); 294 show();
294 } 295 }
295 // else { 296 // else {
296 // cardInSd = FALSE; 297 // cardInSd = FALSE;
297 // } 298 // }
298 } 299 }
299 endmntent( mntfp ); 300 endmntent( mntfp );
300 } 301 }
301 302
302 if ( !showPopUp && cardWas != cardInSd ) { 303 if ( !showPopUp && cardWas != cardInSd ) {
303 QString text = QString::null; 304 QString text = QString::null;
304 QString what = QString::null; 305 QString what = QString::null;
305 if ( cardInSd ) { 306 if ( cardInSd ) {
306 text += tr("New card: SD/MMC"); 307 text += tr("New card: SD/MMC");
307 what = "on"; 308 what = "on";
308 } else { 309 } else {
309 text += tr("Ejected: SD/MMC"); 310 text += tr("Ejected: SD/MMC");
310 what = "off"; 311 what = "off";
311 } 312 }
312 //odebug << "TEXT: " + text << oendl; 313 //odebug << "TEXT: " + text << oendl;
313 #ifndef QT_NO_SOUND 314 #ifndef QT_NO_SOUND
314 QSound::play( Resource::findSound( "cardmon/card" + what ) ); 315 QSound::play( Resource::findSound( "cardmon/card" + what ) );
315 #endif 316 #endif
316 317
317 popUp( text, "cardmon/ide" ); // XX add SD pic 318 popUp( text, "cardmon/ide" ); // XX add SD pic
318 } 319 }
319 #else 320 #else
320 #error "Not on Linux" 321 #error "Not on Linux"
321 #endif 322 #endif
322 repaint( FALSE ); 323 repaint( FALSE );
323 return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); 324 return ( ( cardWas == cardInSd ) ? FALSE : TRUE );
324} 325}
325 326
326void CardMonitor::paintEvent( QPaintEvent * ) { 327void CardMonitor::paintEvent( QPaintEvent * ) {
327 328
328 QPainter p( this ); 329 QPainter p( this );
329 330
330 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { 331 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) {
331 p.drawPixmap( 0, 0, pm ); 332 p.drawPixmap( 0, 0, pm );
332 show(); 333 show();
333 } else { 334 } else {
334 //p.eraseRect(rect()); 335 //p.eraseRect(rect());
335 hide(); 336 hide();
336 } 337 }
337} 338}
338 339
339int CardMonitor::position() { 340int CardMonitor::position() {
340 return 7; 341 return 7;
341} 342}
342 343
343void CardMonitor::execCommand( const QStringList &strList ) { 344void CardMonitor::execCommand( const QStringList &strList ) {
344 delete m_process; 345 delete m_process;
345 m_process = 0; 346 m_process = 0;
346 347
347 if ( m_process == 0 ) { 348 if ( m_process == 0 ) {
348 m_process = new OProcess(); 349 m_process = new OProcess();
349 350
350 351
351 for ( QStringList::ConstIterator it = strList.begin(); it != strList.end(); ++it ) { 352 for ( QStringList::ConstIterator it = strList.begin(); it != strList.end(); ++it ) {
352 *m_process << *it; 353 *m_process << *it;
353 } 354 }
354 355
355 connect(m_process, SIGNAL(processExited(Opie::Core::OProcess*)), 356 connect(m_process, SIGNAL(processExited(Opie::Core::OProcess*)),
356 this, SLOT( slotExited(Opie::Core::OProcess*))); 357 this, SLOT( slotExited(Opie::Core::OProcess*)));
357 358
358 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ) { 359 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ) {
359 delete m_process; 360 delete m_process;
360 m_process = 0; 361 m_process = 0;
361 } 362 }
362 } 363 }
363} 364}
364 365
365void CardMonitor::slotExited( OProcess* ) { 366void CardMonitor::slotExited( OProcess* ) {
366 367
367 if( m_process->normalExit() ) { 368 if( m_process->normalExit() ) {
368 int ret = m_process->exitStatus(); 369 int ret = m_process->exitStatus();
369 if( ret != 0 ) { 370 if( ret != 0 ) {
370 if ( m_commandOrig == PCMCIA_Socket1 || 371 if ( m_commandOrig == PCMCIA_Socket1 ||
371 m_commandOrig == PCMCIA_Socket2 ) { 372 m_commandOrig == PCMCIA_Socket2 ) {
372 popUp( tr( "CF/PCMCIA card eject failed!" ) ); 373 popUp( tr( "CF/PCMCIA card eject failed!" ) );
373 } else if ( m_commandOrig == MMC_Socket ) { 374 } else if ( m_commandOrig == MMC_Socket ) {
374 popUp( tr( "SD/MMC card eject failed!" ) ); 375 popUp( tr( "SD/MMC card eject failed!" ) );
375 } 376 }
376 } 377 }
377 } 378 }
378} 379}
379 380
380EXPORT_OPIE_APPLET_v1( CardMonitor ) 381EXPORT_OPIE_APPLET_v1( CardMonitor )
381 382