BtLocalDevice::BtLocalDevice(QObject *parent) : QObject(parent), securityFlags(QBluetooth::NoSecurity) { localDevice = new QBluetoothLocalDevice(this); connect(localDevice, SIGNAL(error(QBluetoothLocalDevice::Error)), this, SIGNAL(error(QBluetoothLocalDevice::Error))); connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)), this, SIGNAL(hostModeStateChanged())); connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)), this, SLOT(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing))); connect(localDevice, SIGNAL(deviceConnected(QBluetoothAddress)), this, SLOT(connected(QBluetoothAddress))); connect(localDevice, SIGNAL(deviceDisconnected(QBluetoothAddress)), this, SLOT(disconnected(QBluetoothAddress))); connect(localDevice, SIGNAL(pairingDisplayConfirmation(QBluetoothAddress,QString)), this, SLOT(pairingDisplayConfirmation(QBluetoothAddress,QString))); if (localDevice->isValid()) { deviceAgent = new QBluetoothDeviceDiscoveryAgent(this); connect(deviceAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(deviceDiscovered(QBluetoothDeviceInfo))); connect(deviceAgent, SIGNAL(finished()), this, SLOT(discoveryFinished())); connect(deviceAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(discoveryError(QBluetoothDeviceDiscoveryAgent::Error))); connect(deviceAgent, SIGNAL(canceled()), this, SLOT(discoveryCanceled())); serviceAgent = new QBluetoothServiceDiscoveryAgent(this); connect(serviceAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(serviceDiscovered(QBluetoothServiceInfo))); connect(serviceAgent, SIGNAL(finished()), this, SLOT(serviceDiscoveryFinished())); connect(serviceAgent, SIGNAL(canceled()), this, SLOT(serviceDiscoveryCanceled())); connect(serviceAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error))); socket = new QBluetoothSocket(SOCKET_PROTOCOL, this); connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socketStateChanged(QBluetoothSocket::SocketState))); connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socketError(QBluetoothSocket::SocketError))); connect(socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(socket, SIGNAL(readyRead()), this, SLOT(readData())); setSecFlags(socket->preferredSecurityFlags()); server = new QBluetoothServer(SOCKET_PROTOCOL, this); connect(server, SIGNAL(newConnection()), this, SLOT(serverNewConnection())); connect(server, SIGNAL(error(QBluetoothServer::Error)), this, SLOT(serverError(QBluetoothServer::Error))); } else { deviceAgent = 0; serviceAgent = 0; socket = 0; server = 0; } }
bool QBluetoothTransferReplySymbian::start() { if (m_address.isNull()) return false; m_running = true; m_discoveryAgent = new QBluetoothServiceDiscoveryAgent(m_address); connect(m_discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(serviceDiscovered(QBluetoothServiceInfo))); connect(m_discoveryAgent, SIGNAL(finished()), this, SLOT(serviceDiscoveryFinished())); // Automatically delete agent when device discovery finishes. connect(m_discoveryAgent, SIGNAL(finished()), this, SLOT(deleteLater())); m_discoveryAgent->setUuidFilter(QBluetoothUuid(QBluetoothUuid::ObexObjectPush)); m_discoveryAgent->start(); return true; }