Commit 99e13e5b authored by Pawel Polanski's avatar Pawel Polanski
Browse files

CODA: Added info button to WLan mode

parent a6637d15
......@@ -67,6 +67,8 @@
#include <QtGui/QRadioButton>
#include <QtGui/QValidator>
#include <QtNetwork/QTcpSocket>
Q_DECLARE_METATYPE(SymbianUtils::SymbianDevice)
namespace Qt4ProjectManager {
......@@ -214,10 +216,8 @@ void S60DeployConfigurationWidget::init(ProjectExplorer::DeployConfiguration *dc
m_serialRadioButton->setChecked(!usingTcp);
m_wlanRadioButton->setChecked(usingTcp);
connect(m_trkRadioButton, SIGNAL(clicked()), this, SLOT(updateDebugClient()));
connect(m_codaRadioButton, SIGNAL(clicked()), this, SLOT(updateDebugClient()));
updateDebugClient();
connect(m_trkRadioButton, SIGNAL(clicked()), this, SLOT(updateCommunicationChannel()));
connect(m_codaRadioButton, SIGNAL(clicked()), this, SLOT(updateCommunicationChannel()));
formLayout->addRow(debugClientGroupBox);
......@@ -237,6 +237,8 @@ void S60DeployConfigurationWidget::init(ProjectExplorer::DeployConfiguration *dc
this, SLOT(updateTargetInformation()));
connect(m_deployConfiguration, SIGNAL(availableDeviceDrivesChanged()),
this, SLOT(updateInstallationDrives()));
connect(this, SIGNAL(infoCollected()),
this, SLOT(collectingInfoFinished()));
}
QWidget *S60DeployConfigurationWidget::createCommunicationChannel()
......@@ -322,7 +324,6 @@ void S60DeployConfigurationWidget::silentInstallChanged(int state)
void S60DeployConfigurationWidget::updateSerialDevices()
{
m_serialPortsCombo->clear();
clearDeviceInfo();
const QString previouPortName = m_deployConfiguration->serialPortName();
const QList<SymbianUtils::SymbianDevice> devices = SymbianUtils::SymbianDeviceManager::instance()->devices();
int newIndex = -1;
......@@ -332,6 +333,14 @@ void S60DeployConfigurationWidget::updateSerialDevices()
if (device.portName() == previouPortName)
newIndex = i;
}
if(m_deployConfiguration->communicationChannel()
== S60DeployConfiguration::CommunicationCodaTcpConnection) {
m_deviceInfoButton->setEnabled(true);
return;
}
clearDeviceInfo();
// Set new index: prefer to keep old or set to 0, if available.
if (newIndex == -1 && !devices.empty())
newIndex = 0;
......@@ -344,9 +353,6 @@ void S60DeployConfigurationWidget::updateSerialDevices()
const QString newPortName = device(newIndex).portName();
m_deployConfiguration->setSerialPortName(newPortName);
}
if (m_deployConfiguration->communicationChannel() != S60DeployConfiguration::CommunicationTrkSerialConnection
&& m_deployConfiguration->communicationChannel() != S60DeployConfiguration::CommunicationCodaSerialConnection)
m_deviceInfoButton->setEnabled(false);
}
SymbianUtils::SymbianDevice S60DeployConfigurationWidget::device(int i) const
......@@ -389,41 +395,34 @@ void S60DeployConfigurationWidget::setSerialPort(int index)
clearDeviceInfo();
}
void S60DeployConfigurationWidget::updateDebugClient()
{
if (!m_trkRadioButton->isChecked() && !m_codaRadioButton->isChecked())
m_trkRadioButton->setChecked(true);
if (m_trkRadioButton->isChecked()) {
m_serialRadioButton->setEnabled(true);
m_serialRadioButton->setChecked(true);
m_wlanRadioButton->setEnabled(false);
updateSerialDevices();
} else if(m_codaRadioButton->isChecked()) {
m_serialRadioButton->setEnabled(true);
m_wlanRadioButton->setEnabled(true);
}
updateCommunicationChannel();
}
void S60DeployConfigurationWidget::updateCommunicationChannel()
{
if (!m_serialRadioButton->isChecked() && !m_wlanRadioButton->isChecked())
m_serialRadioButton->setChecked(true);
if (!m_trkRadioButton->isChecked() && !m_codaRadioButton->isChecked())
m_trkRadioButton->setChecked(true);
if (m_serialRadioButton->isChecked()) {
if (m_trkRadioButton->isChecked()) {
m_serialRadioButton->setChecked(true);
m_wlanRadioButton->setDisabled(true);
m_ipAddress->setDisabled(true);
m_serialPortsCombo->setDisabled(false);
if (m_trkRadioButton->isChecked())
m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationTrkSerialConnection);
else
m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationCodaSerialConnection);
m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationTrkSerialConnection);
updateSerialDevices();
} else if(m_wlanRadioButton->isChecked()) {
m_ipAddress->setDisabled(false);
m_serialPortsCombo->setDisabled(true);
m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationCodaTcpConnection);
} else if (m_codaRadioButton->isChecked()) {
if (!m_wlanRadioButton->isChecked() && !m_serialRadioButton->isChecked())
m_serialRadioButton->setChecked(true);
m_wlanRadioButton->setDisabled(false);
if (m_wlanRadioButton->isChecked()) {
m_ipAddress->setDisabled(false);
m_serialPortsCombo->setDisabled(true);
m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationCodaTcpConnection);
m_deviceInfoButton->setEnabled(true);
} else {
m_ipAddress->setDisabled(true);
m_serialPortsCombo->setDisabled(false);
m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationCodaSerialConnection);
updateSerialDevices();
}
}
}
......@@ -546,121 +545,139 @@ 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);
} else if(m_deployConfiguration->communicationChannel() == S60DeployConfiguration::CommunicationCodaTcpConnection) {
setDeviceInfoLabel(tr("Connecting..."));
// 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(tcfEvent(Coda::CodaEvent)), this, SLOT(codaEvent(Coda::CodaEvent)));
const QSharedPointer<QTcpSocket> codaSocket(new QTcpSocket);
m_codaInfoDevice->setDevice(codaSocket);
codaSocket->connectToHost(m_deployConfiguration->deviceAddress(),
m_deployConfiguration->devicePort().toInt());
m_deviceInfoButton->setEnabled(false);
} else
setDeviceInfoLabel(tr("Currently there is no information about the device for this connection type."), true);
}
void S60DeployConfigurationWidget::getQtVersionCommandResult(const Coda::CodaCommandResult &result)
void S60DeployConfigurationWidget::codaEvent(const Coda::CodaEvent &event)
{
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){
QString message;
startTable(message);
QTextStream str(&message);
addErrorToTable(str, tr("Qt version: "), tr("Not installed on device"));
finishTable(message);
setDeviceInfoLabel(message, false);
} else {
QString resultString;
if (result.values.count()) {
QHash<QString, QVariant> obj = result.values[0].toVariant().toHash();
QString ver = obj.value("qVersion").toString();
startTable(resultString);
QTextStream str(&resultString);
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(resultString);
}
setDeviceInfoLabel(resultString);
switch (event.type()) {
case Coda::CodaEvent::LocatorHello: // Commands accepted now
m_codaInfoDevice->sendSymbianOsDataGetQtVersionCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getQtVersionCommandResult));
break;
default:
break;
}
m_codaInfoDevice->sendSymbianOsDataGetRomInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getRomInfoResult));
}
void S60DeployConfigurationWidget::getRomInfoResult(const Coda::CodaCommandResult &result)
{
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
QString resultString = m_deviceInfoLabel->text();
startTable(resultString);
QTextStream str(&resultString);
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(resultString);
setDeviceInfoLabel(resultString);
}
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)
{
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)
{
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)
{
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
QString resultString = m_deviceInfoLabel->text();
startTable(resultString);
QTextStream str(&resultString);
startTable(m_deviceInfo);
QTextStream str(&m_deviceInfo);
QVariantList resultsList = result.values[0].toVariant().toList();
foreach (const QVariant& var, resultsList) {
......@@ -696,8 +713,7 @@ void S60DeployConfigurationWidget::getInstalledPackagesResult(const Coda::CodaCo
}
}
}
finishTable(resultString);
setDeviceInfoLabel(resultString);
finishTable(m_deviceInfo);
}
QStringList keys;
......@@ -707,33 +723,37 @@ void S60DeployConfigurationWidget::getInstalledPackagesResult(const Coda::CodaCo
m_codaInfoDevice->sendSymbianOsDataGetHalInfoCommand(Coda::CodaCallback(this, &S60DeployConfigurationWidget::getHalResult), keys);
}
void S60DeployConfigurationWidget::getHalResult(const Coda::CodaCommandResult &result)
{
if (result.type == Coda::CodaCommandResult::SuccessReply && result.values.count()) {
QString resultString = m_deviceInfoLabel->text();
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(resultString);
QTextStream str(&resultString);
addToTable(str, tr("Screen size:"), QString("%1x%2").arg(x).arg(y));
finishTable(resultString);
setDeviceInfoLabel(resultString);
}
}
// Done with collecting info
m_deviceInfoButton->setEnabled(true);
SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaInfoDevice);
}
void S60DeployConfigurationWidget::getHalResult(const Coda::CodaCommandResult &result)
{
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);
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -63,6 +63,7 @@ class SymbianDevice;
namespace Coda {
class CodaDevice;
class CodaEvent;
struct CodaCommandResult;
}
......@@ -83,6 +84,9 @@ public:
void init(ProjectExplorer::DeployConfiguration *dc);
signals:
void infoCollected();
private slots:
void updateTargetInformation();
void updateInstallationDrives();
......@@ -95,9 +99,10 @@ private slots:
void slotWaitingForTrkClosed();
void silentInstallChanged(int);
void updateCommunicationChannel();
void updateDebugClient();
void updateWlanAddress(const QString &address);
void cleanWlanAddress();
void codaEvent(const Coda::CodaEvent &event);
void collectingInfoFinished();
private:
inline SymbianUtils::SymbianDevice device(int i) const;
......@@ -128,6 +133,7 @@ private:
QRadioButton *m_trkRadioButton;
QRadioButton *m_codaRadioButton;
QSharedPointer<Coda::CodaDevice> m_codaInfoDevice;
QString m_deviceInfo;
};
} // namespace Internal
......
......@@ -468,7 +468,7 @@ void S60DeployStep::slotSerialPong(const QString &message)
qDebug() << "CODA serial pong:" << message;
}
void S60DeployStep::slotCodaEvent (const Coda::CodaEvent &event)
void S60DeployStep::slotCodaEvent(const Coda::CodaEvent &event)
{
if (debug)
qDebug() << "CODA event:" << "Type:" << event.type() << "Message:" << event.toString();
......
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