summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index d57104b..848ddb4 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -1,410 +1,410 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> 2** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org>
3** Max Reiss <harlekin@handhelds.org> [trivial stuff] 3** Max Reiss <harlekin@handhelds.org> [trivial stuff]
4** Robert Griebl <sandman@handhelds.org> 4** Robert Griebl <sandman@handhelds.org>
5** Holger Freyther <zecke@handhelds.org> QCOP Interface 5** Holger Freyther <zecke@handhelds.org> QCOP Interface
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15**********************************************************************/ 15**********************************************************************/
16 16
17#include "irda.h" 17#include "irda.h"
18 18
19/* OPIE */ 19/* OPIE */
20#include <opie2/oresource.h> 20#include <opie2/oresource.h>
21#include <opie2/otaskbarapplet.h> 21#include <opie2/otaskbarapplet.h>
22 22
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/ir.h> 25#include <qpe/ir.h>
26 26
27 27
28/* QT */ 28/* QT */
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qtimer.h> 31#include <qtimer.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33 33
34/* STD */ 34/* STD */
35#include <unistd.h> 35#include <unistd.h>
36#include <net/if.h> 36#include <net/if.h>
37#include <netinet/in.h> 37#include <netinet/in.h>
38#include <sys/types.h> 38#include <sys/types.h>
39#include <sys/socket.h> 39#include <sys/socket.h>
40#include <sys/ioctl.h> 40#include <sys/ioctl.h>
41 41
42//=========================================================================== 42//===========================================================================
43 43
44IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) : 44IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) :
45 QWidget ( parent, name ), 45 QWidget ( parent, name ),
46 m_irda_active( false ), 46 m_irda_active( false ),
47 m_irda_discovery_active( false ), 47 m_irda_discovery_active( false ),
48 m_receive_active( false ), 48 m_receive_active( false ),
49 m_receive_state_changed( false ), 49 m_receive_state_changed( false ),
50 m_popup( 0 ), 50 m_popup( 0 ),
51 m_wasOn( false ), 51 m_wasOn( false ),
52 m_wasDiscover( false ) 52 m_wasDiscover( false )
53{ 53{
54 setFixedHeight( AppLnk::smallIconSize() ); 54 setFixedHeight( AppLnk::smallIconSize() );
55 setFixedWidth( AppLnk::smallIconSize() ); 55 setFixedWidth( AppLnk::smallIconSize() );
56 56
57 if (m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ) == -1) 57 if ( ( m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ) ) == -1)
58 perror ( "failed grabbing IrDA socket" ); 58 perror ( "failed grabbing IrDA socket" );
59 59
60 m_irdaOnPixmap = 60 m_irdaOnPixmap =
61 Opie::Core::OResource::loadPixmap( "irdaapplet/irdaon", 61 Opie::Core::OResource::loadPixmap( "irdaapplet/irdaon",
62 Opie::Core::OResource::SmallIcon ); 62 Opie::Core::OResource::SmallIcon );
63 m_irdaOffPixmap = 63 m_irdaOffPixmap =
64 Opie::Core::OResource::loadPixmap( "irdaapplet/irdaoff", 64 Opie::Core::OResource::loadPixmap( "irdaapplet/irdaoff",
65 Opie::Core::OResource::SmallIcon ); 65 Opie::Core::OResource::SmallIcon );
66 m_irdaDiscoveryOnPixmap = 66 m_irdaDiscoveryOnPixmap =
67 Opie::Core::OResource::loadPixmap( "irdaapplet/magglass", 67 Opie::Core::OResource::loadPixmap( "irdaapplet/magglass",
68 Opie::Core::OResource::SmallIcon ); 68 Opie::Core::OResource::SmallIcon );
69 m_receiveActivePixmap = 69 m_receiveActivePixmap =
70 Opie::Core::OResource::loadPixmap( "irdaapplet/receive", 70 Opie::Core::OResource::loadPixmap( "irdaapplet/receive",
71 Opie::Core::OResource::SmallIcon ); 71 Opie::Core::OResource::SmallIcon );
72 72
73 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); 73 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this );
74 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), this, 74 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), this,
75 SLOT(slotMessage(const QCString&,const QByteArray&) ) ); 75 SLOT(slotMessage(const QCString&,const QByteArray&) ) );
76} 76}
77 77
78int IrdaApplet::position() 78int IrdaApplet::position()
79{ 79{
80 return 6; 80 return 6;
81} 81}
82 82
83void IrdaApplet::show() 83void IrdaApplet::show()
84{ 84{
85 QWidget::show ( ); 85 QWidget::show ( );
86 startTimer ( 2000 ); 86 startTimer ( 2000 );
87} 87}
88 88
89IrdaApplet::~IrdaApplet() 89IrdaApplet::~IrdaApplet()
90{ 90{
91 if ( m_sockfd >= 0 ) 91 if ( m_sockfd >= 0 )
92 ::close ( m_sockfd ); 92 ::close ( m_sockfd );
93} 93}
94 94
95void IrdaApplet::popup ( QString message, QString icon ) 95void IrdaApplet::popup ( QString message, QString icon )
96{ 96{
97 if ( !m_popup ) 97 if ( !m_popup )
98 m_popup = new QPopupMenu ( this ); 98 m_popup = new QPopupMenu ( this );
99 99
100 m_popup-> clear ( ); 100 m_popup-> clear ( );
101 101
102 if ( icon. isEmpty ( )) 102 if ( icon. isEmpty ( ))
103 m_popup-> insertItem ( message, 0 ); 103 m_popup-> insertItem ( message, 0 );
104 else 104 else
105 m_popup-> insertItem ( QIconSet ( 105 m_popup-> insertItem ( QIconSet (
106 Opie::Core::OResource::loadPixmap ( 106 Opie::Core::OResource::loadPixmap (
107 icon, 107 icon,
108 Opie::Core::OResource::SmallIcon 108 Opie::Core::OResource::SmallIcon
109 ) 109 )
110 ), 110 ),
111 message, 0 111 message, 0
112 ); 112 );
113 113
114 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 114 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
115 QSize s = m_popup-> sizeHint ( ); 115 QSize s = m_popup-> sizeHint ( );
116 m_popup-> popup ( QPoint ( 116 m_popup-> popup ( QPoint (
117 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), 117 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
118 p. y ( ) - s. height ( ) 118 p. y ( ) - s. height ( )
119 ) 119 )
120 ); 120 );
121 121
122 QTimer::singleShot ( 2000, this, SLOT( popupTimeout())); 122 QTimer::singleShot ( 2000, this, SLOT( popupTimeout()));
123} 123}
124 124
125void IrdaApplet::popupTimeout ( ) 125void IrdaApplet::popupTimeout ( )
126{ 126{
127 m_popup-> hide ( ); 127 m_popup-> hide ( );
128} 128}
129 129
130bool IrdaApplet::checkIrdaStatus ( ) 130bool IrdaApplet::checkIrdaStatus ( )
131{ 131{
132 struct ifreq ifr; 132 struct ifreq ifr;
133 strcpy ( ifr. ifr_name, "irda0" ); 133 strcpy ( ifr. ifr_name, "irda0" );
134 134
135 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) 135 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
136 return false; 136 return false;
137 137
138 return ( ifr. ifr_flags & IFF_UP ); 138 return ( ifr. ifr_flags & IFF_UP );
139} 139}
140 140
141bool IrdaApplet::setIrdaStatus ( bool b ) 141bool IrdaApplet::setIrdaStatus ( bool b )
142{ 142{
143 struct ifreq ifr; 143 struct ifreq ifr;
144 strcpy ( ifr. ifr_name, "irda0" ); 144 strcpy ( ifr. ifr_name, "irda0" );
145 145
146 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) 146 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
147 return false; 147 return false;
148 148
149 if ( b ) 149 if ( b )
150 ifr. ifr_flags |= IFF_UP; 150 ifr. ifr_flags |= IFF_UP;
151 else { 151 else {
152 setIrdaDiscoveryStatus ( 0 ); 152 setIrdaDiscoveryStatus ( 0 );
153 setIrdaReceiveStatus ( 0 ); 153 setIrdaReceiveStatus ( 0 );
154 ifr. ifr_flags &= ~IFF_UP; 154 ifr. ifr_flags &= ~IFF_UP;
155 } 155 }
156 156
157 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) 157 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 )
158 return false; 158 return false;
159 159
160 return true; 160 return true;
161} 161}
162 162
163bool IrdaApplet::checkIrdaDiscoveryStatus ( ) 163bool IrdaApplet::checkIrdaDiscoveryStatus ( )
164{ 164{
165 QFile discovery ( "/proc/sys/net/irda/discovery" ); 165 QFile discovery ( "/proc/sys/net/irda/discovery" );
166 166
167 QString streamIn = "0"; 167 QString streamIn = "0";
168 168
169 if ( discovery. open ( IO_ReadOnly )) { 169 if ( discovery. open ( IO_ReadOnly )) {
170 QTextStream stream ( &discovery ); 170 QTextStream stream ( &discovery );
171 streamIn = stream. read ( ); 171 streamIn = stream. read ( );
172 } 172 }
173 173
174 return streamIn. toInt ( ) > 0; 174 return streamIn. toInt ( ) > 0;
175} 175}
176 176
177 177
178bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) 178bool IrdaApplet::setIrdaDiscoveryStatus ( bool d )
179{ 179{
180 QFile discovery ( "/proc/sys/net/irda/discovery" ); 180 QFile discovery ( "/proc/sys/net/irda/discovery" );
181 181
182 if ( discovery. open ( IO_WriteOnly | IO_Raw )) { 182 if ( discovery. open ( IO_WriteOnly | IO_Raw )) {
183 discovery.putch ( d ? '1' : '0' ); 183 discovery.putch ( d ? '1' : '0' );
184 return true; 184 return true;
185 } 185 }
186 return false; 186 return false;
187} 187}
188 188
189 189
190bool IrdaApplet::setIrdaReceiveStatus ( bool d ) 190bool IrdaApplet::setIrdaReceiveStatus ( bool d )
191{ 191{
192 QCopEnvelope e ( "QPE/Obex", "receive(int)" ); 192 QCopEnvelope e ( "QPE/Obex", "receive(int)" );
193 e << ( d ? 1 : 0 ); 193 e << ( d ? 1 : 0 );
194 194
195 m_receive_active = d; 195 m_receive_active = d;
196 m_receive_state_changed = true; 196 m_receive_state_changed = true;
197 197
198 return true; 198 return true;
199} 199}
200 200
201 201
202void IrdaApplet::showDiscovered ( ) 202void IrdaApplet::showDiscovered ( )
203{ 203{
204 //static Sound snd_found ( "irdaapplet/irdaon" ); 204 //static Sound snd_found ( "irdaapplet/irdaon" );
205 //static Sound snd_lost ( "irdaapplet/irdaoff" ); 205 //static Sound snd_lost ( "irdaapplet/irdaoff" );
206 206
207 QFile discovery ( "/proc/net/irda/discovery" ); 207 QFile discovery ( "/proc/net/irda/discovery" );
208 208
209 if ( discovery. open ( IO_ReadOnly )) { 209 if ( discovery. open ( IO_ReadOnly )) {
210 bool qcopsend = false; 210 bool qcopsend = false;
211 211
212 QString discoveredDevice; 212 QString discoveredDevice;
213 QString deviceAddr; 213 QString deviceAddr;
214 214
215 /*! 215 /*!
216 * @note To read /proc, it makes more sense to use QTextStream. 216 * @note To read /proc, it makes more sense to use QTextStream.
217 */ 217 */
218 QStringList list = 218 QStringList list =
219 QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); 219 QStringList::split ( "\n", QTextStream ( &discovery ). read ( ));
220 220
221 QMap <QString, QString>::Iterator it; 221 QMap <QString, QString>::Iterator it;
222 222
223 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) 223 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it )
224 it. data ( ). prepend ( "+++" ); 224 it. data ( ). prepend ( "+++" );
225 225
226 for ( QStringList::Iterator lit = list. begin ( ); 226 for ( QStringList::Iterator lit = list. begin ( );
227 lit != list. end ( ); ++lit 227 lit != list. end ( ); ++lit
228 ) 228 )
229 { 229 {
230 const QString &line = *lit; 230 const QString &line = *lit;
231 231
232 if ( line. startsWith ( "nickname:" )) { 232 if ( line. startsWith ( "nickname:" )) {
233 discoveredDevice = 233 discoveredDevice =
234 line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - 234 line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) -
235 line. find ( ':' ) - 2 ); 235 line. find ( ':' ) - 2 );
236 deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); 236 deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 );
237 237
238 // odebug << discoveredDevice + "(" + deviceAddr + ")" << oendl; 238 // odebug << discoveredDevice + "(" + deviceAddr + ")" << oendl;
239 239
240 if ( !m_devices. contains ( deviceAddr )) { 240 if ( !m_devices. contains ( deviceAddr )) {
241 popup ( tr( "Found:" ) + " " + discoveredDevice ); 241 popup ( tr( "Found:" ) + " " + discoveredDevice );
242 //snd_found. play ( ); 242 //snd_found. play ( );
243 qcopsend = true; 243 qcopsend = true;
244 } 244 }
245 m_devices. replace ( deviceAddr, discoveredDevice ); 245 m_devices. replace ( deviceAddr, discoveredDevice );
246 } 246 }
247 } 247 }
248 248
249 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { 249 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) {
250 // odebug << "IrdaMon: delete " + it.currentKey() + "=" + 250 // odebug << "IrdaMon: delete " + it.currentKey() + "=" +
251 // *devicesAvailable[it.currentKey()] + "?" << oendl; 251 // *devicesAvailable[it.currentKey()] + "?" << oendl;
252 252
253 if ( it. data ( ). left ( 3 ) == "+++" ) { 253 if ( it. data ( ). left ( 3 ) == "+++" ) {
254 popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); 254 popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 ));
255 //snd_lost. play ( ); 255 //snd_lost. play ( );
256 256
257 QMap <QString, QString>::Iterator tmp = it; 257 QMap <QString, QString>::Iterator tmp = it;
258 tmp++; 258 tmp++;
259 m_devices. remove ( it ); 259 m_devices. remove ( it );
260 ///< @note In contrast to QValueListIterator this remove doesn't 260 ///< @note In contrast to QValueListIterator this remove doesn't
261 ///< return the next Iterator 261 ///< return the next Iterator
262 262
263 it = tmp; 263 it = tmp;
264 qcopsend = true; 264 qcopsend = true;
265 } else 265 } else
266 it++; 266 it++;
267 } 267 }
268 // XXX if( qcopsend ) { 268 // XXX if( qcopsend ) {
269 QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); 269 QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" );
270 e << ( m_devices. count ( ) > 0 ); 270 e << ( m_devices. count ( ) > 0 );
271 // } 271 // }
272 } 272 }
273} 273}
274 274
275void IrdaApplet::mousePressEvent ( QMouseEvent * ) 275void IrdaApplet::mousePressEvent ( QMouseEvent * )
276{ 276{
277 QPopupMenu *menu = new QPopupMenu ( this ); 277 QPopupMenu *menu = new QPopupMenu ( this );
278 QString cmd; 278 QString cmd;
279 279
280 /* Refresh active state */ 280 /* Refresh active state */
281 timerEvent ( 0 ); 281 timerEvent ( 0 );
282 282
283 //menu->insertItem( tr("More..."), 4 ); 283 //menu->insertItem( tr("More..."), 4 );
284 284
285 if ( m_irda_active && !m_devices. isEmpty ( )) { 285 if ( m_irda_active && !m_devices. isEmpty ( )) {
286 menu-> insertItem ( tr( "Discovered Device:" ), 9 ); 286 menu-> insertItem ( tr( "Discovered Device:" ), 9 );
287 287
288 for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); 288 for ( QMap<QString, QString>::Iterator it = m_devices. begin ( );
289 it != m_devices. end ( ); ++it ) 289 it != m_devices. end ( ); ++it )
290 { 290 {
291 menu-> insertItem ( *it ); 291 menu-> insertItem ( *it );
292 } 292 }
293 293
294 menu-> insertSeparator ( ); 294 menu-> insertSeparator ( );
295 } 295 }
296 296
297 menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); 297 menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 );
298 298
299 if ( m_irda_active ) { 299 if ( m_irda_active ) {
300 menu-> insertItem ( 300 menu-> insertItem (
301 m_irda_discovery_active ? tr( "Disable Discovery" ) : 301 m_irda_discovery_active ? tr( "Disable Discovery" ) :
302 tr( "Enable Discovery" ), 1 302 tr( "Enable Discovery" ), 1
303 ); 303 );
304 304
305 /* Only Receive if OBEX is installed */ 305 /* Only Receive if OBEX is installed */
306 if( Ir::supported() ) 306 if( Ir::supported() )
307 menu-> insertItem ( 307 menu-> insertItem (
308 m_receive_active ? tr( "Disable Receive" ) : 308 m_receive_active ? tr( "Disable Receive" ) :
309 tr( "Enable Receive" ), 2 309 tr( "Enable Receive" ), 2
310 ); 310 );
311 } 311 }
312 312
313 QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); 313 QPoint p = mapToGlobal ( QPoint ( 0, 0 ) );
314 QSize s = menu-> sizeHint ( ); 314 QSize s = menu-> sizeHint ( );
315 315
316 p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - 316 p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) -
317 s. height ( )); 317 s. height ( ));
318 318
319 switch ( menu-> exec ( p )) { 319 switch ( menu-> exec ( p )) {
320 case 0: 320 case 0:
321 setIrdaStatus ( !m_irda_active ); 321 setIrdaStatus ( !m_irda_active );
322 timerEvent ( 0 ); 322 timerEvent ( 0 );
323 break; 323 break;
324 case 1: 324 case 1:
325 setIrdaDiscoveryStatus ( !m_irda_discovery_active ); 325 setIrdaDiscoveryStatus ( !m_irda_discovery_active );
326 timerEvent ( 0 ); 326 timerEvent ( 0 );
327 break; 327 break;
328 case 2: 328 case 2:
329 setIrdaReceiveStatus ( !m_receive_active ); 329 setIrdaReceiveStatus ( !m_receive_active );
330 timerEvent( 0 ); 330 timerEvent( 0 );
331 break; 331 break;
332 } 332 }
333 333
334 delete menu; 334 delete menu;
335} 335}
336 336
337void IrdaApplet::timerEvent ( QTimerEvent * ) 337void IrdaApplet::timerEvent ( QTimerEvent * )
338{ 338{
339 bool oldactive = m_irda_active; 339 bool oldactive = m_irda_active;
340 bool olddiscovery = m_irda_discovery_active; 340 bool olddiscovery = m_irda_discovery_active;
341 bool receiveUpdate = false; 341 bool receiveUpdate = false;
342 342
343 if ( m_receive_state_changed ) { 343 if ( m_receive_state_changed ) {
344 receiveUpdate = true; 344 receiveUpdate = true;
345 m_receive_state_changed = false; 345 m_receive_state_changed = false;
346 } 346 }
347 347
348 m_irda_active = checkIrdaStatus ( ); 348 m_irda_active = checkIrdaStatus ( );
349 m_irda_discovery_active = checkIrdaDiscoveryStatus ( ); 349 m_irda_discovery_active = checkIrdaDiscoveryStatus ( );
350 350
351 if ( m_irda_discovery_active ) 351 if ( m_irda_discovery_active )
352 showDiscovered ( ); 352 showDiscovered ( );
353 353
354 if (( m_irda_active != oldactive ) || 354 if (( m_irda_active != oldactive ) ||
355 ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) 355 ( m_irda_discovery_active != olddiscovery ) || receiveUpdate )
356 { 356 {
357 update ( ); 357 update ( );
358 } 358 }
359} 359}
360 360
361void IrdaApplet::paintEvent ( QPaintEvent * ) 361void IrdaApplet::paintEvent ( QPaintEvent * )
362{ 362{
363 QPainter p( this ); 363 QPainter p( this );
364 364
365 p.drawPixmap( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap ); 365 p.drawPixmap( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap );
366 366
367 if ( m_irda_discovery_active ) 367 if ( m_irda_discovery_active )
368 p.drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap ); 368 p.drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap );
369 369
370 if ( m_receive_active ) 370 if ( m_receive_active )
371 p.drawPixmap( 0, 1, m_receiveActivePixmap ); 371 p.drawPixmap( 0, 1, m_receiveActivePixmap );
372} 372}
373 373
374/*! 374/*!
375 * We recognize 3 events: 375 * We recognize 3 events:
376 * - enable: Attempt to enable the IrDA device 376 * - enable: Attempt to enable the IrDA device
377 * - disable: Attempt to disable the IrDA device if it was already enabled 377 * - disable: Attempt to disable the IrDA device if it was already enabled
378 * - listDevices: Returns a list of known IrDA devices 378 * - listDevices: Returns a list of known IrDA devices
379 */ 379 */
380void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ) { 380void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ) {
381 if ( str == "enableIrda()") { 381 if ( str == "enableIrda()") {
382 m_wasOn = checkIrdaStatus(); 382 m_wasOn = checkIrdaStatus();
383 m_wasDiscover = checkIrdaDiscoveryStatus(); 383 m_wasDiscover = checkIrdaDiscoveryStatus();
384 if (!m_wasOn) { 384 if (!m_wasOn) {
385 setIrdaStatus( true ); 385 setIrdaStatus( true );
386 } 386 }
387 if ( !m_wasDiscover ) { 387 if ( !m_wasDiscover ) {
388 setIrdaDiscoveryStatus ( true ); 388 setIrdaDiscoveryStatus ( true );
389 } 389 }
390 } else if ( str == "disableIrda()") { 390 } else if ( str == "disableIrda()") {
391 if (!m_wasOn) { 391 if (!m_wasOn) {
392 setIrdaStatus( false ); 392 setIrdaStatus( false );
393 } 393 }
394 if ( !m_wasDiscover ) { 394 if ( !m_wasDiscover ) {
395 setIrdaDiscoveryStatus ( false ); 395 setIrdaDiscoveryStatus ( false );
396 } 396 }
397 } else if ( str == "listDevices()") { 397 } else if ( str == "listDevices()") {
398 QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)"); 398 QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)");
399 399
400 QStringList list; 400 QStringList list;
401 QMap<QString, QString>::Iterator it; 401 QMap<QString, QString>::Iterator it;
402 for (it = m_devices.begin(); it != m_devices.end(); ++it ) 402 for (it = m_devices.begin(); it != m_devices.end(); ++it )
403 list << (*it); 403 list << (*it);
404 404
405 e << list; 405 e << list;
406 } 406 }
407} 407}
408 408
409EXPORT_OPIE_APPLET_v1( IrdaApplet ) 409EXPORT_OPIE_APPLET_v1( IrdaApplet )
410 410