-rw-r--r-- | core/applets/irdaapplet/.cvsignore | 3 | ||||
-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 159 | ||||
-rw-r--r-- | core/applets/irdaapplet/irda.h | 57 | ||||
-rw-r--r-- | core/applets/irdaapplet/irdaapplet.pro | 11 | ||||
-rw-r--r-- | core/applets/irdaapplet/irdaappletimpl.cpp | 64 | ||||
-rw-r--r-- | core/applets/irdaapplet/irdaappletimpl.h | 44 | ||||
-rw-r--r-- | core/applets/irdaapplet/opie-irdaapplet.control | 9 | ||||
-rw-r--r-- | pics/irdaapplet/irdaoff.png | bin | 0 -> 272 bytes | |||
-rw-r--r-- | pics/irdaapplet/irdaon.png | bin | 0 -> 258 bytes |
9 files changed, 347 insertions, 0 deletions
diff --git a/core/applets/irdaapplet/.cvsignore b/core/applets/irdaapplet/.cvsignore new file mode 100644 index 0000000..2c33e73 --- a/dev/null +++ b/core/applets/irdaapplet/.cvsignore | |||
@@ -0,0 +1,3 @@ | |||
1 | moc_* | ||
2 | *.moc | ||
3 | Makefile* | ||
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp new file mode 100644 index 0000000..2eff2a9 --- a/dev/null +++ b/core/applets/irdaapplet/irda.cpp | |||
@@ -0,0 +1,159 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> | ||
3 | ** Heavily based on volumeapplet, (C) 2002 L.J. Potter ljp@llornkcor.com | ||
4 | ** All rights reserved. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "irda.h" | ||
17 | #include <qapplication.h> | ||
18 | #include <stdlib.h> | ||
19 | |||
20 | |||
21 | #include <qpe/resource.h> | ||
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qpe/timestring.h> | ||
24 | #include <qpe/resource.h> | ||
25 | #include <qpe/config.h> | ||
26 | #include <qpe/applnk.h> | ||
27 | #include <qpe/config.h> | ||
28 | |||
29 | #include <qdir.h> | ||
30 | #include <qfileinfo.h> | ||
31 | #include <qpoint.h> | ||
32 | #include <qpushbutton.h> | ||
33 | #include <qpainter.h> | ||
34 | #include <qcombobox.h> | ||
35 | #include <qspinbox.h> | ||
36 | #include <qslider.h> | ||
37 | #include <qlayout.h> | ||
38 | #include <qframe.h> | ||
39 | #include <qpixmap.h> | ||
40 | #include <qstring.h> | ||
41 | #include <qfile.h> | ||
42 | #include <qtimer.h> | ||
43 | #include <qpopupmenu.h> | ||
44 | |||
45 | #include <net/if.h> | ||
46 | #include <netinet/in.h> | ||
47 | #include <sys/types.h> | ||
48 | #include <sys/socket.h> | ||
49 | #include <sys/ioctl.h> | ||
50 | |||
51 | |||
52 | //=========================================================================== | ||
53 | |||
54 | IrdaApplet::IrdaApplet( QWidget *parent, const char *name ) | ||
55 | : QWidget( parent, name ) | ||
56 | { | ||
57 | setFixedHeight( 18 ); | ||
58 | setFixedWidth( 14 ); | ||
59 | sockfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); | ||
60 | irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); | ||
61 | irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); | ||
62 | startTimer(5000); | ||
63 | timerEvent(NULL); | ||
64 | } | ||
65 | |||
66 | IrdaApplet::~IrdaApplet() | ||
67 | { | ||
68 | close(sockfd); | ||
69 | } | ||
70 | |||
71 | int IrdaApplet::checkIrdaStatus() | ||
72 | { | ||
73 | struct ifreq ifr; | ||
74 | |||
75 | strcpy(ifr.ifr_name, "irda0"); | ||
76 | |||
77 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr)) | ||
78 | return -1; | ||
79 | |||
80 | return (ifr.ifr_flags & IFF_UP)?1:0; | ||
81 | } | ||
82 | |||
83 | int IrdaApplet::setIrdaStatus(int c) | ||
84 | { | ||
85 | struct ifreq ifr; | ||
86 | |||
87 | strcpy(ifr.ifr_name, "irda0"); | ||
88 | |||
89 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr)) | ||
90 | return -1; | ||
91 | |||
92 | if (c) | ||
93 | ifr.ifr_flags |= IFF_UP; | ||
94 | else | ||
95 | ifr.ifr_flags &= ~IFF_UP; | ||
96 | |||
97 | if (ioctl(sockfd, SIOCSIFFLAGS, &ifr)) | ||
98 | return -1; | ||
99 | |||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | void IrdaApplet::mousePressEvent( QMouseEvent *) | ||
104 | { | ||
105 | QPopupMenu *menu = new QPopupMenu(); | ||
106 | QString cmd; | ||
107 | int ret=0; | ||
108 | |||
109 | /* Refresh active state */ | ||
110 | timerEvent(NULL); | ||
111 | |||
112 | //menu->insertItem( tr("More..."), 2 ); | ||
113 | if (irdaactive) | ||
114 | menu->insertItem( tr("Disable IrDA"), 0 ); | ||
115 | else | ||
116 | menu->insertItem( tr("Enable IrDA"), 1 ); | ||
117 | |||
118 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); | ||
119 | ret = menu->exec(p, 1); | ||
120 | |||
121 | qDebug("ret was %d\n", ret); | ||
122 | |||
123 | switch(ret) { | ||
124 | case 0: | ||
125 | setIrdaStatus(0); | ||
126 | timerEvent(NULL); | ||
127 | break; | ||
128 | case 1: | ||
129 | setIrdaStatus(1); | ||
130 | timerEvent(NULL); | ||
131 | break; | ||
132 | case 2: | ||
133 | qDebug("FIXME: Bring up pretty menu...\n"); | ||
134 | // With 'discovery' button to enable/disable, | ||
135 | // and table of currently-detected devices. | ||
136 | } | ||
137 | |||
138 | } | ||
139 | |||
140 | void IrdaApplet::timerEvent( QTimerEvent * ) | ||
141 | { | ||
142 | int oldactive = irdaactive; | ||
143 | |||
144 | irdaactive = checkIrdaStatus(); | ||
145 | if (irdaactive != oldactive) | ||
146 | paintEvent(NULL); | ||
147 | |||
148 | } | ||
149 | |||
150 | void IrdaApplet::paintEvent( QPaintEvent* ) | ||
151 | { | ||
152 | QPainter p(this); | ||
153 | qDebug("paint irda pixmap"); | ||
154 | |||
155 | if (irdaactive > 0) | ||
156 | p.drawPixmap( 0, 1, irdaOnPixmap ); | ||
157 | else | ||
158 | p.drawPixmap( 0, 1, irdaOffPixmap ); | ||
159 | } | ||
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h new file mode 100644 index 0000000..d762ff3 --- a/dev/null +++ b/core/applets/irdaapplet/irda.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com | ||
3 | ** All rights reserved. | ||
4 | ** | ||
5 | ** This file may be distributed and/or modified under the terms of the | ||
6 | ** GNU General Public License version 2 as published by the Free Software | ||
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
8 | ** packaging of this file. | ||
9 | ** | ||
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
12 | ** | ||
13 | **********************************************************************/ | ||
14 | |||
15 | #ifndef __SCREENSHOT_APPLET_H__ | ||
16 | #define __SCREENSHOT_APPLET_H__ | ||
17 | |||
18 | |||
19 | |||
20 | #include <qwidget.h> | ||
21 | #include <qframe.h> | ||
22 | #include <qpixmap.h> | ||
23 | #include <qguardedptr.h> | ||
24 | #include <qtimer.h> | ||
25 | |||
26 | |||
27 | class IrdaApplet : public QWidget | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | public: | ||
31 | IrdaApplet( QWidget *parent = 0, const char *name=0 ); | ||
32 | ~IrdaApplet(); | ||
33 | |||
34 | protected: | ||
35 | void timerEvent(QTimerEvent *te ); | ||
36 | |||
37 | public slots: | ||
38 | private: | ||
39 | void mousePressEvent( QMouseEvent * ); | ||
40 | void paintEvent( QPaintEvent* ); | ||
41 | int checkIrdaStatus(); | ||
42 | int setIrdaStatus(int); | ||
43 | int sockfd; | ||
44 | |||
45 | private: | ||
46 | QPixmap irdaOnPixmap; | ||
47 | QPixmap irdaOffPixmap; | ||
48 | int irdaactive; | ||
49 | |||
50 | private slots: | ||
51 | |||
52 | |||
53 | }; | ||
54 | |||
55 | |||
56 | #endif // __SCREENSHOT_APPLET_H__ | ||
57 | |||
diff --git a/core/applets/irdaapplet/irdaapplet.pro b/core/applets/irdaapplet/irdaapplet.pro new file mode 100644 index 0000000..c8f3fdc --- a/dev/null +++ b/core/applets/irdaapplet/irdaapplet.pro | |||
@@ -0,0 +1,11 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on release | ||
3 | HEADERS = irda.h irdaappletimpl.h | ||
4 | SOURCES = irda.cpp irdaappletimpl.cpp | ||
5 | TARGET = irdaapplet | ||
6 | DESTDIR = ../../plugins/applets | ||
7 | INCLUDEPATH += $(OPIEDIR)/include | ||
8 | DEPENDPATH += ../$(OPIEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | VERSION = 1.0.0 | ||
11 | |||
diff --git a/core/applets/irdaapplet/irdaappletimpl.cpp b/core/applets/irdaapplet/irdaappletimpl.cpp new file mode 100644 index 0000000..02443db --- a/dev/null +++ b/core/applets/irdaapplet/irdaappletimpl.cpp | |||
@@ -0,0 +1,64 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include "irda.h" | ||
21 | #include "irdaappletimpl.h" | ||
22 | |||
23 | |||
24 | IrdaAppletImpl::IrdaAppletImpl() | ||
25 | : irda(0), ref(0) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | IrdaAppletImpl::~IrdaAppletImpl() | ||
30 | { | ||
31 | delete irda; | ||
32 | } | ||
33 | |||
34 | QWidget *IrdaAppletImpl::applet( QWidget *parent ) | ||
35 | { | ||
36 | if ( !irda ) | ||
37 | irda = new IrdaApplet( parent ); | ||
38 | return irda; | ||
39 | } | ||
40 | |||
41 | int IrdaAppletImpl::position() const | ||
42 | { | ||
43 | return 6; | ||
44 | } | ||
45 | |||
46 | QRESULT IrdaAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
47 | { | ||
48 | *iface = 0; | ||
49 | if ( uuid == IID_QUnknown ) | ||
50 | *iface = this; | ||
51 | else if ( uuid == IID_TaskbarApplet ) | ||
52 | *iface = this; | ||
53 | |||
54 | if ( *iface ) | ||
55 | (*iface)->addRef(); | ||
56 | return QS_OK; | ||
57 | } | ||
58 | |||
59 | Q_EXPORT_INTERFACE() | ||
60 | { | ||
61 | Q_CREATE_INSTANCE( IrdaAppletImpl ) | ||
62 | } | ||
63 | |||
64 | |||
diff --git a/core/applets/irdaapplet/irdaappletimpl.h b/core/applets/irdaapplet/irdaappletimpl.h new file mode 100644 index 0000000..abedb07 --- a/dev/null +++ b/core/applets/irdaapplet/irdaappletimpl.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef SCREENSHOTAPPLETIMPL_H | ||
21 | #define SCREENSHOTAPPLETIMPL_H | ||
22 | |||
23 | #include <qpe/taskbarappletinterface.h> | ||
24 | |||
25 | class IrdaApplet; | ||
26 | |||
27 | class IrdaAppletImpl : public TaskbarAppletInterface | ||
28 | { | ||
29 | public: | ||
30 | IrdaAppletImpl(); | ||
31 | virtual ~IrdaAppletImpl(); | ||
32 | |||
33 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
34 | Q_REFCOUNT | ||
35 | |||
36 | virtual QWidget *applet( QWidget *parent ); | ||
37 | virtual int position() const; | ||
38 | |||
39 | private: | ||
40 | IrdaApplet *irda; | ||
41 | ulong ref; | ||
42 | }; | ||
43 | |||
44 | #endif | ||
diff --git a/core/applets/irdaapplet/opie-irdaapplet.control b/core/applets/irdaapplet/opie-irdaapplet.control new file mode 100644 index 0000000..d730554 --- a/dev/null +++ b/core/applets/irdaapplet/opie-irdaapplet.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: plugins/applets/libirdaapplet.so* pics/irdaapplet/* | ||
2 | Priority: optional | ||
3 | Section: opie/system | ||
4 | Maintainer: David Woodhouse <dwmw2@infradead.org> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-$SUB_VERSION.1 | ||
7 | Depends: opie-base ($QPE_VERSION) | ||
8 | Description: Irda Applet | ||
9 | An IrDA taskbar applet for the Opie environment | ||
diff --git a/pics/irdaapplet/irdaoff.png b/pics/irdaapplet/irdaoff.png new file mode 100644 index 0000000..4e6c731 --- a/dev/null +++ b/pics/irdaapplet/irdaoff.png | |||
Binary files differ | |||
diff --git a/pics/irdaapplet/irdaon.png b/pics/irdaapplet/irdaon.png new file mode 100644 index 0000000..53fc7e9 --- a/dev/null +++ b/pics/irdaapplet/irdaon.png | |||
Binary files differ | |||