summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-12-17 10:52:56 +0100
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-12-18 11:54:14 +0100
commite5e5b853d6326952305b2471877a47bc083202b3 (patch)
tree53c1747325bc0cb78c3de7ad4e58d6f6cc23ea6e
parenta007a6c6b40f14b4ad41130abbb445e45e919759 (diff)
QBluetoothServiceDiscoveryAgent - cleanup (OS X)
Use Q_FUNC_INFO in asserts/messages. Change-Id: I2d9429cff0b1cd5d28a04fe50328289a891d04f5 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r--src/bluetooth/osx/osxbtdeviceinquiry.mm1
-rw-r--r--src/bluetooth/osx/osxbtdevicepair.mm1
-rw-r--r--src/bluetooth/osx/osxbtsdpinquiry.mm35
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_osx.mm53
4 files changed, 34 insertions, 56 deletions
diff --git a/src/bluetooth/osx/osxbtdeviceinquiry.mm b/src/bluetooth/osx/osxbtdeviceinquiry.mm
index 12902e1a..4f67b726 100644
--- a/src/bluetooth/osx/osxbtdeviceinquiry.mm
+++ b/src/bluetooth/osx/osxbtdeviceinquiry.mm
@@ -43,7 +43,6 @@
#include "osxbtutility_p.h"
#include <QtCore/qloggingcategory.h>
-#include <QtCore/qglobal.h>
#include <QtCore/qdebug.h>
diff --git a/src/bluetooth/osx/osxbtdevicepair.mm b/src/bluetooth/osx/osxbtdevicepair.mm
index ad00bb23..fdb95522 100644
--- a/src/bluetooth/osx/osxbtdevicepair.mm
+++ b/src/bluetooth/osx/osxbtdevicepair.mm
@@ -43,7 +43,6 @@
#include "osxbtutility_p.h"
#include <QtCore/qloggingcategory.h>
-#include <QtCore/qglobal.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
diff --git a/src/bluetooth/osx/osxbtsdpinquiry.mm b/src/bluetooth/osx/osxbtsdpinquiry.mm
index 9cafd572..b460f929 100644
--- a/src/bluetooth/osx/osxbtsdpinquiry.mm
+++ b/src/bluetooth/osx/osxbtsdpinquiry.mm
@@ -48,11 +48,7 @@
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
-// We have to import - objc header files, no inclusion guards.
-#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
-#import <IOBluetooth/objc/IOBluetoothSDPDataElement.h>
-#import <IOBluetooth/objc/IOBluetoothSDPUUID.h>
-#import <IOBluetooth/objc/IOBluetoothDevice.h>
+#include "corebluetoothwrapper_p.h"
QT_BEGIN_NAMESPACE
@@ -64,7 +60,7 @@ SDPInquiryDelegate::~SDPInquiryDelegate()
QVariant extract_attribute_value(IOBluetoothSDPDataElement *dataElement)
{
- Q_ASSERT_X(dataElement, "extractAttributeValue()", "invalid data element (nil)");
+ Q_ASSERT_X(dataElement, Q_FUNC_INFO, "invalid data element (nil)");
// TODO: error handling and diagnostic messages.
@@ -158,7 +154,7 @@ using namespace OSXBluetooth;
- (id)initWithDelegate:(SDPInquiryDelegate *)aDelegate
{
- Q_ASSERT_X(aDelegate, "-initWithDelegate:", "invalid delegate (null)");
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
if (self = [super init]) {
delegate = aDelegate;
@@ -177,8 +173,7 @@ using namespace OSXBluetooth;
- (IOReturn)performSDPQueryWithDevice:(const QBluetoothAddress &)address
{
- Q_ASSERT_X(!isActive, "-performSDPQueryWithDevice",
- "SDP query in process");
+ Q_ASSERT_X(!isActive, Q_FUNC_INFO, "SDP query in progress");
QList<QBluetoothUuid> emptyFilter;
return [self performSDPQueryWithDevice:address filters:emptyFilter];
@@ -187,10 +182,8 @@ using namespace OSXBluetooth;
- (IOReturn)performSDPQueryWithDevice:(const QBluetoothAddress &)address
filters:(const QList<QBluetoothUuid> &)qtFilters
{
- Q_ASSERT_X(!isActive, "-performSDPQueryWithDevice:filters:",
- "SDP query in progress");
- Q_ASSERT_X(!address.isNull(), "-performSDPQueryWithDevice:filters:",
- "invalid target device address");
+ Q_ASSERT_X(!isActive, Q_FUNC_INFO, "SDP query in progress");
+ Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO, "invalid target device address");
QT_BT_MAC_AUTORELEASEPOOL;
@@ -199,8 +192,7 @@ using namespace OSXBluetooth;
if (qtFilters.size()) {
array.reset([[NSMutableArray alloc] init]);
if (!array) {
- qCCritical(QT_BT_OSX) << "-performSDPQueryWithDevices:filters:, "
- "failed to allocate an uuid filter";
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate an uuid filter";
return kIOReturnError;
}
@@ -211,8 +203,7 @@ using namespace OSXBluetooth;
}
if (int([array count]) != qtFilters.size()) {
- qCCritical(QT_BT_OSX) << "-performSDPQueryWithDevices:filters:, "
- << "failed to create an uuid filter";
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an uuid filter";
return kIOReturnError;
}
}
@@ -220,8 +211,7 @@ using namespace OSXBluetooth;
const BluetoothDeviceAddress iobtAddress(iobluetooth_address(address));
ObjCScopedPointer<IOBluetoothDevice> newDevice([[IOBluetoothDevice deviceWithAddress:&iobtAddress] retain]);
if (!newDevice) {
- qCCritical(QT_BT_OSX) << "-performSDPQueryWithDevices:filters:, "
- << "failed to create an IOBluetoothDevice object";
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an IOBluetoothDevice object";
return kIOReturnError;
}
@@ -235,9 +225,7 @@ using namespace OSXBluetooth;
result = [device performSDPQuery:self];
if (result != kIOReturnSuccess) {
- qCCritical(QT_BT_OSX) << "-preformSDPQueryWithDevices:filters:, "
- "failed to start an SDP query";
-
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to start an SDP query";
device = oldDevice.take();
} else {
isActive = true;
@@ -265,8 +253,7 @@ using namespace OSXBluetooth;
if (device != aDevice)
return;
- Q_ASSERT_X(delegate, "-sdpQueryComplete:status:",
- "invalid delegate (null)");
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
isActive = false;
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
index 9311df55..caa3942c 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
@@ -49,13 +49,13 @@
#include <QtCore/qloggingcategory.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qstring.h>
+#include <QtCore/qglobal.h>
#include <QtCore/qdebug.h>
#include <QtCore/qlist.h>
-// We have to import obj-C headers, they are not guarded against a multiple inclusion.
-#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
-#import <IOBluetooth/objc/IOBluetoothHostController.h>
-#import <IOBluetooth/objc/IOBluetoothDevice.h>
+#include <Foundation/Foundation.h>
+// Only after Foundation.h
+#include "osx/corebluetoothwrapper_p.h"
QT_BEGIN_NAMESPACE
@@ -130,10 +130,10 @@ QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(c
void QBluetoothServiceDiscoveryAgentPrivate::startDeviceDiscovery()
{
- Q_ASSERT_X(q_ptr, "startDeviceDiscovery()", "invalid q_ptr (null)");
- Q_ASSERT_X(state == Inactive, "startDeviceDiscovery()", "invalid state");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+ Q_ASSERT_X(state == Inactive, Q_FUNC_INFO, "invalid state");
Q_ASSERT_X(error != QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapterError,
- "startDeviceDiscovery()", "invalid bluetooth adapter");
+ Q_FUNC_INFO, "invalid bluetooth adapter");
Q_ASSERT_X(deviceDiscoveryAgent.isNull(), "startDeviceDiscovery()",
"discovery agent already exists");
@@ -146,11 +146,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::startDeviceDiscovery()
void QBluetoothServiceDiscoveryAgentPrivate::stopDeviceDiscovery()
{
- Q_ASSERT_X(q_ptr, "stopDeviceDiscovery()", "invalid q_ptr (null)");
- Q_ASSERT_X(!deviceDiscoveryAgent.isNull(), "stopDeviceDiscovery()",
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+ Q_ASSERT_X(!deviceDiscoveryAgent.isNull(), Q_FUNC_INFO,
"invalid device discovery agent (null)");
- Q_ASSERT_X(state == DeviceDiscovery, "stopDeviceDiscovery()",
- "invalid state");
+ Q_ASSERT_X(state == DeviceDiscovery, Q_FUNC_INFO, "invalid state");
deviceDiscoveryAgent->stop();
deviceDiscoveryAgent.reset(Q_NULLPTR);
@@ -164,9 +163,9 @@ void QBluetoothServiceDiscoveryAgentPrivate::startServiceDiscovery()
// Any of 'Inactive'/'DeviceDiscovery'/'ServiceDiscovery' states
// are possible.
- Q_ASSERT_X(q_ptr, "startServiceDiscovery()", "invalid q_ptr (null)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
Q_ASSERT_X(error != QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapterError,
- "startServiceDiscovery()", "invalid bluetooth adapter");
+ Q_FUNC_INFO, "invalid bluetooth adapter");
if (discoveredDevices.isEmpty()) {
state = Inactive;
@@ -210,8 +209,8 @@ void QBluetoothServiceDiscoveryAgentPrivate::startServiceDiscovery()
void QBluetoothServiceDiscoveryAgentPrivate::stopServiceDiscovery()
{
- Q_ASSERT_X(state != Inactive, "stopServiceDiscovery()", "invalid state");
- Q_ASSERT_X(q_ptr, "stopServiceDiscovery()", "invalid q_ptr (null)");
+ Q_ASSERT_X(state != Inactive, Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
discoveredDevices.clear();
state = Inactive;
@@ -256,7 +255,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscovered(const QBluetoot
void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error)
{
- Q_ASSERT_X(q_ptr, "_q_deviceDiscoveryError()", "invalid q_ptr (null)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
error = QBluetoothServiceDiscoveryAgent::UnknownError;
errorString = tr("Unknown error while scanning for devices");
@@ -271,8 +270,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryError(QBluetoothD
void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryFinished()
{
- Q_ASSERT_X(q_ptr, "_q_deviceDiscoveryFinished()",
- "invalid q_ptr (null)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
if (deviceDiscoveryAgent->error() != QBluetoothDeviceDiscoveryAgent::NoError) {
//Forward the device discovery error
@@ -295,7 +293,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_serviceDiscoveryFinished()
void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryFinished(IOBluetoothDevice *device)
{
- Q_ASSERT_X(device, "SDPInquiryFinished()", "invalid IOBluetoothDevice (nil)");
+ Q_ASSERT_X(device, Q_FUNC_INFO, "invalid IOBluetoothDevice (nil)");
if (state == Inactive)
return;
@@ -305,8 +303,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryFinished(IOBluetoothDevic
NSArray *const records = device.services;
for (IOBluetoothSDPServiceRecord *record in records) {
QBluetoothServiceInfo serviceInfo;
- Q_ASSERT_X(discoveredDevices.size() >= 1, "SDPInquiryFinished()",
- "invalid number of devices");
+ Q_ASSERT_X(discoveredDevices.size() >= 1, Q_FUNC_INFO, "invalid number of devices");
serviceInfo.setDevice(discoveredDevices.at(0));
OSXBluetooth::extract_service_record(record, serviceInfo);
@@ -331,8 +328,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryError(IOBluetoothDevice *
{
Q_UNUSED(device)
- qCWarning(QT_BT_OSX) << "QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryError(), "
- "inquiry failed with IOKit code: " << int(errorCode);
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "inquiry failed with IOKit code: " << int(errorCode);
discoveredDevices.clear();
// TODO: find a better mapping from IOReturn to QBluetoothServiceDiscoveryAgent::Error.
@@ -347,8 +343,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryError(IOBluetoothDevice *
void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(const QBluetoothAddress &deviceAddress)
{
- Q_ASSERT_X(!deviceAddress.isNull(), "performMinimalServiceDiscovery()",
- "invalid device address");
+ Q_ASSERT_X(!deviceAddress.isNull(), Q_FUNC_INFO, "invalid device address");
QT_BT_MAC_AUTORELEASEPOOL;
@@ -365,7 +360,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(cons
NSArray *const records = device.services;
for (IOBluetoothSDPServiceRecord *record in records) {
QBluetoothServiceInfo serviceInfo;
- Q_ASSERT_X(discoveredDevices.size() >= 1, "SDPInquiryFinished()",
+ Q_ASSERT_X(discoveredDevices.size() >= 1, Q_FUNC_INFO,
"invalid number of devices");
serviceInfo.setDevice(discoveredDevices.at(0));
@@ -389,11 +384,9 @@ void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(cons
void QBluetoothServiceDiscoveryAgentPrivate::setupDeviceDiscoveryAgent()
{
- Q_ASSERT_X(q_ptr, "setupDeviceDiscoveryAgent()",
- "invalid q_ptr (null)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
Q_ASSERT_X(deviceDiscoveryAgent.isNull() || !deviceDiscoveryAgent->isActive(),
- "setupDeviceDiscoveryAgent()",
- "device discovery agent is active");
+ Q_FUNC_INFO, "device discovery agent is active");
deviceDiscoveryAgent.reset(new QBluetoothDeviceDiscoveryAgent(localAdapterAddress, q_ptr));