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 /core/applets/irdaapplet/irda.cpp | |
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
Diffstat (limited to 'core/applets/irdaapplet/irda.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 24 |
1 files changed, 13 insertions, 11 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 | |||
@@ -45,4 +45,5 @@ | |||
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> |
@@ -65,10 +66,13 @@ IrdaApplet::IrdaApplet( QWidget *parent, const char *name ) | |||
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); |
@@ -207,13 +211,14 @@ void IrdaApplet::showDiscovered() { | |||
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 | } |
@@ -225,9 +230,10 @@ void IrdaApplet::showDiscovered() { | |||
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 | } |
@@ -253,5 +259,4 @@ void IrdaApplet::mousePressEvent( QMouseEvent *) { | |||
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() ) { |
@@ -317,7 +322,4 @@ void IrdaApplet::mousePressEvent( QMouseEvent *) { | |||
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 |
@@ -350,5 +352,5 @@ void IrdaApplet::timerEvent( QTimerEvent * ) { | |||
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() ); |