summaryrefslogtreecommitdiff
authorerik <erik>2007-03-06 01:25:46 (UTC)
committer erik <erik>2007-03-06 01:25:46 (UTC)
commitf6b4fc71812aa4db9c7209e28667010d1f04d771 (patch) (unidiff)
tree77bc5b50326ba2d525684eaf46b671b82defcf3c
parent3efe70df6fdaf32a8213ceadbdd1679a0a658934 (diff)
downloadopie-f6b4fc71812aa4db9c7209e28667010d1f04d771.zip
opie-f6b4fc71812aa4db9c7209e28667010d1f04d771.tar.gz
opie-f6b4fc71812aa4db9c7209e28667010d1f04d771.tar.bz2
Reworked to fit into the Opie style guidelines.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp134
-rw-r--r--core/applets/irdaapplet/irda.h6
2 files changed, 89 insertions, 51 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index cea836e..d57104b 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -43,4 +43,11 @@
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 ),
47 m_irda_discovery_active( false ),
48 m_receive_active( false ),
49 m_receive_state_changed( false ),
50 m_popup( 0 ),
51 m_wasOn( false ),
52 m_wasDiscover( false )
46{ 53{
@@ -49,20 +56,21 @@ IrdaApplet::IrdaApplet ( QWidget *parent, const char *name )
49 56
50 m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); 57 if (m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ) == -1)
51 58 perror ( "failed grabbing IrDA socket" );
52 m_irdaOnPixmap = Opie::Core::OResource::loadPixmap( "irdaapplet/irdaon", Opie::Core::OResource::SmallIcon ); 59
53 m_irdaOffPixmap = Opie::Core::OResource::loadPixmap( "irdaapplet/irdaoff", Opie::Core::OResource::SmallIcon ); 60 m_irdaOnPixmap =
54 m_irdaDiscoveryOnPixmap = Opie::Core::OResource::loadPixmap( "irdaapplet/magglass", Opie::Core::OResource::SmallIcon ); 61 Opie::Core::OResource::loadPixmap( "irdaapplet/irdaon",
55 m_receiveActivePixmap = Opie::Core::OResource::loadPixmap( "irdaapplet/receive", Opie::Core::OResource::SmallIcon ); 62 Opie::Core::OResource::SmallIcon );
56 63 m_irdaOffPixmap =
57 m_irda_active = false; 64 Opie::Core::OResource::loadPixmap( "irdaapplet/irdaoff",
58 m_irda_discovery_active = false; 65 Opie::Core::OResource::SmallIcon );
59 m_receive_active = false; 66 m_irdaDiscoveryOnPixmap =
60 m_receive_state_changed = false; 67 Opie::Core::OResource::loadPixmap( "irdaapplet/magglass",
61 m_popup = 0; 68 Opie::Core::OResource::SmallIcon );
62 m_wasOn = false; 69 m_receiveActivePixmap =
63 m_wasDiscover = false; 70 Opie::Core::OResource::loadPixmap( "irdaapplet/receive",
71 Opie::Core::OResource::SmallIcon );
64 72
65 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); 73 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this );
66 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), 74 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), this,
67 this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); 75 SLOT(slotMessage(const QCString&,const QByteArray&) ) );
68} 76}
@@ -96,4 +104,10 @@ void IrdaApplet::popup ( QString message, QString icon )
96 else 104 else
97 m_popup-> insertItem ( QIconSet ( Opie::Core::OResource::loadPixmap ( icon, Opie::Core::OResource::SmallIcon )), 105 m_popup-> insertItem ( QIconSet (
98 message, 0 ); 106 Opie::Core::OResource::loadPixmap (
107 icon,
108 Opie::Core::OResource::SmallIcon
109 )
110 ),
111 message, 0
112 );
99 113
@@ -101,4 +115,7 @@ void IrdaApplet::popup ( QString message, QString icon )
101 QSize s = m_popup-> sizeHint ( ); 115 QSize s = m_popup-> sizeHint ( );
102 m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), 116 m_popup-> popup ( QPoint (
103 p. y ( ) - s. height ( ))); 117 p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
118 p. y ( ) - s. height ( )
119 )
120 );
104 121
@@ -117,3 +134,3 @@ bool IrdaApplet::checkIrdaStatus ( )
117 134
118 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) 135 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
119 return false; 136 return false;
@@ -128,8 +145,7 @@ bool IrdaApplet::setIrdaStatus ( bool b )
128 145
129 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) 146 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
130 return false; 147 return false;
131 148
132 if ( b ) { 149 if ( b )
133 ifr. ifr_flags |= IFF_UP; 150 ifr. ifr_flags |= IFF_UP;
134 }
135 else { 151 else {
@@ -140,3 +156,3 @@ bool IrdaApplet::setIrdaStatus ( bool b )
140 156
141 if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) 157 if ( m_sockfd < 0 || ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 )
142 return false; 158 return false;
@@ -198,4 +214,7 @@ void IrdaApplet::showDiscovered ( )
198 214
199 // since it is /proc we _must_ use QTextStream 215 /*!
200 QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); 216 * @note To read /proc, it makes more sense to use QTextStream.
217 */
218 QStringList list =
219 QStringList::split ( "\n", QTextStream ( &discovery ). read ( ));
201 220
@@ -206,3 +225,6 @@ void IrdaApplet::showDiscovered ( )
206 225
207 for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { 226 for ( QStringList::Iterator lit = list. begin ( );
227 lit != list. end ( ); ++lit
228 )
229 {
208 const QString &line = *lit; 230 const QString &line = *lit;
@@ -210,3 +232,5 @@ void IrdaApplet::showDiscovered ( )
210 if ( line. startsWith ( "nickname:" )) { 232 if ( line. startsWith ( "nickname:" )) {
211 discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); 233 discoveredDevice =
234 line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) -
235 line. find ( ':' ) - 2 );
212 deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); 236 deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 );
@@ -225,3 +249,4 @@ void IrdaApplet::showDiscovered ( )
225 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { 249 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) {
226 // odebug << "IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?" << oendl; 250 // odebug << "IrdaMon: delete " + it.currentKey() + "=" +
251 // *devicesAvailable[it.currentKey()] + "?" << oendl;
227 252
@@ -233,8 +258,9 @@ void IrdaApplet::showDiscovered ( )
233 tmp++; 258 tmp++;
234 m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator 259 m_devices. remove ( it );
235 it = tmp; 260 ///< @note In contrast to QValueListIterator this remove doesn't
261 ///< return the next Iterator
236 262
263 it = tmp;
237 qcopsend = true; 264 qcopsend = true;
238 } 265 } else
239 else
240 it++; 266 it++;
@@ -261,4 +287,7 @@ void IrdaApplet::mousePressEvent ( QMouseEvent * )
261 287
262 for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) 288 for ( QMap<QString, QString>::Iterator it = m_devices. begin ( );
289 it != m_devices. end ( ); ++it )
290 {
263 menu-> insertItem ( *it ); 291 menu-> insertItem ( *it );
292 }
264 293
@@ -270,3 +299,6 @@ void IrdaApplet::mousePressEvent ( QMouseEvent * )
270 if ( m_irda_active ) { 299 if ( m_irda_active ) {
271 menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); 300 menu-> insertItem (
301 m_irda_discovery_active ? tr( "Disable Discovery" ) :
302 tr( "Enable Discovery" ), 1
303 );
272 304
@@ -274,3 +306,6 @@ void IrdaApplet::mousePressEvent ( QMouseEvent * )
274 if( Ir::supported() ) 306 if( Ir::supported() )
275 menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); 307 menu-> insertItem (
308 m_receive_active ? tr( "Disable Receive" ) :
309 tr( "Enable Receive" ), 2
310 );
276 } 311 }
@@ -280,3 +315,4 @@ void IrdaApplet::mousePressEvent ( QMouseEvent * )
280 315
281 p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); 316 p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) -
317 s. height ( ));
282 318
@@ -317,5 +353,8 @@ void IrdaApplet::timerEvent ( QTimerEvent * )
317 353
318 if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) 354 if (( m_irda_active != oldactive ) ||
355 ( m_irda_discovery_active != olddiscovery ) || receiveUpdate )
356 {
319 update ( ); 357 update ( );
320} 358}
359}
321 360
@@ -333,8 +372,8 @@ void IrdaApplet::paintEvent ( QPaintEvent * )
333} 372}
334/* 373
335 * We know 3 calls 374/*!
336 * a) enable 375 * We recognize 3 events:
337 * b) disable 376 * - enable: Attempt to enable the IrDA device
338 * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on 377 * - disable: Attempt to disable the IrDA device if it was already enabled
339 * c) listDevices: We will return a list of known devices 378 * - listDevices: Returns a list of known IrDA devices
340 */ 379 */
@@ -370 +409,2 @@ void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ) {
370EXPORT_OPIE_APPLET_v1( IrdaApplet ) 409EXPORT_OPIE_APPLET_v1( IrdaApplet )
410
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h
index f713bbe..2cbf4f7 100644
--- a/core/applets/irdaapplet/irda.h
+++ b/core/applets/irdaapplet/irda.h
@@ -54,3 +54,2 @@ private:
54 54
55private:
56 QPixmap m_irdaOnPixmap; 55 QPixmap m_irdaOnPixmap;
@@ -71,7 +70,6 @@ private:
71 70
72 bool m_wasOn; // if IrDa was enabled 71 bool m_wasOn; ///< If IrDA was enabled this is true
73 bool m_wasDiscover; 72 bool m_wasDiscover;
74}; 73};
75
76
77#endif // __OPIE_IRDA_APPLET_H__ 74#endif // __OPIE_IRDA_APPLET_H__
75