Skip to content
Snippets Groups Projects
Commit e077d260 authored by ck's avatar ck
Browse files

Maemo: Fix end-of-process detection.

The remote terminal likes to insert backspaces just for fun.
parent 5b47f47d
No related branches found
No related tags found
No related merge requests found
......@@ -123,7 +123,8 @@ void MaemoSshRunner::initState()
void MaemoSshRunner::handleRemoteOutput(const QByteArray &curOutput)
{
const QByteArray output = m_potentialEndMarkerPrefix + curOutput;
const QByteArray output
= filterTerminalControlChars(m_potentialEndMarkerPrefix + curOutput);
// Wait for a prompt before sending the command.
if (!m_promptEncountered) {
......@@ -184,7 +185,26 @@ void MaemoSshRunner::handleRemoteOutput(const QByteArray &curOutput)
if (m_endMarkerCount == 2)
stop();
m_potentialEndMarkerPrefix = output.right(EndMarker.count() - 1);
m_potentialEndMarkerPrefix = output.right(EndMarker.count());
}
QByteArray MaemoSshRunner::filterTerminalControlChars(const QByteArray &data)
{
QByteArray filteredData;
for (int i = 0; i < data.size(); ++i) {
if (data.at(i) == '\b') {
if (filteredData.isEmpty()) {
qWarning("Failed to filter terminal control characters, "
"remote output may not appear.");
} else {
filteredData.remove(filteredData.count() - 1, 1);
}
} else {
filteredData.append(data.at(i));
}
}
return filteredData;
}
const QByteArray MaemoSshRunner::EndMarker(QString(QChar(0x13a0)).toUtf8());
......
......@@ -98,6 +98,7 @@ private:
virtual bool runInternal();
Q_SLOT void handleRemoteOutput(const QByteArray &output);
void initState();
QByteArray filterTerminalControlChars(const QByteArray &data);
static const QByteArray EndMarker;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment