-rw-r--r-- | noncore/net/opietooth/applet/applet.pro | 12 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 199 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.h | 75 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezappletimpl.cpp | 72 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezappletimpl.h | 55 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/opie-bluetoothapplet.control | 9 |
6 files changed, 422 insertions, 0 deletions
diff --git a/noncore/net/opietooth/applet/applet.pro b/noncore/net/opietooth/applet/applet.pro new file mode 100644 index 0000000..9520a5e --- a/dev/null +++ b/noncore/net/opietooth/applet/applet.pro | |||
@@ -0,0 +1,12 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on release | ||
3 | HEADERS = bluezapplet.h bluezappletimpl.h | ||
4 | SOURCES = bluezapplet.cpp bluezappletimpl.cpp | ||
5 | TARGET = bluetoothapplet | ||
6 | DESTDIR = $(OPIEDIR)/plugins/applets | ||
7 | INCLUDEPATH += $(OPIEDIR)/include | ||
8 | INCLUDEPATH += $(OPIEDIR)/noncore/opietooth/lib | ||
9 | DEPENDPATH += $(OPIEDIR)/include | ||
10 | LIBS += -lqpe -lopietooth | ||
11 | VERSION = 0.0.3 | ||
12 | |||
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp new file mode 100644 index 0000000..9569b36 --- a/dev/null +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -0,0 +1,199 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <, > . <= redistribute it and/or modify it under | ||
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. . .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-= this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | |||
30 | #include "bluezapplet.h" | ||
31 | #include <qapplication.h> | ||
32 | |||
33 | #include <qpe/resource.h> | ||
34 | #include <qpe/qcopenvelope_qws.h> | ||
35 | #include <qpe/resource.h> | ||
36 | #include <qpe/config.h> | ||
37 | |||
38 | #include <qpoint.h> | ||
39 | #include <qpainter.h> | ||
40 | #include <qlayout.h> | ||
41 | #include <qframe.h> | ||
42 | #include <qpixmap.h> | ||
43 | #include <qstring.h> | ||
44 | #include <qtimer.h> | ||
45 | #include <qpopupmenu.h> | ||
46 | |||
47 | #include <device.h> | ||
48 | |||
49 | namespace OpieTooth { | ||
50 | |||
51 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { | ||
52 | setFixedHeight( 18 ); | ||
53 | setFixedWidth( 14 ); | ||
54 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); | ||
55 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); | ||
56 | // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); | ||
57 | startTimer(5000); | ||
58 | timerEvent(NULL); | ||
59 | } | ||
60 | |||
61 | BluezApplet::~BluezApplet() { | ||
62 | } | ||
63 | |||
64 | int BluezApplet::checkBluezStatus() { | ||
65 | if (btDevice->isLoaded() ) { | ||
66 | return 1; | ||
67 | } else { | ||
68 | return 0; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | int BluezApplet::setBluezStatus(int c) { | ||
73 | |||
74 | if (c == 1) { | ||
75 | btDevice = new Device("/dev/ttySB0", "scr" ); | ||
76 | // system("hciattach /dev/ttySB0 csr"); | ||
77 | //system("hcid"); | ||
78 | } else { | ||
79 | if (btDevice) { | ||
80 | delete btDevice; | ||
81 | } | ||
82 | //system("killall hciattach"); | ||
83 | //system("killall hcid"); | ||
84 | } | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | int BluezApplet::checkBluezDiscoveryStatus() { | ||
89 | } | ||
90 | |||
91 | int BluezApplet::setBluezDiscoveryStatus(int d) { | ||
92 | } | ||
93 | |||
94 | void BluezApplet::mousePressEvent( QMouseEvent *) { | ||
95 | |||
96 | QPopupMenu *menu = new QPopupMenu(); | ||
97 | QPopupMenu *signal = new QPopupMenu(); | ||
98 | int ret=0; | ||
99 | |||
100 | /* Refresh active state */ | ||
101 | timerEvent(NULL); | ||
102 | |||
103 | |||
104 | if (bluezactive) { | ||
105 | menu->insertItem( tr("Disable Bluetooth"), 0 ); | ||
106 | } else { | ||
107 | menu->insertItem( tr("Enable Bluetooth"), 1 ); | ||
108 | } | ||
109 | |||
110 | menu->insertItem( tr("Launch manager"), 2 ); | ||
111 | |||
112 | menu->insertSeparator(6); | ||
113 | menu->insertItem( tr("Signal strength"), signal, 5); | ||
114 | menu->insertSeparator(8); | ||
115 | |||
116 | if (bluezDiscoveryActive) { | ||
117 | menu->insertItem( tr("Disable discovery"), 3 ); | ||
118 | } else { | ||
119 | menu->insertItem( tr("Enable discovery"), 4 ); | ||
120 | } | ||
121 | //menu->insertItem( tr("More..."), 7 ) | ||
122 | |||
123 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); | ||
124 | ret = menu->exec(p, 2); | ||
125 | |||
126 | // qDebug("ret was %d\n", ret); | ||
127 | |||
128 | switch(ret) { | ||
129 | case 0: | ||
130 | setBluezStatus(0); | ||
131 | timerEvent(NULL); | ||
132 | break; | ||
133 | case 1: | ||
134 | setBluezStatus(1); | ||
135 | timerEvent(NULL); | ||
136 | break; | ||
137 | case 2: | ||
138 | // start bluetoothmanager | ||
139 | launchManager(); | ||
140 | timerEvent(NULL); | ||
141 | break; | ||
142 | case 3: | ||
143 | setBluezDiscoveryStatus(0); | ||
144 | timerEvent(NULL); | ||
145 | break; | ||
146 | case 4: | ||
147 | setBluezDiscoveryStatus(1); | ||
148 | timerEvent(NULL); | ||
149 | break; | ||
150 | //case 7: | ||
151 | // With table of currently-detected devices. | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * Launches the bluetooth manager | ||
157 | */ | ||
158 | void BluezApplet::launchManager() { | ||
159 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
160 | e << QString("bluetooth-manager"); | ||
161 | } | ||
162 | |||
163 | /** | ||
164 | * Refresh timer | ||
165 | * @param the timer event | ||
166 | */ | ||
167 | void BluezApplet::timerEvent( QTimerEvent * ) { | ||
168 | int oldactive = bluezactive; | ||
169 | int olddiscovery = bluezDiscoveryActive; | ||
170 | |||
171 | bluezactive = checkBluezStatus(); | ||
172 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); | ||
173 | |||
174 | if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) { | ||
175 | paintEvent(NULL); | ||
176 | } | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * Implementation of the paint event | ||
181 | * @param the QPaintEvent | ||
182 | */ | ||
183 | void BluezApplet::paintEvent( QPaintEvent* ) { | ||
184 | QPainter p(this); | ||
185 | qDebug("paint bluetooth pixmap"); | ||
186 | |||
187 | p.eraseRect ( 0, 0, this->width(), this->height() ); | ||
188 | |||
189 | if (bluezactive > 0) { | ||
190 | p.drawPixmap( 0, 1, bluezOnPixmap ); | ||
191 | } else { | ||
192 | p.drawPixmap( 0, 1, bluezOffPixmap ); | ||
193 | } | ||
194 | |||
195 | if (bluezDiscoveryActive > 0) { | ||
196 | p.drawPixmap( 0, 1, bluezDiscoveryOnPixmap ); | ||
197 | } | ||
198 | } | ||
199 | }; | ||
diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h new file mode 100644 index 0000000..da05a18 --- a/dev/null +++ b/noncore/net/opietooth/applet/bluezapplet.h | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <, > . <= redistribute it and/or modify it under | ||
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. . .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-= this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef __BLUEZAPPLET_H__ | ||
30 | #define __BLUEZAPPLET_H__ | ||
31 | |||
32 | #include <qwidget.h> | ||
33 | #include <qpixmap.h> | ||
34 | #include <qtimer.h> | ||
35 | |||
36 | namespace OpieTooth { | ||
37 | class Device; | ||
38 | |||
39 | class BluezApplet : public QWidget { | ||
40 | Q_OBJECT | ||
41 | public: | ||
42 | BluezApplet( QWidget *parent = 0, const char *name=0 ); | ||
43 | ~BluezApplet(); | ||
44 | |||
45 | protected: | ||
46 | void timerEvent(QTimerEvent *te ); | ||
47 | |||
48 | public slots: | ||
49 | private: | ||
50 | void mousePressEvent( QMouseEvent * ); | ||
51 | void paintEvent( QPaintEvent* ); | ||
52 | void launchManager(); | ||
53 | int checkBluezStatus(); | ||
54 | int setBluezStatus(int); | ||
55 | int checkBluezDiscoveryStatus(); | ||
56 | int setBluezDiscoveryStatus(int); | ||
57 | int sockfd; | ||
58 | |||
59 | private: | ||
60 | Device* btDevice; | ||
61 | QPixmap bluezOnPixmap; | ||
62 | QPixmap bluezOffPixmap; | ||
63 | QPixmap bluezDiscoveryOnPixmap; | ||
64 | int bluezactive; | ||
65 | int bluezDiscoveryActive; | ||
66 | |||
67 | private slots: | ||
68 | |||
69 | |||
70 | }; | ||
71 | }; | ||
72 | |||
73 | |||
74 | #endif | ||
75 | |||
diff --git a/noncore/net/opietooth/applet/bluezappletimpl.cpp b/noncore/net/opietooth/applet/bluezappletimpl.cpp new file mode 100644 index 0000000..6677454 --- a/dev/null +++ b/noncore/net/opietooth/applet/bluezappletimpl.cpp | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <, > . <= redistribute it and/or modify it under | ||
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. . .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-= this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "bluezapplet.h" | ||
30 | #include "bluezappletimpl.h" | ||
31 | |||
32 | namespace OpieTooth { | ||
33 | |||
34 | BluezAppletImpl::BluezAppletImpl() : bluetooth(0), ref(0) { | ||
35 | } | ||
36 | |||
37 | BluezAppletImpl::~BluezAppletImpl() { | ||
38 | delete bluetooth; | ||
39 | } | ||
40 | |||
41 | QWidget *BluezAppletImpl::applet( QWidget *parent ) { | ||
42 | if ( !bluetooth ) { | ||
43 | bluetooth = new BluezApplet( parent ); | ||
44 | } | ||
45 | return bluetooth; | ||
46 | } | ||
47 | |||
48 | int BluezAppletImpl::position() const { | ||
49 | return 6; | ||
50 | } | ||
51 | |||
52 | QRESULT BluezAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | ||
53 | *iface = 0; | ||
54 | if ( uuid == IID_QUnknown ) { | ||
55 | *iface = this; | ||
56 | } else if ( uuid == IID_TaskbarApplet ) { | ||
57 | *iface = this; | ||
58 | } | ||
59 | |||
60 | if ( *iface ) { | ||
61 | (*iface)->addRef(); | ||
62 | } | ||
63 | return QS_OK; | ||
64 | } | ||
65 | |||
66 | Q_EXPORT_INTERFACE() { | ||
67 | Q_CREATE_INSTANCE( BluezAppletImpl ) | ||
68 | } | ||
69 | |||
70 | }; | ||
71 | |||
72 | |||
diff --git a/noncore/net/opietooth/applet/bluezappletimpl.h b/noncore/net/opietooth/applet/bluezappletimpl.h new file mode 100644 index 0000000..3a4faa6 --- a/dev/null +++ b/noncore/net/opietooth/applet/bluezappletimpl.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <, > . <= redistribute it and/or modify it under | ||
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. . .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-= this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef BLUEZAPPLETIMPL_H | ||
30 | #define BLUEZAPPLETIMPL_H | ||
31 | |||
32 | #include <qpe/taskbarappletinterface.h> | ||
33 | |||
34 | namespace OpieTooth { | ||
35 | |||
36 | class BluezApplet; | ||
37 | |||
38 | class BluezAppletImpl : public TaskbarAppletInterface { | ||
39 | public: | ||
40 | BluezAppletImpl(); | ||
41 | virtual ~BluezAppletImpl(); | ||
42 | |||
43 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
44 | Q_REFCOUNT | ||
45 | |||
46 | virtual QWidget *applet( QWidget *parent ); | ||
47 | virtual int position() const; | ||
48 | |||
49 | private: | ||
50 | BluezApplet *bluetooth; | ||
51 | ulong ref; | ||
52 | }; | ||
53 | }; | ||
54 | |||
55 | #endif | ||
diff --git a/noncore/net/opietooth/applet/opie-bluetoothapplet.control b/noncore/net/opietooth/applet/opie-bluetoothapplet.control new file mode 100644 index 0000000..13c2c69 --- a/dev/null +++ b/noncore/net/opietooth/applet/opie-bluetoothapplet.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: plugins/applets/libbluetoothapplet.so* pics/bluetoothapplet/* | ||
2 | Priority: optional | ||
3 | Section: opie/system | ||
4 | Maintainer: Maximilian Reiss <max.reiss@gmx.de> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-$SUB_VERSION.1 | ||
7 | Depends: opie-base ($QPE_VERSION) | ||
8 | Description: Bluetooth Applet | ||
9 | An bluetooth taskbar applet for the Opie environment | ||