forked from qt-creator/qt-creator
CODA: API has changed
and Creator site has to be adjusted Change-Id: If93d56bc2ad19aae985e8e861c6030950d8d846d Reviewed-on: http://codereview.qt.nokia.com/706 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
committed by
Paweł Polański
parent
44e905d08c
commit
0e4af76313
@@ -70,7 +70,8 @@ CodaRunControl::CodaRunControl(RunConfiguration *runConfiguration, const QString
|
||||
S60RunControlBase(runConfiguration, mode),
|
||||
m_port(0),
|
||||
m_state(StateUninit),
|
||||
m_stopAfterConnect(false)
|
||||
m_stopAfterConnect(false),
|
||||
m_codaFlags(0)
|
||||
{
|
||||
const S60DeviceRunConfiguration *s60runConfig = qobject_cast<S60DeviceRunConfiguration *>(runConfiguration);
|
||||
QTC_ASSERT(s60runConfig, return);
|
||||
@@ -133,29 +134,25 @@ bool CodaRunControl::setupLauncher()
|
||||
}
|
||||
connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)),
|
||||
this, SLOT(deviceRemoved(SymbianUtils::SymbianDevice)));
|
||||
connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(slotError(QString)));
|
||||
connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotCodaLogMessage(QString)));
|
||||
connect(m_codaDevice.data(), SIGNAL(codaEvent(Coda::CodaEvent)), this, SLOT(slotCodaEvent(Coda::CodaEvent)));
|
||||
connect(m_codaDevice.data(), SIGNAL(serialPong(QString)), this, SLOT(slotSerialPong(QString)));
|
||||
m_state = StateConnecting;
|
||||
m_codaDevice->sendSerialPing(false);
|
||||
} else {
|
||||
// For TCP we don't use device manager, we just set it up directly
|
||||
m_codaDevice = QSharedPointer<Coda::CodaDevice>(new Coda::CodaDevice, &QObject::deleteLater); // finishRunControl, which deletes m_codaDevice, can get called from within a coda callback, so need to use deleteLater
|
||||
connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(slotError(QString)));
|
||||
connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotCodaLogMessage(QString)));
|
||||
connect(m_codaDevice.data(), SIGNAL(codaEvent(Coda::CodaEvent)), this, SLOT(slotCodaEvent(Coda::CodaEvent)));
|
||||
|
||||
const QSharedPointer<QTcpSocket> codaSocket(new QTcpSocket);
|
||||
m_codaDevice->setDevice(codaSocket);
|
||||
codaSocket->connectToHost(m_address, m_port);
|
||||
m_state = StateConnecting;
|
||||
appendMessage(tr("Connecting to %1:%2...\n").arg(m_address).arg(m_port), Utils::NormalMessageFormat);
|
||||
}
|
||||
|
||||
connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(slotError(QString)));
|
||||
connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotCodaLogMessage(QString)));
|
||||
connect(m_codaDevice.data(), SIGNAL(codaEvent(Coda::CodaEvent)), this, SLOT(slotCodaEvent(Coda::CodaEvent)));
|
||||
|
||||
QTimer::singleShot(5000, this, SLOT(checkForTimeout()));
|
||||
if (debug)
|
||||
m_codaDevice->setVerbose(debug);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -172,6 +169,10 @@ void CodaRunControl::doStop()
|
||||
m_codaDevice->sendRunControlTerminateCommand(CodaCallback(),
|
||||
m_runningProcessId.toAscii());
|
||||
break;
|
||||
default:
|
||||
if (debug)
|
||||
qDebug() << "Unrecognised state while performing shutdown" << m_state;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,13 +188,6 @@ void CodaRunControl::slotCodaLogMessage(const QString &log)
|
||||
qDebug("CODA log: %s", qPrintable(log.size()>200?log.left(200).append(QLatin1String(" ...")): log));
|
||||
}
|
||||
|
||||
void CodaRunControl::slotSerialPong(const QString &message)
|
||||
{
|
||||
if (debug > 1)
|
||||
qDebug() << "CODA serial pong:" << message;
|
||||
handleConnected();
|
||||
}
|
||||
|
||||
void CodaRunControl::slotCodaEvent(const CodaEvent &event)
|
||||
{
|
||||
if (debug)
|
||||
@@ -201,7 +195,7 @@ void CodaRunControl::slotCodaEvent(const CodaEvent &event)
|
||||
|
||||
switch (event.type()) {
|
||||
case CodaEvent::LocatorHello:
|
||||
handleConnected();
|
||||
handleConnected(event);
|
||||
break;
|
||||
case CodaEvent::RunControlContextRemoved:
|
||||
handleContextRemoved(event);
|
||||
@@ -220,6 +214,9 @@ void CodaRunControl::slotCodaEvent(const CodaEvent &event)
|
||||
case CodaEvent::LoggingWriteEvent:
|
||||
handleLogging(event);
|
||||
break;
|
||||
case CodaEvent::ProcessExitedEvent:
|
||||
handleProcessExited(event);
|
||||
break;
|
||||
default:
|
||||
if (debug)
|
||||
qDebug() << "CODA event not handled" << event.type();
|
||||
@@ -229,16 +226,24 @@ void CodaRunControl::slotCodaEvent(const CodaEvent &event)
|
||||
|
||||
void CodaRunControl::initCommunication()
|
||||
{
|
||||
if (m_codaFlags & OptionsUseDebugSession)
|
||||
m_codaDevice->sendDebugSessionControlSessionStartCommand(CodaCallback(this, &CodaRunControl::handleDebugSessionStarted));
|
||||
else
|
||||
m_codaDevice->sendLoggingAddListenerCommand(CodaCallback(this, &CodaRunControl::handleAddListener));
|
||||
}
|
||||
|
||||
void CodaRunControl::handleConnected()
|
||||
void CodaRunControl::handleConnected(const CodaEvent &event)
|
||||
{
|
||||
if (m_state >= StateConnected)
|
||||
return;
|
||||
m_state = StateConnected;
|
||||
appendMessage(tr("Connected.\n"), Utils::NormalMessageFormat);
|
||||
setProgress(maxProgress()*0.80);
|
||||
|
||||
m_codaServices = static_cast<const CodaLocatorHelloEvent &>(event).services();
|
||||
if (m_codaServices.contains(QLatin1String("DebugSessionControl")))
|
||||
m_codaFlags |= OptionsUseDebugSession;
|
||||
|
||||
emit connected();
|
||||
if (!m_stopAfterConnect)
|
||||
initCommunication();
|
||||
@@ -251,6 +256,9 @@ void CodaRunControl::handleContextRemoved(const CodaEvent &event)
|
||||
if (!m_runningProcessId.isEmpty()
|
||||
&& removedItems.contains(m_runningProcessId.toAscii())) {
|
||||
appendMessage(tr("Process has finished.\n"), Utils::NormalMessageFormat);
|
||||
if (m_codaFlags & OptionsUseDebugSession)
|
||||
m_codaDevice->sendDebugSessionControlSessionEndCommand(CodaCallback(this, &CodaRunControl::handleDebugSessionEnded));
|
||||
else
|
||||
finishRunControl();
|
||||
}
|
||||
}
|
||||
@@ -305,6 +313,13 @@ void CodaRunControl::handleLogging(const CodaEvent &event)
|
||||
appendMessage(QString::fromLatin1(QByteArray(me.message() + '\n')), Utils::StdOutFormat);
|
||||
}
|
||||
|
||||
void CodaRunControl::handleProcessExited(const CodaEvent &event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
appendMessage(tr("Process has finished.\n"), Utils::NormalMessageFormat);
|
||||
m_codaDevice->sendDebugSessionControlSessionEndCommand(CodaCallback(this, &CodaRunControl::handleDebugSessionEnded));
|
||||
}
|
||||
|
||||
void CodaRunControl::handleAddListener(const CodaCommandResult &result)
|
||||
{
|
||||
Q_UNUSED(result)
|
||||
@@ -313,6 +328,20 @@ void CodaRunControl::handleAddListener(const CodaCommandResult &result)
|
||||
QByteArray::number(executableUid(), 16));
|
||||
}
|
||||
|
||||
void CodaRunControl::handleDebugSessionStarted(const CodaCommandResult &result)
|
||||
{
|
||||
Q_UNUSED(result)
|
||||
m_state = StateDebugSessionStarted;
|
||||
m_codaDevice->sendLoggingAddListenerCommand(CodaCallback(this, &CodaRunControl::handleAddListener));
|
||||
}
|
||||
|
||||
void CodaRunControl::handleDebugSessionEnded(const CodaCommandResult &result)
|
||||
{
|
||||
Q_UNUSED(result)
|
||||
m_state = StateDebugSessionEnded;
|
||||
finishRunControl();
|
||||
}
|
||||
|
||||
void CodaRunControl::handleFindProcesses(const CodaCommandResult &result)
|
||||
{
|
||||
if (result.values.size() && result.values.at(0).type() == JsonValue::Array && result.values.at(0).children().count()) {
|
||||
@@ -326,7 +355,7 @@ void CodaRunControl::handleFindProcesses(const CodaCommandResult &result)
|
||||
executableUid(),
|
||||
commandLineArguments().split(' '),
|
||||
QString(),
|
||||
true);
|
||||
!(m_codaFlags & OptionsUseDebugSession));
|
||||
appendMessage(tr("Launching: %1\n").arg(executableName()), Utils::NormalMessageFormat);
|
||||
}
|
||||
}
|
||||
@@ -334,7 +363,21 @@ void CodaRunControl::handleFindProcesses(const CodaCommandResult &result)
|
||||
void CodaRunControl::handleCreateProcess(const CodaCommandResult &result)
|
||||
{
|
||||
const bool ok = result.type == CodaCommandResult::SuccessReply;
|
||||
bool processCreated = false;
|
||||
if (ok) {
|
||||
if (m_codaFlags & OptionsUseDebugSession) {
|
||||
if (result.values.size()) {
|
||||
JsonValue id = result.values.at(0).findChild("ID");
|
||||
if (id.isValid()) {
|
||||
m_state = StateProcessRunning;
|
||||
m_runningProcessId = id.data();
|
||||
processCreated = true;
|
||||
}
|
||||
}
|
||||
} else // If no DebugSession is present the process will already be created by now
|
||||
processCreated = true;
|
||||
}
|
||||
if (processCreated) {
|
||||
setProgress(maxProgress());
|
||||
appendMessage(tr("Launched.\n"), Utils::NormalMessageFormat);
|
||||
} else {
|
||||
|
||||
@@ -87,21 +87,23 @@ private slots:
|
||||
void slotError(const QString &error);
|
||||
void slotCodaLogMessage(const QString &log);
|
||||
void slotCodaEvent(const Coda::CodaEvent &event);
|
||||
void slotSerialPong(const QString &message);
|
||||
|
||||
private:
|
||||
void initCommunication();
|
||||
|
||||
void handleConnected();
|
||||
void handleConnected(const Coda::CodaEvent &event);
|
||||
void handleModuleLoadSuspended(const Coda::CodaEvent &event);
|
||||
void handleContextSuspended(const Coda::CodaEvent &event);
|
||||
void handleContextAdded(const Coda::CodaEvent &event);
|
||||
void handleContextRemoved(const Coda::CodaEvent &event);
|
||||
void handleLogging(const Coda::CodaEvent &event);
|
||||
void handleProcessExited(const Coda::CodaEvent &event);
|
||||
|
||||
private:
|
||||
void handleCreateProcess(const Coda::CodaCommandResult &result);
|
||||
void handleAddListener(const Coda::CodaCommandResult &result);
|
||||
void handleDebugSessionStarted(const Coda::CodaCommandResult &result);
|
||||
void handleDebugSessionEnded(const Coda::CodaCommandResult &result);
|
||||
void handleFindProcesses(const Coda::CodaCommandResult &result);
|
||||
|
||||
private:
|
||||
@@ -109,7 +111,14 @@ private:
|
||||
StateUninit,
|
||||
StateConnecting,
|
||||
StateConnected,
|
||||
StateProcessRunning
|
||||
StateDebugSessionStarted,
|
||||
StateProcessRunning,
|
||||
StateDebugSessionEnded
|
||||
};
|
||||
|
||||
enum Options {
|
||||
OptionsNone = 0,
|
||||
OptionsUseDebugSession = 1
|
||||
};
|
||||
|
||||
QSharedPointer<Coda::CodaDevice> m_codaDevice;
|
||||
@@ -118,8 +127,10 @@ private:
|
||||
unsigned short m_port;
|
||||
QString m_serialPort;
|
||||
QString m_runningProcessId;
|
||||
QStringList m_codaServices;
|
||||
|
||||
State m_state;
|
||||
quint32 m_codaFlags;
|
||||
bool m_stopAfterConnect;
|
||||
};
|
||||
|
||||
|
||||
@@ -1465,5 +1465,16 @@ void Coda::CodaDevice::sendSymbianInstallGetPackageInfoCommand(const Coda::CodaC
|
||||
sendCodaMessage(MessageWithReply, SymbianInstallService, "getPackageInfo", data, callBack, cookie);
|
||||
}
|
||||
|
||||
void Coda::CodaDevice::sendDebugSessionControlSessionStartCommand(const Coda::CodaCallback &callBack,
|
||||
const QVariant &cookie)
|
||||
{
|
||||
sendCodaMessage(MessageWithReply, DebugSessionControl, "sessionStart", QByteArray(), callBack, cookie);
|
||||
}
|
||||
|
||||
void Coda::CodaDevice::sendDebugSessionControlSessionEndCommand(const Coda::CodaCallback &callBack,
|
||||
const QVariant &cookie)
|
||||
{
|
||||
sendCodaMessage(MessageWithReply, DebugSessionControl, "sessionEnd ", QByteArray(), callBack, cookie);
|
||||
}
|
||||
|
||||
} // namespace Coda
|
||||
|
||||
@@ -218,6 +218,8 @@ public:
|
||||
const QByteArray &id,
|
||||
const QVariant &cookie = QVariant());
|
||||
|
||||
// TODO: In CODA 4.1.13 the Terminate option does order CODA to kill
|
||||
// a process and CODA reports contextRemoved but does not kill the process
|
||||
void sendProcessTerminateCommand(const CodaCallback &callBack,
|
||||
const QByteArray &id,
|
||||
const QVariant &cookie = QVariant());
|
||||
@@ -375,6 +377,13 @@ public:
|
||||
const QStringList &keys = QStringList(),
|
||||
const QVariant &cookie = QVariant());
|
||||
|
||||
// DebugSessionControl
|
||||
void sendDebugSessionControlSessionStartCommand(const CodaCallback &callBack,
|
||||
const QVariant &cookie = QVariant());
|
||||
|
||||
void sendDebugSessionControlSessionEndCommand(const CodaCallback &callBack,
|
||||
const QVariant &cookie = QVariant());
|
||||
|
||||
// Settings
|
||||
void sendSettingsEnableLogCommand();
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
static const char *serviceNamesC[] =
|
||||
{ "Locator", "RunControl", "Processes", "Memory", "Settings", "Breakpoints",
|
||||
"Registers", "Logging", "FileSystem", "SymbianInstall", "SymbianOSData",
|
||||
"DebugSessionControl",
|
||||
"UnknownService"};
|
||||
|
||||
namespace Coda {
|
||||
@@ -414,6 +415,10 @@ CodaEvent *CodaEvent::parseEvent(Services s, const QByteArray &nameBA, const QVe
|
||||
if ((nameBA == "writeln" || nameBA == "write" /*not yet used*/) && values.size() >= 2)
|
||||
return new CodaLoggingWriteEvent(values.at(0).data(), values.at(1).data());
|
||||
break;
|
||||
case ProcessesService:
|
||||
if (nameBA == "exited" && values.size() >= 2)
|
||||
return new CodaProcessExitedEvent(values.at(0).data());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -574,5 +579,15 @@ QString CodaRunControlModuleLoadContextSuspendedEvent::toString() const
|
||||
return rc;
|
||||
}
|
||||
|
||||
// -------------- CodaIdEvent
|
||||
CodaProcessExitedEvent::CodaProcessExitedEvent(const QByteArray &id) :
|
||||
CodaEvent(ProcessExitedEvent), m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
QString CodaProcessExitedEvent::toString() const
|
||||
{
|
||||
return QString("Process \"%1\" exited").arg(idString());
|
||||
}
|
||||
|
||||
} // namespace Coda
|
||||
|
||||
@@ -59,6 +59,7 @@ enum Services {
|
||||
FileSystemService,
|
||||
SymbianInstallService, // non-standard, CODA specific
|
||||
SymbianOSData, // non-standard, CODA specific
|
||||
DebugSessionControl, // non-standard, CODA specific
|
||||
UnknownService
|
||||
}; // Note: Check string array 'serviceNamesC' of same size when modifying this.
|
||||
|
||||
@@ -167,7 +168,8 @@ public:
|
||||
RunControlBreakpointSuspended,
|
||||
RunControlModuleLoadSuspended,
|
||||
RunControlResumed,
|
||||
LoggingWriteEvent // Non-standard
|
||||
LoggingWriteEvent, // Non-standard
|
||||
ProcessExitedEvent // Non-standard
|
||||
};
|
||||
|
||||
virtual ~CodaEvent();
|
||||
@@ -189,7 +191,7 @@ class SYMBIANUTILS_EXPORT CodaLocatorHelloEvent : public CodaEvent {
|
||||
public:
|
||||
explicit CodaLocatorHelloEvent(const QStringList &);
|
||||
|
||||
const QStringList &services() { return m_services; }
|
||||
const QStringList &services() const { return m_services; }
|
||||
virtual QString toString() const;
|
||||
|
||||
private:
|
||||
@@ -305,5 +307,18 @@ private:
|
||||
const ModuleLoadEventInfo m_mi;
|
||||
};
|
||||
|
||||
// Process exited event
|
||||
class SYMBIANUTILS_EXPORT CodaProcessExitedEvent : public CodaEvent {
|
||||
public:
|
||||
explicit CodaProcessExitedEvent(const QByteArray &id);
|
||||
|
||||
QByteArray id() const { return m_id; }
|
||||
QString idString() const { return QString::fromUtf8(m_id); }
|
||||
virtual QString toString() const;
|
||||
|
||||
private:
|
||||
const QByteArray m_id;
|
||||
};
|
||||
|
||||
} // namespace Coda
|
||||
#endif // CODAMESSAGE_H
|
||||
|
||||
Reference in New Issue
Block a user