summaryrefslogtreecommitdiff
path: root/core/applets/irdaapplet/irda.cpp
Unidiff
Diffstat (limited to 'core/applets/irdaapplet/irda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index afc0592..dde8050 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -15,134 +15,134 @@
15**********************************************************************/ 15**********************************************************************/
16 16
17#include "irda.h" 17#include "irda.h"
18 18
19/* OPIE */ 19/* OPIE */
20#include <opie2/otaskbarapplet.h> 20#include <opie2/otaskbarapplet.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23 23
24/* QT */ 24/* QT */
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qtextstream.h> 28#include <qtextstream.h>
29 29
30/* STD */ 30/* STD */
31#include <unistd.h> 31#include <unistd.h>
32#include <net/if.h> 32#include <net/if.h>
33#include <netinet/in.h> 33#include <netinet/in.h>
34#include <sys/types.h> 34#include <sys/types.h>
35#include <sys/socket.h> 35#include <sys/socket.h>
36#include <sys/ioctl.h> 36#include <sys/ioctl.h>
37 37
38//=========================================================================== 38//===========================================================================
39 39
40IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) 40IrdaApplet::IrdaApplet ( QWidget *parent, const char *name )
41 : QWidget ( parent, name ) 41 : QWidget ( parent, name )
42{ 42{
43 setFixedHeight ( 18 ); 43 setFixedHeight ( 18 );
44 setFixedWidth ( 14 ); 44 setFixedWidth ( 14 );
45 45
46 m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); 46 m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP );
47 47
48 m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); 48 m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" );
49 m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); 49 m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" );
50 m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); 50 m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" );
51 m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); 51 m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" );
52 52
53 m_irda_active = false; 53 m_irda_active = false;
54 m_irda_discovery_active = false; 54 m_irda_discovery_active = false;
55 m_receive_active = false; 55 m_receive_active = false;
56 m_receive_state_changed = false; 56 m_receive_state_changed = false;
57 m_popup = 0; 57 m_popup = 0;
58 m_wasOn = false; 58 m_wasOn = false;
59 m_wasDiscover = false; 59 m_wasDiscover = false;
60 60
61 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); 61 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this );
62 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), 62 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
63 this, SLOT(slotMessage(const QCString&, const QByteArray& ) ) ); 63 this, SLOT(slotMessage(const QCString&,const QByteArray&) ) );
64} 64}
65 65
66int IrdaApplet::position() 66int IrdaApplet::position()
67{ 67{
68 return 6; 68 return 6;
69} 69}
70 70
71void IrdaApplet::show() 71void IrdaApplet::show()
72{ 72{
73 QWidget::show ( ); 73 QWidget::show ( );
74 startTimer ( 2000 ); 74 startTimer ( 2000 );
75} 75}
76 76
77IrdaApplet::~IrdaApplet() 77IrdaApplet::~IrdaApplet()
78{ 78{
79 if ( m_sockfd >= 0 ) 79 if ( m_sockfd >= 0 )
80 ::close ( m_sockfd ); 80 ::close ( m_sockfd );
81} 81}
82 82
83void IrdaApplet::popup ( QString message, QString icon ) 83void IrdaApplet::popup ( QString message, QString icon )
84{ 84{
85 if ( !m_popup ) 85 if ( !m_popup )
86 m_popup = new QPopupMenu ( this ); 86 m_popup = new QPopupMenu ( this );
87 87
88 m_popup-> clear ( ); 88 m_popup-> clear ( );
89 89
90 if ( icon. isEmpty ( )) 90 if ( icon. isEmpty ( ))
91 m_popup-> insertItem ( message, 0 ); 91 m_popup-> insertItem ( message, 0 );
92 else 92 else
93 m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); 93 m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 );
94 94
95 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 95 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
96 QSize s = m_popup-> sizeHint ( ); 96 QSize s = m_popup-> sizeHint ( );
97 m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), 97 m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
98 p. y ( ) - s. height ( ))); 98 p. y ( ) - s. height ( )));
99 99
100 QTimer::singleShot ( 2000, this, SLOT( popupTimeout ( ))); 100 QTimer::singleShot ( 2000, this, SLOT( popupTimeout()));
101} 101}
102 102
103void IrdaApplet::popupTimeout ( ) 103void IrdaApplet::popupTimeout ( )
104{ 104{
105 m_popup-> hide ( ); 105 m_popup-> hide ( );
106} 106}
107 107
108bool IrdaApplet::checkIrdaStatus ( ) 108bool IrdaApplet::checkIrdaStatus ( )
109{ 109{
110 struct ifreq ifr; 110 struct ifreq ifr;
111 strcpy ( ifr. ifr_name, "irda0" ); 111 strcpy ( ifr. ifr_name, "irda0" );
112 112
113 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) 113 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
114 return false; 114 return false;
115 115
116 return ( ifr. ifr_flags & IFF_UP ); 116 return ( ifr. ifr_flags & IFF_UP );
117} 117}
118 118
119bool IrdaApplet::setIrdaStatus ( bool b ) 119bool IrdaApplet::setIrdaStatus ( bool b )
120{ 120{
121 struct ifreq ifr; 121 struct ifreq ifr;
122 strcpy ( ifr. ifr_name, "irda0" ); 122 strcpy ( ifr. ifr_name, "irda0" );
123 123
124 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) 124 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
125 return false; 125 return false;
126 126
127 if ( b ) { 127 if ( b ) {
128 ifr. ifr_flags |= IFF_UP; 128 ifr. ifr_flags |= IFF_UP;
129 } 129 }
130 else { 130 else {
131 setIrdaDiscoveryStatus ( 0 ); 131 setIrdaDiscoveryStatus ( 0 );
132 setIrdaReceiveStatus ( 0 ); 132 setIrdaReceiveStatus ( 0 );
133 ifr. ifr_flags &= ~IFF_UP; 133 ifr. ifr_flags &= ~IFF_UP;
134 } 134 }
135 135
136 if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) 136 if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 )
137 return false; 137 return false;
138 138
139 return true; 139 return true;
140} 140}
141 141
142bool IrdaApplet::checkIrdaDiscoveryStatus ( ) 142bool IrdaApplet::checkIrdaDiscoveryStatus ( )
143{ 143{
144 QFile discovery ( "/proc/sys/net/irda/discovery" ); 144 QFile discovery ( "/proc/sys/net/irda/discovery" );
145 145
146 QString streamIn = "0"; 146 QString streamIn = "0";
147 147
148 if ( discovery. open ( IO_ReadOnly )) { 148 if ( discovery. open ( IO_ReadOnly )) {