Commit 2ec85cc6 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Make some stateless functions static.

parent 3af81887
#include "maemodeploystepfactory.h"
#include "maemodeploystep.h"
#include "maemomanager.h"
#include "maemoglobal.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsteplist.h>
......@@ -24,7 +24,7 @@ MaemoDeployStepFactory::MaemoDeployStepFactory(QObject *parent)
QStringList MaemoDeployStepFactory::availableCreationIds(BuildStepList *parent) const
{
if (parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
&& MaemoManager::instance().isMaemoTargetId(parent->target()->id())
&& MaemoGlobal::isMaemoTargetId(parent->target()->id())
&& !parent->contains(MaemoDeployStep::Id))
return QStringList() << MaemoDeployStep::Id;
return QStringList();
......@@ -42,7 +42,7 @@ bool MaemoDeployStepFactory::canCreate(BuildStepList *parent, const QString &id)
{
return parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
&& id == QLatin1String(MaemoDeployStep::Id)
&& MaemoManager::instance().isMaemoTargetId(parent->target()->id())
&& MaemoGlobal::isMaemoTargetId(parent->target()->id())
&& !parent->contains(MaemoDeployStep::Id);
}
......
......@@ -38,6 +38,7 @@
#include <coreplugin/filemanager.h>
#include <coreplugin/ssh/sshconnection.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qt4projectmanager/qtversionmanager.h>
#include <utils/environment.h>
......@@ -55,6 +56,46 @@ namespace {
static const QLatin1String binQmake("/bin/qmake" EXEC_SUFFIX);
}
bool MaemoGlobal::isMaemoTargetId(const QString &id)
{
return id == QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)
|| id == QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID);
}
bool MaemoGlobal::isValidMaemo5QtVersion(const QtVersion *version)
{
return isValidMaemoQtVersion(version, Maemo5);
}
bool MaemoGlobal::isValidHarmattanQtVersion(const QtVersion *version)
{
return isValidMaemoQtVersion(version, Maemo6);
}
bool MaemoGlobal::isValidMaemoQtVersion(const QtVersion *qtVersion,
MaemoVersion maemoVersion)
{
if (version(qtVersion) != maemoVersion)
return false;
QProcess madAdminProc;
const QStringList arguments(QLatin1String("list"));
if (!callMadAdmin(madAdminProc, arguments, qtVersion))
return false;
if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished())
return false;
madAdminProc.setReadChannel(QProcess::StandardOutput);
const QByteArray tgtName = targetName(qtVersion).toAscii();
while (madAdminProc.canReadLine()) {
const QByteArray &line = madAdminProc.readLine();
if (line.contains(tgtName)
&& (line.contains("(installed)") || line.contains("(default)")))
return true;
}
return false;
}
QString MaemoGlobal::homeDirOnDevice(const QString &uname)
{
return uname == QLatin1String("root")
......
......@@ -71,6 +71,10 @@ public:
const QString m_fileName;
};
static bool isMaemoTargetId(const QString &id);
static bool isValidMaemo5QtVersion(const Qt4ProjectManager::QtVersion *version);
static bool isValidHarmattanQtVersion(const Qt4ProjectManager::QtVersion *version);
static QString homeDirOnDevice(const QString &uname);
static QString remoteSudo();
static QString remoteCommandPrefix(const QString &commandFilePath);
......@@ -127,6 +131,8 @@ public:
}
private:
static bool isValidMaemoQtVersion(const Qt4ProjectManager::QtVersion *qtVersion,
MaemoVersion maemoVersion);
static QString madAdminCommand(const QtVersion *qtVersion);
static bool callMaddeShellScript(QProcess &proc, const QString &maddeRoot,
const QString &command, const QStringList &args);
......
......@@ -45,7 +45,6 @@
#include "qt4maemotargetfactory.h"
#include <extensionsystem/pluginmanager.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qt4projectmanager/qtversionmanager.h>
#include <QtCore/QDir>
......@@ -110,45 +109,6 @@ MaemoManager &MaemoManager::instance()
return *m_instance;
}
bool MaemoManager::isMaemoTargetId(const QString &id) const
{
return id == QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)
|| id == QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID);
}
bool MaemoManager::isValidMaemo5QtVersion(const QtVersion *version) const
{
return isValidMaemoQtVersion(version, MaemoGlobal::Maemo5);
}
bool MaemoManager::isValidHarmattanQtVersion(const QtVersion *version) const
{
return isValidMaemoQtVersion(version, MaemoGlobal::Maemo6);
}
bool MaemoManager::isValidMaemoQtVersion(const QtVersion *qtVersion,
MaemoGlobal::MaemoVersion maemoVersion) const
{
if (MaemoGlobal::version(qtVersion) != maemoVersion)
return false;
QProcess madAdminProc;
const QStringList arguments(QLatin1String("list"));
if (!MaemoGlobal::callMadAdmin(madAdminProc, arguments, qtVersion))
return false;
if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished())
return false;
madAdminProc.setReadChannel(QProcess::StandardOutput);
const QByteArray targetName = MaemoGlobal::targetName(qtVersion).toAscii();
while (madAdminProc.canReadLine()) {
const QByteArray &line = madAdminProc.readLine();
if (line.contains(targetName)
&& (line.contains("(installed)") || line.contains("(default)")))
return true;
}
return false;
}
ToolChain* MaemoManager::maemo5ToolChain(const QtVersion *version) const
{
return new Maemo5ToolChain(version);
......
......@@ -34,8 +34,6 @@
#ifndef MAEMOMANAGER_H
#define MAEMOMANAGER_H
#include "maemoglobal.h"
#include <QtCore/QObject>
namespace ProjectExplorer {
......@@ -66,9 +64,6 @@ public:
~MaemoManager();
static MaemoManager &instance();
bool isMaemoTargetId(const QString &id) const;
bool isValidMaemo5QtVersion(const Qt4ProjectManager::QtVersion *version) const;
bool isValidHarmattanQtVersion(const Qt4ProjectManager::QtVersion *version) const;
ToolChain *maemo5ToolChain(const Qt4ProjectManager::QtVersion *version) const;
ToolChain *harmattanToolChain(const Qt4ProjectManager::QtVersion *version) const;
......@@ -76,9 +71,6 @@ public:
MaemoQemuSettingsPage *qemuSettingsPage() const { return m_qemuSettingsPage; }
private:
bool isValidMaemoQtVersion(const Qt4ProjectManager::QtVersion *qtVersion,
MaemoGlobal::MaemoVersion maemoVersion) const;
static MaemoManager *m_instance;
MaemoRunControlFactory *m_runControlFactory;
......
......@@ -67,7 +67,7 @@ MaemoPackageCreationFactory::MaemoPackageCreationFactory(QObject *parent)
QStringList MaemoPackageCreationFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
{
if (parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
&& MaemoManager::instance().isMaemoTargetId(parent->target()->id())
&& MaemoGlobal::isMaemoTargetId(parent->target()->id())
&& !parent->contains(MaemoPackageCreationStep::CreatePackageId))
return QStringList() << MaemoPackageCreationStep::CreatePackageId;
return QStringList();
......@@ -85,7 +85,7 @@ bool MaemoPackageCreationFactory::canCreate(ProjectExplorer::BuildStepList *pare
{
return parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
&& id == QLatin1String(MaemoPackageCreationStep::CreatePackageId)
&& MaemoManager::instance().isMaemoTargetId(parent->target()->id())
&& MaemoGlobal::isMaemoTargetId(parent->target()->id())
&& !parent->contains(MaemoPackageCreationStep::CreatePackageId);
}
......
......@@ -224,7 +224,7 @@ void MaemoQemuManager::projectChanged(ProjectExplorer::Project *project)
void MaemoQemuManager::targetAdded(ProjectExplorer::Target *target)
{
if (!target || !MaemoManager::instance().isMaemoTargetId(target->id()))
if (!target || !MaemoGlobal::isMaemoTargetId(target->id()))
return;
// handle all run configuration changes, add, remove, etc...
......@@ -253,7 +253,7 @@ void MaemoQemuManager::targetAdded(ProjectExplorer::Target *target)
void MaemoQemuManager::targetRemoved(ProjectExplorer::Target *target)
{
if (!target || !MaemoManager::instance().isMaemoTargetId(target->id()))
if (!target || !MaemoGlobal::isMaemoTargetId(target->id()))
return;
disconnect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
......@@ -287,14 +287,14 @@ void MaemoQemuManager::targetChanged(ProjectExplorer::Target *target)
void MaemoQemuManager::runConfigurationAdded(ProjectExplorer::RunConfiguration *rc)
{
if (!rc || !MaemoManager::instance().isMaemoTargetId(rc->target()->id()))
if (!rc || !MaemoGlobal::isMaemoTargetId(rc->target()->id()))
return;
toggleDeviceConnections(qobject_cast<MaemoRunConfiguration*> (rc), true);
}
void MaemoQemuManager::runConfigurationRemoved(ProjectExplorer::RunConfiguration *rc)
{
if (!rc || !MaemoManager::instance().isMaemoTargetId(rc->target()->id()))
if (!rc || !MaemoGlobal::isMaemoTargetId(rc->target()->id()))
return;
toggleDeviceConnections(qobject_cast<MaemoRunConfiguration*> (rc), false);
}
......@@ -307,7 +307,7 @@ void MaemoQemuManager::runConfigurationChanged(ProjectExplorer::RunConfiguration
void MaemoQemuManager::buildConfigurationAdded(ProjectExplorer::BuildConfiguration *bc)
{
if (!bc || !MaemoManager::instance().isMaemoTargetId(bc->target()->id()))
if (!bc || !MaemoGlobal::isMaemoTargetId(bc->target()->id()))
return;
connect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentChanged()));
......@@ -315,7 +315,7 @@ void MaemoQemuManager::buildConfigurationAdded(ProjectExplorer::BuildConfigurati
void MaemoQemuManager::buildConfigurationRemoved(ProjectExplorer::BuildConfiguration *bc)
{
if (!bc || !MaemoManager::instance().isMaemoTargetId(bc->target()->id()))
if (!bc || !MaemoGlobal::isMaemoTargetId(bc->target()->id()))
return;
disconnect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentChanged()));
......@@ -529,7 +529,7 @@ bool MaemoQemuManager::sessionHasMaemoTarget() const
const QList<Project*> &projects = explorer->session()->projects();
foreach (const Project *p, projects) {
foreach (const Target * const target, p->targets()) {
if (MaemoManager::instance().isMaemoTargetId(target->id()))
if (MaemoGlobal::isMaemoTargetId(target->id()))
return true;
}
}
......
......@@ -27,11 +27,11 @@
**
**************************************************************************/
#include "maemomanager.h"
#include "qt4maemotargetfactory.h"
#include "qt4project.h"
#include "qt4projectmanagerconstants.h"
#include "qt-maemo/maemodeploystep.h"
#include "maemoglobal.h"
#include "qt-maemo/maemopackagecreationstep.h"
#include "qt-maemo/maemorunconfiguration.h"
#include "qt-maemo/qt4maemotarget.h"
......@@ -62,7 +62,7 @@ Qt4MaemoTargetFactory::~Qt4MaemoTargetFactory()
bool Qt4MaemoTargetFactory::supportsTargetId(const QString &id) const
{
return MaemoManager::instance().isMaemoTargetId(id);
return MaemoGlobal::isMaemoTargetId(id);
}
QStringList Qt4MaemoTargetFactory::supportedTargetIds(ProjectExplorer::Project *parent) const
......
......@@ -37,6 +37,7 @@
#include "qt4target.h"
#include "profilereader.h"
#include "qt-maemo/maemoglobal.h"
#include "qt-maemo/maemomanager.h"
#include "qt-s60/s60manager.h"
#include "qt-s60/s60projectchecker.h"
......@@ -1464,10 +1465,10 @@ void QtVersion::updateToolChainAndMkspec() const
m_targetIds.insert(QLatin1String(Constants::S60_DEVICE_TARGET_ID));
# endif
}
} else if (MaemoManager::instance().isValidMaemo5QtVersion(this)) {
} else if (MaemoGlobal::isValidMaemo5QtVersion(this)) {
m_toolChains << ToolChainPtr(MaemoManager::instance().maemo5ToolChain(this));
m_targetIds.insert(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID));
} else if (MaemoManager::instance().isValidHarmattanQtVersion(this)) {
} else if (MaemoGlobal::isValidHarmattanQtVersion(this)) {
m_toolChains << ToolChainPtr(MaemoManager::instance().harmattanToolChain(this));
m_targetIds.insert(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID));
} else if (qmakeCXX == "cl" || qmakeCXX == "icl") {
......
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