2011-04-13 08:42:33 +02:00
|
|
|
/**************************************************************************
|
2010-02-23 16:17:04 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file is part of Qt Creator
|
2010-02-23 16:17:04 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-23 16:17:04 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2010-02-23 16:17:04 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2011-04-13 08:42:33 +02:00
|
|
|
**
|
|
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2010-02-23 16:17:04 +01:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-02-23 16:17:04 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-02-23 16:17:04 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
**************************************************************************/
|
2010-05-20 15:47:42 +02:00
|
|
|
|
2010-02-23 16:17:04 +01:00
|
|
|
#include "maemorunfactories.h"
|
|
|
|
|
|
|
|
|
|
#include "maemoconstants.h"
|
2010-07-15 16:43:56 +02:00
|
|
|
#include "maemodebugsupport.h"
|
2011-01-04 14:14:12 +01:00
|
|
|
#include "maemoglobal.h"
|
2010-08-13 15:25:22 +02:00
|
|
|
#include "maemoremotemountsmodel.h"
|
2010-02-23 16:17:04 +01:00
|
|
|
#include "maemorunconfiguration.h"
|
|
|
|
|
#include "maemoruncontrol.h"
|
2010-12-10 19:02:19 +01:00
|
|
|
#include "maemotoolchain.h"
|
|
|
|
|
#include "qt4maemotarget.h"
|
2010-02-23 16:17:04 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2010-11-12 20:18:29 +01:00
|
|
|
#include <debugger/debuggerconstants.h>
|
2010-02-23 16:17:04 +01:00
|
|
|
#include <qt4projectmanager/qt4project.h>
|
2010-05-20 15:47:42 +02:00
|
|
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
2010-02-23 16:17:04 +01:00
|
|
|
|
|
|
|
|
namespace Qt4ProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2010-07-08 15:46:50 +02:00
|
|
|
QString pathFromId(const QString &id)
|
2010-02-23 16:17:04 +01:00
|
|
|
{
|
|
|
|
|
if (!id.startsWith(MAEMO_RC_ID_PREFIX))
|
|
|
|
|
return QString();
|
|
|
|
|
return id.mid(QString(MAEMO_RC_ID_PREFIX).size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
MaemoRunConfigurationFactory::MaemoRunConfigurationFactory(QObject *parent)
|
|
|
|
|
: IRunConfigurationFactory(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaemoRunConfigurationFactory::~MaemoRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MaemoRunConfigurationFactory::canCreate(Target *parent,
|
|
|
|
|
const QString &id) const
|
|
|
|
|
{
|
2011-01-18 15:20:57 +01:00
|
|
|
AbstractQt4MaemoTarget *target = qobject_cast<AbstractQt4MaemoTarget *>(parent);
|
|
|
|
|
if (!target)
|
2010-02-23 16:17:04 +01:00
|
|
|
return false;
|
2010-07-08 15:46:50 +02:00
|
|
|
return target->qt4Project()->hasApplicationProFile(pathFromId(id));
|
2010-02-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MaemoRunConfigurationFactory::canRestore(Target *parent,
|
|
|
|
|
const QVariantMap &map) const
|
|
|
|
|
{
|
2011-01-18 15:20:57 +01:00
|
|
|
if (!qobject_cast<AbstractQt4MaemoTarget *>(parent))
|
2010-07-13 11:06:06 +02:00
|
|
|
return false;
|
|
|
|
|
return ProjectExplorer::idFromMap(map)
|
|
|
|
|
.startsWith(QLatin1String(MAEMO_RC_ID));
|
2010-02-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MaemoRunConfigurationFactory::canClone(Target *parent,
|
|
|
|
|
RunConfiguration *source) const
|
|
|
|
|
{
|
|
|
|
|
return canCreate(parent, source->id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList MaemoRunConfigurationFactory::availableCreationIds(Target *parent) const
|
|
|
|
|
{
|
2011-01-18 15:20:57 +01:00
|
|
|
if (AbstractQt4MaemoTarget *t = qobject_cast<AbstractQt4MaemoTarget *>(parent)) {
|
|
|
|
|
if (t) {
|
2010-02-23 16:17:04 +01:00
|
|
|
return t->qt4Project()->
|
|
|
|
|
applicationProFilePathes(QLatin1String(MAEMO_RC_ID_PREFIX));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QStringList();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-22 17:34:35 +02:00
|
|
|
QString MaemoRunConfigurationFactory::displayNameForId(const QString &id) const
|
2010-02-23 16:17:04 +01:00
|
|
|
{
|
2010-07-08 15:46:50 +02:00
|
|
|
return QFileInfo(pathFromId(id)).completeBaseName();
|
2010-02-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration *MaemoRunConfigurationFactory::create(Target *parent,
|
|
|
|
|
const QString &id)
|
|
|
|
|
{
|
|
|
|
|
if (!canCreate(parent, id))
|
|
|
|
|
return 0;
|
2011-01-18 15:20:57 +01:00
|
|
|
AbstractQt4MaemoTarget *pqt4parent = static_cast<AbstractQt4MaemoTarget *>(parent);
|
2010-07-08 15:46:50 +02:00
|
|
|
return new MaemoRunConfiguration(pqt4parent, pathFromId(id));
|
2010-02-23 16:17:04 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration *MaemoRunConfigurationFactory::restore(Target *parent,
|
|
|
|
|
const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
2011-01-18 15:20:57 +01:00
|
|
|
AbstractQt4MaemoTarget *target = static_cast<AbstractQt4MaemoTarget *>(parent);
|
2010-02-23 17:44:24 +01:00
|
|
|
MaemoRunConfiguration *rc = new MaemoRunConfiguration(target, QString());
|
|
|
|
|
if (rc->fromMap(map))
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
|
|
delete rc;
|
|
|
|
|
return 0;
|
2010-02-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration *MaemoRunConfigurationFactory::clone(Target *parent,
|
|
|
|
|
RunConfiguration *source)
|
|
|
|
|
{
|
|
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2010-02-23 17:44:24 +01:00
|
|
|
MaemoRunConfiguration *old = static_cast<MaemoRunConfiguration *>(source);
|
2011-01-18 15:20:57 +01:00
|
|
|
return new MaemoRunConfiguration(static_cast<AbstractQt4MaemoTarget *>(parent), old);
|
2010-02-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #pragma mark -- MaemoRunControlFactory
|
|
|
|
|
|
|
|
|
|
MaemoRunControlFactory::MaemoRunControlFactory(QObject *parent)
|
|
|
|
|
: IRunControlFactory(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaemoRunControlFactory::~MaemoRunControlFactory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration,
|
|
|
|
|
const QString &mode) const
|
|
|
|
|
{
|
2010-08-13 15:25:22 +02:00
|
|
|
const MaemoRunConfiguration * const maemoRunConfig
|
|
|
|
|
= qobject_cast<MaemoRunConfiguration *>(runConfiguration);
|
2011-01-11 16:08:51 +01:00
|
|
|
if (!maemoRunConfig
|
2011-01-13 13:49:23 +01:00
|
|
|
|| !maemoRunConfig->deviceConfig() || !maemoRunConfig->toolchain()
|
2010-09-28 09:51:16 +02:00
|
|
|
|| maemoRunConfig->remoteExecutableFilePath().isEmpty())
|
2010-08-13 15:25:22 +02:00
|
|
|
return false;
|
|
|
|
|
const int freePortCount = maemoRunConfig->freePorts().count();
|
2010-10-11 18:12:46 +02:00
|
|
|
|
2011-01-19 11:06:43 +01:00
|
|
|
const bool remoteMountsAllowed
|
|
|
|
|
= maemoRunConfig->maemoTarget()->allowsRemoteMounts();
|
2011-01-04 14:14:12 +01:00
|
|
|
if (remoteMountsAllowed && freePortCount == 0)
|
2010-08-13 15:25:22 +02:00
|
|
|
return false;
|
|
|
|
|
const int mountDirCount
|
2011-01-04 14:14:12 +01:00
|
|
|
= remoteMountsAllowed
|
2010-09-15 10:36:38 +02:00
|
|
|
? maemoRunConfig->remoteMounts()->validMountSpecificationCount()
|
|
|
|
|
: 0;
|
2010-11-12 20:18:29 +01:00
|
|
|
if (mode == Debugger::Constants::DEBUGMODE)
|
2010-09-16 17:08:07 +02:00
|
|
|
return freePortCount >= mountDirCount + maemoRunConfig->portsUsedByDebuggers();
|
2010-08-13 15:25:22 +02:00
|
|
|
if (mode == ProjectExplorer::Constants::RUNMODE)
|
|
|
|
|
return freePortCount >= mountDirCount;
|
|
|
|
|
return false;
|
2010-02-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig,
|
|
|
|
|
const QString &mode)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(mode == ProjectExplorer::Constants::RUNMODE
|
2010-11-12 20:18:29 +01:00
|
|
|
|| mode == Debugger::Constants::DEBUGMODE);
|
2010-09-28 09:51:16 +02:00
|
|
|
Q_ASSERT(canRun(runConfig, mode));
|
|
|
|
|
MaemoRunConfiguration *rc = qobject_cast<MaemoRunConfiguration *>(runConfig);
|
|
|
|
|
Q_ASSERT(rc);
|
2010-02-23 16:17:04 +01:00
|
|
|
if (mode == ProjectExplorer::Constants::RUNMODE)
|
|
|
|
|
return new MaemoRunControl(rc);
|
2010-07-15 16:43:56 +02:00
|
|
|
return MaemoDebugSupport::createDebugRunControl(rc);
|
2010-02-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoRunControlFactory::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("Run on device");
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
RunConfigWidget *MaemoRunControlFactory::createConfigurationWidget(RunConfiguration *config)
|
2010-02-23 16:17:04 +01:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(config)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qt4ProjectManager
|