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,153 +1,153 @@
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 );