author | harlekin <harlekin> | 2002-06-24 21:05:01 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-24 21:05:01 (UTC) |
commit | 67b1be897a8c02b70b6e0805ff0c5ae19146905c (patch) (unidiff) | |
tree | 02f0e45847959560f1912a06d31f5895618edc88 | |
parent | 2751bb111d21a5672c7caa7a6c2c45d14a642dbd (diff) | |
download | opie-67b1be897a8c02b70b6e0805ff0c5ae19146905c.zip opie-67b1be897a8c02b70b6e0805ff0c5ae19146905c.tar.gz opie-67b1be897a8c02b70b6e0805ff0c5ae19146905c.tar.bz2 |
fixed a segfault if a device is discovered on opie start and added sounds
-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 28 | ||||
-rw-r--r-- | core/applets/irdaapplet/irda.h | 3 | ||||
-rw-r--r-- | core/applets/irdaapplet/irdaapplet.pro | 31 | ||||
-rw-r--r-- | core/applets/irdaapplet/opie-irdaapplet.control | 2 |
4 files changed, 36 insertions, 28 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index c0f11c0..42bed5e 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp | |||
@@ -1,120 +1,124 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> | 2 | ** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> |
3 | ** Heavily based on volumeapplet, (C) 2002 L.J. Potter ljp@llornkcor.com | 3 | ** Heavily based on volumeapplet, (C) 2002 L.J. Potter ljp@llornkcor.com |
4 | ** All rights reserved. | 4 | ** All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "irda.h" | 16 | #include "irda.h" |
17 | #include <qapplication.h> | 17 | #include <qapplication.h> |
18 | #include <stdlib.h> | 18 | #include <stdlib.h> |
19 | 19 | ||
20 | 20 | ||
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/timestring.h> | 23 | #include <qpe/timestring.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/ir.h> | 28 | #include <qpe/ir.h> |
29 | #include <qpe/qcopenvelope_qws.h> | 29 | #include <qpe/qcopenvelope_qws.h> |
30 | 30 | ||
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfileinfo.h> | 32 | #include <qfileinfo.h> |
33 | #include <qpoint.h> | 33 | #include <qpoint.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qslider.h> | 38 | #include <qslider.h> |
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | #include <qframe.h> | 40 | #include <qframe.h> |
41 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
42 | #include <qstring.h> | 42 | #include <qstring.h> |
43 | #include <qfile.h> | 43 | #include <qfile.h> |
44 | #include <qtimer.h> | 44 | #include <qtimer.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | #include <qpopupmenu.h> | 46 | #include <qpopupmenu.h> |
47 | #include <qsound.h> | ||
47 | 48 | ||
48 | #include <net/if.h> | 49 | #include <net/if.h> |
49 | #include <netinet/in.h> | 50 | #include <netinet/in.h> |
50 | #include <sys/types.h> | 51 | #include <sys/types.h> |
51 | #include <sys/socket.h> | 52 | #include <sys/socket.h> |
52 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
53 | 54 | ||
54 | 55 | ||
55 | //=========================================================================== | 56 | //=========================================================================== |
56 | 57 | ||
57 | IrdaApplet::IrdaApplet( QWidget *parent, const char *name ) | 58 | IrdaApplet::IrdaApplet( QWidget *parent, const char *name ) |
58 | : QWidget( parent, name ) { | 59 | : QWidget( parent, name ) { |
59 | setFixedHeight( 14 ); | 60 | setFixedHeight( 14 ); |
60 | setFixedWidth( 14 ); | 61 | setFixedWidth( 14 ); |
61 | sockfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); | 62 | sockfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); |
62 | irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); | 63 | irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); |
63 | irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); | 64 | irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); |
64 | irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); | 65 | irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); |
65 | receiveActivePixmap = Resource::loadPixmap("irdaapplet/receive"); | 66 | receiveActivePixmap = Resource::loadPixmap("irdaapplet/receive"); |
66 | receiveActive = false; | 67 | receiveActive = false; |
67 | startTimer(5000); | ||
68 | timerEvent(NULL); | ||
69 | popupMenu = 0; | 68 | popupMenu = 0; |
70 | devicesAvailable.setAutoDelete(TRUE); | 69 | devicesAvailable.setAutoDelete(TRUE); |
71 | } | 70 | } |
72 | 71 | ||
72 | void IrdaApplet::show() { | ||
73 | QWidget::show(); | ||
74 | startTimer(2000); | ||
75 | } | ||
76 | |||
73 | IrdaApplet::~IrdaApplet() { | 77 | IrdaApplet::~IrdaApplet() { |
74 | close(sockfd); | 78 | close(sockfd); |
75 | if( popupMenu ) { delete popupMenu; } | 79 | if( popupMenu ) { delete popupMenu; } |
76 | } | 80 | } |
77 | 81 | ||
78 | void IrdaApplet::popup(QString message, QString icon="") { | 82 | void IrdaApplet::popup(QString message, QString icon="") { |
79 | if ( ! popupMenu ) { | 83 | if ( ! popupMenu ) { |
80 | popupMenu = new QPopupMenu(); | 84 | popupMenu = new QPopupMenu(); |
81 | } | 85 | } |
82 | popupMenu->clear(); | 86 | popupMenu->clear(); |
83 | if( icon == "" ) { | 87 | if( icon == "" ) { |
84 | popupMenu->insertItem( message, 0 ); | 88 | popupMenu->insertItem( message, 0 ); |
85 | } else { | 89 | } else { |
86 | popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )), | 90 | popupMenu->insertItem( QIconSet ( Resource::loadPixmap ( icon )), |
87 | message, 0 ); | 91 | message, 0 ); |
88 | } | 92 | } |
89 | 93 | ||
90 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 94 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
91 | QSize s = popupMenu->sizeHint ( ); | 95 | QSize s = popupMenu->sizeHint ( ); |
92 | popupMenu->popup( QPoint ( | 96 | popupMenu->popup( QPoint ( |
93 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 97 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
94 | p. y ( ) - s. height ( ) ), 0); | 98 | p. y ( ) - s. height ( ) ), 0); |
95 | 99 | ||
96 | QTimer::singleShot( 2000, this, SLOT(popupTimeout()) ); | 100 | QTimer::singleShot( 2000, this, SLOT(popupTimeout()) ); |
97 | } | 101 | } |
98 | 102 | ||
99 | void IrdaApplet::popupTimeout() { | 103 | void IrdaApplet::popupTimeout() { |
100 | popupMenu->hide(); | 104 | popupMenu->hide(); |
101 | } | 105 | } |
102 | 106 | ||
103 | int IrdaApplet::checkIrdaStatus() { | 107 | int IrdaApplet::checkIrdaStatus() { |
104 | struct ifreq ifr; | 108 | struct ifreq ifr; |
105 | 109 | ||
106 | strcpy(ifr.ifr_name, "irda0"); | 110 | strcpy(ifr.ifr_name, "irda0"); |
107 | 111 | ||
108 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr)) | 112 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr)) |
109 | return -1; | 113 | return -1; |
110 | 114 | ||
111 | return (ifr.ifr_flags & IFF_UP)?1:0; | 115 | return (ifr.ifr_flags & IFF_UP)?1:0; |
112 | } | 116 | } |
113 | 117 | ||
114 | int IrdaApplet::setIrdaStatus(int c) { | 118 | int IrdaApplet::setIrdaStatus(int c) { |
115 | struct ifreq ifr; | 119 | struct ifreq ifr; |
116 | 120 | ||
117 | strcpy(ifr.ifr_name, "irda0"); | 121 | strcpy(ifr.ifr_name, "irda0"); |
118 | 122 | ||
119 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr)) | 123 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr)) |
120 | return -1; | 124 | return -1; |
@@ -161,207 +165,205 @@ int IrdaApplet::setIrdaDiscoveryStatus(int d) { | |||
161 | discovery.putch('0'); | 165 | discovery.putch('0'); |
162 | 166 | ||
163 | discovery.close(); | 167 | discovery.close(); |
164 | 168 | ||
165 | return 0; | 169 | return 0; |
166 | } | 170 | } |
167 | 171 | ||
168 | int IrdaApplet::setIrdaReceiveStatus(int d) { | 172 | int IrdaApplet::setIrdaReceiveStatus(int d) { |
169 | if(d) { | 173 | if(d) { |
170 | qWarning("Enable receive" ); | 174 | qWarning("Enable receive" ); |
171 | QCopEnvelope e("QPE/Obex", "receive(int)" ); | 175 | QCopEnvelope e("QPE/Obex", "receive(int)" ); |
172 | e << 1; | 176 | e << 1; |
173 | receiveActive = true; | 177 | receiveActive = true; |
174 | receiveStateChanged = true; | 178 | receiveStateChanged = true; |
175 | } else { | 179 | } else { |
176 | qWarning("Disable receive" ); | 180 | qWarning("Disable receive" ); |
177 | QCopEnvelope e("QPE/Obex", "receive(int)" ); | 181 | QCopEnvelope e("QPE/Obex", "receive(int)" ); |
178 | e << 0; | 182 | e << 0; |
179 | receiveActive = false; | 183 | receiveActive = false; |
180 | receiveStateChanged = true; | 184 | receiveStateChanged = true; |
181 | } | 185 | } |
182 | return 0; | 186 | return 0; |
183 | } | 187 | } |
184 | 188 | ||
185 | void IrdaApplet::showDiscovered() { | 189 | void IrdaApplet::showDiscovered() { |
186 | QFile discovery("/proc/net/irda/discovery"); | 190 | QFile discovery("/proc/net/irda/discovery"); |
187 | 191 | ||
188 | if (discovery.open(IO_ReadOnly) ) { | 192 | if (discovery.open(IO_ReadOnly) ) { |
189 | int qcopsend = FALSE; | 193 | int qcopsend = FALSE; |
190 | 194 | ||
191 | QString discoveredDevice; | 195 | QString discoveredDevice; |
192 | QString deviceAddr; | 196 | QString deviceAddr; |
193 | QStringList list; | 197 | QStringList list; |
194 | // since it is /proc we _must_ use QTextStream | 198 | // since it is /proc we _must_ use QTextStream |
195 | QTextStream stream ( &discovery); | 199 | QTextStream stream ( &discovery); |
196 | QString streamIn; | 200 | QString streamIn; |
197 | streamIn = stream.read(); | 201 | streamIn = stream.read(); |
198 | list = QStringList::split("\n", streamIn); | 202 | list = QStringList::split("\n", streamIn); |
199 | 203 | ||
200 | QDictIterator<QString> it( devicesAvailable ); | 204 | QDictIterator<QString> it( devicesAvailable ); |
201 | while ( it.current() ) { | 205 | while ( it.current() ) { |
202 | devicesAvailable.replace( it.currentKey(), new QString("+++" + *devicesAvailable[it.currentKey()]) ); | 206 | devicesAvailable.replace( it.currentKey(), new QString("+++" + *devicesAvailable[it.currentKey()]) ); |
203 | //qDebug("IrdaMon: " + it.currentKey()); | 207 | //qDebug("IrdaMon: " + it.currentKey()); |
204 | //qDebug(" =" + *devicesAvailable[it.currentKey()] ); | 208 | //qDebug(" =" + *devicesAvailable[it.currentKey()] ); |
205 | ++it; | 209 | ++it; |
206 | } | 210 | } |
207 | 211 | ||
208 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 212 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
209 | qDebug( (*line) ); | 213 | // qDebug( (*line) ); |
210 | if( (*line).startsWith("nickname:") ){ | 214 | if( (*line).startsWith("nickname:") ){ |
211 | discoveredDevice = (*line).mid(((*line).find(':'))+2,(*line).find(',')-(*line).find(':')-2); | 215 | discoveredDevice = (*line).mid(((*line).find(':'))+2,(*line).find(',')-(*line).find(':')-2); |
212 | deviceAddr = (*line).mid( (*line).find( "daddr:" )+9, 8 ); | 216 | deviceAddr = (*line).mid( (*line).find( "daddr:" )+9, 8 ); |
213 | 217 | ||
214 | qDebug(discoveredDevice + "(" + deviceAddr + ")"); | 218 | // qDebug(discoveredDevice + "(" + deviceAddr + ")"); |
215 | 219 | ||
216 | if( ! devicesAvailable.find(deviceAddr) ) { | 220 | if( ! devicesAvailable.find(deviceAddr) ) { |
217 | popup( tr("Found:") + " " + discoveredDevice ); | 221 | popup( tr("Found:") + " " + discoveredDevice ); |
222 | QSound::play(Resource::findSound("irdaapplet/irdaon")); | ||
218 | qcopsend = TRUE; | 223 | qcopsend = TRUE; |
219 | } | 224 | } |
220 | devicesAvailable.replace( deviceAddr, new QString(discoveredDevice) ); | 225 | devicesAvailable.replace( deviceAddr, new QString(discoveredDevice) ); |
221 | //qDebug("IrdaMon: " + deviceAddr + "=" + *devicesAvailable[deviceAddr] ); | 226 | // qDebug("IrdaMon: " + deviceAddr + "=" + *devicesAvailable[deviceAddr] ); |
222 | } | 227 | } |
223 | } | 228 | } |
224 | 229 | ||
225 | it.toFirst(); | 230 | it.toFirst(); |
226 | while ( it.current() ) { | 231 | while ( it.current() ) { |
227 | qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); | 232 | // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); |
228 | if ( (*it.current()).left(3) == "+++" ) { | 233 | if ( (*it.current()).left(3) == "+++" ) { |
229 | popup( tr("Lost:") + " " + (*devicesAvailable[it.currentKey()]).mid(3) ); | 234 | popup( tr("Lost:") + " " + (*devicesAvailable[it.currentKey()]).mid(3) ); |
235 | QSound::play(Resource::findSound("irdaapplet/irdaoff")); | ||
230 | devicesAvailable.remove( it.currentKey() ); | 236 | devicesAvailable.remove( it.currentKey() ); |
231 | qDebug("IrdaMon: delete " + it.currentKey() + "!"); | 237 | // qDebug("IrdaMon: delete " + it.currentKey() + "!"); |
232 | qcopsend = TRUE; | 238 | qcopsend = TRUE; |
233 | } | 239 | } |
234 | ++it; | 240 | ++it; |
235 | } | 241 | } |
236 | /* XXX if( qcopsend ) { | 242 | /* XXX if( qcopsend ) { |
237 | QCopEnvelope e("QPE/Network", "irdaSend(bool)" ); | 243 | QCopEnvelope e("QPE/Network", "irdaSend(bool)" ); |
238 | e << (devicesAvailable.count() > 0) ; | 244 | e << (devicesAvailable.count() > 0) ; |
239 | } */ | 245 | } */ |
240 | } | 246 | } |
241 | } | 247 | } |
242 | 248 | ||
243 | void IrdaApplet::mousePressEvent( QMouseEvent *) { | 249 | void IrdaApplet::mousePressEvent( QMouseEvent *) { |
244 | QPopupMenu *menu = new QPopupMenu(); | 250 | QPopupMenu *menu = new QPopupMenu(); |
245 | QString cmd; | 251 | QString cmd; |
246 | int ret=0; | 252 | int ret=0; |
247 | 253 | ||
248 | /* Refresh active state */ | 254 | /* Refresh active state */ |
249 | timerEvent(NULL); | 255 | timerEvent(NULL); |
250 | 256 | ||
251 | //menu->insertItem( tr("More..."), 4 ); | 257 | //menu->insertItem( tr("More..."), 4 ); |
252 | 258 | ||
253 | if (irdaactive && devicesAvailable.count() > 0) { | 259 | if (irdaactive && devicesAvailable.count() > 0) { |
254 | menu->insertItem( tr("Discovered Device:"), 9); | 260 | menu->insertItem( tr("Discovered Device:"), 9); |
255 | |||
256 | QDictIterator<QString> it( devicesAvailable ); | 261 | QDictIterator<QString> it( devicesAvailable ); |
257 | while ( it.current() ) { | 262 | while ( it.current() ) { |
258 | menu->insertItem( *devicesAvailable[it.currentKey()]); | 263 | menu->insertItem( *devicesAvailable[it.currentKey()]); |
259 | ++it; | 264 | ++it; |
260 | } | 265 | } |
261 | menu->insertSeparator(); | 266 | menu->insertSeparator(); |
262 | } | 267 | } |
263 | 268 | ||
264 | if (irdaactive) { | 269 | if (irdaactive) { |
265 | menu->insertItem( tr("Disable IrDA"), 0 ); | 270 | menu->insertItem( tr("Disable IrDA"), 0 ); |
266 | } else { | 271 | } else { |
267 | menu->insertItem( tr("Enable IrDA"), 1 ); | 272 | menu->insertItem( tr("Enable IrDA"), 1 ); |
268 | } | 273 | } |
269 | 274 | ||
270 | if (irdaactive) { | 275 | if (irdaactive) { |
271 | if (irdaDiscoveryActive) { | 276 | if (irdaDiscoveryActive) { |
272 | menu->insertItem( tr("Disable Discovery"), 2 ); | 277 | menu->insertItem( tr("Disable Discovery"), 2 ); |
273 | } else { | 278 | } else { |
274 | menu->insertItem( tr("Enable Discovery"), 3 ); | 279 | menu->insertItem( tr("Enable Discovery"), 3 ); |
275 | } | 280 | } |
276 | 281 | ||
277 | if( receiveActive ){ | 282 | if( receiveActive ){ |
278 | menu->insertItem( tr("Disable Receive"), 4 ); | 283 | menu->insertItem( tr("Disable Receive"), 4 ); |
279 | } else { | 284 | } else { |
280 | menu->insertItem( tr("Enable Receive"), 5 ); | 285 | menu->insertItem( tr("Enable Receive"), 5 ); |
281 | } | 286 | } |
282 | } | 287 | } |
283 | 288 | ||
284 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 289 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
285 | QSize s = menu-> sizeHint ( ); | 290 | QSize s = menu-> sizeHint ( ); |
286 | ret = menu->exec( QPoint ( | 291 | ret = menu->exec( QPoint ( |
287 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 292 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
288 | p. y ( ) - s. height ( ) ), 0); | 293 | p. y ( ) - s. height ( ) ), 0); |
289 | 294 | ||
290 | // qDebug("ret was %d\n", ret); | 295 | // qDebug("ret was %d\n", ret); |
291 | 296 | ||
292 | switch(ret) { | 297 | switch(ret) { |
293 | case 0: | 298 | case 0: |
294 | setIrdaStatus(0); | 299 | setIrdaStatus(0); |
295 | timerEvent(NULL); | 300 | timerEvent(NULL); |
296 | break; | 301 | break; |
297 | case 1: | 302 | case 1: |
298 | setIrdaStatus(1); | 303 | setIrdaStatus(1); |
299 | timerEvent(NULL); | 304 | timerEvent(NULL); |
300 | break; | 305 | break; |
301 | case 2: | 306 | case 2: |
302 | setIrdaDiscoveryStatus(0); | 307 | setIrdaDiscoveryStatus(0); |
303 | timerEvent(NULL); | 308 | timerEvent(NULL); |
304 | break; | 309 | break; |
305 | case 3: | 310 | case 3: |
306 | setIrdaDiscoveryStatus(1); | 311 | setIrdaDiscoveryStatus(1); |
307 | timerEvent(NULL); // NULL is undefined in c++ use 0 or 0l | 312 | timerEvent(NULL); // NULL is undefined in c++ use 0 or 0l |
308 | break; | 313 | break; |
309 | case 4: { // enable receive | 314 | case 4: { // enable receive |
310 | setIrdaReceiveStatus(0); | 315 | setIrdaReceiveStatus(0); |
311 | timerEvent(NULL); | 316 | timerEvent(NULL); |
312 | break; | 317 | break; |
313 | } | 318 | } |
314 | case 5: { // disable receive | 319 | case 5: { // disable receive |
315 | setIrdaReceiveStatus(1); | 320 | setIrdaReceiveStatus(1); |
316 | timerEvent(NULL); | 321 | timerEvent(NULL); |
317 | break; | 322 | break; |
318 | } | 323 | } |
319 | case 6: | ||
320 | qDebug("FIXME: Bring up pretty menu...\n"); | ||
321 | // With table of currently-detected devices. | ||
322 | } | 324 | } |
323 | delete menu; // Can somebody explain why use a QPopupMenu* and not QPopupMenu nor QAction. with out delete we will leak cause QPopupMenu doesn't have a parent in this case | 325 | delete menu; // Can somebody explain why use a QPopupMenu* and not QPopupMenu nor QAction. with out delete we will leak cause QPopupMenu doesn't have a parent in this case |
324 | } | 326 | } |
325 | 327 | ||
326 | void IrdaApplet::timerEvent( QTimerEvent * ) { | 328 | void IrdaApplet::timerEvent( QTimerEvent * ) { |
327 | int oldactive = irdaactive; | 329 | int oldactive = irdaactive; |
328 | int olddiscovery = irdaDiscoveryActive; | 330 | int olddiscovery = irdaDiscoveryActive; |
329 | bool receiveUpdate = false; | 331 | bool receiveUpdate = false; |
330 | 332 | ||
331 | if (receiveStateChanged) { | 333 | if (receiveStateChanged) { |
332 | receiveUpdate = true; | 334 | receiveUpdate = true; |
333 | receiveStateChanged = false; | 335 | receiveStateChanged = false; |
334 | } | 336 | } |
335 | 337 | ||
336 | irdaactive = checkIrdaStatus(); | 338 | irdaactive = checkIrdaStatus(); |
337 | irdaDiscoveryActive = checkIrdaDiscoveryStatus(); | 339 | irdaDiscoveryActive = checkIrdaDiscoveryStatus(); |
338 | 340 | ||
339 | 341 | ||
340 | if (irdaDiscoveryActive) { | 342 | if (irdaDiscoveryActive) { |
341 | showDiscovered(); | 343 | showDiscovered(); |
342 | } | 344 | } |
343 | 345 | ||
344 | if ((irdaactive != oldactive) || (irdaDiscoveryActive != olddiscovery) || receiveUpdate ) { | 346 | if ((irdaactive != oldactive) || (irdaDiscoveryActive != olddiscovery) || receiveUpdate ) { |
345 | paintEvent(NULL); | 347 | paintEvent(NULL); |
346 | } | 348 | } |
347 | 349 | ||
348 | } | 350 | } |
349 | 351 | ||
350 | void IrdaApplet::paintEvent( QPaintEvent* ) { | 352 | void IrdaApplet::paintEvent( QPaintEvent* ) { |
351 | QPainter p(this); | 353 | QPainter p(this); |
352 | qDebug("paint irda pixmap"); | 354 | // qDebug("paint irda pixmap"); |
353 | 355 | ||
354 | p.eraseRect ( 0, 0, this->width(), this->height() ); | 356 | p.eraseRect ( 0, 0, this->width(), this->height() ); |
355 | if (irdaactive > 0) { | 357 | if (irdaactive > 0) { |
356 | p.drawPixmap( 0, 0, irdaOnPixmap ); | 358 | p.drawPixmap( 0, 0, irdaOnPixmap ); |
357 | } else { | 359 | } else { |
358 | p.drawPixmap( 0, 0, irdaOffPixmap ); | 360 | p.drawPixmap( 0, 0, irdaOffPixmap ); |
359 | } | 361 | } |
360 | 362 | ||
361 | if (irdaDiscoveryActive > 0) { | 363 | if (irdaDiscoveryActive > 0) { |
362 | p.drawPixmap( 0, 0, irdaDiscoveryOnPixmap ); | 364 | p.drawPixmap( 0, 0, irdaDiscoveryOnPixmap ); |
363 | } | 365 | } |
364 | if (receiveActive) { | 366 | if (receiveActive) { |
365 | p.drawPixmap( 0, 0, receiveActivePixmap); | 367 | p.drawPixmap( 0, 0, receiveActivePixmap); |
366 | } | 368 | } |
367 | } | 369 | } |
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h index 7b37847..e878946 100644 --- a/core/applets/irdaapplet/irda.h +++ b/core/applets/irdaapplet/irda.h | |||
@@ -2,67 +2,70 @@ | |||
2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com | 2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #ifndef SCREENSHOT_APPLET_H__ | 15 | #ifndef SCREENSHOT_APPLET_H__ |
16 | #define SCREENSHOT_APPLET_H__ | 16 | #define SCREENSHOT_APPLET_H__ |
17 | 17 | ||
18 | 18 | ||
19 | 19 | ||
20 | #include <qwidget.h> | 20 | #include <qwidget.h> |
21 | #include <qframe.h> | 21 | #include <qframe.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | #include <qguardedptr.h> | 23 | #include <qguardedptr.h> |
24 | #include <qtimer.h> | 24 | #include <qtimer.h> |
25 | #include <qfile.h> | 25 | #include <qfile.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qdict.h> | 27 | #include <qdict.h> |
28 | 28 | ||
29 | class IrdaApplet : public QWidget | 29 | class IrdaApplet : public QWidget |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | IrdaApplet( QWidget *parent = 0, const char *name=0 ); | 33 | IrdaApplet( QWidget *parent = 0, const char *name=0 ); |
34 | ~IrdaApplet(); | 34 | ~IrdaApplet(); |
35 | 35 | ||
36 | protected: | 36 | protected: |
37 | void timerEvent(QTimerEvent *te ); | 37 | void timerEvent(QTimerEvent *te ); |
38 | 38 | ||
39 | private: | 39 | private: |
40 | void mousePressEvent( QMouseEvent * ); | 40 | void mousePressEvent( QMouseEvent * ); |
41 | void paintEvent( QPaintEvent* ); | 41 | void paintEvent( QPaintEvent* ); |
42 | int checkIrdaStatus(); | 42 | int checkIrdaStatus(); |
43 | int setIrdaStatus(int); | 43 | int setIrdaStatus(int); |
44 | int checkIrdaDiscoveryStatus(); | 44 | int checkIrdaDiscoveryStatus(); |
45 | int setIrdaDiscoveryStatus(int); | 45 | int setIrdaDiscoveryStatus(int); |
46 | int setIrdaReceiveStatus(int); | 46 | int setIrdaReceiveStatus(int); |
47 | void showDiscovered(); | 47 | void showDiscovered(); |
48 | int sockfd; | 48 | int sockfd; |
49 | 49 | ||
50 | public slots: | ||
51 | void show(); | ||
52 | |||
50 | private slots: | 53 | private slots: |
51 | void popupTimeout(); | 54 | void popupTimeout(); |
52 | 55 | ||
53 | private: | 56 | private: |
54 | QPixmap irdaOnPixmap; | 57 | QPixmap irdaOnPixmap; |
55 | QPixmap irdaOffPixmap; | 58 | QPixmap irdaOffPixmap; |
56 | QPixmap irdaDiscoveryOnPixmap; | 59 | QPixmap irdaDiscoveryOnPixmap; |
57 | QPixmap receiveActivePixmap; | 60 | QPixmap receiveActivePixmap; |
58 | int irdaactive; // bool and bitfields later bool irdaactive :1 ; | 61 | int irdaactive; // bool and bitfields later bool irdaactive :1 ; |
59 | int irdaDiscoveryActive; | 62 | int irdaDiscoveryActive; |
60 | bool receiveActive : 1; | 63 | bool receiveActive : 1; |
61 | bool receiveStateChanged; | 64 | bool receiveStateChanged; |
62 | QPopupMenu *popupMenu; | 65 | QPopupMenu *popupMenu; |
63 | void popup(QString message, QString icon=""); | 66 | void popup(QString message, QString icon=""); |
64 | QDict<QString> devicesAvailable; | 67 | QDict<QString> devicesAvailable; |
65 | }; | 68 | }; |
66 | 69 | ||
67 | 70 | ||
68 | #endif // __SCREENSHOT_APPLET_H__ | 71 | #endif // __SCREENSHOT_APPLET_H__ |
diff --git a/core/applets/irdaapplet/irdaapplet.pro b/core/applets/irdaapplet/irdaapplet.pro index 035b0c1..47267f7 100644 --- a/core/applets/irdaapplet/irdaapplet.pro +++ b/core/applets/irdaapplet/irdaapplet.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 = irda.h irdaappletimpl.h | 3 | HEADERS = irda.h irdaappletimpl.h |
4 | SOURCES = irda.cpp irdaappletimpl.cpp | 4 | SOURCES = irda.cpp irdaappletimpl.cpp |
5 | TARGET = irdaapplet | 5 | TARGET = irdaapplet |
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 6 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include | 8 | DEPENDPATH += ../$(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe |
10 | VERSION = 1.0.0 | 10 | VERSION = 1.0.0 |
11 | 11 | ||
12 | TRANSLATIONS = ../../i18n/de/libirdaapplet.ts | 12 | |
13 | TRANSLATIONS += ../../i18n/en/libirdaapplet.ts | 13 | |
14 | TRANSLATIONS += ../../i18n/es/libirdaapplet.ts | 14 | TRANSLATIONS = ../../../i18n/de/libirdaapplet.ts |
15 | TRANSLATIONS += ../../i18n/fr/libirdaapplet.ts | 15 | TRANSLATIONS += ../../../i18n/en/libirdaapplet.ts |
16 | TRANSLATIONS += ../../i18n/hu/libirdaapplet.ts | 16 | TRANSLATIONS += ../../../i18n/es/libirdaapplet.ts |
17 | TRANSLATIONS += ../../i18n/ja/libirdaapplet.ts | 17 | TRANSLATIONS += ../../../i18n/fr/libirdaapplet.ts |
18 | TRANSLATIONS += ../../i18n/ko/libirdaapplet.ts | 18 | TRANSLATIONS += ../../../i18n/hu/libirdaapplet.ts |
19 | TRANSLATIONS += ../../i18n/no/libirdaapplet.ts | 19 | TRANSLATIONS += ../../../i18n/ja/libirdaapplet.ts |
20 | TRANSLATIONS += ../../i18n/pl/libirdaapplet.ts | 20 | TRANSLATIONS += ../../../i18n/ko/libirdaapplet.ts |
21 | TRANSLATIONS += ../../i18n/pt/libirdaapplet.ts | 21 | TRANSLATIONS += ../../../i18n/no/libirdaapplet.ts |
22 | TRANSLATIONS += ../../i18n/pt_BR/libirdaapplet.ts | 22 | TRANSLATIONS += ../../../i18n/pl/libirdaapplet.ts |
23 | TRANSLATIONS += ../../i18n/sl/libirdaapplet.ts | 23 | TRANSLATIONS += ../../../i18n/pt/libirdaapplet.ts |
24 | TRANSLATIONS += ../../i18n/zh_CN/libirdaapplet.ts | 24 | TRANSLATIONS += ../../../i18n/pt_BR/libirdaapplet.ts |
25 | TRANSLATIONS += ../../i18n/zh_TW/libirdaapplet.ts | 25 | TRANSLATIONS += ../../../i18n/sl/libirdaapplet.ts |
26 | TRANSLATIONS += ../../../i18n/zh_CN/libirdaapplet.ts | ||
27 | TRANSLATIONS += ../../../i18n/zh_TW/libirdaapplet.ts | ||
28 | |||
diff --git a/core/applets/irdaapplet/opie-irdaapplet.control b/core/applets/irdaapplet/opie-irdaapplet.control index 85c3386..5b901de 100644 --- a/core/applets/irdaapplet/opie-irdaapplet.control +++ b/core/applets/irdaapplet/opie-irdaapplet.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: plugins/applets/libirdaapplet.so* pics/irdaapplet/* | 1 | Files: plugins/applets/libirdaapplet.so* pics/irdaapplet/* sounds/irdaapplet/*.wav |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/system | 3 | Section: opie/system |
4 | Maintainer: David Woodhouse <dwmw2@infradead.org> | 4 | Maintainer: David Woodhouse <dwmw2@infradead.org> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION.1 | 6 | Version: $QPE_VERSION-$SUB_VERSION.1 |
7 | Depends: opie-base ($QPE_VERSION), libopieobex | 7 | Depends: opie-base ($QPE_VERSION), libopieobex |
8 | Description: Irda Applet | 8 | Description: Irda Applet |
9 | An IrDA taskbar applet for the Opie environment | 9 | An IrDA taskbar applet for the Opie environment |