Maemo: Rename "Runtime" class to make the name more unique.

This commit is contained in:
Christian Kandeler
2010-11-30 14:14:55 +01:00
parent c7acef6e9a
commit 9a26654878
3 changed files with 34 additions and 35 deletions

View File

@@ -144,9 +144,9 @@ MaemoQemuManager &MaemoQemuManager::instance(QObject *parent)
return *m_instance; return *m_instance;
} }
bool MaemoQemuManager::runtimeForQtVersion(int uniqueId, Runtime *rt) const bool MaemoQemuManager::runtimeForQtVersion(int uniqueId, MaemoQemuRuntime *rt) const
{ {
*rt = m_runtimes.value(uniqueId, Runtime()); *rt = m_runtimes.value(uniqueId, MaemoQemuRuntime());
return rt->isValid(); return rt->isValid();
} }
@@ -157,7 +157,7 @@ void MaemoQemuManager::qtVersionsChanged(const QList<int> &uniqueIds)
if (manager->isValidId(uniqueId)) { if (manager->isValidId(uniqueId)) {
QtVersion *version = manager->version(uniqueId); QtVersion *version = manager->version(uniqueId);
if (version->supportsTargetId(Constants::MAEMO_DEVICE_TARGET_ID)) { if (version->supportsTargetId(Constants::MAEMO_DEVICE_TARGET_ID)) {
Runtime runtime = createRuntime(version); MaemoQemuRuntime runtime = createRuntime(version);
if (runtime.isValid()) { if (runtime.isValid()) {
runtime.m_watchPath = runtime.m_watchPath =
runtime.m_root.left(runtime.m_root.lastIndexOf(QLatin1Char('/'))); runtime.m_root.left(runtime.m_root.lastIndexOf(QLatin1Char('/')));
@@ -359,7 +359,7 @@ void MaemoQemuManager::startRuntime()
const QString root const QString root
= QDir::toNativeSeparators(maddeRoot(version->qmakeCommand()) = QDir::toNativeSeparators(maddeRoot(version->qmakeCommand())
+ QLatin1Char('/')); + QLatin1Char('/'));
const Runtime rt = m_runtimes.value(version->uniqueId()); const MaemoQemuRuntime rt = m_runtimes.value(version->uniqueId());
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
const QLatin1Char colon(';'); const QLatin1Char colon(';');
@@ -475,14 +475,14 @@ void MaemoQemuManager::qemuOutput()
void MaemoQemuManager::runtimeRootChanged(const QString &directory) void MaemoQemuManager::runtimeRootChanged(const QString &directory)
{ {
QList<int> uniqueIds; QList<int> uniqueIds;
QMap<int, Runtime>::const_iterator it; QMap<int, MaemoQemuRuntime>::const_iterator it;
for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) { for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) {
if (QDir(it.value().m_watchPath) == QDir(directory)) if (QDir(it.value().m_watchPath) == QDir(directory))
uniqueIds.append(it.key()); uniqueIds.append(it.key());
} }
foreach (int uniqueId, uniqueIds) { foreach (int uniqueId, uniqueIds) {
Runtime runtime = m_runtimes.value(uniqueId, Runtime()); MaemoQemuRuntime runtime = m_runtimes.value(uniqueId, MaemoQemuRuntime());
if (runtime.isValid()) { if (runtime.isValid()) {
if (QFile::exists(runtime.m_root)) { if (QFile::exists(runtime.m_root)) {
// nothing changed, so we can remove it // nothing changed, so we can remove it
@@ -505,7 +505,7 @@ void MaemoQemuManager::runtimeFolderChanged(const QString &directory)
{ {
if (QFile::exists(directory + QLatin1String("/information"))) { if (QFile::exists(directory + QLatin1String("/information"))) {
QList<int> uniqueIds; QList<int> uniqueIds;
QMap<int, Runtime>::const_iterator it; QMap<int, MaemoQemuRuntime>::const_iterator it;
for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) { for (it = m_runtimes.constBegin(); it != m_runtimes.constEnd(); ++it) {
if (QDir(it.value().m_root) == QDir(directory)) if (QDir(it.value().m_root) == QDir(directory))
uniqueIds.append(it.key()); uniqueIds.append(it.key());
@@ -553,7 +553,7 @@ void MaemoQemuManager::toggleStarterButton(Target *target)
if (m_runningQtId == uniqueId) if (m_runningQtId == uniqueId)
isRunning = false; isRunning = false;
m_qemuAction->setEnabled(m_runtimes.value(uniqueId, Runtime()).isValid() m_qemuAction->setEnabled(m_runtimes.value(uniqueId, MaemoQemuRuntime()).isValid()
&& targetUsesMatchingRuntimeConfig(target) && !isRunning); && targetUsesMatchingRuntimeConfig(target) && !isRunning);
m_qemuAction->setVisible(!m_runtimes.isEmpty() && sessionHasMaemoTarget()); m_qemuAction->setVisible(!m_runtimes.isEmpty() && sessionHasMaemoTarget());
} }
@@ -583,7 +583,7 @@ bool MaemoQemuManager::targetUsesMatchingRuntimeConfig(Target *target,
if (!bc) if (!bc)
return false; return false;
QtVersion *version = bc->qtVersion(); QtVersion *version = bc->qtVersion();
if (!version || !m_runtimes.value(version->uniqueId(), Runtime()).isValid()) if (!version || !m_runtimes.value(version->uniqueId(), MaemoQemuRuntime()).isValid())
return false; return false;
if (qtVersion) if (qtVersion)
@@ -605,7 +605,7 @@ QString MaemoQemuManager::targetRoot(const QString &qmake) const
return target.mid(target.lastIndexOf(QLatin1Char('/')) + 1); return target.mid(target.lastIndexOf(QLatin1Char('/')) + 1);
} }
bool MaemoQemuManager::fillRuntimeInformationForOldMadInfo(Runtime *runtime) const bool MaemoQemuManager::fillRuntimeInformationForOldMadInfo(MaemoQemuRuntime *runtime) const
{ {
const QStringList files = QDir(runtime->m_root).entryList(QDir::Files const QStringList files = QDir(runtime->m_root).entryList(QDir::Files
| QDir::NoSymLinks | QDir::NoDotAndDotDot); | QDir::NoSymLinks | QDir::NoDotAndDotDot);
@@ -643,7 +643,7 @@ bool MaemoQemuManager::fillRuntimeInformationForOldMadInfo(Runtime *runtime) con
return false; return false;
} }
void MaemoQemuManager::setEnvironment(Runtime *runTime, void MaemoQemuManager::setEnvironment(MaemoQemuRuntime *runTime,
const QString &envSpec) const const QString &envSpec) const
{ {
QString remainingEnvSpec = envSpec; QString remainingEnvSpec = envSpec;
@@ -672,9 +672,9 @@ void MaemoQemuManager::setEnvironment(Runtime *runTime,
} }
} }
Runtime MaemoQemuManager::createRuntime(const QtVersion *qtVersion) const MaemoQemuRuntime MaemoQemuManager::createRuntime(const QtVersion *qtVersion) const
{ {
Runtime runtime; MaemoQemuRuntime runtime;
const QString maddeRootPath = maddeRoot(qtVersion->qmakeCommand()); const QString maddeRootPath = maddeRoot(qtVersion->qmakeCommand());
const QString madCommand = maddeRootPath + QLatin1String("/bin/mad"); const QString madCommand = maddeRootPath + QLatin1String("/bin/mad");
if (!QFileInfo(madCommand).exists()) if (!QFileInfo(madCommand).exists())
@@ -700,12 +700,12 @@ Runtime MaemoQemuManager::createRuntime(const QtVersion *qtVersion) const
} }
} }
Runtime MaemoQemuManager::parseRuntimeFromMadInfo(const QByteArray &output, MaemoQemuRuntime MaemoQemuManager::parseRuntimeFromMadInfo(const QByteArray &output,
const QString &targetName) const const QString &targetName) const
{ {
QXmlStreamReader infoReader(output); QXmlStreamReader infoReader(output);
QString runtimeName; QString runtimeName;
QList<Runtime> runtimes; QList<MaemoQemuRuntime> runtimes;
while (infoReader.readNextStartElement()) { while (infoReader.readNextStartElement()) {
if (infoReader.name() == QLatin1String("madde")) { if (infoReader.name() == QLatin1String("madde")) {
while (infoReader.readNextStartElement()) { while (infoReader.readNextStartElement()) {
@@ -714,7 +714,7 @@ Runtime MaemoQemuManager::parseRuntimeFromMadInfo(const QByteArray &output,
handleMadInfoTargetTag(infoReader, runtimeName, targetName); handleMadInfoTargetTag(infoReader, runtimeName, targetName);
} else if (infoReader.name() == QLatin1String("runtimes")) { } else if (infoReader.name() == QLatin1String("runtimes")) {
while (infoReader.readNextStartElement()) { while (infoReader.readNextStartElement()) {
const Runtime &rt = handleMadInfoRuntimeTag(infoReader); const MaemoQemuRuntime &rt = handleMadInfoRuntimeTag(infoReader);
if (!rt.m_name.isEmpty() && !rt.m_bin.isEmpty() if (!rt.m_name.isEmpty() && !rt.m_bin.isEmpty()
&& !rt.m_args.isEmpty()) { && !rt.m_args.isEmpty()) {
runtimes << rt; runtimes << rt;
@@ -726,14 +726,14 @@ Runtime MaemoQemuManager::parseRuntimeFromMadInfo(const QByteArray &output,
} }
} }
} }
foreach (const Runtime &rt, runtimes) { foreach (const MaemoQemuRuntime &rt, runtimes) {
if (rt.m_name == runtimeName) if (rt.m_name == runtimeName)
return rt; return rt;
} }
return Runtime(); return MaemoQemuRuntime();
} }
Runtime MaemoQemuManager::parseRuntimeFromOldMadInfo(const QString &output, MaemoQemuRuntime MaemoQemuManager::parseRuntimeFromOldMadInfo(const QString &output,
const QString &maddeRootPath, const QString &targetName) const const QString &maddeRootPath, const QString &targetName) const
{ {
QXmlStreamReader infoReader(output); QXmlStreamReader infoReader(output);
@@ -770,7 +770,7 @@ Runtime MaemoQemuManager::parseRuntimeFromOldMadInfo(const QString &output,
} }
} }
Runtime runtime; MaemoQemuRuntime runtime;
if (installedRuntimes.contains(targetRuntime)) { if (installedRuntimes.contains(targetRuntime)) {
runtime.m_name = targetRuntime; runtime.m_name = targetRuntime;
runtime.m_root = maddeRootPath + QLatin1String("/runtimes/") runtime.m_root = maddeRootPath + QLatin1String("/runtimes/")
@@ -799,9 +799,9 @@ void MaemoQemuManager::handleMadInfoTargetTag(QXmlStreamReader &infoReader,
} }
} }
Runtime MaemoQemuManager::handleMadInfoRuntimeTag(QXmlStreamReader &infoReader) const MaemoQemuRuntime MaemoQemuManager::handleMadInfoRuntimeTag(QXmlStreamReader &infoReader) const
{ {
Runtime runtime; MaemoQemuRuntime runtime;
const QXmlStreamAttributes &attrs = infoReader.attributes(); const QXmlStreamAttributes &attrs = infoReader.attributes();
if (infoReader.name() != QLatin1String("runtime") if (infoReader.name() != QLatin1String("runtime")
|| attrs.value(QLatin1String("installed")) != QLatin1String("true")) { || attrs.value(QLatin1String("installed")) != QLatin1String("true")) {

View File

@@ -57,11 +57,10 @@ namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
class MaemoRunConfiguration; class MaemoRunConfiguration;
// TODO: Rename to something more unique struct MaemoQemuRuntime
struct Runtime
{ {
Runtime() {} MaemoQemuRuntime() {}
Runtime(const QString &root) MaemoQemuRuntime(const QString &root)
: m_root(root) {} : m_root(root) {}
bool isValid() const { bool isValid() const {
return !m_bin.isEmpty(); return !m_bin.isEmpty();
@@ -84,7 +83,7 @@ class MaemoQemuManager : public QObject
public: public:
static MaemoQemuManager& instance(QObject *parent = 0); static MaemoQemuManager& instance(QObject *parent = 0);
bool runtimeForQtVersion(int uniqueId, Runtime *rt) const; bool runtimeForQtVersion(int uniqueId, MaemoQemuRuntime *rt) const;
signals: signals:
void qemuProcessStatus(QemuStatus, const QString &error = QString()); void qemuProcessStatus(QemuStatus, const QString &error = QString());
@@ -136,16 +135,16 @@ private:
QString maddeRoot(const QString &qmake) const; QString maddeRoot(const QString &qmake) const;
QString targetRoot(const QString &qmake) const; QString targetRoot(const QString &qmake) const;
bool fillRuntimeInformationForOldMadInfo(Runtime *runtime) const; bool fillRuntimeInformationForOldMadInfo(MaemoQemuRuntime *runtime) const;
void setEnvironment(Runtime *runTime, const QString &envSpec) const; void setEnvironment(MaemoQemuRuntime *runTime, const QString &envSpec) const;
Runtime createRuntime(const QtVersion *qtVersion) const; MaemoQemuRuntime createRuntime(const QtVersion *qtVersion) const;
Runtime parseRuntimeFromMadInfo(const QByteArray &output, MaemoQemuRuntime parseRuntimeFromMadInfo(const QByteArray &output,
const QString &targetName) const; const QString &targetName) const;
Runtime parseRuntimeFromOldMadInfo(const QString &output, MaemoQemuRuntime parseRuntimeFromOldMadInfo(const QString &output,
const QString &maddeRootPath, const QString &targetName) const; const QString &maddeRootPath, const QString &targetName) const;
void handleMadInfoTargetTag(QXmlStreamReader &infoReader, void handleMadInfoTargetTag(QXmlStreamReader &infoReader,
QString &runtimeName, const QString &targetName) const; QString &runtimeName, const QString &targetName) const;
Runtime handleMadInfoRuntimeTag(QXmlStreamReader &infoReader) const; MaemoQemuRuntime handleMadInfoRuntimeTag(QXmlStreamReader &infoReader) const;
QHash<QString, QString> handleMadInfoEnvironmentTag(QXmlStreamReader &infoReader) const; QHash<QString, QString> handleMadInfoEnvironmentTag(QXmlStreamReader &infoReader) const;
QPair<QString, QString> handleMadInfoVariableTag(QXmlStreamReader &infoReader) const; QPair<QString, QString> handleMadInfoVariableTag(QXmlStreamReader &infoReader) const;
MaemoPortList handleMadInfoTcpPortListTag(QXmlStreamReader &infoReader) const; MaemoPortList handleMadInfoTcpPortListTag(QXmlStreamReader &infoReader) const;
@@ -161,7 +160,7 @@ private:
int m_runningQtId; int m_runningQtId;
bool m_userTerminated; bool m_userTerminated;
QIcon m_qemuStarterIcon; QIcon m_qemuStarterIcon;
QMap<int, Runtime> m_runtimes; QMap<int, MaemoQemuRuntime> m_runtimes;
static MaemoQemuManager *m_instance; static MaemoQemuManager *m_instance;
QFileSystemWatcher *m_runtimeRootWatcher; QFileSystemWatcher *m_runtimeRootWatcher;
QFileSystemWatcher *m_runtimeFolderWatcher; QFileSystemWatcher *m_runtimeFolderWatcher;

View File

@@ -322,7 +322,7 @@ MaemoPortList MaemoRunConfiguration::freePorts() const
const MaemoDeviceConfig &devConfig = deviceConfig(); const MaemoDeviceConfig &devConfig = deviceConfig();
const Qt4BuildConfiguration * const qt4bc = activeQt4BuildConfiguration(); const Qt4BuildConfiguration * const qt4bc = activeQt4BuildConfiguration();
if (devConfig.type == MaemoDeviceConfig::Simulator && qt4bc) { if (devConfig.type == MaemoDeviceConfig::Simulator && qt4bc) {
Runtime rt; MaemoQemuRuntime rt;
const int id = qt4bc->qtVersion()->uniqueId(); const int id = qt4bc->qtVersion()->uniqueId();
if (MaemoQemuManager::instance().runtimeForQtVersion(id, &rt)) if (MaemoQemuManager::instance().runtimeForQtVersion(id, &rt))
return rt.m_freePorts; return rt.m_freePorts;