#ifndef DBUS_BlueZ_Adapter #define DBUS_BlueZ_Adapter /******************************************************************************** ** Manage and Drive Each Bluetooth Adapter *********************************************************************************/ /** * @brief Defines the part of the BlueZ DBUS API regarding the each Bluetooth adapter that are physicaly connected on the host computer. * This API implementation is directly derived from BLUEZ documentation : * \nosubgrouping */ class BlueZ_Adapter : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.bluez.Adapter") public: BlueZ_Adapter(QObject *parent=0); ~BlueZ_Adapter(); public slots: /** * @name Adapter Manager API * Methods for driving each adapter. * All of the following method should be accesss from the \b org.bluez.Adapter interface. * Object path [variable prefix]/{hci0,hci1,...} * @{ */ /** * @brief Returns all global properties : * - Address [readonly]: The Bluetooth device address. * - Name [readwrite]: The Bluetooth friendly name. This value can be changed and a PropertyChanged signal will be emitted. * - Class [readonly]: The Bluetooth class of device. * - Powered [readwrite]: Switch an adapter on or off. This will also set the appropiate connectable state. * - Discoverable [readwrite]: Switch an adapter to discoverable or non-discoverable to either make it visible or hide it. This is a global setting and should only be used by the settings application. * If the DiscoverableTimeout is set to a non-zero value then the system will set this value back to false after the timer expired. * In case the adapter is switched off, setting this value will fail. * When changing the Powered property the new state of this property will be updated via a PropertyChanged signal. * - Pairable [readwrite]: Switch an adapter to pairable or non-pairable. This is a global setting and should only be used by the settings application. * Note that this property only affects incoming pairing requests. * - PaireableTimeout [readwrite]: The pairable timeout in seconds. A value of zero means that the timeout is disabled and it will stay in pairable mode forever. * - DiscoverableTimeout [readwrite]: The discoverable timeout in seconds. A value of zero means that the timeout is disabled and it will stay in discoverable/limited mode forever. * The default value for the discoverable timeout should be 180 seconds (3 minutes). * - Discovering [readonly] : Indicates that a device discovery procedure is active. * - Devices [readonly] : List of device object paths. * - UUIDs [readonly] : List of 128-bit UUIDs that represents the available local services. * @return Returns a Array of structure containing property name and associated value */ QMap GetProperties(); /** * @brief Changes the value of the specified property. Only properties that are listed as read-write are changeable. On success this will emit a PropertyChanged signal. * @param name name string for the desired property. * @param value : a variant containing the expected value for the property. */ void SetProperty(QString name, QDBusVariant value); /** * @brief This method will request a client session that provides operational Bluetooth. A possible mode change must be confirmed by the user via the agent. */ void RequestSession(); /** * @brief Release a previous requested session. */ void ReleaseSession(); /** * @brief This method starts the device discovery session. * This includes an inquiry procedure and remote device name resolving. Use StopDiscovery to release the sessions acquired. * This process will start emitting DeviceFound and PropertyChanged "Discovering" signals. */ void StartDiscovery(); /** * @brief This method will cancel any previous StartDiscovery transaction. * Note that a discovery procedure is shared between all discovery sessions thus calling StopDiscovery will only release a single session. */ void StopDiscovery(); /** * @brief Returns the object path of device for given address. The device object needs to be first created via CreateDevice or CreatePairedDevice. * @param address * @return Returns object path for the specified adapter. */ QDBusObjectPath FindDevice(QString address); /** * @brief Creates a new object path for a remote device. * This method will connect to the remote device and retrieve all SDP records. * If the object for the remote device already exists this method will fail. * @param address * * @return Returns object path for the specified adapter. */ QDBusObjectPath CreateDevice(QString address); /** * @brief Creates a new object path for a remote device. This method will connect to the remote device and retrieve all SDP records and then initiate the pairing. * If previously CreateDevice was used successfully, this method will only initiate the pairing. * Compared to CreateDevice this method will fail if the pairing already exists, but not if the object path already has been created. This allows applications to use CreateDevice first and the if needed use CreatePairedDevice to initiate pairing. * The agent object path is assumed to reside within the process (D-Bus connection instance) that calls this method. No separate registration procedure is needed for it and it gets automatically released once the pairing operation is complete. * @param address * @param agent * @param capability The capability parameter is the same as for the RegisterAgent method * @return Returns object path for the specified adapter. */ QDBusObjectPath CreatePairedDevice(QString address, QDBusObjectPath agent, QString capability); /** * @brief Aborts either a CreateDevice call or a CreatePairedDevice call. * @param address */ void CancelDeviceCreation(QString address); /** * @brief This removes the remote device object at the given path. * It will remove also the pairing information. * @param TimeoutInMS The number of millisecond to wait before ending the discovery * * @return Returns object path for the specified adapter. Valid patterns are "hci0" or "00:11:22:33:44:55" */ void RemoveDevice(QDBusObjectPath device); /** * @brief This registers the adapter wide agent. * The object path defines the path of the agent that will be called when user input is needed. * If an application disconnects from the bus all of its registered agents will be removed. * @param agent * @param capability The capability parameterwhich reflects the input and output capabilities of the agent can have the values : * - "DisplayOnly" - "DisplayYesNo" - "KeyboardOnly" - "NoInputNoOutput" . note : If an empty string is used it will fallback to "DisplayYesNo". */ void RegisterAgent(QDBusObjectPath agent , QString capability); /** * @brief This unregisters the agent that has been previously registered. * The object path parameter must match the same value that has been used on registration. * @param agent */ void UnregisterAgent(QDBusObjectPath agent); signals: /** * @brief This signal indicates a changed value of the given property. * The object path parameter must match the same value that has been used on registration. * @return Returns object path for the specified adapter. Valid patterns are "hci0" or "00:11:22:33:44:55" */ void PropertyChanged(QString name, QDBusVariant value); /** * @brief This signal will be sent every time an inquiry result has been found by the service daemon. * In general they only appear during a device discovery. * The dictionary can contain basically the same values that are returned by the GetProperties method from the org.bluez.Device interface. * In addition there can be values for the RSSI, the TX power level and Broadcaster role. * @return Returns object path for the specified adapter. Valid patterns are "hci0" or "00:11:22:33:44:55" */ void DeviceFound(QString address, QVariantMap values); /** * @brief This signal will be sent when an inquiry session for a periodic discovery finishes and previously found devices are no longer in range or visible. */ void DeviceDisappeared(QString address); /** * @brief This unregisters the agent that has been previously registered. * @return Returns object path */ void DeviceCreated(QDBusObjectPath device); /** * @brief This unregisters the agent that has been previously registered. * @param agent * @return Returns Parameter is object path of removed device. */ void DeviceRemoved(QDBusObjectPath device); }; #endif