void SymbianIDeviceConfigurationWidget::updateDeviceInfo()
{
    setDeviceInfoLabel(tr("Connecting"));
    if (symbianDevice()->communicationChannel() == SymbianIDevice::CommunicationCodaSerialConnection) {
        const SymbianUtils::SymbianDevice commDev = currentRawDevice();
        m_codaInfoDevice = SymbianUtils::SymbianDeviceManager::instance()->getCodaDevice(commDev.portName());
        if (m_codaInfoDevice.isNull()) {
            setDeviceInfoLabel(tr("Unable to create CODA connection. Please try again."), true);
            return;
        }
        if (!m_codaInfoDevice->device()->isOpen()) {
            setDeviceInfoLabel(m_codaInfoDevice->device()->errorString(), true);
            return;
        }
        //TODO error handling - for now just throw the command at coda
        m_codaInfoDevice->sendSymbianOsDataGetQtVersionCommand(Coda::CodaCallback(this, &SymbianIDeviceConfigurationWidget::getQtVersionCommandResult));
        m_deviceInfoButton->setEnabled(false);
        m_codaTimeout->start(1000);
    } else if (symbianDevice()->communicationChannel() == SymbianIDevice::CommunicationCodaTcpConnection) {
        // collectingInfoFinished, which deletes m_codaDevice, can get called from within a coda callback, so need to use deleteLater
        m_codaInfoDevice =  QSharedPointer<Coda::CodaDevice>(new Coda::CodaDevice, &QObject::deleteLater);
        connect(m_codaInfoDevice.data(), SIGNAL(codaEvent(Coda::CodaEvent)), this, SLOT(codaEvent(Coda::CodaEvent)));

        const QSharedPointer<QTcpSocket> codaSocket(new QTcpSocket);
        m_codaInfoDevice->setDevice(codaSocket);
        codaSocket->connectToHost(symbianDevice()->address(),
                                  symbianDevice()->port().toInt());
        m_deviceInfoButton->setEnabled(false);
        m_codaTimeout->start(1500);
    } else
        setDeviceInfoLabel(tr("Currently there is no information about the device for this connection type."), true);
}
Esempio n. 2
0
void S60DeployConfigurationWidget::updateDeviceInfo()
{
    //TODO: No CODA device info! Implement it when it is available
    if (m_deployConfiguration->communicationChannel() == S60DeployConfiguration::CommunicationTrkSerialConnection) {
        QTC_ASSERT(!m_infoLauncher, return)
                setDeviceInfoLabel(tr("Connecting..."));
        // Do a launcher run with the ping protocol. Prompt to connect and
        // go asynchronous afterwards to pop up launch trk box if a timeout occurs.
        QString message;
        const SymbianUtils::SymbianDevice commDev = currentDevice();
        m_infoLauncher = trk::Launcher::acquireFromDeviceManager(commDev.portName(), this, &message);
        if (!m_infoLauncher) {
            setDeviceInfoLabel(message, true);
            return;
        }
        connect(m_infoLauncher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int)));

        m_infoLauncher->setSerialFrame(commDev.type() == SymbianUtils::SerialPortCommunication);
        m_infoLauncher->setTrkServerName(commDev.portName());

        // Prompt user
        const trk::PromptStartCommunicationResult src =
                S60RunConfigBluetoothStarter::startCommunication(m_infoLauncher->trkDevice(),
                                                                 this, &message);
        switch (src) {
        case trk::PromptStartCommunicationConnected:
            break;
        case trk::PromptStartCommunicationCanceled:
            clearDeviceInfo();
            m_infoLauncher->deleteLater();
            return;
        case trk::PromptStartCommunicationError:
            setDeviceInfoLabel(message, true);
            m_infoLauncher->deleteLater();
            return;
        };
        if (!m_infoLauncher->startServer(&message)) {
            setDeviceInfoLabel(message, true);
            m_infoLauncher->deleteLater();
            return;
        }
        // Wait for either timeout or results
        m_deviceInfoButton->setEnabled(false);
    } else
void S60DeviceRunConfigurationWidget::slotLauncherStateChanged(int s)
{
    switch (s) {
    case trk::Launcher::WaitingForTrk: {
        // Entered trk wait state..open message box
        QMessageBox *mb = S60DeviceRunControlBase::createTrkWaitingMessageBox(m_infoLauncher->trkServerName(), this);
        connect(m_infoLauncher, SIGNAL(stateChanged(int)), mb, SLOT(close()));
        connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForTrkClosed()));
        mb->open();
    }
        break;
    case trk::Launcher::DeviceDescriptionReceived: // All ok, done
        setDeviceInfoLabel(m_infoLauncher->deviceDescription());
        m_deviceInfoButton->setEnabled(true);
        m_infoLauncher->deleteLater();
        break;
    }
}
void SymbianIDeviceConfigurationWidget::getQtVersionCommandResult(const Coda::CodaCommandResult &result)
{
    m_deviceInfo.clear();
    if (result.type == Coda::CodaCommandResult::FailReply) {
        setDeviceInfoLabel(tr("No device information available"), true);
        SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaInfoDevice);
        m_deviceInfoButton->setEnabled(true);
        m_codaTimeout->stop();
        return;
    } else if (result.type == Coda::CodaCommandResult::CommandErrorReply){
        startTable(m_deviceInfo);
        QTextStream str(&m_deviceInfo);
        addErrorToTable(str, tr("Qt version: "), tr("Not installed on device"));
        finishTable(m_deviceInfo);
    } else {
        if (result.values.count()) {
            QHash<QString, QVariant> obj = result.values[0].toVariant().toHash();
            QString ver = obj.value(QLatin1String("qVersion")).toString();

            startTable(m_deviceInfo);
            QTextStream str(&m_deviceInfo);
            addToTable(str, tr("Qt version:"), ver);
            QString systemVersion;

            const int symVer = obj.value(QLatin1String("symbianVersion")).toInt();
            // Ugh why won't QSysInfo define these on non-symbian builds...
            switch (symVer) {
            case 10:
                systemVersion.append(QLatin1String("Symbian OS v9.2"));
                break;
            case 20:
                systemVersion.append(QLatin1String("Symbian OS v9.3"));
                break;
            case 30:
                systemVersion.append(QLatin1String("Symbian OS v9.4 / Symbian^1"));
                break;
            case 40:
                systemVersion.append(QLatin1String("Symbian^2"));
                break;
            case 50:
                systemVersion.append(QLatin1String("Symbian^3"));
                break;
            case 60:
                systemVersion.append(QLatin1String("Symbian^4"));
                break;
            case 70:
                systemVersion.append(QLatin1String("Symbian^3")); // TODO: might change
                break;
            default:
                systemVersion.append(tr("Unrecognised Symbian version 0x%1").arg(symVer, 0, 16));
                break;
            }
            systemVersion.append(QLatin1String(", "));
            int s60Ver = obj.value(QLatin1String("s60Version")).toInt();
            switch (s60Ver) {
            case 10:
                systemVersion.append(QLatin1String("S60 3rd Edition Feature Pack 1"));
                break;
            case 20:
                systemVersion.append(QLatin1String("S60 3rd Edition Feature Pack 2"));
                break;
            case 30:
                systemVersion.append(QLatin1String("S60 5th Edition"));
                break;
            case 40:
                systemVersion.append(QLatin1String("S60 5th Edition Feature Pack 1"));
                break;
            case 50:
                systemVersion.append(QLatin1String("S60 5th Edition Feature Pack 2"));
                break;
            case 70:
                systemVersion.append(QLatin1String("S60 5th Edition Feature Pack 3")); // TODO: might change
                break;
            default:
                systemVersion.append(tr("Unrecognised S60 version 0x%1").arg(symVer, 0, 16));
                break;
            }
            addToTable(str, tr("OS version:"), systemVersion);
            finishTable(m_deviceInfo);
        }
    }
    codaIncreaseProgress();
    if (m_codaInfoDevice)
        m_codaInfoDevice->sendSymbianOsDataGetRomInfoCommand(Coda::CodaCallback(this, &SymbianIDeviceConfigurationWidget::getRomInfoResult));
}