summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp520
-rw-r--r--core/applets/cardmon/cardmon.h2
-rw-r--r--core/applets/cardmon/cardmon.pro6
-rw-r--r--core/applets/cardmon/cardmonimpl.cpp42
-rw-r--r--core/applets/cardmon/cardmonimpl.h18
5 files changed, 300 insertions, 288 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index 4ed09b8..8ffaada 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -1,353 +1,425 @@
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
20#include "cardmon.h" 19#include "cardmon.h"
21 20
22#include <qpe/resource.h> 21/* OPIE */
23 22#include <opie2/odevice.h>
24#include <opie/odevice.h> 23#include <opie2/otaskbarapplet.h>
25
26#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/resource.h>
27 26
27/* QT */
28#include <qapplication.h>
28#include <qcopchannel_qws.h> 29#include <qcopchannel_qws.h>
29#include <qpainter.h> 30#include <qpainter.h>
30#include <qmessagebox.h> 31#include <qmessagebox.h>
31#include <qfile.h> 32#include <qfile.h>
32#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qsound.h>
33#include <qtimer.h> 35#include <qtimer.h>
34#include <qapplication.h>
35 36
37/* STD */
36#include <stdio.h> 38#include <stdio.h>
37#include <unistd.h> 39#include <unistd.h>
38#include <stdlib.h> 40#include <stdlib.h>
39#include <string.h> 41#include <string.h>
40#include <fcntl.h> 42#include <fcntl.h>
41#include <qsound.h>
42 43
43#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 44#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
44#include <sys/vfs.h> 45#include <sys/vfs.h>
45#include <mntent.h> 46#include <mntent.h>
46#endif 47#endif
47 48
48using namespace Opie; 49using namespace Opie;
49 50
50CardMonitor::CardMonitor(QWidget * parent):QWidget(parent), 51CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ),
51 pm( Resource::loadPixmap("cardmon/pcmcia") ) 52 pm( Resource::loadPixmap( "cardmon/pcmcia" ) )
52{ 53{
53 54
54 QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this); 55 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
55 connect(pcmciaChannel, 56 connect( pcmciaChannel,
56 SIGNAL(received(const QCString &, const QByteArray &)), this, 57 SIGNAL( received( const QCString &, const QByteArray & ) ), this,
57 SLOT(cardMessage(const QCString &, const QByteArray &))); 58 SLOT( cardMessage( const QCString &, const QByteArray & ) ) );
58 59
59 QCopChannel *sdChannel = new QCopChannel("QPE/Card", this); 60 QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this );
60 connect(sdChannel, 61 connect( sdChannel,
61 SIGNAL(received(const QCString &, const QByteArray &)), this, 62 SIGNAL( received( const QCString &, const QByteArray & ) ), this,
62 SLOT(cardMessage(const QCString &, const QByteArray &))); 63 SLOT( cardMessage( const QCString &, const QByteArray & ) ) );
63 64
64 cardInPcmcia0 = FALSE; 65 cardInPcmcia0 = FALSE;
65 cardInPcmcia1 = FALSE; 66 cardInPcmcia1 = FALSE;
66 cardInSd = FALSE; 67 cardInSd = FALSE;
67 68
68 setFocusPolicy( NoFocus ); 69 setFocusPolicy( NoFocus );
69 70
70 setFixedWidth ( AppLnk::smallIconSize() ); 71 setFixedWidth ( AppLnk::smallIconSize() );
71 setFixedHeight ( AppLnk::smallIconSize() ); 72 setFixedHeight ( AppLnk::smallIconSize() );
72 73
73 getStatusPcmcia(TRUE); 74 getStatusPcmcia( TRUE );
74 getStatusSd(TRUE); 75 getStatusSd( TRUE );
75 repaint(FALSE); 76 repaint( FALSE );
76 popupMenu = 0; 77 popupMenu = 0;
77} 78}
78 79
79CardMonitor::~CardMonitor() 80CardMonitor::~CardMonitor()
80{ 81{
81 if (popupMenu) { 82 if ( popupMenu )
82 delete popupMenu; 83 {
84 delete popupMenu;
83 } 85 }
84} 86}
85 87
86void CardMonitor::popUp(QString message, QString icon) 88void CardMonitor::popUp( QString message, QString icon )
87{ 89{
88 if (!popupMenu) { 90 if ( !popupMenu )
89 popupMenu = new QPopupMenu(this); 91 {
92 popupMenu = new QPopupMenu( this );
90 } 93 }
91 94
92 popupMenu->clear(); 95 popupMenu->clear();
93 if (icon.isEmpty()) { 96 if ( icon.isEmpty() )
94 popupMenu->insertItem(message, 0); 97 {
95 } else { 98 popupMenu->insertItem( message, 0 );
96 popupMenu->insertItem(QIconSet(Resource::loadPixmap(icon)), 99 }
97 message, 0); 100 else
101 {
102 popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ),
103 message, 0 );
98 } 104 }
99 105
100 QPoint p = mapToGlobal(QPoint(0, 0)); 106 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
101 QSize s = popupMenu->sizeHint(); 107 QSize s = popupMenu->sizeHint();
102 popupMenu->popup(QPoint(p.x() + (width() / 2) - (s.width() / 2), 108 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
103 p.y() - s.height()), 0); 109 p.y() - s.height() ), 0 );
104 110
105 QTimer::singleShot(2000, this, SLOT(popupTimeout())); 111 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
106} 112}
107 113
108void CardMonitor::popupTimeout() 114void CardMonitor::popupTimeout()
109{ 115{
110 popupMenu->hide(); 116 popupMenu->hide();
111} 117}
112 118
113void CardMonitor::mousePressEvent(QMouseEvent *) 119void CardMonitor::mousePressEvent( QMouseEvent * )
114{ 120{
115 QPopupMenu *menu = new QPopupMenu(this); 121 QPopupMenu * menu = new QPopupMenu( this );
116 QString cmd; 122 QString cmd;
117 int err = 0; 123 int err = 0;
118 124
119 if (cardInSd) { 125 if ( cardInSd )
120 menu->insertItem(QIconSet(Resource::loadPixmap("cardmon/ide")), 126 {
121 tr("Eject SD/MMC card"), 0); 127 menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ),
128 tr( "Eject SD/MMC card" ), 0 );
122 } 129 }
123 130
124 if (cardInPcmcia0) { 131 if ( cardInPcmcia0 )
125 menu-> 132 {
126 insertItem(QIconSet 133 menu->
127 (Resource::loadPixmap("cardmon/" + cardInPcmcia0Type)), 134 insertItem( QIconSet
128 tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1); 135 ( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ),
136 tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 );
129 } 137 }
130 138
131 if (cardInPcmcia1) { 139 if ( cardInPcmcia1 )
132 menu-> 140 {
133 insertItem(QIconSet 141 menu->
134 (Resource::loadPixmap("cardmon/" + cardInPcmcia1Type)), 142 insertItem( QIconSet
135 tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2); 143 ( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ),
144 tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 );
136 } 145 }
137 146
138 QPoint p = mapToGlobal(QPoint(0, 0)); 147 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
139 QSize s = menu->sizeHint(); 148 QSize s = menu->sizeHint();
140 int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), 149 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
141 p.y() - s.height()), 0); 150 p.y() - s.height() ), 0 );
142 151
143 if (opt == 1) { 152 if ( opt == 1 )
144 cmd = "/sbin/cardctl eject 0"; 153 {
145 err = system((const char *) cmd); 154 cmd = "/sbin/cardctl eject 0";
146 if (err != 0) { 155 err = system( ( const char * ) cmd );
147 qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", 156 if ( err != 0 )
148 err); 157 {
149 popUp(tr("CF/PCMCIA card eject failed!")); 158 qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d",
150 } 159 err );
151 } else if (opt == 0) { 160 popUp( tr( "CF/PCMCIA card eject failed!" ) );
152 if (ODevice::inst()->system() == System_Familiar) { 161 }
153 cmd = "umount /dev/mmc/part1"; 162 }
154 } else { 163 else if ( opt == 0 )
155 cmd = "umount /dev/mmcda1"; 164 {
156 } 165 if ( ODevice::inst() ->system() == System_Familiar )
157 err = system((const char *) cmd); 166 {
158 if (err != 0) { 167 cmd = "umount /dev/mmc/part1";
159 popUp(tr("SD/MMC card eject failed!")); 168 }
160 } 169 else
161 } else if (opt == 2) { 170 {
162 cmd = "/sbin/cardctl eject 1"; 171 cmd = "umount /dev/mmcda1";
163 err = system((const char *) cmd); 172 }
164 if (err != 0) { 173 err = system( ( const char * ) cmd );
165 qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", 174 if ( err != 0 )
166 err); 175 {
167 popUp(tr("CF/PCMCIA card eject failed!")); 176 popUp( tr( "SD/MMC card eject failed!" ) );
168 } 177 }
178 }
179 else if ( opt == 2 )
180 {
181 cmd = "/sbin/cardctl eject 1";
182 err = system( ( const char * ) cmd );
183 if ( err != 0 )
184 {
185 qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d",
186 err );
187 popUp( tr( "CF/PCMCIA card eject failed!" ) );
188 }
169 } 189 }
170 delete menu; 190 delete menu;
171} 191}
172 192
173 193
174void CardMonitor::cardMessage(const QCString & msg, const QByteArray &) 194void CardMonitor::cardMessage( const QCString & msg, const QByteArray & )
175{ 195{
176 if (msg == "stabChanged()") { 196 if ( msg == "stabChanged()" )
177 // qDebug("Pcmcia: stabchanged"); 197 {
178 getStatusPcmcia(); 198 // qDebug("Pcmcia: stabchanged");
179 } else if (msg == "mtabChanged()") { 199 getStatusPcmcia();
180 // qDebug("CARDMONAPPLET: mtabchanged"); 200 }
181 getStatusSd(); 201 else if ( msg == "mtabChanged()" )
202 {
203 // qDebug("CARDMONAPPLET: mtabchanged");
204 getStatusSd();
182 } 205 }
183} 206}
184 207
185bool CardMonitor::getStatusPcmcia(int showPopUp) 208bool CardMonitor::getStatusPcmcia( int showPopUp )
186{ 209{
187 210
188 bool cardWas0 = cardInPcmcia0;// remember last state 211 bool cardWas0 = cardInPcmcia0;// remember last state
189 bool cardWas1 = cardInPcmcia1; 212 bool cardWas1 = cardInPcmcia1;
190 213
191 QString fileName; 214 QString fileName;
192 215
193 // one of these 3 files should exist 216 // one of these 3 files should exist
194 if (QFile::exists("/var/run/stab")) { 217 if ( QFile::exists( "/var/run/stab" ) )
195 fileName = "/var/run/stab"; 218 {
196 } else if (QFile::exists("/var/state/pcmcia/stab")) { 219 fileName = "/var/run/stab";
197 fileName = "/var/state/pcmcia/stab"; 220 }
198 } else { 221 else if ( QFile::exists( "/var/state/pcmcia/stab" ) )
199 fileName = "/var/lib/pcmcia/stab"; 222 {
223 fileName = "/var/state/pcmcia/stab";
224 }
225 else
226 {
227 fileName = "/var/lib/pcmcia/stab";
200 } 228 }
201 229
202 QFile f(fileName); 230 QFile f( fileName );
203 231
204 if (f.open(IO_ReadOnly)) { 232 if ( f.open( IO_ReadOnly ) )
205 QStringList list; 233 {
206 QTextStream stream(&f); 234 QStringList list;
207 QString streamIn; 235 QTextStream stream( &f );
208 streamIn = stream.read(); 236 QString streamIn;
209 list = QStringList::split("\n", streamIn); 237 streamIn = stream.read();
210 for (QStringList::Iterator line = list.begin(); line != list.end(); 238 list = QStringList::split( "\n", streamIn );
211 line++) { 239 for ( QStringList::Iterator line = list.begin(); line != list.end();
212 if ((*line).startsWith("Socket 0:")) { 240 line++ )
213 if ((*line).startsWith("Socket 0: empty") && cardInPcmcia0) { 241 {
214 cardInPcmcia0 = FALSE; 242 if ( ( *line ).startsWith( "Socket 0:" ) )
215 } else if (!(*line).startsWith("Socket 0: empty") 243 {
216 && !cardInPcmcia0) { 244 if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 )
217 cardInPcmcia0Name = 245 {
218 (*line).mid(((*line).find(':') + 1), 246 cardInPcmcia0 = FALSE;
219 (*line).length() - 9); 247 }
220 cardInPcmcia0Name.stripWhiteSpace(); 248 else if ( !( *line ).startsWith( "Socket 0: empty" )
221 cardInPcmcia0 = TRUE; 249 && !cardInPcmcia0 )
222 show(); 250 {
223 line++; 251 cardInPcmcia0Name =
224 int pos = (*line).find('\t') + 1; 252 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ),
225 cardInPcmcia0Type = 253 ( *line ).length() - 9 );
226 (*line).mid(pos, (*line).find("\t", pos) - pos); 254 cardInPcmcia0Name.stripWhiteSpace();
227 } 255 cardInPcmcia0 = TRUE;
228 } else if ((*line).startsWith("Socket 1:")) { 256 show();
229 if ((*line).startsWith("Socket 1: empty") && cardInPcmcia1) { 257 line++;
230 cardInPcmcia1 = FALSE; 258 int pos = ( *line ).find( '\t' ) + 1;
231 } else if (!(*line).startsWith("Socket 1: empty") 259 cardInPcmcia0Type =
232 && !cardInPcmcia1) { 260 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos );
233 cardInPcmcia1Name = 261 }
234 (*line).mid(((*line).find(':') + 1), 262 }
235 (*line).length() - 9); 263 else if ( ( *line ).startsWith( "Socket 1:" ) )
236 cardInPcmcia1Name.stripWhiteSpace(); 264 {
237 cardInPcmcia1 = TRUE; 265 if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 )
238 show(); 266 {
239 line++; 267 cardInPcmcia1 = FALSE;
240 int pos = (*line).find('\t') + 1; 268 }
241 cardInPcmcia1Type = 269 else if ( !( *line ).startsWith( "Socket 1: empty" )
242 (*line).mid(pos, (*line).find("\t", pos) - pos); 270 && !cardInPcmcia1 )
243 } 271 {
244 } 272 cardInPcmcia1Name =
245 } 273 ( *line ).mid( ( ( *line ).find( ':' ) + 1 ),
246 f.close(); 274 ( *line ).length() - 9 );
247 275 cardInPcmcia1Name.stripWhiteSpace();
248 if (!showPopUp 276 cardInPcmcia1 = TRUE;
249 && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { 277 show();
250 QString text = QString::null; 278 line++;
251 QString what = QString::null; 279 int pos = ( *line ).find( '\t' ) + 1;
252 if (cardWas0 != cardInPcmcia0) { 280 cardInPcmcia1Type =
253 if (cardInPcmcia0) { 281 ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos );
254 text += tr("New card: "); 282 }
255 what = "on"; 283 }
256 } else { 284 }
257 text += tr("Ejected: "); 285 f.close();
258 what = "off"; 286
259 } 287 if ( !showPopUp
260 text += cardInPcmcia0Name; 288 && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) )
261 popUp(text, "cardmon/" + cardInPcmcia0Type); 289 {
262 } 290 QString text = QString::null;
263 291 QString what = QString::null;
264 if (cardWas1 != cardInPcmcia1) { 292 if ( cardWas0 != cardInPcmcia0 )
265 if (cardInPcmcia1) { 293 {
266 text += tr("New card: "); 294 if ( cardInPcmcia0 )
267 what = "on"; 295 {
268 } else { 296 text += tr( "New card: " );
269 text += tr("Ejected: "); 297 what = "on";
270 what = "off"; 298 }
271 } 299 else
272 text += cardInPcmcia1Name; 300 {
273 popUp(text, "cardmon/" + cardInPcmcia1Type); 301 text += tr( "Ejected: " );
274 } 302 what = "off";
303 }
304 text += cardInPcmcia0Name;
305 popUp( text, "cardmon/" + cardInPcmcia0Type );
306 }
307
308 if ( cardWas1 != cardInPcmcia1 )
309 {
310 if ( cardInPcmcia1 )
311 {
312 text += tr( "New card: " );
313 what = "on";
314 }
315 else
316 {
317 text += tr( "Ejected: " );
318 what = "off";
319 }
320 text += cardInPcmcia1Name;
321 popUp( text, "cardmon/" + cardInPcmcia1Type );
322 }
275#ifndef QT_NO_SOUND 323#ifndef QT_NO_SOUND
276 QSound::play(Resource::findSound("cardmon/card" + what)); 324 QSound::play( Resource::findSound( "cardmon/card" + what ) );
277#endif 325#endif
278 } 326
279 } else { 327 }
280 // no file found 328 }
281 qDebug("no file found"); 329 else
282 cardInPcmcia0 = FALSE; 330 {
283 cardInPcmcia1 = FALSE; 331 // no file found
332 qDebug( "no file found" );
333 cardInPcmcia0 = FALSE;
334 cardInPcmcia1 = FALSE;
284 } 335 }
285 repaint( FALSE ); 336 repaint( FALSE );
286 return ((cardWas0 == cardInPcmcia0 337 return ( ( cardWas0 == cardInPcmcia0
287 && cardWas1 == cardInPcmcia1) ? FALSE : TRUE); 338 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE );
288 339
289} 340}
290 341
291 342
292bool CardMonitor::getStatusSd(int showPopUp) 343bool CardMonitor::getStatusSd( int showPopUp )
293{ 344{
294 345
295 bool cardWas = cardInSd;// remember last state 346 bool cardWas = cardInSd;// remember last state
296 cardInSd = FALSE; 347 cardInSd = FALSE;
297 348
298#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 349#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
299 struct mntent *me; 350 struct mntent *me;
300 FILE *mntfp = setmntent("/etc/mtab", "r"); 351 FILE *mntfp = setmntent( "/etc/mtab", "r" );
301 352
302 if (mntfp) { 353 if ( mntfp )
303 while ((me = getmntent(mntfp)) != 0) { 354 {
304 QString fs = me->mnt_fsname; 355 while ( ( me = getmntent( mntfp ) ) != 0 )
305 //qDebug( fs ); 356 {
306 if (fs.left(14) == "/dev/mmc/part1" || fs.left(7) == "/dev/sd" 357 QString fs = me->mnt_fsname;
307 || fs.left(9) == "/dev/mmcd") { 358 //qDebug( fs );
308 cardInSd = TRUE; 359 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd"
309 show(); 360 || fs.left( 9 ) == "/dev/mmcd" )
310 } 361 {
311// else { 362 cardInSd = TRUE;
312// cardInSd = FALSE; 363 show();
313// } 364 }
314 } 365 // else {
315 endmntent(mntfp); 366 // cardInSd = FALSE;
367 // }
368 }
369 endmntent( mntfp );
316 } 370 }
317 371
318 if (!showPopUp && cardWas != cardInSd) { 372 if ( !showPopUp && cardWas != cardInSd )
319 QString text = QString::null; 373 {
320 QString what = QString::null; 374 QString text = QString::null;
321 if (cardInSd) { 375 QString what = QString::null;
322 text += "New card: SD/MMC"; 376 if ( cardInSd )
323 what = "on"; 377 {
324 } else { 378 text += "New card: SD/MMC";
325 text += "Ejected: SD/MMC"; 379 what = "on";
326 what = "off"; 380 }
327 } 381 else
328 //qDebug("TEXT: " + text ); 382 {
383 text += "Ejected: SD/MMC";
384 what = "off";
385 }
386 //qDebug("TEXT: " + text );
329#ifndef QT_NO_SOUND 387#ifndef QT_NO_SOUND
330 QSound::play(Resource::findSound("cardmon/card" + what)); 388 QSound::play( Resource::findSound( "cardmon/card" + what ) );
331#endif 389#endif
332 popUp(text, "cardmon/ide");// XX add SD pic 390 popUp( text, "cardmon/ide" );// XX add SD pic
333 } 391 }
334#else 392#else
335#error "Not on Linux" 393#error "Not on Linux"
336#endif 394#endif
337 repaint( FALSE ); 395 repaint( FALSE );
338 return ((cardWas == cardInSd) ? FALSE : TRUE); 396 return ( ( cardWas == cardInSd ) ? FALSE : TRUE );
339} 397}
340 398
341void CardMonitor::paintEvent(QPaintEvent *) 399void CardMonitor::paintEvent( QPaintEvent * )
342{ 400{
343 401
344 QPainter p(this); 402 QPainter p( this );
345 403
346 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { 404 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd )
347 p.drawPixmap(0, 0, pm ); 405 {
348 show(); 406 p.drawPixmap( 0, 0, pm );
349 } else { 407 show();
350 //p.eraseRect(rect()); 408 }
351 hide(); 409 else
410 {
411 //p.eraseRect(rect());
412 hide();
352 } 413 }
353} 414}
415
416int CardMonitor::position()
417{
418 return 7;
419}
420
421Q_EXPORT_INTERFACE()
422{
423 Q_CREATE_INSTANCE( OTaskbarAppletWrapper<CardMonitor> );
424}
425
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h
index 4f00920..37de366 100644
--- a/core/applets/cardmon/cardmon.h
+++ b/core/applets/cardmon/cardmon.h
@@ -1,58 +1,58 @@
1/* 1/*
2 * cardmon.h 2 * cardmon.h
3 * 3 *
4 * --------------------- 4 * ---------------------
5 * 5 *
6 * copyright : (c) 2003 by Maximilian Reiss 6 * copyright : (c) 2003 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#ifndef CARDMON_H 19#ifndef CARDMON_H
20#define CARDMON_H 20#define CARDMON_H
21 21
22#include <qwidget.h> 22#include <qwidget.h>
23#include <qpixmap.h> 23#include <qpixmap.h>
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25 25
26class CardMonitor : public QWidget { 26class CardMonitor : public QWidget {
27 Q_OBJECT 27 Q_OBJECT
28public: 28public:
29 CardMonitor( QWidget *parent = 0 ); 29 CardMonitor( QWidget *parent = 0 );
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 static int position();
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 = QString::null ); 54 void popUp(QString message, QString icon = QString::null );
55 }; 55 };
56 56
57#endif 57#endif
58 58
diff --git a/core/applets/cardmon/cardmon.pro b/core/applets/cardmon/cardmon.pro
index 1e8f86f..7c0c739 100644
--- a/core/applets/cardmon/cardmon.pro
+++ b/core/applets/cardmon/cardmon.pro
@@ -1,13 +1,13 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt plugin warn_on release 2 CONFIG += qt plugin warn_on release
3 HEADERS =cardmon.h cardmonimpl.h 3 HEADERS =cardmon.h
4 SOURCES =cardmon.cpp cardmonimpl.cpp 4 SOURCES =cardmon.cpp
5 TARGET = cardmonapplet 5 TARGET = cardmonapplet
6 DESTDIR = $(OPIEDIR)/plugins/applets 6 DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include ../launcher 8DEPENDPATH += $(OPIEDIR)/include ../launcher
9LIBS += -lqpe -lopie 9LIBS += -lqpe -lopiecore2
10 VERSION = 1.0.0 10 VERSION = 1.0.0
11 11
12include ( $(OPIEDIR)/include.pro ) 12include ( $(OPIEDIR)/include.pro )
13target.path = $$prefix/plugins/applets 13target.path = $$prefix/plugins/applets
diff --git a/core/applets/cardmon/cardmonimpl.cpp b/core/applets/cardmon/cardmonimpl.cpp
deleted file mode 100644
index 7b144d4..0000000
--- a/core/applets/cardmon/cardmonimpl.cpp
+++ b/dev/null
@@ -1,42 +0,0 @@
1#include "cardmon.h"
2#include "cardmonimpl.h"
3
4
5CardMonitorImpl::CardMonitorImpl()
6 : cardMonitor(0) {
7}
8
9CardMonitorImpl::~CardMonitorImpl() {
10 delete cardMonitor;
11}
12
13QWidget *CardMonitorImpl::applet( QWidget *parent ) {
14 if ( !cardMonitor ) {
15 cardMonitor = new CardMonitor( parent );
16 }
17 return cardMonitor;
18}
19
20int CardMonitorImpl::position() const {
21 return 7;
22}
23
24QRESULT CardMonitorImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
25 *iface = 0;
26 if ( uuid == IID_QUnknown ) {
27 *iface = this;
28 } else if ( uuid == IID_TaskbarApplet ) {
29 *iface = this;
30 } else {
31 return QS_FALSE;
32 }
33
34 if ( *iface ) {
35 (*iface)->addRef();
36 }
37 return QS_OK;
38}
39
40Q_EXPORT_INTERFACE() {
41 Q_CREATE_INSTANCE( CardMonitorImpl )
42}
diff --git a/core/applets/cardmon/cardmonimpl.h b/core/applets/cardmon/cardmonimpl.h
deleted file mode 100644
index 26b7fe5..0000000
--- a/core/applets/cardmon/cardmonimpl.h
+++ b/dev/null
@@ -1,18 +0,0 @@
1#include <qpe/taskbarappletinterface.h>
2
3class CardMonitor;
4
5class CardMonitorImpl : public TaskbarAppletInterface {
6public:
7 CardMonitorImpl();
8 virtual ~CardMonitorImpl();
9
10 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
11 Q_REFCOUNT
12
13 virtual QWidget *applet( QWidget *parent );
14 virtual int position() const;
15
16private:
17 CardMonitor *cardMonitor;
18};