Make QBluetoothSocket's _q_writeNotify & _q_readNotify private

These two functions are really only needed by Linux style socket code.
There is no need for other platforms to implement them as dummy too.
It simplifies the code somewhat.

Change-Id: I3e0aced8d9f7b590d1c6aaa60f97bd060ee8f4b4
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
This commit is contained in:
Alex Blasche 2014-08-22 13:52:51 +02:00
parent 2b5027a808
commit d02f13307f
6 changed files with 19 additions and 44 deletions

View File

@ -152,8 +152,6 @@ protected:
QBluetoothSocketPrivate *d_ptr;
private:
Q_PRIVATE_SLOT(d_func(), void _q_readNotify())
Q_PRIVATE_SLOT(d_func(), void _q_writeNotify())
friend class QLowEnergyControllerPrivate;
};

View File

@ -221,14 +221,6 @@ void QBluetoothSocketPrivate::connectToServiceConc(const QBluetoothAddress &addr
emit q->connected();
}
void QBluetoothSocketPrivate::_q_writeNotify()
{
}
void QBluetoothSocketPrivate::_q_readNotify()
{
}
void QBluetoothSocketPrivate::abort()
{
if (state == QBluetoothSocket::UnconnectedState)

View File

@ -110,9 +110,9 @@ bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol
Q_Q(QBluetoothSocket);
readNotifier = new QSocketNotifier(socket, QSocketNotifier::Read);
QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_readNotify()));
QObject::connect(readNotifier, SIGNAL(activated(int)), this, SLOT(_q_readNotify()));
connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q);
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), q, SLOT(_q_writeNotify()));
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), this, SLOT(_q_writeNotify()));
connectWriteNotifier->setEnabled(false);
readNotifier->setEnabled(false);
@ -232,8 +232,6 @@ void QBluetoothSocketPrivate::_q_writeNotify()
}
}
// TODO: move to private backend?
void QBluetoothSocketPrivate::_q_readNotify()
{
Q_Q(QBluetoothSocket);
@ -483,7 +481,7 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
if(txBuffer.size() == 0) {
connectWriteNotifier->setEnabled(true);
QMetaObject::invokeMethod(q, "_q_writeNotify", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "_q_writeNotify", Qt::QueuedConnection);
}
char *txbuf = txBuffer.reserve(maxSize);
@ -547,9 +545,9 @@ bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoo
fcntl(socket, F_SETFL, flags | O_NONBLOCK);
readNotifier = new QSocketNotifier(socket, QSocketNotifier::Read);
QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_readNotify()));
QObject::connect(readNotifier, SIGNAL(activated(int)), this, SLOT(_q_readNotify()));
connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q);
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), q, SLOT(_q_writeNotify()));
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), this, SLOT(_q_writeNotify()));
q->setSocketState(socketState);
q->setOpenMode(openMode);

View File

@ -61,14 +61,6 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address,
Q_UNUSED(port);
}
void QBluetoothSocketPrivate::_q_writeNotify()
{
}
void QBluetoothSocketPrivate::_q_readNotify()
{
}
void QBluetoothSocketPrivate::abort()
{
}

View File

@ -70,14 +70,9 @@ public:
class QBluetoothSocket;
class QBluetoothServiceDiscoveryAgent;
class QBluetoothSocketPrivate
#if defined(QT_QNX_BLUETOOTH) || defined(QT_ANDROID_BLUETOOTH)
: public QObject
class QBluetoothSocketPrivate : public QObject
{
Q_OBJECT
#else
{
#endif
Q_DECLARE_PUBLIC(QBluetoothSocket)
friend class QBluetoothServerPrivate;
@ -147,12 +142,6 @@ public:
// qint64 rxOffset;
QString errorString;
// private slots
void _q_readNotify();
void _q_writeNotify();
void _q_serviceDiscovered(const QBluetoothServiceInfo &service);
void _q_discoveryFinished();
#ifdef QT_ANDROID_BLUETOOTH
QAndroidJniObject adapter;
QAndroidJniObject socketObject;
@ -166,6 +155,12 @@ private slots:
#endif
#if defined(QT_QNX_BLUETOOTH) || defined(QT_BLUEZ_BLUETOOTH)
private slots:
void _q_readNotify();
void _q_writeNotify();
#endif
protected:
QBluetoothSocket *q_ptr;

View File

@ -114,9 +114,9 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address,
delete connectWriteNotifier;
readNotifier = new QSocketNotifier(socket, QSocketNotifier::Read);
QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_readNotify()));
QObject::connect(readNotifier, SIGNAL(activated(int)), this, SLOT(_q_readNotify()));
connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q);
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), q, SLOT(_q_writeNotify()));
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), this, SLOT(_q_writeNotify()));
connecting = true;
q->setOpenMode(openMode);
@ -280,7 +280,7 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
if (txBuffer.size() == 0) {
connectWriteNotifier->setEnabled(true);
QMetaObject::invokeMethod(q, "_q_writeNotify", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "_q_writeNotify", Qt::QueuedConnection);
}
char *txbuf = txBuffer.reserve(maxSize);
@ -325,9 +325,9 @@ bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoo
socketType = socketType_;
readNotifier = new QSocketNotifier(socket, QSocketNotifier::Read);
QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_readNotify()));
QObject::connect(readNotifier, SIGNAL(activated(int)), this, SLOT(_q_readNotify()));
connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q);
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), q, SLOT(_q_writeNotify()));
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), this, SLOT(_q_writeNotify()));
q->setSocketState(socketState);
q->setOpenMode(openMode);
@ -390,9 +390,9 @@ void QBluetoothSocketPrivate::controlReply(ppsResult result)
Q_Q(QBluetoothSocket);
readNotifier = new QSocketNotifier(socket, QSocketNotifier::Read);
QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_readNotify()));
QObject::connect(readNotifier, SIGNAL(activated(int)), this, SLOT(_q_readNotify()));
connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q);
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), q, SLOT(_q_writeNotify()));
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), this, SLOT(_q_writeNotify()));
connectWriteNotifier->setEnabled(true);
readNotifier->setEnabled(true);