summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-16 15:12:06 (UTC)
committer harlekin <harlekin>2002-06-16 15:12:06 (UTC)
commit47f58b07e3718500193262bf4a0a2d13c9b7d539 (patch) (unidiff)
tree10a8cc4c29ad1e3b121c78034e83c6b111d46d92
parentbec7383f8b00706eb5ad0eedb6fcb0e013041ad3 (diff)
downloadopie-47f58b07e3718500193262bf4a0a2d13c9b7d539.zip
opie-47f58b07e3718500193262bf4a0a2d13c9b7d539.tar.gz
opie-47f58b07e3718500193262bf4a0a2d13c9b7d539.tar.bz2
update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index 6e5ee82..94e29c7 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -42,63 +42,61 @@
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
49namespace OpieTooth { 49namespace 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(5000); 57 startTimer(5000);
58 timerEvent(NULL); 58 btDevice = 0;
59
59 } 60 }
60 61
61 BluezApplet::~BluezApplet() { 62 BluezApplet::~BluezApplet() {
62 } 63 }
63 64
64 int BluezApplet::checkBluezStatus() { 65 int BluezApplet::checkBluezStatus() {
65 if (btDevice) { 66 if (btDevice) {
66 if (btDevice->isLoaded() ) { 67 if (btDevice->isLoaded() ) {
67 return 1; 68 return 1;
69 } else {
70 return 0;
71 }
68 } else { 72 } else {
69 return 0; 73 return 0;
70 } 74 }
71 } else {
72 return 0;
73 }
74 } 75 }
75 76
76 int BluezApplet::setBluezStatus(int c) { 77 int BluezApplet::setBluezStatus(int c) {
77 78
78 if (c == 1) { 79 if (c == 1) {
79 btDevice = new Device("/dev/ttySB0", "csr" ); 80 btDevice = new Device("/dev/ttySB0", "csr" );
80 // system("hciattach /dev/ttySB0 csr");
81 //system("hcid");
82 } else { 81 } else {
83 if (btDevice) { 82 if (btDevice) {
84 delete btDevice; 83 delete btDevice;
84 btDevice = 0;
85 } 85 }
86 //system("killall hciattach"); 86 }
87 //system("killall hcid");
88 }
89 return 0; 87 return 0;
90 } 88 }
91 89
92 int BluezApplet::checkBluezDiscoveryStatus() { 90 int BluezApplet::checkBluezDiscoveryStatus() {
93 } 91 }
94 92
95 int BluezApplet::setBluezDiscoveryStatus(int d) { 93 int BluezApplet::setBluezDiscoveryStatus(int d) {
96 } 94 }
97 95
98 void BluezApplet::mousePressEvent( QMouseEvent *) { 96 void BluezApplet::mousePressEvent( QMouseEvent *) {
99 97
100 QPopupMenu *menu = new QPopupMenu(); 98 QPopupMenu *menu = new QPopupMenu();
101 QPopupMenu *signal = new QPopupMenu(); 99 QPopupMenu *signal = new QPopupMenu();
102 int ret=0; 100 int ret=0;
103 101
104 /* Refresh active state */ 102 /* Refresh active state */
@@ -109,64 +107,60 @@ namespace OpieTooth {
109 menu->insertItem( tr("Disable Bluetooth"), 0 ); 107 menu->insertItem( tr("Disable Bluetooth"), 0 );
110 } else { 108 } else {
111 menu->insertItem( tr("Enable Bluetooth"), 1 ); 109 menu->insertItem( tr("Enable Bluetooth"), 1 );
112 } 110 }
113 111
114 menu->insertItem( tr("Launch manager"), 2 ); 112 menu->insertItem( tr("Launch manager"), 2 );
115 113
116 menu->insertSeparator(6); 114 menu->insertSeparator(6);
117 menu->insertItem( tr("Signal strength"), signal, 5); 115 menu->insertItem( tr("Signal strength"), signal, 5);
118 menu->insertSeparator(8); 116 menu->insertSeparator(8);
119 117
120 if (bluezDiscoveryActive) { 118 if (bluezDiscoveryActive) {
121 menu->insertItem( tr("Disable discovery"), 3 ); 119 menu->insertItem( tr("Disable discovery"), 3 );
122 } else { 120 } else {
123 menu->insertItem( tr("Enable discovery"), 4 ); 121 menu->insertItem( tr("Enable discovery"), 4 );
124 } 122 }
125 //menu->insertItem( tr("More..."), 7 ) 123
126 124
127 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); 125 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) );
128 ret = menu->exec(p, 0); 126 ret = menu->exec(p, 0);
129 127
130 // qDebug("ret was %d\n", ret);
131
132 switch(ret) { 128 switch(ret) {
133 case 0: 129 case 0:
134 setBluezStatus(0); 130 setBluezStatus(0);
135 timerEvent(NULL);
136 break; 131 break;
137 case 1: 132 case 1:
138 setBluezStatus(1); 133 setBluezStatus(1);
139 timerEvent(NULL);
140 break; 134 break;
141 case 2: 135 case 2:
142 // start bluetoothmanager 136 // start bluetoothmanager
143 launchManager(); 137 launchManager();
144 timerEvent(NULL);
145 break; 138 break;
146 case 3: 139 case 3:
147 setBluezDiscoveryStatus(0); 140 setBluezDiscoveryStatus(0);
148 timerEvent(NULL);
149 break; 141 break;
150 case 4: 142 case 4:
151 setBluezDiscoveryStatus(1); 143 setBluezDiscoveryStatus(1);
152 timerEvent(NULL);
153 break; 144 break;
154 //case 7: 145 //case 7:
155 // With table of currently-detected devices. 146 // With table of currently-detected devices.
156 } 147 }
148
149 timerEvent(NULL);
150 delete signal;
157 delete menu; 151 delete menu;
158 } 152 }
159 153
160 154
161/** 155/**
162 * Launches the bluetooth manager 156 * Launches the bluetooth manager
163 */ 157 */
164 void BluezApplet::launchManager() { 158 void BluezApplet::launchManager() {
165 QCopEnvelope e("QPE/System", "execute(QString)"); 159 QCopEnvelope e("QPE/System", "execute(QString)");
166 e << QString("bluetooth-manager"); 160 e << QString("bluetooth-manager");
167 } 161 }
168 162
169/** 163/**
170 * Refresh timer 164 * Refresh timer
171 * @param the timer event 165 * @param the timer event
172 */ 166 */