-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 80 | ||||
-rw-r--r-- | core/applets/cardmon/cardmon.h | 11 | ||||
-rw-r--r-- | core/applets/cardmon/opie-cardmon.control | 2 |
3 files changed, 51 insertions, 42 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 93bc97a..de02fe6 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,281 +1,289 @@ | |||
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 <qcopchannel_qws.h> | 24 | #include <qcopchannel_qws.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | 30 | ||
31 | #include <stdio.h> | 31 | #include <stdio.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <string.h> | 34 | #include <string.h> |
35 | #include <fcntl.h> | 35 | #include <fcntl.h> |
36 | 36 | ||
37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
38 | #include <sys/vfs.h> | 38 | #include <sys/vfs.h> |
39 | #include <mntent.h> | 39 | #include <mntent.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), | 42 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), |
43 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { | 43 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { |
44 | 44 | ||
45 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 45 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
46 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 46 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
47 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 47 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
48 | 48 | ||
49 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); | 49 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); |
50 | connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 50 | connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
51 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 51 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
52 | 52 | ||
53 | cardInPcmcia0 = FALSE; | ||
54 | cardInPcmcia1 = FALSE; | ||
55 | |||
53 | setFixedSize( pm.size() ); | 56 | setFixedSize( pm.size() ); |
54 | getStatusPcmcia(TRUE); | 57 | getStatusPcmcia(TRUE); |
55 | getStatusSd(TRUE); | 58 | getStatusSd(TRUE); |
56 | repaint(FALSE); | 59 | repaint(FALSE); |
57 | popUpMenu = 0; | 60 | popupMenu = 0; |
58 | popUpMenuTimer = 0; | ||
59 | } | 61 | } |
60 | 62 | ||
61 | CardMonitor::~CardMonitor() { | 63 | CardMonitor::~CardMonitor() { |
64 | if( popupMenu ) { delete popupMenu; } | ||
62 | } | 65 | } |
63 | 66 | ||
64 | void CardMonitor::popUp(QString message) { | 67 | void CardMonitor::popup(QString message, QString icon="") { |
65 | if ( ! popUpMenu ) { | 68 | if ( ! popupMenu ) { |
66 | popUpMenu = new QPopupMenu(); | 69 | popupMenu = new QPopupMenu(); |
70 | } | ||
71 | popupMenu->clear(); | ||
72 | if( icon == "" ) { | ||
73 | popupMenu->insertItem( message, 0 ); | ||
74 | } else { | ||
75 | popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )), | ||
76 | message, 0 ); | ||
67 | } | 77 | } |
68 | popUpMenu->clear(); | ||
69 | popUpMenu->insertItem( message, 0 ); | ||
70 | 78 | ||
71 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 79 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
72 | QSize s = popUpMenu->sizeHint ( ); | 80 | QSize s = popupMenu->sizeHint ( ); |
73 | popUpMenu->popup( QPoint ( | 81 | popupMenu->popup( QPoint ( |
74 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 82 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
75 | p. y ( ) - s. height ( ) ), 0); | 83 | p. y ( ) - s. height ( ) ), 0); |
76 | 84 | ||
77 | if ( ! popUpMenuTimer ) { | 85 | QTimer::singleShot( 2000, this, SLOT(popupMenuTimeout()) ); |
78 | popUpMenuTimer = new QTimer( this ); | ||
79 | connect( popUpMenuTimer, SIGNAL(timeout()), this, SLOT(popUpTimeout()) ); | ||
80 | } | ||
81 | timerEvent(0); | ||
82 | popUpMenuTimer->start( 2000 ); | ||
83 | } | ||
84 | |||
85 | void CardMonitor::popUpTimeout() { | ||
86 | popUpMenu->hide(); | ||
87 | popUpMenuTimer->stop(); | ||
88 | } | 86 | } |
89 | 87 | ||
90 | void CardMonitor::mousePressEvent( QMouseEvent * ) { | 88 | void CardMonitor::mousePressEvent( QMouseEvent * ) { |
91 | QPopupMenu *menu = new QPopupMenu(); | 89 | QPopupMenu *menu = new QPopupMenu(); |
92 | QString cmd; | 90 | QString cmd; |
93 | int err=0; | 91 | int err=0; |
94 | 92 | ||
95 | if ( cardInSd ) { | 93 | if ( cardInSd ) { |
96 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); | 94 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); |
97 | } | 95 | } |
98 | 96 | ||
99 | if ( cardInPcmcia0 ) { | 97 | if ( cardInPcmcia0 ) { |
100 | menu->insertItem( tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); | 98 | menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia0Type) )), |
99 | tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); | ||
101 | } | 100 | } |
102 | 101 | ||
103 | if ( cardInPcmcia1 ) { | 102 | if ( cardInPcmcia1 ) { |
104 | menu->insertItem( tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); | 103 | menu->insertItem( QIconSet ( Resource::loadPixmap ( getIconName(cardInPcmcia1Type) )), |
104 | tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); | ||
105 | } | 105 | } |
106 | 106 | ||
107 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 107 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
108 | QSize s = menu->sizeHint ( ); | 108 | QSize s = menu->sizeHint ( ); |
109 | int opt = menu->exec( QPoint ( | 109 | int opt = menu->exec( QPoint ( |
110 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 110 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
111 | p. y ( ) - s. height ( ) ), 0); | 111 | p. y ( ) - s. height ( ) ), 0); |
112 | 112 | ||
113 | if ( opt == 1 ) { | 113 | if ( opt == 1 ) { |
114 | 114 | ||
115 | cmd = "/sbin/cardctl eject 0"; | 115 | cmd = "/sbin/cardctl eject 0"; |
116 | err = system( (const char *) cmd ); | 116 | err = system( (const char *) cmd ); |
117 | if ( ( err == 127 ) || ( err < 0 ) ) { | 117 | if ( ( err == 127 ) || ( err < 0 ) ) { |
118 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); | 118 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); |
119 | popUp( tr("CF/PCMCIA card eject failed!")); | 119 | popup( tr("CF/PCMCIA card eject failed!")); |
120 | } | 120 | } |
121 | } else if ( opt == 0 ) { | 121 | } else if ( opt == 0 ) { |
122 | cmd = "/etc/sdcontrol compeject"; | 122 | cmd = "/etc/sdcontrol compeject"; |
123 | err = system( (const char *) cmd ); | 123 | err = system( (const char *) cmd ); |
124 | if ( ( err != 0 ) ) { | 124 | if ( ( err != 0 ) ) { |
125 | qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); | 125 | qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); |
126 | popUp( tr("SD/MMC card eject failed!")); | 126 | popup( tr("SD/MMC card eject failed!")); |
127 | } | 127 | } |
128 | } else if ( opt == 2 ) { | 128 | } else if ( opt == 2 ) { |
129 | cmd = "/sbin/cardctl eject 1"; | 129 | cmd = "/sbin/cardctl eject 1"; |
130 | err = system( (const char *) cmd ); | 130 | err = system( (const char *) cmd ); |
131 | if ( ( err == 127 ) || ( err < 0 ) ) { | 131 | if ( ( err == 127 ) || ( err < 0 ) ) { |
132 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); | 132 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); |
133 | popUp( tr("CF/PCMCIA card eject failed!")); | 133 | popup( tr("CF/PCMCIA card eject failed!")); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | delete menu; | 137 | delete menu; |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { | 141 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { |
142 | if ( msg == "stabChanged()" ) { | 142 | if ( msg == "stabChanged()" ) { |
143 | // qDebug("Pcmcia: stabchanged"); | 143 | // qDebug("Pcmcia: stabchanged"); |
144 | if ( getStatusPcmcia() ) { | 144 | if ( getStatusPcmcia() ) { |
145 | repaint(FALSE); | 145 | repaint(FALSE); |
146 | } | 146 | } |
147 | } else if ( msg == "mtabChanged()" ) { | 147 | } else if ( msg == "mtabChanged()" ) { |
148 | // qDebug("Pcmcia: mtabchanged"); | 148 | // qDebug("Pcmcia: mtabchanged"); |
149 | if ( getStatusSd() ) { | 149 | if ( getStatusSd() ) { |
150 | repaint(FALSE); | 150 | repaint(FALSE); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { | 155 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { |
156 | 156 | ||
157 | bool cardWas0 = cardInPcmcia0; // remember last state | 157 | bool cardWas0 = cardInPcmcia0; // remember last state |
158 | bool cardWas1 = cardInPcmcia1; | 158 | bool cardWas1 = cardInPcmcia1; |
159 | 159 | ||
160 | QString fileName; | 160 | QString fileName; |
161 | 161 | ||
162 | // one of these 3 files should exist | 162 | // one of these 3 files should exist |
163 | if (QFile::exists("/var/run/stab")) { | 163 | if (QFile::exists("/var/run/stab")) { |
164 | fileName = "/var/run/stab"; | 164 | fileName = "/var/run/stab"; |
165 | } else if (QFile::exists("/var/state/pcmcia/stab")) { | 165 | } else if (QFile::exists("/var/state/pcmcia/stab")) { |
166 | fileName="/var/state/pcmcia/stab"; | 166 | fileName="/var/state/pcmcia/stab"; |
167 | } else { | 167 | } else { |
168 | fileName="/var/lib/pcmcia/stab"; | 168 | fileName="/var/lib/pcmcia/stab"; |
169 | } | 169 | } |
170 | 170 | ||
171 | QFile f(fileName); | 171 | QFile f(fileName); |
172 | 172 | ||
173 | if ( f.open(IO_ReadOnly) ) { | 173 | if ( f.open(IO_ReadOnly) ) { |
174 | QStringList list; | 174 | QStringList list; |
175 | QTextStream stream ( &f); | 175 | QTextStream stream ( &f); |
176 | QString streamIn; | 176 | QString streamIn; |
177 | streamIn = stream.read(); | 177 | streamIn = stream.read(); |
178 | list = QStringList::split("\n", streamIn); | 178 | list = QStringList::split("\n", streamIn); |
179 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 179 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
180 | if( (*line).startsWith("Socket 0:") ){ | 180 | if( (*line).startsWith("Socket 0:") ){ |
181 | if( (*line).startsWith("Socket 0: empty") && cardInPcmcia0 ){ | 181 | if( (*line).startsWith("Socket 0: empty") && cardInPcmcia0 ){ |
182 | cardInPcmcia0 = FALSE; | 182 | cardInPcmcia0 = FALSE; |
183 | } else if ( !(*line).startsWith("Socket 0: empty") && !cardInPcmcia0 ){ | 183 | } else if ( !(*line).startsWith("Socket 0: empty") && !cardInPcmcia0 ){ |
184 | cardInPcmcia0Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); | 184 | cardInPcmcia0Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); |
185 | cardInPcmcia0Name.stripWhiteSpace(); | 185 | cardInPcmcia0Name.stripWhiteSpace(); |
186 | cardInPcmcia0 = TRUE; | 186 | cardInPcmcia0 = TRUE; |
187 | show(); | 187 | show(); |
188 | line++; | ||
189 | int pos=(*line).find('\t')+1; | ||
190 | cardInPcmcia0Type = (*line).mid( pos, (*line).find("\t", pos) - pos); | ||
188 | } | 191 | } |
189 | } | 192 | } |
190 | if( (*line).startsWith("Socket 1:") ){ | 193 | else if( (*line).startsWith("Socket 1:") ){ |
191 | if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ | 194 | if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ |
192 | cardInPcmcia1 = FALSE; | 195 | cardInPcmcia1 = FALSE; |
193 | } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){ | 196 | } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){ |
194 | cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); | 197 | cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); |
195 | cardInPcmcia1Name.stripWhiteSpace(); | 198 | cardInPcmcia1Name.stripWhiteSpace(); |
196 | cardInPcmcia1 = TRUE; | 199 | cardInPcmcia1 = TRUE; |
197 | show(); | 200 | show(); |
201 | line++; | ||
202 | int pos=(*line).find('\t')+1; | ||
203 | cardInPcmcia1Type = (*line).mid( pos, (*line).find("\t", pos) - pos); | ||
198 | } | 204 | } |
199 | } | 205 | } |
200 | } | 206 | } |
207 | f.close(); | ||
201 | } else { | 208 | } else { |
202 | // no file found | 209 | // no file found |
203 | qDebug("no file found"); | 210 | qDebug("no file found"); |
204 | cardInPcmcia0 = FALSE; | 211 | cardInPcmcia0 = FALSE; |
205 | cardInPcmcia1 = FALSE; | 212 | cardInPcmcia1 = FALSE; |
206 | return FALSE; | 213 | return FALSE; |
207 | 214 | ||
208 | } | 215 | } |
209 | 216 | ||
210 | if(!cardInPcmcia0 && !cardInPcmcia1) { | ||
211 | qDebug("Pcmcia: no cards"); | ||
212 | } | ||
213 | |||
214 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { | 217 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { |
215 | QString text = ""; | 218 | QString text = ""; |
216 | if(cardWas0 != cardInPcmcia0) { | 219 | if(cardWas0 != cardInPcmcia0) { |
217 | if(cardInPcmcia0) { text += tr("New card: "); } | 220 | if(cardInPcmcia0) { text += tr("New card: "); } |
218 | else { text += tr("Ejected: "); } | 221 | else { text += tr("Ejected: "); } |
219 | text += cardInPcmcia0Name; | 222 | text += cardInPcmcia0Name; |
220 | } | 223 | popup( text, getIconName( cardInPcmcia0Type ) ); |
221 | if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) { | ||
222 | text += "\n"; | ||
223 | } | 224 | } |
224 | if(cardWas1 != cardInPcmcia1) { | 225 | if(cardWas1 != cardInPcmcia1) { |
225 | if(cardInPcmcia1) { text += tr("New card: "); } | 226 | if(cardInPcmcia1) { text += tr("New card: "); } |
226 | else { text += tr("Ejected: "); } | 227 | else { text += tr("Ejected: "); } |
227 | text += cardInPcmcia1Name; | 228 | text += cardInPcmcia1Name; |
229 | popup( text, getIconName( cardInPcmcia1Type ) ); | ||
228 | } | 230 | } |
229 | popUp( text ); | ||
230 | } | 231 | } |
231 | 232 | ||
232 | f.close(); | ||
233 | 233 | ||
234 | return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); | 234 | return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | bool CardMonitor::getStatusSd( int showPopUp ) { | 238 | bool CardMonitor::getStatusSd( int showPopUp ) { |
239 | 239 | ||
240 | bool cardWas=cardInSd; // remember last state | 240 | bool cardWas=cardInSd; // remember last state |
241 | cardInSd=false; | 241 | cardInSd=false; |
242 | 242 | ||
243 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 243 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
244 | struct mntent *me; | 244 | struct mntent *me; |
245 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 245 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
246 | 246 | ||
247 | if ( mntfp ) { | 247 | if ( mntfp ) { |
248 | while ( (me = getmntent( mntfp )) != 0 ) { | 248 | while ( (me = getmntent( mntfp )) != 0 ) { |
249 | QString fs = me->mnt_fsname; | 249 | QString fs = me->mnt_fsname; |
250 | if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { | 250 | if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { |
251 | cardInSd=true; | 251 | cardInSd=true; |
252 | } | 252 | } |
253 | } | 253 | } |
254 | endmntent( mntfp ); | 254 | endmntent( mntfp ); |
255 | } | 255 | } |
256 | if(!showPopUp && cardWas != cardInSd) { | 256 | if(!showPopUp && cardWas != cardInSd) { |
257 | QString text = ""; | 257 | QString text = ""; |
258 | if(cardInSd) { text += "SD Inserted"; } | 258 | if(cardInSd) { text += "SD Inserted"; } |
259 | else { text += "SD Removed"; } | 259 | else { text += "SD Removed"; } |
260 | popUp( text ); | 260 | popup( text); // XX add SD pic |
261 | } | 261 | } |
262 | 262 | ||
263 | #else | 263 | #else |
264 | #error "Not on Linux" | 264 | #error "Not on Linux" |
265 | #endif | 265 | #endif |
266 | return ((cardWas == cardInSd) ? FALSE : TRUE); | 266 | return ((cardWas == cardInSd) ? FALSE : TRUE); |
267 | } | 267 | } |
268 | 268 | ||
269 | void CardMonitor::paintEvent( QPaintEvent * ) { | 269 | void CardMonitor::paintEvent( QPaintEvent * ) { |
270 | QPainter p( this ); | 270 | QPainter p( this ); |
271 | 271 | ||
272 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 272 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { |
273 | p.drawPixmap( 0, 0, pm ); | 273 | p.drawPixmap( 0, 0, pm ); |
274 | show(); | 274 | show(); |
275 | } else { | 275 | } else { |
276 | p.eraseRect( rect() ); | 276 | p.eraseRect( rect() ); |
277 | hide(); | 277 | hide(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | QString CardMonitor::getIconName( QString type ) { | ||
282 | if( type != "network" && | ||
283 | type != "ide" ) { | ||
284 | type="cardmon"; | ||
285 | } | ||
286 | return "cardmon/"+type; | ||
287 | } | ||
288 | |||
281 | 289 | ||
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h index 34b8d95..e424192 100644 --- a/core/applets/cardmon/cardmon.h +++ b/core/applets/cardmon/cardmon.h | |||
@@ -1,58 +1,59 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.h | 2 | * cardmon.h |
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 | #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 | #include <qtimer.h> | ||
26 | 25 | ||
27 | class CardMonitor : public QWidget { | 26 | class CardMonitor : public QWidget { |
28 | Q_OBJECT | 27 | Q_OBJECT |
29 | public: | 28 | public: |
30 | CardMonitor( QWidget *parent = 0 ); | 29 | CardMonitor( QWidget *parent = 0 ); |
31 | ~CardMonitor(); | 30 | ~CardMonitor(); |
32 | bool getStatusPcmcia( int showPopUp = FALSE ); | 31 | bool getStatusPcmcia( int showPopUp = FALSE ); |
33 | bool getStatusSd( int showPopUp = FALSE ); | 32 | bool getStatusSd( int showPopUp = FALSE ); |
34 | 33 | ||
35 | private slots: | 34 | private slots: |
36 | void cardMessage( const QCString &msg, const QByteArray & ); | 35 | void cardMessage( const QCString &msg, const QByteArray & ); |
37 | void popUpTimeout(); | 36 | void popupTimeout(); |
38 | 37 | ||
39 | protected: | 38 | protected: |
40 | void paintEvent( QPaintEvent* ); | 39 | void paintEvent( QPaintEvent* ); |
41 | void mousePressEvent( QMouseEvent * ); | 40 | void mousePressEvent( QMouseEvent * ); |
42 | private: | 41 | private: |
43 | QPixmap pm; | 42 | QPixmap pm; |
44 | QPopupMenu *popUpMenu; | ||
45 | QTimer *popUpMenuTimer; | ||
46 | // pcmcia socket 0 | 43 | // pcmcia socket 0 |
47 | bool cardInPcmcia0; | 44 | bool cardInPcmcia0; |
48 | QString cardInPcmcia0Name; | 45 | QString cardInPcmcia0Name; |
46 | QString cardInPcmcia0Type; | ||
49 | // pcmcia socket 1 | 47 | // pcmcia socket 1 |
50 | bool cardInPcmcia1; | 48 | bool cardInPcmcia1; |
51 | QString cardInPcmcia1Name; | 49 | QString cardInPcmcia1Name; |
50 | QString cardInPcmcia1Type; | ||
52 | bool cardInSd; | 51 | bool cardInSd; |
53 | void iconShow(); | 52 | void iconShow(); |
54 | void popUp(QString message); | 53 | QPopupMenu *popupMenu; |
54 | void popup(QString message, QString icon=""); | ||
55 | QString getIconName(QString type); | ||
55 | }; | 56 | }; |
56 | 57 | ||
57 | #endif | 58 | #endif |
58 | 59 | ||
diff --git a/core/applets/cardmon/opie-cardmon.control b/core/applets/cardmon/opie-cardmon.control index 9f941f8..bcd0326 100644 --- a/core/applets/cardmon/opie-cardmon.control +++ b/core/applets/cardmon/opie-cardmon.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: plugins/applets/libcardmonapplet.so* pics/cardmon/pcmcia.png | 1 | Files: plugins/applets/libcardmonapplet.so* pics/cardmon/*.png |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/taskbar | 3 | Section: opie/taskbar |
4 | Maintainer: Maximilian Reiß <max.reiss@gmx.de> | 4 | Maintainer: Maximilian Reiß <max.reiss@gmx.de> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: CF/PCMCIA Card Monitor applet | 8 | Description: CF/PCMCIA Card Monitor applet |
9 | SD/MMC/CF/PCMCIA Card Monitor applet for the Opie environment taskbar. | 9 | SD/MMC/CF/PCMCIA Card Monitor applet for the Opie environment taskbar. |