1 /* This file is part of the KDE project
2 Copyright (C) 2006 Will Stephenson <wstephenson@kde.org>
3 Copyright (C) 2007 Daniel Gollub <dgollub@suse.de>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 #ifndef SOLID_BLUETOOTHINTERFACE_H
23 #define SOLID_BLUETOOTHINTERFACE_H
25 #include <QtCore/QDateTime>
26 #include <QtCore/QPair>
27 #include <QtCore/QObject>
29 #include <solid/control/bluetoothremotedevice.h>
30 #include <solid/control/ifaces/bluetoothremotedevice.h>
38 class BluetoothRemoteDevice
;
39 typedef QList
<BluetoothRemoteDevice
> BluetoothRemoteDeviceList
;
40 class BluetoothInterfacePrivate
;
43 * Represents a bluetooth interface as seen by the bluetooth subsystem.
45 class SOLIDCONTROL_EXPORT BluetoothInterface
: public QObject
51 * Describes the operating mode of a bluetooth interface
53 * - Off : The interface's transceiver is turned off
54 * - Discoverable : The interface may be discovered by other devices and connected to
55 * - Connectable : The interface may only be connected to but not discovered
57 enum Mode
{ Off
, Discoverable
, Connectable
};
59 * Constructs an invalid bluetooth interface
64 * Constructs a bluetooth interface for a given Unique Bluetooth Identifier (UBI).
65 * This object will be auto deleted, DON'T delete it.
66 * @param ubi the ubi of the bluetooth interface to create
68 explicit BluetoothInterface(const QString
&ubi
);
71 * Constructs a new bluetooth interface taking its data from a backend.
73 * @param backendObject the object given by the backend
75 explicit BluetoothInterface(QObject
*backendObject
);
78 * Constructs a copy of a bluetooth interface.
80 * @param device the bluetooth interface to copy
82 BluetoothInterface(const BluetoothInterface
&device
);
85 * Destroys the device.
87 ~BluetoothInterface();
91 * Assigns a bluetooth interface to this bluetooth interface and returns a reference to it.
93 * @param device the bluetooth interface to assign
94 * @return a reference to the bluetooth interface
96 BluetoothInterface
&operator=(const BluetoothInterface
&device
);
99 * Retrieves the Unique Bluetooth Identifier (UBI) of the BluetoothInterface.
100 * This identifier is ubique for each bluetooth and bluetooth interface in the system.
102 * @returns the Unique Bluetooth Identifier of the current bluetooth interface
107 * Create new BluetoothRemoteDevice object from this interface given its UBI.
109 * @param ubi the identifier of the bluetooth device to instantiate
110 * @returns a bluetooth object, if a bluetooth device having the given UBI, for this interface exists, 0 otherwise
112 BluetoothRemoteDevice
*createBluetoothRemoteDevice(const QString
& ubi
);
115 * Finds a BluetoothRemoteDevice object given its UBI.
117 * @param ubi the identifier of the bluetooth remote device to find from this bluetooth interface
118 * @returns a valid BluetoothRemoteDevice object if a remote device having the given UBI for this interface exists, an invalid BluetoothRemoteDevice object otherwise.
120 BluetoothRemoteDevice
findBluetoothRemoteDevice(const QString
&ubi
) const;
123 * Retrieves the MAC address of the bluetooth interface/adapter.
125 * @returns MAC address of bluetooth interface
127 QString
address() const;
130 * Retrieves the version of the chip of the bluetooth interface/adapter.
131 * Example: "Bluetooth 2.0 + EDR"
133 * @returns bluetooth chip version
135 QString
version() const;
138 * Retrieves the revision of the chip of the bluetooth interface/adapter.
139 * Example: "HCI 19.2"
141 * @returns bluetooth chip revision
143 QString
revision() const;
146 * Retrieves the name of the bluetooth chip manufacturer.
147 * Example: "Boston Silicon Radio"
149 * @returns manufacturer string of bluetooth interface/adapter
151 QString
manufacturer() const;
154 * Retrieves the name of the manufacturer of the bluetooth interface,
155 * using the chip supplied by BluetoothInterface::manufacterer()
156 * Based on device address.
158 * @returns company string of bluetooth interface/adapter
160 QString
company() const;
163 * Retrieves the current mode of the bluetooth interface/adapter.
165 * @returns the current mode of bluetooth interface/adapter
170 * Retrieves the discoverable timeout of the bluetooth interface/adapter.
171 * Discoverable timeout of 0 means never disappear.
173 * @returns current discoverable timeout in seconds
175 int discoverableTimeout() const;
178 * Retrieves the current discoverable staut of the bluetooth interface/adapter.
180 * @returns current discoverable status of bluetooth interface/adapter
182 bool isDiscoverable() const;
185 * List all UBIs of connected remote bluetooth devices of this handled bluetooth
188 * @returns list UBIs of connected bluetooth remote devices
190 BluetoothRemoteDeviceList
listConnections() const;
193 * Retrieves major class of the bluetooth interface/adapter.
195 * @returns current major class of the bluetooth interface/adapter
197 QString
majorClass() const;
200 * List supported minor classes of the bluetooth interface/adapter.
203 * @returns list of supported minor classes by bluetooth interface/adapter
205 QStringList
listAvailableMinorClasses() const;
208 * Retrieves minor class of the bluetooth interface/adapter.
209 * Valid classes, see listAvailableMinorClasses()
212 * @returns minor class of the bluetooth interface/adapter.
214 QString
minorClass() const;
217 * List services class of the bluetooth interface/adapter.
220 * @returns list of service classes or empty list if no services registered
222 QStringList
serviceClasses() const;
225 * Retrieves name of bluetooth interface/adapter.
228 * @returns name of bluetooth interface/adapter
230 QString
name() const;
233 * List UBIs of bonded/paired remote bluetooth devices with this bluetooth
236 * @returns UBIs of bonded/paired bluetooth remote devices
238 QStringList
listBondings() const;
241 * Periodic discovery status of this bluetooth interface/adapter.
243 * @returns true if periodic discovery is already active otherwise false
245 bool isPeriodicDiscoveryActive() const;
248 * Name resolving status of periodic discovery routing.
250 * @returns true if name got resolved while periodic discovery of this bluetooth
253 bool isPeriodicDiscoveryNameResolvingActive() const;
256 * List the Unique Bluetooth Identifier (UBI) of all known remote devices,
257 * whether they are seen, used or paired/bonded.
259 * See listConnections()
261 * @returns a QStringList of UBIs of all known remote bluetooth devices
263 QStringList
listRemoteDevices() const;
266 * List the Unique Bluetooth Identifier (UBI) of all known remote devices since a specific
267 * datestamp. Known remote devices means remote bluetooth which are seen, used or
270 * See listConnections(), listRemoteDevices()
272 * @param date the datestamp of the beginning of recent used devices
273 * @returns a QStringList of UBIs of all known remote bluetooth devices
275 QStringList
listRecentRemoteDevices(const QDateTime
&date
) const;
279 * Set mode of bluetooth interface/adapter.
280 * Valid modes, see mode()
282 * @param mode the mode of the bluetooth interface/adapter
284 void setMode(const Mode mode
);
287 * Set discoverable timeout of bluetooth interface/adapter.
289 * @param timeout timeout in seconds
291 void setDiscoverableTimeout(int timeout
);
294 * Set minor class of bluetooth interface/adapter.
296 * @param minor set minor class. Valid mode see listAvaliableMinorClasses()
298 void setMinorClass(const QString
&minor
);
301 * Set name of bluetooth interface/adapter.
303 * @param name the name of bluetooth interface/adapter
305 void setName(const QString
&name
);
308 * Start discovery of remote bluetooth devices with device name resolving.
310 void discoverDevices();
312 * Start discovery of remote bluetooth devices without device name resolving.
314 void discoverDevicesWithoutNameResolving();
316 * Cancel discovery of remote bluetooth devices.
318 void cancelDiscovery();
321 * Start periodic discovery of remote bluetooth devices.
322 * See stopPeriodicDiscovery()
324 void startPeriodicDiscovery();
327 * Stop periodic discovery of remote bluetooth devices.
329 void stopPeriodicDiscovery();
332 * Enable/Disable name resolving of remote bluetooth devices in periodic discovery.
334 * @param resolveName true to enable name resolving otherwise false
336 void setPeriodicDiscoveryNameResolving(bool resolveNames
);
341 * This signal is emitted if the mode of the bluetooth interface/adapter has changed.
342 * See mode() for valid modes.
344 * @param mode the changed mode
346 void modeChanged(Solid::Control::BluetoothInterface::Mode
);
349 * The signal is emitted if the discoverable timeout of the bluetooth interface/adapter
352 * @param timeout the changed timeout in seconds
354 void discoverableTimeoutChanged(int timeout
);
357 * The signal is emitted if the minor class of the bluetooth interface/adapter has changed.
359 * @param minor the new minor class
361 void minorClassChanged(const QString
&minor
);
364 * The signal is emitted if the name of the bluetooth interface/adapter has changed.
366 * @param name the new name of the device
368 void nameChanged(const QString
&name
);
371 * This signal is emitted if a discovery has started.
373 void discoveryStarted();
376 * This signal is emitted if a discovery has completed.
378 void discoveryCompleted();
381 * This signal is emitted if the bluetooth interface/adapter detects a new remote bluetooth device.
383 * @todo change arguments types of deviceClass (uint32) and rssi (int16)
385 * @param ubi the new bluetooth identifier
386 * @param deviceClass the device class of the remote device
387 * @param rssi the Received Signal Strength Information (RSSI) of the remote device
389 void remoteDeviceFound(const QString
&ubi
, int deviceClass
, int rssi
);
392 * This signal is emitted if the bluetooth interface/adapter detectes a bluetooth device
395 * @param ubi the ubi of the disappering bluetooth remote device
397 void remoteDeviceDisappeared(const QString
&ubi
);
400 Q_PRIVATE_SLOT(d
, void _k_destroyed(QObject
*))
402 BluetoothInterfacePrivate
* const d
;