From: Christian Kandeler Date: Thu, 2 Dec 2010 11:37:25 +0000 (+0100) Subject: Maemo: Fix "mad info" parsing for Qemu, part 1. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d57584b6a6e25c0f0306f138d509357fa05ed0b7;p=qt-creator-jp%2Fqt-creator-jp.git Maemo: Fix "mad info" parsing for Qemu, part 1. We now evaluate the new "service" attribute of the "port" tag. --- diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.cpp index b9d962a4e3..2c64968b75 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.cpp @@ -60,12 +60,18 @@ public: MaemoQemuRuntime parseRuntime(); private: + struct Port { + Port() : port(-1) {} + int port; + bool ssh; + }; + void handleTargetTag(QString &runtimeName); MaemoQemuRuntime handleRuntimeTag(); QProcessEnvironment handleEnvironmentTag(); QPair handleVariableTag(); - MaemoPortList handleTcpPortListTag(); - int handlePortTag(); + QList handleTcpPortListTag(); + Port handlePortTag(); }; MaemoQemuRuntimeParser::MaemoQemuRuntimeParser(const QString &madInfoOutput, @@ -97,9 +103,6 @@ MaemoQemuRuntime MaemoQemuRuntimeParser::parseRuntime(const QtVersion *qtVersion if (!runtime.m_name.isEmpty()) { runtime.m_root = maddeRootPath + QLatin1String("/runtimes/") + runtime.m_name; - - // TODO: Workaround for missing ssh tag. Fix once MADDE is ready. - runtime.m_sshPort = QLatin1String("6666"); } else { runtime = MaemoQemuRuntimeParserV1(madInfoOutput, targetName, maddeRootPath).parseRuntime(); @@ -315,7 +318,13 @@ MaemoQemuRuntime MaemoQemuRuntimeParserV2::handleRuntimeTag() } else if (m_madInfoReader.name() == QLatin1String("environment")) { runtime.m_environment = handleEnvironmentTag(); } else if (m_madInfoReader.name() == QLatin1String("tcpportmap")) { - runtime.m_freePorts = handleTcpPortListTag(); + const QList &ports = handleTcpPortListTag(); + foreach (const Port &port, ports) { + if (port.ssh) + runtime.m_sshPort = QString::number(port.port); + else + runtime.m_freePorts.addPort(port.port); + } } else { m_madInfoReader.skipCurrentElement(); } @@ -362,24 +371,26 @@ QPair MaemoQemuRuntimeParserV2::handleVariableTag() return var; } -MaemoPortList MaemoQemuRuntimeParserV2::handleTcpPortListTag() +QList MaemoQemuRuntimeParserV2::handleTcpPortListTag() { - MaemoPortList ports; + QList ports; while (m_madInfoReader.readNextStartElement()) { - const int port = handlePortTag(); - if (port != -1 && port != 6666) // TODO: Remove second condition once MADDE has ssh tag - ports.addPort(port); + const Port &port = handlePortTag(); + if (port.port != -1) + ports << port; } return ports; } -int MaemoQemuRuntimeParserV2::handlePortTag() +MaemoQemuRuntimeParserV2::Port MaemoQemuRuntimeParserV2::handlePortTag() { - int port = -1; + Port port; if (m_madInfoReader.name() == QLatin1String("port")) { + const QXmlStreamAttributes &attrs = m_madInfoReader.attributes(); + port.ssh = attrs.value(QLatin1String("service")) == QLatin1String("ssh"); while (m_madInfoReader.readNextStartElement()) { if (m_madInfoReader.name() == QLatin1String("host")) - port = m_madInfoReader.readElementText().toInt(); + port.port = m_madInfoReader.readElementText().toInt(); else m_madInfoReader.skipCurrentElement(); }