本文整理汇总了C++中QBluetoothLocalDevice::deviceName方法的典型用法代码示例。如果您正苦于以下问题:C++ QBluetoothLocalDevice::deviceName方法的具体用法?C++ QBluetoothLocalDevice::deviceName怎么用?C++ QBluetoothLocalDevice::deviceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBluetoothLocalDevice
的用法示例。
在下文中一共展示了QBluetoothLocalDevice::deviceName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newConnection
/*!
\internal
*/
void QBluetoothHeadsetService::newConnection()
{
qLog(Bluetooth) << "QBluetoothHeadsetService::New client has connected.";
// New client has connected
QBluetoothRfcommSocket *socket =
static_cast<QBluetoothRfcommSocket *>(m_data->m_server->nextPendingConnection());
qLog(Bluetooth) << "Socket is:" << socket->socketDescriptor();
if (m_data->m_client &&
(m_data->m_connectInProgress ||
(m_data->m_client->state() == QBluetoothRfcommSocket::ConnectedState))) {
qLog(Bluetooth) << "Already connected, closing client socket.";
socket->close();
delete socket;
return;
}
hookupSocket(socket);
m_data->m_interface->setValue("IsConnected", true);
qLog(Bluetooth) << "Starting Bluetooth session for Headset";
if (!m_data->m_session) {
qLog(Bluetooth) << "Lazy initializing the QCommDeviceSession object";
QBluetoothLocalDevice local;
m_data->m_session = new QCommDeviceSession(local.deviceName().toLatin1());
QObject::connect(m_data->m_session, SIGNAL(sessionOpen()), this, SLOT(sessionOpen()));
QObject::connect(m_data->m_session, SIGNAL(sessionFailed()), this, SLOT(sessionFailed()));
}
m_data->m_session->startSession();
qLog(Bluetooth) << "The socket remoteAddress is:" << socket->remoteAddress().toString();
m_data->m_interface->setValue("RemotePeer",
QVariant::fromValue(socket->remoteAddress()));
emit newConnection(socket->remoteAddress());
qLog(Bluetooth) << "The socket has bytesAvailable:" << socket->bytesAvailable();
if (socket->bytesAvailable()) {
readyRead();
}
}
示例2: initiateModemEmulator
/*!
\internal
*/
void QBluetoothSerialPortService::initiateModemEmulator()
{
while ( !d->pendingConnections.isEmpty() ) {
QBluetoothRfcommSerialPort* port = d->pendingConnections.takeFirst();
// Send a message to the modem emulator to add the serial port.
QtopiaServiceRequest req( "ModemEmulator", "addSerialPort(QString)" );
req << port->device();
req.send();
d->runningConnections.append( port );
if (d->runningConnections.size() == 1) {
if (!d->m_session) {
QBluetoothLocalDevice local;
d->m_session = new QCommDeviceSession(local.deviceName().toLatin1(), this);
}
d->m_session->startSession();
}
}
}
示例3: connect
/*!
This method is the concrete implementation of the
QBluetoothAudioGateway interface method of the same name.
It is called from the QBluetoothHandsfreeAudioGatewayServer
class, which acts as a forwarding agent.
The address and channel to connect to are given by \a addr
and \a rfcomm_channel respectively.
\sa QBluetoothHeadsetAudioGatewayServer
*/
void QBluetoothHeadsetService::connect(const QBluetoothAddress &addr,
int rfcomm_channel)
{
// If the service is stop, deny connect requests
if (!m_data->m_server->isListening()) {
emit connectResult(false, tr("Service not available."));
return;
}
// If we're still connecting or disconnecting, return
if (m_data->m_connectInProgress || m_data->m_disconnectInProgress) {
emit connectResult(false, tr("Connection in progress."));
return;
}
// If we're connected, return, caller should call disconnect first
if (m_data->m_client &&
(m_data->m_client->state() == QBluetoothRfcommSocket::ConnectedState)) {
emit connectResult(false, tr("Already connected."));
return;
}
m_data->m_connectInProgress = true;
m_data->m_numRings = 0;
m_data->m_addr = addr;
m_data->m_channel = rfcomm_channel;
qLog(Bluetooth) << "Starting session for headset.";
if (!m_data->m_session) {
qLog(Bluetooth) << "Lazy initializing the QCommDeviceSession object";
QBluetoothLocalDevice local;
m_data->m_session = new QCommDeviceSession(local.deviceName().toLatin1());
QObject::connect(m_data->m_session, SIGNAL(sessionOpen()), this, SLOT(sessionOpen()));
QObject::connect(m_data->m_session, SIGNAL(sessionFailed()), this, SLOT(sessionFailed()));
}
m_data->m_session->startSession();
}