summaryrefslogtreecommitdiff
path: root/core
authorharlekin <harlekin>2002-06-24 21:05:01 (UTC)
committer harlekin <harlekin>2002-06-24 21:05:01 (UTC)
commit67b1be897a8c02b70b6e0805ff0c5ae19146905c (patch) (unidiff)
tree02f0e45847959560f1912a06d31f5895618edc88 /core
parent2751bb111d21a5672c7caa7a6c2c45d14a642dbd (diff)
downloadopie-67b1be897a8c02b70b6e0805ff0c5ae19146905c.zip
opie-67b1be897a8c02b70b6e0805ff0c5ae19146905c.tar.gz
opie-67b1be897a8c02b70b6e0805ff0c5ae19146905c.tar.bz2
fixed a segfault if a device is discovered on opie start and added sounds
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp28
-rw-r--r--core/applets/irdaapplet/irda.h3
-rw-r--r--core/applets/irdaapplet/irdaapplet.pro31
-rw-r--r--core/applets/irdaapplet/opie-irdaapplet.control2
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
@@ -41,12 +41,13 @@
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>
@@ -61,18 +62,21 @@ IrdaApplet::IrdaApplet( QWidget *parent, const char *name )
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
72void IrdaApplet::show() {
73 QWidget::show();
74 startTimer(2000);
75}
76
73IrdaApplet::~IrdaApplet() { 77IrdaApplet::~IrdaApplet() {
74 close(sockfd); 78 close(sockfd);
75 if( popupMenu ) { delete popupMenu; } 79 if( popupMenu ) { delete popupMenu; }
76} 80}
77 81
78void IrdaApplet::popup(QString message, QString icon="") { 82void IrdaApplet::popup(QString message, QString icon="") {
@@ -203,35 +207,37 @@ void IrdaApplet::showDiscovered() {
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)" );
@@ -248,14 +254,13 @@ void IrdaApplet::mousePressEvent( QMouseEvent *) {
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();
@@ -313,15 +318,12 @@ void IrdaApplet::mousePressEvent( QMouseEvent *) {
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
326void IrdaApplet::timerEvent( QTimerEvent * ) { 328void IrdaApplet::timerEvent( QTimerEvent * ) {
327 int oldactive = irdaactive; 329 int oldactive = irdaactive;
@@ -346,13 +348,13 @@ void IrdaApplet::timerEvent( QTimerEvent * ) {
346 } 348 }
347 349
348} 350}
349 351
350void IrdaApplet::paintEvent( QPaintEvent* ) { 352void 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 );
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
@@ -44,12 +44,15 @@ private:
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
50public slots:
51 void show();
52
50private slots: 53private slots:
51 void popupTimeout(); 54 void popupTimeout();
52 55
53private: 56private:
54 QPixmap irdaOnPixmap; 57 QPixmap irdaOnPixmap;
55 QPixmap irdaOffPixmap; 58 QPixmap irdaOffPixmap;
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
@@ -6,20 +6,23 @@ TARGET = irdaapplet
6DESTDIR = $(OPIEDIR)/plugins/applets 6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../$(OPIEDIR)/include 8DEPENDPATH += ../$(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
10VERSION = 1.0.0 10VERSION = 1.0.0
11 11
12TRANSLATIONS = ../../i18n/de/libirdaapplet.ts 12
13TRANSLATIONS += ../../i18n/en/libirdaapplet.ts 13
14TRANSLATIONS += ../../i18n/es/libirdaapplet.ts 14TRANSLATIONS = ../../../i18n/de/libirdaapplet.ts
15TRANSLATIONS += ../../i18n/fr/libirdaapplet.ts 15TRANSLATIONS += ../../../i18n/en/libirdaapplet.ts
16TRANSLATIONS += ../../i18n/hu/libirdaapplet.ts 16TRANSLATIONS += ../../../i18n/es/libirdaapplet.ts
17TRANSLATIONS += ../../i18n/ja/libirdaapplet.ts 17TRANSLATIONS += ../../../i18n/fr/libirdaapplet.ts
18TRANSLATIONS += ../../i18n/ko/libirdaapplet.ts 18TRANSLATIONS += ../../../i18n/hu/libirdaapplet.ts
19TRANSLATIONS += ../../i18n/no/libirdaapplet.ts 19TRANSLATIONS += ../../../i18n/ja/libirdaapplet.ts
20TRANSLATIONS += ../../i18n/pl/libirdaapplet.ts 20TRANSLATIONS += ../../../i18n/ko/libirdaapplet.ts
21TRANSLATIONS += ../../i18n/pt/libirdaapplet.ts 21TRANSLATIONS += ../../../i18n/no/libirdaapplet.ts
22TRANSLATIONS += ../../i18n/pt_BR/libirdaapplet.ts 22TRANSLATIONS += ../../../i18n/pl/libirdaapplet.ts
23TRANSLATIONS += ../../i18n/sl/libirdaapplet.ts 23TRANSLATIONS += ../../../i18n/pt/libirdaapplet.ts
24TRANSLATIONS += ../../i18n/zh_CN/libirdaapplet.ts 24TRANSLATIONS += ../../../i18n/pt_BR/libirdaapplet.ts
25TRANSLATIONS += ../../i18n/zh_TW/libirdaapplet.ts 25TRANSLATIONS += ../../../i18n/sl/libirdaapplet.ts
26TRANSLATIONS += ../../../i18n/zh_CN/libirdaapplet.ts
27TRANSLATIONS += ../../../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,7 +1,7 @@
1Files: plugins/applets/libirdaapplet.so* pics/irdaapplet/* 1Files: plugins/applets/libirdaapplet.so* pics/irdaapplet/* sounds/irdaapplet/*.wav
2Priority: optional 2Priority: optional
3Section: opie/system 3Section: opie/system
4Maintainer: David Woodhouse <dwmw2@infradead.org> 4Maintainer: David Woodhouse <dwmw2@infradead.org>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION.1 6Version: $QPE_VERSION-$SUB_VERSION.1
7Depends: opie-base ($QPE_VERSION), libopieobex 7Depends: opie-base ($QPE_VERSION), libopieobex