author | mickeyl <mickeyl> | 2005-08-21 22:29:07 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-08-21 22:29:07 (UTC) |
commit | 4def5629dc68465b1dc8bb23c115e2f5f7513804 (patch) (unidiff) | |
tree | c2a31fb9e46a3a3e7f797ef3fe0ea66b2f0b69df /noncore/net/opietooth/applet/bluezapplet.cpp | |
parent | 7f931999d32be3fc90b451347dfec52643d8eeb8 (diff) | |
download | opie-4def5629dc68465b1dc8bb23c115e2f5f7513804.zip opie-4def5629dc68465b1dc8bb23c115e2f5f7513804.tar.gz opie-4def5629dc68465b1dc8bb23c115e2f5f7513804.tar.bz2 |
Add some simple interfaces for device scanning (scanning for
discoverable receivers) to support OBEX Send, and requests for
taking BT up or down. Patch courtesy Michael Haynie - thanks!
Diffstat (limited to 'noncore/net/opietooth/applet/bluezapplet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 8925803..48698b6 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -63,15 +63,23 @@ namespace OpieTooth { | |||
63 | //bluezDiscoveryOnPixmap = Resource::loadImage( "bluetoothapplet/magglass" )smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 63 | //bluezDiscoveryOnPixmap = Resource::loadImage( "bluetoothapplet/magglass" )smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
64 | startTimer(4000); | 64 | startTimer(4000); |
65 | btDevice = 0; | 65 | btDevice = 0; |
66 | btManager = 0; | ||
66 | bluezactive = false; | 67 | bluezactive = false; |
67 | bluezDiscoveryActive = false; | 68 | bluezDiscoveryActive = false; |
68 | 69 | ||
70 | // TODO: determine whether this channel has to be closed at destruction time. | ||
71 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); | ||
72 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | ||
73 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); | ||
69 | } | 74 | } |
70 | 75 | ||
71 | BluezApplet::~BluezApplet() { | 76 | BluezApplet::~BluezApplet() { |
72 | if ( btDevice ) { | 77 | if ( btDevice ) { |
73 | delete btDevice; | 78 | delete btDevice; |
74 | } | 79 | } |
80 | if ( btManager ) { | ||
81 | delete btManager; | ||
82 | } | ||
75 | } | 83 | } |
76 | 84 | ||
77 | int BluezApplet::position() | 85 | int BluezApplet::position() |
@@ -118,9 +126,52 @@ int BluezApplet::position() | |||
118 | } | 126 | } |
119 | 127 | ||
120 | int BluezApplet::checkBluezDiscoveryStatus() { | 128 | int BluezApplet::checkBluezDiscoveryStatus() { |
129 | return bluezDiscoveryActive; | ||
121 | } | 130 | } |
122 | 131 | ||
123 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 132 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
133 | return bluezDiscoveryActive=d; | ||
134 | } | ||
135 | |||
136 | // FIXME mbhaynie | ||
137 | // receiver for QCopChannel("QPE/Bluetooth") messages. | ||
138 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) | ||
139 | { | ||
140 | if ( str == "enableBluetooth()") { | ||
141 | if (!checkBluezStatus()) { | ||
142 | setBluezStatus(1); | ||
143 | } | ||
144 | } else if ( str == "disableBluetooth()") { | ||
145 | if (checkBluezStatus()) { | ||
146 | // setBluezStatus(0); | ||
147 | } | ||
148 | } else if ( str == "listDevices()") { | ||
149 | if (!btManager) | ||
150 | { | ||
151 | btManager = new Manager("hci0"); | ||
152 | connect( btManager, SIGNAL( foundDevices(const QString&,RemoteDevice::ValueList) ), | ||
153 | this, SLOT( fillList(const QString&,RemoteDevice::ValueList) ) ) ; | ||
154 | } | ||
155 | |||
156 | btManager->searchDevices(); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | // Once the hcitool scan is complete, report back. | ||
161 | void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList) | ||
162 | { | ||
163 | QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)"); | ||
164 | |||
165 | QStringList list; | ||
166 | QMap<QString, QString> btmap; | ||
167 | |||
168 | RemoteDevice::ValueList::Iterator it; | ||
169 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) | ||
170 | { | ||
171 | btmap[(*it).name()] = (*it).mac(); | ||
172 | } | ||
173 | |||
174 | e << btmap; | ||
124 | } | 175 | } |
125 | 176 | ||
126 | void BluezApplet::mousePressEvent( QMouseEvent *) { | 177 | void BluezApplet::mousePressEvent( QMouseEvent *) { |