void QBtServiceDiscovererPrivate::Construct()
{
	InitBthSdk();

	connect(p_ptr, SIGNAL(discoveryStarted()), 
			this, SLOT(SetBusy()));
	connect(p_ptr, SIGNAL(discoveryStopped()),
			this, SLOT(SetNotBusy()));
}
void QuteMessenger::deviceDiscoveryCompleteReport()
{
    disconnect(devDisc, SIGNAL(newDeviceFound(QBtDevice)), this,
               SLOT(populateDeviceList(QBtDevice)));
    disconnect(devDisc, SIGNAL(discoveryStopped()), this, SLOT(deviceDiscoveryCompleteReport()));

    if (dialog) {
        dialog->hide();
        delete dialog;
    }
}
/*************************************************************
 *  	Start chat from the client side
 *************************************************************/
void QuteMessenger::startChatReport()
{
    SaveSelectedDevice();

    //////////////////////////////////////////////

    //////////////////////////////////////////////

    connect(serviceDisc, SIGNAL(newServiceFound(const QBtDevice&, const QBtService&)), this,
            SLOT(newSerialServiceFound(const QBtDevice&, const QBtService&)));

    connect(serviceDisc, SIGNAL(discoveryStopped ()),
            this, SLOT(unregisterServiceDiscoveryConnection()));

    const QBtUuid uid(QBtConstants::SerialPort);
    serviceDisc->startDiscovery(deviceQueriedForServices, uid);
}
QuteMessenger::~QuteMessenger()
{
    for (int i = 0; i < chatTabs.size(); i++)
        SafeDelete(chatTabs[i]);

    if (rfcommServer) {
        disconnect(rfcommServer, SIGNAL(clientDisconnected()));
        disconnect(rfcommServer, SIGNAL(clientConnected(QBtAddress)));
        delete rfcommServer;
    }
    if (devDisc) {
        disconnect(devDisc, SIGNAL(newDeviceFound(QBtDevice)));
        disconnect(devDisc, SIGNAL(discoveryStopped()));
        delete devDisc;
    }
    if (serviceDisc)
        delete serviceDisc;

}
void QuteMessenger::startDeviceDiscovery()
{
    SetupMenu(true);
    if (devDisc) {
        ui.deviceListWidget->clear();
        foundDevices.clear();
        connect(devDisc, SIGNAL(newDeviceFound(QBtDevice)), this,
                SLOT(populateDeviceList(QBtDevice)));
        connect(devDisc, SIGNAL(discoveryStopped()), this, SLOT(deviceDiscoveryCompleteReport()));
        devDisc->startDiscovery();

        dialog = new QProgressDialog("Searching devices...", "Stop", 0, 0, this);
        dialog->setWindowModality(Qt::WindowModal);
        connect(dialog, SIGNAL(canceled()), this, SLOT(deviceDiscoveryCompleteReport()));
        dialog->setBar(NULL);

        dialog->show();
    }
}