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