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:
Pawel Polanski
2011-06-22 16:26:21 +02:00
committed by Paweł Polański
parent 44e905d08c
commit 0e4af76313
6 changed files with 133 additions and 29 deletions

View File

@@ -70,7 +70,8 @@ CodaRunControl::CodaRunControl(RunConfiguration *runConfiguration, const QString
S60RunControlBase(runConfiguration, mode), S60RunControlBase(runConfiguration, mode),
m_port(0), m_port(0),
m_state(StateUninit), m_state(StateUninit),
m_stopAfterConnect(false) m_stopAfterConnect(false),
m_codaFlags(0)
{ {
const S60DeviceRunConfiguration *s60runConfig = qobject_cast<S60DeviceRunConfiguration *>(runConfiguration); const S60DeviceRunConfiguration *s60runConfig = qobject_cast<S60DeviceRunConfiguration *>(runConfiguration);
QTC_ASSERT(s60runConfig, return); QTC_ASSERT(s60runConfig, return);
@@ -133,29 +134,25 @@ bool CodaRunControl::setupLauncher()
} }
connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)), connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)),
this, SLOT(deviceRemoved(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_state = StateConnecting;
m_codaDevice->sendSerialPing(false); m_codaDevice->sendSerialPing(false);
} else { } else {
// For TCP we don't use device manager, we just set it up directly // 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 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); const QSharedPointer<QTcpSocket> codaSocket(new QTcpSocket);
m_codaDevice->setDevice(codaSocket); m_codaDevice->setDevice(codaSocket);
codaSocket->connectToHost(m_address, m_port); codaSocket->connectToHost(m_address, m_port);
m_state = StateConnecting; m_state = StateConnecting;
appendMessage(tr("Connecting to %1:%2...\n").arg(m_address).arg(m_port), Utils::NormalMessageFormat); 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())); QTimer::singleShot(5000, this, SLOT(checkForTimeout()));
if (debug) if (debug)
m_codaDevice->setVerbose(debug); m_codaDevice->setVerbose(debug);
return true; return true;
} }
@@ -172,6 +169,10 @@ void CodaRunControl::doStop()
m_codaDevice->sendRunControlTerminateCommand(CodaCallback(), m_codaDevice->sendRunControlTerminateCommand(CodaCallback(),
m_runningProcessId.toAscii()); m_runningProcessId.toAscii());
break; 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)); 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) void CodaRunControl::slotCodaEvent(const CodaEvent &event)
{ {
if (debug) if (debug)
@@ -201,7 +195,7 @@ void CodaRunControl::slotCodaEvent(const CodaEvent &event)
switch (event.type()) { switch (event.type()) {
case CodaEvent::LocatorHello: case CodaEvent::LocatorHello:
handleConnected(); handleConnected(event);
break; break;
case CodaEvent::RunControlContextRemoved: case CodaEvent::RunControlContextRemoved:
handleContextRemoved(event); handleContextRemoved(event);
@@ -220,6 +214,9 @@ void CodaRunControl::slotCodaEvent(const CodaEvent &event)
case CodaEvent::LoggingWriteEvent: case CodaEvent::LoggingWriteEvent:
handleLogging(event); handleLogging(event);
break; break;
case CodaEvent::ProcessExitedEvent:
handleProcessExited(event);
break;
default: default:
if (debug) if (debug)
qDebug() << "CODA event not handled" << event.type(); qDebug() << "CODA event not handled" << event.type();
@@ -229,16 +226,24 @@ void CodaRunControl::slotCodaEvent(const CodaEvent &event)
void CodaRunControl::initCommunication() void CodaRunControl::initCommunication()
{ {
if (m_codaFlags & OptionsUseDebugSession)
m_codaDevice->sendDebugSessionControlSessionStartCommand(CodaCallback(this, &CodaRunControl::handleDebugSessionStarted));
else
m_codaDevice->sendLoggingAddListenerCommand(CodaCallback(this, &CodaRunControl::handleAddListener)); m_codaDevice->sendLoggingAddListenerCommand(CodaCallback(this, &CodaRunControl::handleAddListener));
} }
void CodaRunControl::handleConnected() void CodaRunControl::handleConnected(const CodaEvent &event)
{ {
if (m_state >= StateConnected) if (m_state >= StateConnected)
return; return;
m_state = StateConnected; m_state = StateConnected;
appendMessage(tr("Connected.\n"), Utils::NormalMessageFormat); appendMessage(tr("Connected.\n"), Utils::NormalMessageFormat);
setProgress(maxProgress()*0.80); setProgress(maxProgress()*0.80);
m_codaServices = static_cast<const CodaLocatorHelloEvent &>(event).services();
if (m_codaServices.contains(QLatin1String("DebugSessionControl")))
m_codaFlags |= OptionsUseDebugSession;
emit connected(); emit connected();
if (!m_stopAfterConnect) if (!m_stopAfterConnect)
initCommunication(); initCommunication();
@@ -251,6 +256,9 @@ void CodaRunControl::handleContextRemoved(const CodaEvent &event)
if (!m_runningProcessId.isEmpty() if (!m_runningProcessId.isEmpty()
&& removedItems.contains(m_runningProcessId.toAscii())) { && removedItems.contains(m_runningProcessId.toAscii())) {
appendMessage(tr("Process has finished.\n"), Utils::NormalMessageFormat); appendMessage(tr("Process has finished.\n"), Utils::NormalMessageFormat);
if (m_codaFlags & OptionsUseDebugSession)
m_codaDevice->sendDebugSessionControlSessionEndCommand(CodaCallback(this, &CodaRunControl::handleDebugSessionEnded));
else
finishRunControl(); finishRunControl();
} }
} }
@@ -305,6 +313,13 @@ void CodaRunControl::handleLogging(const CodaEvent &event)
appendMessage(QString::fromLatin1(QByteArray(me.message() + '\n')), Utils::StdOutFormat); 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) void CodaRunControl::handleAddListener(const CodaCommandResult &result)
{ {
Q_UNUSED(result) Q_UNUSED(result)
@@ -313,6 +328,20 @@ void CodaRunControl::handleAddListener(const CodaCommandResult &result)
QByteArray::number(executableUid(), 16)); 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) void CodaRunControl::handleFindProcesses(const CodaCommandResult &result)
{ {
if (result.values.size() && result.values.at(0).type() == JsonValue::Array && result.values.at(0).children().count()) { 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(), executableUid(),
commandLineArguments().split(' '), commandLineArguments().split(' '),
QString(), QString(),
true); !(m_codaFlags & OptionsUseDebugSession));
appendMessage(tr("Launching: %1\n").arg(executableName()), Utils::NormalMessageFormat); 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) void CodaRunControl::handleCreateProcess(const CodaCommandResult &result)
{ {
const bool ok = result.type == CodaCommandResult::SuccessReply; const bool ok = result.type == CodaCommandResult::SuccessReply;
bool processCreated = false;
if (ok) { 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()); setProgress(maxProgress());
appendMessage(tr("Launched.\n"), Utils::NormalMessageFormat); appendMessage(tr("Launched.\n"), Utils::NormalMessageFormat);
} else { } else {

View File

@@ -87,21 +87,23 @@ private slots:
void slotError(const QString &error); void slotError(const QString &error);
void slotCodaLogMessage(const QString &log); void slotCodaLogMessage(const QString &log);
void slotCodaEvent(const Coda::CodaEvent &event); void slotCodaEvent(const Coda::CodaEvent &event);
void slotSerialPong(const QString &message);
private: private:
void initCommunication(); void initCommunication();
void handleConnected(); void handleConnected(const Coda::CodaEvent &event);
void handleModuleLoadSuspended(const Coda::CodaEvent &event); void handleModuleLoadSuspended(const Coda::CodaEvent &event);
void handleContextSuspended(const Coda::CodaEvent &event); void handleContextSuspended(const Coda::CodaEvent &event);
void handleContextAdded(const Coda::CodaEvent &event); void handleContextAdded(const Coda::CodaEvent &event);
void handleContextRemoved(const Coda::CodaEvent &event); void handleContextRemoved(const Coda::CodaEvent &event);
void handleLogging(const Coda::CodaEvent &event); void handleLogging(const Coda::CodaEvent &event);
void handleProcessExited(const Coda::CodaEvent &event);
private: private:
void handleCreateProcess(const Coda::CodaCommandResult &result); void handleCreateProcess(const Coda::CodaCommandResult &result);
void handleAddListener(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); void handleFindProcesses(const Coda::CodaCommandResult &result);
private: private:
@@ -109,7 +111,14 @@ private:
StateUninit, StateUninit,
StateConnecting, StateConnecting,
StateConnected, StateConnected,
StateProcessRunning StateDebugSessionStarted,
StateProcessRunning,
StateDebugSessionEnded
};
enum Options {
OptionsNone = 0,
OptionsUseDebugSession = 1
}; };
QSharedPointer<Coda::CodaDevice> m_codaDevice; QSharedPointer<Coda::CodaDevice> m_codaDevice;
@@ -118,8 +127,10 @@ private:
unsigned short m_port; unsigned short m_port;
QString m_serialPort; QString m_serialPort;
QString m_runningProcessId; QString m_runningProcessId;
QStringList m_codaServices;
State m_state; State m_state;
quint32 m_codaFlags;
bool m_stopAfterConnect; bool m_stopAfterConnect;
}; };

View File

@@ -1465,5 +1465,16 @@ void Coda::CodaDevice::sendSymbianInstallGetPackageInfoCommand(const Coda::CodaC
sendCodaMessage(MessageWithReply, SymbianInstallService, "getPackageInfo", data, callBack, cookie); 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 } // namespace Coda

View File

@@ -218,6 +218,8 @@ public:
const QByteArray &id, const QByteArray &id,
const QVariant &cookie = QVariant()); 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, void sendProcessTerminateCommand(const CodaCallback &callBack,
const QByteArray &id, const QByteArray &id,
const QVariant &cookie = QVariant()); const QVariant &cookie = QVariant());
@@ -375,6 +377,13 @@ public:
const QStringList &keys = QStringList(), const QStringList &keys = QStringList(),
const QVariant &cookie = QVariant()); const QVariant &cookie = QVariant());
// DebugSessionControl
void sendDebugSessionControlSessionStartCommand(const CodaCallback &callBack,
const QVariant &cookie = QVariant());
void sendDebugSessionControlSessionEndCommand(const CodaCallback &callBack,
const QVariant &cookie = QVariant());
// Settings // Settings
void sendSettingsEnableLogCommand(); void sendSettingsEnableLogCommand();

View File

@@ -40,6 +40,7 @@
static const char *serviceNamesC[] = static const char *serviceNamesC[] =
{ "Locator", "RunControl", "Processes", "Memory", "Settings", "Breakpoints", { "Locator", "RunControl", "Processes", "Memory", "Settings", "Breakpoints",
"Registers", "Logging", "FileSystem", "SymbianInstall", "SymbianOSData", "Registers", "Logging", "FileSystem", "SymbianInstall", "SymbianOSData",
"DebugSessionControl",
"UnknownService"}; "UnknownService"};
namespace Coda { 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) if ((nameBA == "writeln" || nameBA == "write" /*not yet used*/) && values.size() >= 2)
return new CodaLoggingWriteEvent(values.at(0).data(), values.at(1).data()); return new CodaLoggingWriteEvent(values.at(0).data(), values.at(1).data());
break; break;
case ProcessesService:
if (nameBA == "exited" && values.size() >= 2)
return new CodaProcessExitedEvent(values.at(0).data());
break;
default: default:
break; break;
} }
@@ -574,5 +579,15 @@ QString CodaRunControlModuleLoadContextSuspendedEvent::toString() const
return rc; 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 } // namespace Coda

View File

@@ -59,6 +59,7 @@ enum Services {
FileSystemService, FileSystemService,
SymbianInstallService, // non-standard, CODA specific SymbianInstallService, // non-standard, CODA specific
SymbianOSData, // non-standard, CODA specific SymbianOSData, // non-standard, CODA specific
DebugSessionControl, // non-standard, CODA specific
UnknownService UnknownService
}; // Note: Check string array 'serviceNamesC' of same size when modifying this. }; // Note: Check string array 'serviceNamesC' of same size when modifying this.
@@ -167,7 +168,8 @@ public:
RunControlBreakpointSuspended, RunControlBreakpointSuspended,
RunControlModuleLoadSuspended, RunControlModuleLoadSuspended,
RunControlResumed, RunControlResumed,
LoggingWriteEvent // Non-standard LoggingWriteEvent, // Non-standard
ProcessExitedEvent // Non-standard
}; };
virtual ~CodaEvent(); virtual ~CodaEvent();
@@ -189,7 +191,7 @@ class SYMBIANUTILS_EXPORT CodaLocatorHelloEvent : public CodaEvent {
public: public:
explicit CodaLocatorHelloEvent(const QStringList &); explicit CodaLocatorHelloEvent(const QStringList &);
const QStringList &services() { return m_services; } const QStringList &services() const { return m_services; }
virtual QString toString() const; virtual QString toString() const;
private: private:
@@ -305,5 +307,18 @@ private:
const ModuleLoadEventInfo m_mi; 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 } // namespace Coda
#endif // CODAMESSAGE_H #endif // CODAMESSAGE_H