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