-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 3fdbde0..f1618ae 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -17,96 +17,99 @@ | |||
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. . .: details. | 18 | ++= -. . .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-= this library; see the file COPYING.LIB. | 22 | -- :-= this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | #include "bluezapplet.h" | 30 | #include "bluezapplet.h" |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | 32 | ||
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | #include <qpe/qcopenvelope_qws.h> | 34 | #include <qpe/qcopenvelope_qws.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <qpoint.h> | 38 | #include <qpoint.h> |
39 | #include <qpainter.h> | 39 | #include <qpainter.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qframe.h> | 41 | #include <qframe.h> |
42 | #include <qpixmap.h> | 42 | #include <qpixmap.h> |
43 | #include <qstring.h> | 43 | #include <qstring.h> |
44 | #include <qtimer.h> | 44 | #include <qtimer.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | 46 | ||
47 | #include <device.h> | 47 | #include <device.h> |
48 | 48 | ||
49 | namespace OpieTooth { | 49 | namespace OpieTooth { |
50 | 50 | ||
51 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { | 51 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { |
52 | setFixedHeight( 18 ); | 52 | setFixedHeight( 18 ); |
53 | setFixedWidth( 14 ); | 53 | setFixedWidth( 14 ); |
54 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); | 54 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); |
55 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); | 55 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); |
56 | // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); | 56 | // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); |
57 | startTimer(4000); | 57 | startTimer(4000); |
58 | btDevice = 0; | 58 | btDevice = 0; |
59 | bluezactive = false; | 59 | bluezactive = false; |
60 | bluezDiscoveryActive = false; | 60 | bluezDiscoveryActive = false; |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | BluezApplet::~BluezApplet() { | 64 | BluezApplet::~BluezApplet() { |
65 | if ( btDevice ) { | ||
66 | delete btDevice; | ||
67 | } | ||
65 | } | 68 | } |
66 | 69 | ||
67 | bool BluezApplet::checkBluezStatus() { | 70 | bool BluezApplet::checkBluezStatus() { |
68 | if (btDevice) { | 71 | if (btDevice) { |
69 | if (btDevice->isLoaded() ) { | 72 | if (btDevice->isLoaded() ) { |
70 | return true; | 73 | return true; |
71 | } else { | 74 | } else { |
72 | return false; | 75 | return false; |
73 | } | 76 | } |
74 | } else { | 77 | } else { |
75 | return false; | 78 | return false; |
76 | } | 79 | } |
77 | } | 80 | } |
78 | 81 | ||
79 | int BluezApplet::setBluezStatus(int c) { | 82 | int BluezApplet::setBluezStatus(int c) { |
80 | 83 | ||
81 | if (c == 1) { | 84 | if (c == 1) { |
82 | btDevice = new Device("/dev/ttySB0", "bcsp", "230400" ); | 85 | btDevice = new Device("/dev/ttySB0", "bcsp", "230400" ); |
83 | } else { | 86 | } else { |
84 | if (btDevice) { | 87 | if (btDevice) { |
85 | delete btDevice; | 88 | delete btDevice; |
86 | btDevice = 0; | 89 | btDevice = 0; |
87 | } | 90 | } |
88 | } | 91 | } |
89 | return 0; | 92 | return 0; |
90 | } | 93 | } |
91 | 94 | ||
92 | int BluezApplet::checkBluezDiscoveryStatus() { | 95 | int BluezApplet::checkBluezDiscoveryStatus() { |
93 | } | 96 | } |
94 | 97 | ||
95 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 98 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
96 | } | 99 | } |
97 | 100 | ||
98 | void BluezApplet::mousePressEvent( QMouseEvent *) { | 101 | void BluezApplet::mousePressEvent( QMouseEvent *) { |
99 | 102 | ||
100 | QPopupMenu *menu = new QPopupMenu(); | 103 | QPopupMenu *menu = new QPopupMenu(); |
101 | QPopupMenu *signal = new QPopupMenu(); | 104 | QPopupMenu *signal = new QPopupMenu(); |
102 | int ret=0; | 105 | int ret=0; |
103 | 106 | ||
104 | /* Refresh active state */ | 107 | /* Refresh active state */ |
105 | timerEvent( 0 ); | 108 | timerEvent( 0 ); |
106 | 109 | ||
107 | 110 | ||
108 | if (bluezactive) { | 111 | if (bluezactive) { |
109 | menu->insertItem( tr("Disable Bluetooth"), 0 ); | 112 | menu->insertItem( tr("Disable Bluetooth"), 0 ); |
110 | } else { | 113 | } else { |
111 | menu->insertItem( tr("Enable Bluetooth"), 1 ); | 114 | menu->insertItem( tr("Enable Bluetooth"), 1 ); |
112 | } | 115 | } |