Commit 53e72b0b authored by Pawel Polanski's avatar Pawel Polanski
Browse files

Symbian: process detection added to CODA

parent 119c6e80
......@@ -64,20 +64,6 @@ using namespace tcftrk;
enum { debug = 0 };
static inline bool isProcessRunning(const TcfTrkCommandResult &result, const QString &processName)
{
if (result.values.size() && result.values.at(0).type() == JsonValue::Array) {
foreach(const JsonValue &threadValue, result.values.at(0).children()) {
for (int i = threadValue.children().count()-1; i >= 0; --i) { //Usually our process will be near the end of the list
const JsonValue &value(threadValue.childAt(i));
if (value.hasName("p_name") && QString::fromLatin1(value.data()).startsWith(processName, Qt::CaseInsensitive))
return true;
}
}
}
return false;
}
CodaRunControl::CodaRunControl(RunConfiguration *runConfiguration, const QString &mode) :
S60RunControlBase(runConfiguration, mode),
m_tcfTrkDevice(0),
......@@ -275,20 +261,20 @@ void CodaRunControl::handleLogging(const TcfTrkEvent &event)
void CodaRunControl::handleAddListener(const TcfTrkCommandResult &result)
{
Q_UNUSED(result)
m_tcfTrkDevice->sendSymbianOsDataGetThreadsCommand(TcfTrkCallback(this, &CodaRunControl::handleGetThreads));
m_tcfTrkDevice->sendSymbianOsDataFindProcessesCommand(TcfTrkCallback(this, &CodaRunControl::handleFindProcesses), executableName().toLatin1(), "0");
}
void CodaRunControl::handleGetThreads(const TcfTrkCommandResult &result)
void CodaRunControl::handleFindProcesses(const TcfTrkCommandResult &result)
{
if (isProcessRunning(result, targetName())) {
if (result.values.size() && result.values.at(0).type() == JsonValue::Array && result.values.at(0).children().count()) {
//there are processes running. Cannot run mine
appendMessage(tr("The process is already running on the device. Please first close it."), ErrorMessageFormat);
finishRunControl();
} else {
setProgress(maxProgress()*0.90);
const QString runFileName = QString::fromLatin1("%1.exe").arg(targetName());
m_tcfTrkDevice->sendProcessStartCommand(TcfTrkCallback(this, &CodaRunControl::handleCreateProcess),
runFileName, executableUid(), commandLineArguments().split(" "), QString(), true);
appendMessage(tr("Launching: %1").arg(runFileName), NormalMessageFormat);
executableName(), executableUid(), commandLineArguments().split(" "), QString(), true);
appendMessage(tr("Launching: %1").arg(executableName()), NormalMessageFormat);
}
}
......@@ -327,7 +313,7 @@ QMessageBox *CodaRunControl::createCodaWaitingMessageBox(QWidget *parent)
void CodaRunControl::checkForTimeout()
{
if (m_state >= StateConnected)
if (m_state != StateConnecting)
return;
QMessageBox *mb = createCodaWaitingMessageBox(Core::ICore::instance()->mainWindow());
......@@ -338,7 +324,7 @@ void CodaRunControl::checkForTimeout()
void CodaRunControl::cancelConnection()
{
if (m_state >= StateConnected)
if (m_state != StateConnecting)
return;
stop();
......
......@@ -89,7 +89,7 @@ private:
private:
void handleCreateProcess(const tcftrk::TcfTrkCommandResult &result);
void handleAddListener(const tcftrk::TcfTrkCommandResult &result);
void handleGetThreads(const tcftrk::TcfTrkCommandResult &result);
void handleFindProcesses(const tcftrk::TcfTrkCommandResult &result);
private:
enum State {
......
......@@ -594,7 +594,7 @@ void S60DeployStep::handleFileSystemClose(const tcftrk::TcfTrkCommandResult &res
void S60DeployStep::checkForTimeout()
{
if (m_state >= StateConnected)
if (m_state != StateConnecting)
return;
const QString title = tr("Waiting for CODA");
......
......@@ -220,6 +220,11 @@ quint32 S60RunControlBase::executableUid() const
return m_executableUid;
}
QString S60RunControlBase::executableName() const
{
return QString::fromLatin1("%1.exe").arg(targetName());
}
const QString &S60RunControlBase::targetName() const
{
return m_targetName;
......
......@@ -63,6 +63,7 @@ protected:
protected:
ProjectExplorer::ToolChainType toolChain() const;
quint32 executableUid() const;
QString executableName() const;
const QString &targetName() const;
const QString &commandLineArguments() const;
const QString &executableFileName() const;
......
......@@ -1360,6 +1360,16 @@ void TcfTrkDevice::sendSymbianOsDataGetThreadsCommand(const TcfTrkCallback &call
sendTcfTrkMessage(MessageWithReply, SymbianOSData, "getThreads", data, callBack, cookie);
}
void TcfTrkDevice::sendSymbianOsDataFindProcessesCommand(const TcfTrkCallback &callBack,
const QByteArray &processName,
const QByteArray &uid,
const QVariant &cookie)
{
QByteArray data;
JsonInputStream str(data);
str << processName << '\0' << uid;
sendTcfTrkMessage(MessageWithReply, SymbianOSData, "findRunningProcesses", data, callBack, cookie);
}
void tcftrk::TcfTrkDevice::sendFileSystemOpenCommand(const tcftrk::TcfTrkCallback &callBack,
const QByteArray &name,
......
......@@ -353,6 +353,11 @@ public:
void sendSymbianOsDataGetThreadsCommand(const TcfTrkCallback &callBack,
const QVariant &cookie = QVariant());
void sendSymbianOsDataFindProcessesCommand(const TcfTrkCallback &callBack,
const QByteArray &processName,
const QByteArray &uid,
const QVariant &cookie = QVariant());
// Settings
void sendSettingsEnableLogCommand();
......
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