Exemplo n.º 1
0
void QuteMessenger::newServiceFound(const QBtDevice& dev, const QBtService& serv)
{
    //since we need only the first available service with the given ClassID
    //when the first service is reported, the service discovery stops
    disconnect(serviceDisc, SIGNAL(newServiceFound(const QBtDevice&, const QBtService&)), this,
               SLOT(newServiceFound(const QBtDevice&, const QBtService&)));

    qDebug() << "Service to connect: " << serv.getName();
    qDebug() << "UUID: " << serv.getClass().get();
    qDebug() << "Dev: " << dev.getName();
    qDebug() << "Dev Addr: " << dev.getAddress().toString();

    if(obexClient)
    {
        delete obexClient;
        obexClient = NULL;
    }

    obexClient = new QBtObjectExchangeClient(this);

    connect(obexClient, SIGNAL(connectedToServer()), this, SLOT(connectedToRemoteOBEXServer()));
    connect(obexClient, SIGNAL(objectSent()), this, SLOT(fileSent()));
    connect(obexClient, SIGNAL(error (QBtObjectExchangeClient::ErrorCode)),
            this, SLOT(reportObexError(QBtObjectExchangeClient::ErrorCode)) );

    selectedService = serv;

    obexClient->connectToServer(deviceQueriedForServices, selectedService);
}
Exemplo n.º 2
0
void QuteMessenger::newSerialServiceFound(const QBtDevice& dev, const QBtService& serv)
{
    QString exprectedServiceName("Messenger Protocol ");
    exprectedServiceName += dev.getName();

    qDebug() << exprectedServiceName;
    qDebug() << serv.getName();

    if (QString::compare(exprectedServiceName, serv.getName()) == 0)
    {
        serviceDisc->stopDiscovery();
        selectedService = serv;

        QChatWidgetClient* tmpChat;
        tmpChat = new QChatWidgetClient(this);
        tmpChat->SetName(deviceQueriedForServices.getName());

        ui.tabWidget->addTab(tmpChat, deviceQueriedForServices.getName());
        chatTabs.append((QChatWidget*) tmpChat);

        connect(this, SIGNAL(serialParamRetreived(QBtDevice, QBtService)),
                tmpChat, SLOT(setParameters(QBtDevice, QBtService)));

        emit serialParamRetreived(dev, serv);
    }
}
/**
* ConnectToServer
* Connect to the server
* @param remoteDevice the remote server to connect to
* @param remoteServive the remote service of the server
*/
void QBtObjectExchangeClientPrivate::ConnectToServer(const QBtDevice& remoteDevice, const QBtService& remoteService)
{
	//check
	if( !remoteDevice.getAddress().isValid())
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientNoSelectedDevice);
		return;
	}
	if( remoteService.getClass()  == QBtConstants::UndefinedClass &&
		remoteService.getHandle() == 0)
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientNoSelectedService);
		return;
	}
	
	server = new QBtDevice(remoteDevice);
	connectingService = new QBtService(remoteService);
	
	BTDEVHDL devHandle = GetDeviceHandle(server->getAddress());

	BTINT32 result = BTSDK_FALSE;

	if(connectionHandle != BTSDK_INVALID_HANDLE)
		result = Btsdk_Connect(connectingService->getHandle(), 0, &connectionHandle);
	else
		result = Btsdk_ConnectEx(devHandle, connectingService->getClass(), 0, &connectionHandle);

	if(result != BTSDK_OK)
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientConnectionError);
	else
		emit p_ptr->connectedToServer();
}
Exemplo n.º 4
0
bool QBtLocalDevicePrivate::AddNewDevice(const QBtDevice& device)
{
    BTUINT8 devAddr[6] = {0};
    BTDEVHDL devHandle = BTSDK_INVALID_HANDLE;
    QByteArray addrArray = device.getAddress().toReversedByteArray();
    memcpy(devAddr, addrArray.constData(), addrArray.size());
    devHandle = Btsdk_AddRemoteDevice(devAddr);

    return (devHandle != BTSDK_INVALID_HANDLE);
}
Exemplo n.º 5
0
bool QBtLocalDevice::deleteDevice(const QBtDevice& device)
{
    return QBtLocalDevice::deleteDevice(device.getAddress());
}
Exemplo n.º 6
0
bool QBtLocalDevice::unpairDevice(const QBtDevice& device)
{
    return QBtLocalDevice::unpairDevice(device.getAddress());
}
Exemplo n.º 7
0
void QuteMessenger::populateDeviceList(QBtDevice newDevice)
{
    ui.deviceListWidget->addItem(newDevice.getName());
    foundDevices.append(newDevice);
}
void QBtSingleDeviceSelectorUIPrivate::populateDeviceList(const QBtDevice& device)
{
    QBtDevice* newDev = new QBtDevice(device);
    _devicesFound.append(*newDev);
    _devList->addItem(device.getName());
}
void QBtDeviceDiscovererPrivate::RegisterFoundDevice(BTDEVHDL dev_hdl)
{
	BTUINT8 szDevName[BTSDK_DEVNAME_LEN] = { 0 };
	BTUINT16 usLen = 0;
	BTUINT32 ulDevClass = 0;
	BTUINT8 szBdAddr[6] = {0};
	QBtDevice devInfo;

	usLen = BTSDK_DEVNAME_LEN;

	BTINT32 result = BTSDK_FALSE;
	if ((result = Btsdk_GetRemoteDeviceName(dev_hdl, szDevName, &usLen)) != BTSDK_OK)
	{
		usLen = BTSDK_DEVNAME_LEN;
		ZeroMemory(szDevName, BTSDK_DEVNAME_LEN);
		if ((result = Btsdk_UpdateRemoteDeviceName(dev_hdl, szDevName, &usLen)) != BTSDK_OK)
		{
			strcpy((char*)szDevName, "Unknown");
		}
	}

	devInfo.setName(QString::fromUtf8((char*)szDevName));

	Btsdk_GetRemoteDeviceAddress(dev_hdl, szBdAddr);

	QByteArray btAddrr((char*)szBdAddr, 6);
	devInfo.setAddress(QBtAddress::getAddressFromReversedArray(btAddrr));

	Btsdk_GetRemoteDeviceClass(dev_hdl, &ulDevClass);
	
	if(ulDevClass & BTSDK_DEVCLS_COMPUTER)
		devInfo.setType(QBtDevice::Computer);
	else if(ulDevClass & BTSDK_DEVCLS_PHONE)
		devInfo.setType(QBtDevice::Phone);
	else if(ulDevClass & BTSDK_DEVCLS_LAP)
		devInfo.setType(QBtDevice::LANAccess);
	else if(ulDevClass & BTSDK_DEVCLS_AUDIO)
		devInfo.setType(QBtDevice::AudioVideo);
	else if(ulDevClass & BTSDK_DEVCLS_PERIPHERAL)
		devInfo.setType(QBtDevice::Peripheral);
	else if(ulDevClass & BTSDK_DEVCLS_IMAGE)
		devInfo.setType(QBtDevice::Imaging);
	else if(ulDevClass & BTSDK_DEVCLS_IMAGE)
		devInfo.setType(QBtDevice::Imaging);
	else if(ulDevClass & BTSDK_DEVCLS_WEARABLE)
		devInfo.setType(QBtDevice::Wearable);
	else
		devInfo.setType(QBtDevice::Uncategorized);

	deviceList.append(devInfo);

	if(sp_ptr)
		emit sp_ptr->newDeviceFound(devInfo);
}