QBtLocalDevice.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #ifndef QBTLOCALDEVICE_H
  16. #define QBTLOCALDEVICE_H
  17. #include <QBtGlobal.h>
  18. #include <QBtTypes.h>
  19. #include <QtCore/QObject>
  20. QBT_NAMESPACE_BEGIN
  21. //This class contains only static functions. How can it be used through QML
  22. // TYPE == Q_STATIC
  23. class DLL_EXPORT QBtLocalDevice //: public QObject
  24. {
  25. //Q_OBJECT
  26. public:
  27. ///////////////////////////////////////
  28. /// Bluetooth local properties ///
  29. ///////////////////////////////////////
  30. /**
  31. * Returns if possible the local device address
  32. */
  33. static QBtAddress getLocalDeviceAddress();
  34. /**
  35. * Returns true if local device is visible to other devices.
  36. */
  37. static bool isVisible ();
  38. /**
  39. * Sets the device visibility to other devices.
  40. * @param value true -> visible, false -> invisible
  41. */
  42. static void setVisible (bool value);
  43. static QBtDevice::DeviceMajor getDeviceClass();
  44. /**
  45. * Sets the UUID of the device that characterizes the device's type.
  46. * The possible enumeration values passed as argument are defined in
  47. * QBtDevice::DeviceMajor.
  48. */
  49. static void setDeviceClass(QBtDevice::DeviceMajor classId);
  50. /**
  51. * Sets the name of the device throught which it will be identified by other
  52. * devices during SDP discovery.
  53. */
  54. static void setLocalDeviceName (const QString & deviceName);
  55. /**
  56. * Get local device name.
  57. * @return device name
  58. */
  59. static QString getLocalDeviceName();
  60. /**
  61. * Returns true if bluetooth hardware exists and is plugged in.
  62. */
  63. static bool isBluetoothSupported();
  64. /**
  65. * Symbian specific function.
  66. * Used if bluetooth is powered off, showing a dialog that asks permission
  67. * from the user to power on bluetooth.
  68. */
  69. static void askUserTurnOnBtPower();
  70. /**
  71. * Symbian specific function.
  72. * Turns on/off bluetooth. Returns true is operation was sucessful.
  73. */
  74. static bool setBluetoothPowerState (bool value);
  75. /**
  76. * Returns true/false if bluetooth hardware is powered on/off respectively.
  77. */
  78. static bool getBluetoothPowerState();
  79. /**
  80. * Add a new device in the bluetooth registry.
  81. * @param device the device to be added
  82. * @return true upon success, else false
  83. */
  84. static bool addNewDevice(const QBtDevice& device);
  85. /**
  86. * Delete a device from the bluetooth registry.
  87. * @param device the device to be deleted
  88. * @return true upon success, else false. If device doesn't exists in the registry the also false
  89. */
  90. static bool deleteDevice(const QBtDevice& device);
  91. /**
  92. * Delete a device from the bluetooth registry using the bluetooth address.
  93. * @param address the device address of the device to be delete
  94. * @return true upon success, else false. If device doesn't exists in the registry the also false
  95. */
  96. static bool deleteDevice(const QBtAddress& address);
  97. /**
  98. * Breaks the pairing between the local device and the device passed as argument.
  99. *
  100. * @param device the device class containing the information of the device to be unpaired.
  101. */
  102. static bool unpairDevice(const QBtDevice& device);
  103. /**
  104. * Breaks the pairing between the local device and the remote device identified by
  105. * the bluetooth address passed as argument.
  106. *
  107. * @param address the bluetooth address of the remote device.
  108. */
  109. static bool unpairDevice(const QBtAddress& address);
  110. };
  111. QBT_NAMESPACE_END
  112. Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtLocalDevice))
  113. #if QT_VERSION >= 0x040700
  114. //QML_DECLARE_TYPEINFO(QBT_PREPEND_NAMESPACE(QBtLocalDevice))
  115. #endif
  116. #endif // QBTLOCALDEVICE_H