Commit f6e26afc authored by Pawel Polanski's avatar Pawel Polanski
Browse files

CODA: Added timeout for info button for CODA

parent f5ad4b60
......@@ -43,6 +43,7 @@
#include <symbianutils/symbiandevicemanager.h>
#include <codadevice.h>
#include "codaruncontrol.h"
#include "trkruncontrol.h"
#include <utils/detailswidget.h>
......@@ -51,6 +52,7 @@
#include <utils/pathchooser.h>
#include <QtCore/QDir>
#include <QtCore/QTimer>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QComboBox>
......@@ -137,7 +139,8 @@ S60DeployConfigurationWidget::S60DeployConfigurationWidget(QWidget *parent)
m_wlanRadioButton(new QRadioButton(tr("WLAN:"))),
m_ipAddress(new Utils::IpAddressLineEdit),
m_trkRadioButton(new QRadioButton(tr("TRK"))),
m_codaRadioButton(new QRadioButton(tr("CODA")))
m_codaRadioButton(new QRadioButton(tr("CODA"))),
m_codaTimeout(new QTimer(this))
{
}
......@@ -239,6 +242,9 @@ void S60DeployConfigurationWidget::init(ProjectExplorer::DeployConfiguration *dc
this, SLOT(updateInstallationDrives()));
connect(this, SIGNAL(infoCollected()),
this, SLOT(collectingInfoFinished()));
m_codaTimeout->setSingleShot(true);
connect(m_codaTimeout, SIGNAL(timeout()), this, SLOT(codaTimeout()));
}
QWidget *S60DeployConfigurationWidget::createCommunicationChannel()
......@@ -274,8 +280,8 @@ QWidget *S60DeployConfigurationWidget::createCommunicationChannel()
if(!m_deployConfiguration->deviceAddress().isEmpty())
m_ipAddress->setText(QString("%1:%2")
.arg(m_deployConfiguration->deviceAddress())
.arg(m_deployConfiguration->devicePort()));
.arg(m_deployConfiguration->deviceAddress())
.arg(m_deployConfiguration->devicePort()));
QHBoxLayout *wlanChannelLayout = new QHBoxLayout();
wlanChannelLayout->addWidget(new QLabel(tr("Address:")));
......@@ -473,7 +479,7 @@ void S60DeployConfigurationWidget::slotLauncherStateChanged(int s)
connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForTrkClosed()));
mb->open();
}
break;
break;
case trk::Launcher::DeviceDescriptionReceived: // All ok, done
setDeviceInfoLabel(m_infoLauncher->deviceDescription());
m_deviceInfoButton->setEnabled(true);
......@@ -544,6 +550,7 @@ void S60DeployConfigurationWidget::updateDeviceInfo()
//TODO error handling - for now just throw the command at coda
m_codaInfoDevice->sendSymbianOsDataGetQtVersionCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getQtVersionCommandResult));
m_deviceInfoButton->setEnabled(false);
m_codaTimeout->start(1000);
} else if(m_deployConfiguration->communicationChannel() == S60DeployConfiguration::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);
......@@ -554,6 +561,7 @@ void S60DeployConfigurationWidget::updateDeviceInfo()
codaSocket->connectToHost(m_deployConfiguration->deviceAddress(),
m_deployConfiguration->devicePort().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);
}
......@@ -562,7 +570,7 @@ void S60DeployConfigurationWidget::codaEvent(const Coda::CodaEvent &event)
{
switch (event.type()) {
case Coda::CodaEvent::LocatorHello: // Commands accepted now
setDeviceInfoLabel(m_deviceInfoLabel->text() + '.');
codaIncreaseProgress();
m_codaInfoDevice->sendSymbianOsDataGetQtVersionCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getQtVersionCommandResult));
break;
default:
......@@ -570,112 +578,112 @@ void S60DeployConfigurationWidget::codaEvent(const Coda::CodaEvent &event)
}
}
void S60DeployConfigurationWidget::getQtVersionCommandResult(const Coda::CodaCommandResult &result)
{
setDeviceInfoLabel(m_deviceInfoLabel->text() + '.');
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);
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);
setDeviceInfoLabel(m_deviceInfo, false);
} else {
if (result.values.count()) {
QHash<QString, QVariant> obj = result.values[0].toVariant().toHash();
QString ver = obj.value("qVersion").toString();
startTable(m_deviceInfo);
QTextStream str(&m_deviceInfo);
addToTable(str, tr("Qt version:"), ver);
QString systemVersion;
int symVer = obj.value("symbianVersion").toInt();
// Ugh why won't QSysInfo define these on non-symbian builds...
switch (symVer) {
case 10:
systemVersion.append("Symbian OS v9.2");
break;
case 20:
systemVersion.append("Symbian OS v9.3");
break;
case 30:
systemVersion.append("Symbian OS v9.4 / Symbian^1");
break;
case 40:
systemVersion.append("Symbian^2");
break;
case 50:
systemVersion.append("Symbian^3");
break;
case 60:
systemVersion.append("Symbian^4");
break;
default:
systemVersion.append(tr("Unrecognised Symbian version 0x%1").arg(symVer, 0, 16));
break;
}
systemVersion.append(", ");
int s60Ver = obj.value("s60Version").toInt();
switch (s60Ver) {
case 10:
systemVersion.append("S60 3rd Edition Feature Pack 1");
break;
case 20:
systemVersion.append("S60 3rd Edition Feature Pack 2");
break;
case 30:
systemVersion.append("S60 5th Edition");
break;
case 40:
systemVersion.append("S60 5th Edition Feature Pack 1");
break;
case 50:
systemVersion.append("S60 5th Edition Feature Pack 2");
break;
default:
systemVersion.append(tr("Unrecognised S60 version 0x%1").arg(symVer, 0, 16));
break;
}
addToTable(str, tr("OS version:"), systemVersion);
finishTable(m_deviceInfo);
}
}
m_codaInfoDevice->sendSymbianOsDataGetRomInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getRomInfoResult));
}
void S60DeployConfigurationWidget::getRomInfoResult(const Coda::CodaCommandResult &result)
{
setDeviceInfoLabel(m_deviceInfoLabel->text() + '.');
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
startTable(m_deviceInfo);
QTextStream str(&m_deviceInfo);
QVariantHash obj = result.values[0].toVariant().toHash();
QString romVersion = obj.value("romVersion", tr("unknown")).toString();
romVersion.replace('\n', " "); // The ROM string is split across multiple lines, for some reason.
addToTable(str, tr("ROM version:"), romVersion);
QString pr = obj.value("prInfo").toString();
if (pr.length())
addToTable(str, tr("Release:"), pr);
finishTable(m_deviceInfo);
}
QList<quint32> packagesOfInterest;
packagesOfInterest.append(CODA_UID);
packagesOfInterest.append(QTMOBILITY_UID);
m_codaInfoDevice->sendSymbianInstallGetPackageInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getInstalledPackagesResult), packagesOfInterest);
}
void S60DeployConfigurationWidget::getQtVersionCommandResult(const Coda::CodaCommandResult &result)
{
codaIncreaseProgress();
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);
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);
setDeviceInfoLabel(m_deviceInfo, false);
} else {
if (result.values.count()) {
QHash<QString, QVariant> obj = result.values[0].toVariant().toHash();
QString ver = obj.value("qVersion").toString();
startTable(m_deviceInfo);
QTextStream str(&m_deviceInfo);
addToTable(str, tr("Qt version:"), ver);
QString systemVersion;
int symVer = obj.value("symbianVersion").toInt();
// Ugh why won't QSysInfo define these on non-symbian builds...
switch (symVer) {
case 10:
systemVersion.append("Symbian OS v9.2");
break;
case 20:
systemVersion.append("Symbian OS v9.3");
break;
case 30:
systemVersion.append("Symbian OS v9.4 / Symbian^1");
break;
case 40:
systemVersion.append("Symbian^2");
break;
case 50:
systemVersion.append("Symbian^3");
break;
case 60:
systemVersion.append("Symbian^4");
break;
default:
systemVersion.append(tr("Unrecognised Symbian version 0x%1").arg(symVer, 0, 16));
break;
}
systemVersion.append(", ");
int s60Ver = obj.value("s60Version").toInt();
switch (s60Ver) {
case 10:
systemVersion.append("S60 3rd Edition Feature Pack 1");
break;
case 20:
systemVersion.append("S60 3rd Edition Feature Pack 2");
break;
case 30:
systemVersion.append("S60 5th Edition");
break;
case 40:
systemVersion.append("S60 5th Edition Feature Pack 1");
break;
case 50:
systemVersion.append("S60 5th Edition Feature Pack 2");
break;
default:
systemVersion.append(tr("Unrecognised S60 version 0x%1").arg(symVer, 0, 16));
break;
}
addToTable(str, tr("OS version:"), systemVersion);
finishTable(m_deviceInfo);
}
}
m_codaInfoDevice->sendSymbianOsDataGetRomInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getRomInfoResult));
}
void S60DeployConfigurationWidget::getRomInfoResult(const Coda::CodaCommandResult &result)
{
codaIncreaseProgress();
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
startTable(m_deviceInfo);
QTextStream str(&m_deviceInfo);
QVariantHash obj = result.values[0].toVariant().toHash();
QString romVersion = obj.value("romVersion", tr("unknown")).toString();
romVersion.replace('\n', " "); // The ROM string is split across multiple lines, for some reason.
addToTable(str, tr("ROM version:"), romVersion);
QString pr = obj.value("prInfo").toString();
if (pr.length())
addToTable(str, tr("Release:"), pr);
finishTable(m_deviceInfo);
}
QList<quint32> packagesOfInterest;
packagesOfInterest.append(CODA_UID);
packagesOfInterest.append(QTMOBILITY_UID);
m_codaInfoDevice->sendSymbianInstallGetPackageInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getInstalledPackagesResult), packagesOfInterest);
}
void S60DeployConfigurationWidget::getInstalledPackagesResult(const Coda::CodaCommandResult &result)
{
setDeviceInfoLabel(m_deviceInfoLabel->text() + '.');
codaIncreaseProgress();
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
startTable(m_deviceInfo);
QTextStream str(&m_deviceInfo);
......@@ -686,32 +694,32 @@ void S60DeployConfigurationWidget::getInstalledPackagesResult(const Coda::CodaCo
bool ok = false;
uint uid = obj.value("uid").toString().toUInt(&ok, 16);
if (ok) {
bool error = !obj.value("error").isNull();
QString versionString;
if (!error) {
QVariantList version = obj.value("version").toList();
versionString = QString("%1.%2.%3").arg(version[0].toInt())
.arg(version[1].toInt())
.arg(version[2].toInt());
}
switch (uid) {
case CODA_UID: {
if (error) {
// How can coda not be installed? Presumably some UID wrongness...
addErrorToTable(str, tr("CODA version: "), tr("Error reading CODA version"));
} else
addToTable(str, tr("CODA version: "), versionString);
}
break;
case QTMOBILITY_UID: {
if (error)
addErrorToTable(str, tr("QtMobility version: "), tr("Error reading QtMobility version"));
else
addToTable(str, tr("QtMobility version: "), versionString);
}
break;
default: break;
}
bool error = !obj.value("error").isNull();
QString versionString;
if (!error) {
QVariantList version = obj.value("version").toList();
versionString = QString("%1.%2.%3").arg(version[0].toInt())
.arg(version[1].toInt())
.arg(version[2].toInt());
}
switch (uid) {
case CODA_UID: {
if (error) {
// How can coda not be installed? Presumably some UID wrongness...
addErrorToTable(str, tr("CODA version: "), tr("Error reading CODA version"));
} else
addToTable(str, tr("CODA version: "), versionString);
}
break;
case QTMOBILITY_UID: {
if (error)
addErrorToTable(str, tr("QtMobility version: "), tr("Error reading QtMobility version"));
else
addToTable(str, tr("QtMobility version: "), versionString);
}
break;
default: break;
}
}
}
finishTable(m_deviceInfo);
......@@ -724,38 +732,61 @@ void S60DeployConfigurationWidget::getInstalledPackagesResult(const Coda::CodaCo
m_codaInfoDevice->sendSymbianOsDataGetHalInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getHalResult), keys);
}
void S60DeployConfigurationWidget::getHalResult(const Coda::CodaCommandResult &result)
{
setDeviceInfoLabel(m_deviceInfoLabel->text() + '.');
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
QVariantList resultsList = result.values[0].toVariant().toList();
int x = 0;
int y = 0;
foreach (const QVariant& var, resultsList) {
QVariantHash obj = var.toHash();
if (obj.value("name").toString() == "EDisplayXPixels")
x = obj.value("value").toInt();
else if (obj.value("name").toString() == "EDisplayYPixels")
y = obj.value("value").toInt();
}
if (x && y) {
startTable(m_deviceInfo);
QTextStream str(&m_deviceInfo);
addToTable(str, tr("Screen size:"), QString("%1x%2").arg(x).arg(y));
finishTable(m_deviceInfo);
}
}
// Done with collecting info
emit infoCollected();
}
void S60DeployConfigurationWidget::collectingInfoFinished()
{
m_deviceInfoButton->setEnabled(true);
setDeviceInfoLabel(m_deviceInfo);
SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaInfoDevice);
}
void S60DeployConfigurationWidget::getHalResult(const Coda::CodaCommandResult &result)
{
codaIncreaseProgress();
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
QVariantList resultsList = result.values[0].toVariant().toList();
int x = 0;
int y = 0;
foreach (const QVariant& var, resultsList) {
QVariantHash obj = var.toHash();
if (obj.value("name").toString() == "EDisplayXPixels")
x = obj.value("value").toInt();
else if (obj.value("name").toString() == "EDisplayYPixels")
y = obj.value("value").toInt();
}
if (x && y) {
startTable(m_deviceInfo);
QTextStream str(&m_deviceInfo);
addToTable(str, tr("Screen size:"), QString("%1x%2").arg(x).arg(y));
finishTable(m_deviceInfo);
}
}
// Done with collecting info
emit infoCollected();
}
void S60DeployConfigurationWidget::codaIncreaseProgress()
{
m_codaTimeout->start();
setDeviceInfoLabel(m_deviceInfoLabel->text() + '.');
}
void S60DeployConfigurationWidget::collectingInfoFinished()
{
m_codaTimeout->stop();
emit codaConnected();
m_deviceInfoButton->setEnabled(true);
setDeviceInfoLabel(m_deviceInfo);
SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaInfoDevice);
}
void S60DeployConfigurationWidget::codaTimeout()
{
QMessageBox *mb = CodaRunControl::createCodaWaitingMessageBox(this);
connect(this, SIGNAL(codaConnected()), mb, SLOT(close()));
connect(mb, SIGNAL(finished(int)), this, SLOT(codaCanceled()));
mb->open();
}
void S60DeployConfigurationWidget::codaCanceled()
{
clearDeviceInfo();
m_deviceInfoButton->setEnabled(true);
SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaInfoDevice);
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -86,6 +86,7 @@ public:
signals:
void infoCollected();
void codaConnected();
private slots:
void updateTargetInformation();
......@@ -103,6 +104,9 @@ private slots:
void cleanWlanAddress();
void codaEvent(const Coda::CodaEvent &event);
void collectingInfoFinished();
void codaTimeout();
void codaCanceled();
void codaIncreaseProgress();
private:
inline SymbianUtils::SymbianDevice device(int i) const;
......@@ -134,6 +138,7 @@ private:
QRadioButton *m_codaRadioButton;
QSharedPointer<Coda::CodaDevice> m_codaInfoDevice;
QString m_deviceInfo;
QTimer *m_codaTimeout;
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment