void connect() { Q_ASSERT(m_service); //qDebug() << "Connecting to: " << m_service->serviceInfo()->device().address().toString(); m_error = QDeclarativeBluetoothSocket::NoError; if (m_socket) m_socket->deleteLater(); QBluetoothServiceInfo::Protocol socketProtocol; if (m_service->serviceInfo()->socketProtocol() == QBluetoothServiceInfo::L2capProtocol) socketProtocol = QBluetoothServiceInfo::L2capProtocol; else if (m_service->serviceInfo()->socketProtocol() == QBluetoothServiceInfo::RfcommProtocol) socketProtocol = QBluetoothServiceInfo::RfcommProtocol; else socketProtocol = QBluetoothServiceInfo::UnknownProtocol; m_socket = new QBluetoothSocket(socketProtocol); m_socket->connectToService(*m_service->serviceInfo()); QObject::connect(m_socket, SIGNAL(connected()), m_dbs, SLOT(socket_connected())); QObject::connect(m_socket, SIGNAL(disconnected()), m_dbs, SLOT(socket_disconnected())); QObject::connect(m_socket, SIGNAL(error(QBluetoothSocket::SocketError)), m_dbs, SLOT(socket_error(QBluetoothSocket::SocketError))); QObject::connect(m_socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), m_dbs, SLOT(socket_state(QBluetoothSocket::SocketState))); QObject::connect(m_socket, SIGNAL(readyRead()), m_dbs, SLOT(socket_readyRead())); }
QDeclarativeBluetoothSocket::QDeclarativeBluetoothSocket(QBluetoothSocket *socket, QDeclarativeBluetoothService *service, QObject *parent) : QObject(parent) { d = new QDeclarativeBluetoothSocketPrivate(this); d->m_service = service; d->m_socket = socket; d->m_connected = true; d->m_componentCompleted = true; QObject::connect(socket, SIGNAL(connected()), this, SLOT(socket_connected())); QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(socket_disconnected())); QObject::connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socket_error(QBluetoothSocket::SocketError))); QObject::connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socket_state(QBluetoothSocket::SocketState))); QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(socket_readyRead())); }
void connect() { Q_ASSERT(m_service); qDebug() << "Connecting to: " << m_service->serviceInfo()->device().address().toString(); m_error = QLatin1String("No Error"); if(m_socket) m_socket->deleteLater(); // delete m_socket; m_socket = new QBluetoothSocket(); m_socket->connectToService(*m_service->serviceInfo()); QObject::connect(m_socket, SIGNAL(connected()), m_dbs, SLOT(socket_connected())); QObject::connect(m_socket, SIGNAL(disconnected()), m_dbs, SLOT(socket_disconnected())); QObject::connect(m_socket, SIGNAL(error(QBluetoothSocket::SocketError)), m_dbs, SLOT(socket_error(QBluetoothSocket::SocketError))); QObject::connect(m_socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), m_dbs, SLOT(socket_state(QBluetoothSocket::SocketState))); QObject::connect(m_socket, SIGNAL(readyRead()), m_dbs, SLOT(socket_readyRead())); m_stream = new QDataStream(m_socket); }
void QDeclarativeBluetoothSocket::newSocket(QBluetoothSocket *socket, QDeclarativeBluetoothService *service) { if (d->m_socket){ delete d->m_socket; } d->m_service = service; d->m_socket = socket; d->m_connected = true; d->m_componentCompleted = true; d->m_error = NoError; QObject::connect(socket, SIGNAL(connected()), this, SLOT(socket_connected())); QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(socket_disconnected())); QObject::connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socket_error(QBluetoothSocket::SocketError))); QObject::connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socket_state(QBluetoothSocket::SocketState))); QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(socket_readyRead())); socket_state(socket->state()); emit connectedChanged(); }
void connect() { Q_ASSERT(!uri.isEmpty()); m_error = QLatin1String("No Error"); if (m_socket) m_socket->deleteLater(); m_socket = new QLlcpSocket; Q_Q(const QDeclarativeNearFieldSocket); QObject::connect(m_socket, SIGNAL(connected()), q, SLOT(socket_connected())); QObject::connect(m_socket, SIGNAL(disconnected()), q, SLOT(socket_disconnected())); QObject::connect(m_socket, SIGNAL(error(QLlcpSocket::SocketError)), q, SLOT(socket_error(QLlcpSocket::SocketError))); QObject::connect(m_socket, SIGNAL(stateChanged(QLlcpSocket::SocketState)), q, SLOT(socket_state(QLlcpSocket::SocketState))); QObject::connect(m_socket, SIGNAL(readyRead()), q, SLOT(socket_readyRead())); m_socket->connectToService(0, uri); }