Commit aa8786fb authored by El Mehdi Fekari's avatar El Mehdi Fekari Committed by Mehdi Fekari

Qnx: Add BlackBerry runtime management support

Add support for managing user BlackBerry runtime configurations.

This does not handle adding manual runtimes yet, but only detects
runtimes from the NDK directories of the available API levels.

The BlackBerry NDK should provide a better way to detect installed
runtimes (e.g xml installation files) in order to improve
the BlackBerry runtime managemnt in Qt Creator.

Change-Id: I4f139d52352f903a27dfe4175d12b016b4ee25a9
Reviewed-by: Nicolas Arnaud-Cormos's avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
parent b840a243
......@@ -29,11 +29,12 @@
**
****************************************************************************/
#include "blackberryconfiguration.h"
#include "blackberryapilevelconfiguration.h"
#include "blackberryconfigurationmanager.h"
#include "blackberryqtversion.h"
#include "qnxtoolchain.h"
#include "qnxconstants.h"
#include <utils/qtcassert.h>
......@@ -76,10 +77,10 @@ const QLatin1String NDKAutoDetectionSourceKey("NDKAutoDetectionSource");
const QLatin1String NDKAutoDetectedKey("NDKAutoDetectedKey");
#ifdef WITH_TESTS
bool BlackBerryConfiguration::m_fakeConfig = false;
bool BlackBerryApiLevelConfiguration::m_fakeConfig = false;
#endif
BlackBerryConfiguration::BlackBerryConfiguration(const NdkInstallInformation &ndkInstallInfo)
BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const NdkInstallInformation &ndkInstallInfo)
{
QString envFilePath = QnxUtils::envFilePath(ndkInstallInfo.path, ndkInstallInfo.version);
QTC_ASSERT(!envFilePath.isEmpty(), return);
......@@ -96,7 +97,7 @@ BlackBerryConfiguration::BlackBerryConfiguration(const NdkInstallInformation &nd
ctor();
}
BlackBerryConfiguration::BlackBerryConfiguration(const FileName &ndkEnvFile)
BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const FileName &ndkEnvFile)
: m_autoDetectionSource(Utils::FileName())
{
QTC_ASSERT(!QFileInfo(ndkEnvFile.toString()).isDir(), return);
......@@ -129,7 +130,7 @@ BlackBerryConfiguration::BlackBerryConfiguration(const FileName &ndkEnvFile)
ctor();
}
BlackBerryConfiguration::BlackBerryConfiguration(const QVariantMap &data)
BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const QVariantMap &data)
{
QString envFilePath = data.value(NDKEnvFileKey).toString();
QTC_ASSERT(!envFilePath.isEmpty(), return);
......@@ -148,7 +149,7 @@ BlackBerryConfiguration::BlackBerryConfiguration(const QVariantMap &data)
ctor();
}
void BlackBerryConfiguration::ctor()
void BlackBerryApiLevelConfiguration::ctor()
{
FileName qmake4Path = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/qmake")));
FileName qmake5Path = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/qt5/qmake")));
......@@ -172,42 +173,42 @@ void BlackBerryConfiguration::ctor()
m_simulatorDebugger = simulatorGdbPath;
}
QString BlackBerryConfiguration::ndkPath() const
QString BlackBerryApiLevelConfiguration::ndkPath() const
{
return m_ndkEnvFile.parentDir().toString();
}
QString BlackBerryConfiguration::displayName() const
QString BlackBerryApiLevelConfiguration::displayName() const
{
return m_displayName;
}
QString BlackBerryConfiguration::targetName() const
QString BlackBerryApiLevelConfiguration::targetName() const
{
return m_targetName;
}
QString BlackBerryConfiguration::qnxHost() const
QString BlackBerryApiLevelConfiguration::qnxHost() const
{
return m_qnxHost;
}
BlackBerryVersionNumber BlackBerryConfiguration::version() const
BlackBerryVersionNumber BlackBerryApiLevelConfiguration::version() const
{
return m_version;
}
bool BlackBerryConfiguration::isAutoDetected() const
bool BlackBerryApiLevelConfiguration::isAutoDetected() const
{
return !m_autoDetectionSource.isEmpty();
}
Utils::FileName BlackBerryConfiguration::autoDetectionSource() const
Utils::FileName BlackBerryApiLevelConfiguration::autoDetectionSource() const
{
return m_autoDetectionSource;
}
bool BlackBerryConfiguration::isActive() const
bool BlackBerryApiLevelConfiguration::isActive() const
{
foreach (Kit *kit, KitManager::kits()) {
if (kit->isAutoDetected() &&
......@@ -218,10 +219,10 @@ bool BlackBerryConfiguration::isActive() const
return false;
}
bool BlackBerryConfiguration::isValid() const
bool BlackBerryApiLevelConfiguration::isValid() const
{
#ifdef WITH_TESTS
if (BlackBerryConfiguration::fakeConfig())
if (BlackBerryApiLevelConfiguration::fakeConfig())
return true;
#endif
......@@ -232,49 +233,51 @@ bool BlackBerryConfiguration::isValid() const
&& m_sysRoot.toFileInfo().exists());
}
FileName BlackBerryConfiguration::ndkEnvFile() const
FileName BlackBerryApiLevelConfiguration::ndkEnvFile() const
{
return m_ndkEnvFile;
}
FileName BlackBerryConfiguration::qmake4BinaryFile() const
FileName BlackBerryApiLevelConfiguration::qmake4BinaryFile() const
{
return m_qmake4BinaryFile;
}
FileName BlackBerryConfiguration::qmake5BinaryFile() const
FileName BlackBerryApiLevelConfiguration::qmake5BinaryFile() const
{
return m_qmake5BinaryFile;
}
FileName BlackBerryConfiguration::gccCompiler() const
FileName BlackBerryApiLevelConfiguration::gccCompiler() const
{
return m_gccCompiler;
}
FileName BlackBerryConfiguration::deviceDebuger() const
FileName BlackBerryApiLevelConfiguration::deviceDebuger() const
{
return m_deviceDebugger;
}
FileName BlackBerryConfiguration::simulatorDebuger() const
FileName BlackBerryApiLevelConfiguration::simulatorDebuger() const
{
return m_simulatorDebugger;
}
FileName BlackBerryConfiguration::sysRoot() const
FileName BlackBerryApiLevelConfiguration::sysRoot() const
{
return m_sysRoot;
}
QList<Utils::EnvironmentItem> BlackBerryConfiguration::qnxEnv() const
QList<Utils::EnvironmentItem> BlackBerryApiLevelConfiguration::qnxEnv() const
{
return m_qnxEnv;
}
QVariantMap BlackBerryConfiguration::toMap() const
QVariantMap BlackBerryApiLevelConfiguration::toMap() const
{
QVariantMap data;
data.insert(QLatin1String(Qnx::Constants::QNX_BB_KEY_CONFIGURATION_TYPE),
QLatin1String(Qnx::Constants::QNX_BB_APILEVEL_TYPE));
data.insert(QLatin1String(NDKEnvFileKey), m_ndkEnvFile.toString());
data.insert(QLatin1String(NDKDisplayNameKey), m_displayName);
data.insert(QLatin1String(NDKPathKey), ndkPath());
......@@ -286,7 +289,7 @@ QVariantMap BlackBerryConfiguration::toMap() const
return data;
}
QnxAbstractQtVersion *BlackBerryConfiguration::createQtVersion(
QnxAbstractQtVersion *BlackBerryApiLevelConfiguration::createQtVersion(
const FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName)
{
QnxAbstractQtVersion *version = new BlackBerryQtVersion(
......@@ -296,7 +299,7 @@ QnxAbstractQtVersion *BlackBerryConfiguration::createQtVersion(
return version;
}
QnxToolChain *BlackBerryConfiguration::createToolChain(
QnxToolChain *BlackBerryApiLevelConfiguration::createToolChain(
ProjectExplorer::Abi abi, const QString &versionName)
{
QnxToolChain* toolChain = new QnxToolChain(ToolChain::AutoDetection);
......@@ -309,7 +312,7 @@ QnxToolChain *BlackBerryConfiguration::createToolChain(
return toolChain;
}
QVariant BlackBerryConfiguration::createDebuggerItem(
QVariant BlackBerryApiLevelConfiguration::createDebuggerItem(
QList<ProjectExplorer::Abi> abis, Qnx::QnxArchitecture arch, const QString &versionName)
{
Utils::FileName command = arch == X86 ? m_simulatorDebugger : m_deviceDebugger;
......@@ -322,7 +325,7 @@ QVariant BlackBerryConfiguration::createDebuggerItem(
return DebuggerItemManager::registerDebugger(debugger);
}
Kit *BlackBerryConfiguration::createKit(
Kit *BlackBerryApiLevelConfiguration::createKit(
QnxAbstractQtVersion *version, QnxToolChain *toolChain, const QVariant &debuggerItemId)
{
Kit *kit = new Kit;
......@@ -359,7 +362,7 @@ Kit *BlackBerryConfiguration::createKit(
return kit;
}
bool BlackBerryConfiguration::activate()
bool BlackBerryApiLevelConfiguration::activate()
{
if (!isValid()) {
if (!m_autoDetectionSource.isEmpty())
......@@ -441,7 +444,7 @@ bool BlackBerryConfiguration::activate()
return true;
}
void BlackBerryConfiguration::deactivate()
void BlackBerryApiLevelConfiguration::deactivate()
{
foreach (Kit *kit, KitManager::kits()) {
if (kit->isAutoDetected() &&
......@@ -464,12 +467,12 @@ void BlackBerryConfiguration::deactivate()
}
#ifdef WITH_TESTS
void BlackBerryConfiguration::setFakeConfig(bool fakeConfig)
void BlackBerryApiLevelConfiguration::setFakeConfig(bool fakeConfig)
{
m_fakeConfig = fakeConfig;
}
bool BlackBerryConfiguration::fakeConfig()
bool BlackBerryApiLevelConfiguration::fakeConfig()
{
return m_fakeConfig;
}
......
......@@ -54,13 +54,13 @@ namespace Internal {
class QnxAbstractQtVersion;
class QnxToolChain;
class BlackBerryConfiguration
class BlackBerryApiLevelConfiguration
{
Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::BlackBerryConfiguration)
Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::BlackBerryApiLevelConfiguration)
public:
BlackBerryConfiguration(const NdkInstallInformation &ndkInstallInfo);
BlackBerryConfiguration(const Utils::FileName &ndkEnvFile);
BlackBerryConfiguration(const QVariantMap &data);
BlackBerryApiLevelConfiguration(const NdkInstallInformation &ndkInstallInfo);
BlackBerryApiLevelConfiguration(const Utils::FileName &ndkEnvFile);
BlackBerryApiLevelConfiguration(const QVariantMap &data);
bool activate();
void deactivate();
QString ndkPath() const;
......
......@@ -30,7 +30,7 @@
****************************************************************************/
#include "blackberrycertificate.h"
#include "blackberryconfiguration.h"
#include "blackberryapilevelconfiguration.h"
#include "blackberryconfigurationmanager.h"
#include "blackberryndkprocess.h"
......
......@@ -31,7 +31,8 @@
#include "blackberryconfigurationmanager.h"
#include "blackberrycertificate.h"
#include "blackberryconfiguration.h"
#include "blackberryapilevelconfiguration.h"
#include "blackberryruntimeconfiguration.h"
#include "qnxtoolchain.h"
#include "qnxutils.h"
......@@ -54,6 +55,7 @@
#include <QMessageBox>
#include <QFileInfo>
#include <QDebug>
#include <QDir>
using namespace ProjectExplorer;
......@@ -79,7 +81,7 @@ static Utils::FileName bbConfigSettingsFileName()
+ QLatin1String(Constants::QNX_BLACKBERRY_CONFIGS_FILENAME));
}
static bool sortConfigurationsByVersion(const BlackBerryConfiguration *a, const BlackBerryConfiguration *b)
template <class T> static bool sortConfigurationsByVersion(const T *a, const T *b)
{
return a->version() > b->version();
}
......@@ -99,8 +101,17 @@ void BlackBerryConfigurationManager::saveConfigurations()
QVariantMap data;
data.insert(QLatin1String(BBConfigsFileVersionKey), 1);
int count = 0;
foreach (BlackBerryConfiguration *config, m_configs) {
QVariantMap tmp = config->toMap();
foreach (BlackBerryApiLevelConfiguration *apiLevel, m_apiLevels) {
QVariantMap tmp = apiLevel->toMap();
if (tmp.isEmpty())
continue;
data.insert(BBConfigDataKey + QString::number(count), tmp);
++count;
}
foreach (BlackBerryRuntimeConfiguration *runtime, m_runtimes) {
QVariantMap tmp = runtime->toMap();
if (tmp.isEmpty())
continue;
......@@ -110,8 +121,8 @@ void BlackBerryConfigurationManager::saveConfigurations()
data.insert(QLatin1String(BBConfigCountKey), count);
const QString newestConfig = (newestConfigurationEnabled())
? NewestConfigurationValue : defaultConfiguration()->ndkEnvFile().toString();
const QString newestConfig = (newestApiLevelEnabled())
? NewestConfigurationValue : defaultApiLevel()->ndkEnvFile().toString();
//save default configuration
data.insert(QLatin1String(DefaultConfigurationKey), newestConfig);
......@@ -142,13 +153,19 @@ void BlackBerryConfigurationManager::restoreConfigurations()
continue;
const QVariantMap dMap = data.value(key).toMap();
BlackBerryConfiguration *config = new BlackBerryConfiguration(dMap);
insertByVersion(config);
if (!useNewestConfiguration && (config->ndkEnvFile().toString() == ndkEnvFile))
setDefaultConfiguration(config);
const QString configurationType =
dMap.value(QLatin1String(Constants::QNX_BB_KEY_CONFIGURATION_TYPE)).toString();
if (configurationType == QLatin1String(Constants::QNX_BB_RUNTIME_TYPE)) {
BlackBerryRuntimeConfiguration *runtime = new BlackBerryRuntimeConfiguration(dMap);
insertRuntimeByVersion(runtime);
} else if (configurationType == QLatin1String(Constants::QNX_BB_APILEVEL_TYPE)
|| configurationType.isEmpty()) { // Backward compatibility
BlackBerryApiLevelConfiguration *apiLevel = new BlackBerryApiLevelConfiguration(dMap);
insertApiLevelByVersion(apiLevel);
if (!useNewestConfiguration && (apiLevel->ndkEnvFile().toString() == ndkEnvFile))
setDefaultConfiguration(apiLevel);
}
}
emit settingsChanged();
......@@ -174,8 +191,9 @@ void BlackBerryConfigurationManager::loadManualConfigurations()
ndkEnvPath = QnxUtils::envFilePath(ndkPath);
}
BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(ndkEnvPath));
if (!addConfiguration(config))
BlackBerryApiLevelConfiguration *config =
new BlackBerryApiLevelConfiguration(Utils::FileName::fromString(ndkEnvPath));
if (!addApiLevel(config))
delete config;
settings->endGroup();
......@@ -186,20 +204,36 @@ void BlackBerryConfigurationManager::loadManualConfigurations()
settings->endGroup();
}
void BlackBerryConfigurationManager::loadAutoDetectedConfigurations()
void BlackBerryConfigurationManager::loadAutoDetectedApiLevels()
{
foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) {
BlackBerryConfiguration *config = new BlackBerryConfiguration(ndkInfo);
if (!addConfiguration(config)) {
BlackBerryApiLevelConfiguration *config = new BlackBerryApiLevelConfiguration(ndkInfo);
if (!addApiLevel(config)) {
delete config;
continue;
}
}
}
void BlackBerryConfigurationManager::setDefaultConfiguration(BlackBerryConfiguration *config)
void BlackBerryConfigurationManager::loadAutoDetectedRuntimes()
{
QRegExp regExp(QLatin1String("runtime_(\\d+)_(\\d+)_(\\d+)_(\\d+)"));
foreach (BlackBerryApiLevelConfiguration *apiLevel, m_apiLevels) {
QDir ndkDir(apiLevel->ndkPath());
foreach (const QFileInfo& fi, ndkDir.entryInfoList(QDir::Dirs)) {
if (regExp.exactMatch(fi.baseName())) {
BlackBerryRuntimeConfiguration *runtime =
new BlackBerryRuntimeConfiguration(fi.absoluteFilePath());
if (!addRuntime(runtime))
delete runtime;
}
}
}
}
void BlackBerryConfigurationManager::setDefaultConfiguration(
BlackBerryApiLevelConfiguration *config)
{
if (config && !m_configs.contains(config)) {
if (config && !m_apiLevels.contains(config)) {
qWarning() << "BlackBerryConfigurationManager::setDefaultConfiguration -"
" configuration does not belong to this instance: "
<< config->ndkEnvFile().toString();
......@@ -210,7 +244,7 @@ void BlackBerryConfigurationManager::setDefaultConfiguration(BlackBerryConfigura
emit settingsChanged();
}
bool BlackBerryConfigurationManager::newestConfigurationEnabled() const
bool BlackBerryConfigurationManager::newestApiLevelEnabled() const
{
return !m_defaultConfiguration;
}
......@@ -227,7 +261,7 @@ void BlackBerryConfigurationManager::setKitsAutoDetectionSource()
(DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_BB_CATEGORY_ICON) &&
kit->autoDetectionSource().isEmpty()) {
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
foreach (BlackBerryConfiguration *config, m_configs) {
foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) {
if ((version &&
(version->qmakeCommand() == config->qmake4BinaryFile() || version->qmakeCommand() == config->qmake5BinaryFile()))
&& (SysRootKitInformation::sysRoot(kit) == config->sysRoot()))
......@@ -237,17 +271,28 @@ void BlackBerryConfigurationManager::setKitsAutoDetectionSource()
}
}
void BlackBerryConfigurationManager::insertByVersion(BlackBerryConfiguration *config)
void BlackBerryConfigurationManager::insertApiLevelByVersion(
BlackBerryApiLevelConfiguration *apiLevel)
{
QList<BlackBerryApiLevelConfiguration *>::iterator it =
qLowerBound(m_apiLevels.begin(), m_apiLevels.end(),
apiLevel, sortConfigurationsByVersion<BlackBerryApiLevelConfiguration>);
m_apiLevels.insert(it, apiLevel);
}
void BlackBerryConfigurationManager::insertRuntimeByVersion(
BlackBerryRuntimeConfiguration *runtime)
{
QList<BlackBerryConfiguration *>::iterator it = qLowerBound(m_configs.begin(), m_configs.end(),
config, &sortConfigurationsByVersion);
m_configs.insert(it, config);
QList<BlackBerryRuntimeConfiguration *>::iterator it =
qLowerBound(m_runtimes.begin(), m_runtimes.end(),
runtime, sortConfigurationsByVersion<BlackBerryRuntimeConfiguration>);
m_runtimes.insert(it, runtime);
}
// Switch to QnxToolchain for exisintg configuration using GccToolChain
void BlackBerryConfigurationManager::checkToolChainConfiguration()
{
foreach (BlackBerryConfiguration *config, m_configs) {
foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) {
foreach (ToolChain *tc, ToolChainManager::toolChains()) {
if (tc->compilerCommand() == config->gccCompiler()
&& !tc->id().startsWith(QLatin1String(Constants::QNX_TOOLCHAIN_ID))) {
......@@ -262,9 +307,9 @@ void BlackBerryConfigurationManager::checkToolChainConfiguration()
}
}
bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *config)
bool BlackBerryConfigurationManager::addApiLevel(BlackBerryApiLevelConfiguration *config)
{
foreach (BlackBerryConfiguration *c, m_configs) {
foreach (BlackBerryApiLevelConfiguration *c, m_apiLevels) {
if (config->ndkEnvFile() == c->ndkEnvFile()) {
if (!config->isAutoDetected())
QMessageBox::warning(Core::ICore::mainWindow(), tr("NDK Already Known"),
......@@ -274,7 +319,7 @@ bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *c
}
if (config->isValid()) {
insertByVersion(config);
insertApiLevelByVersion(config);
emit settingsChanged();
return true;
}
......@@ -282,7 +327,7 @@ bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *c
return false;
}
void BlackBerryConfigurationManager::removeConfiguration(BlackBerryConfiguration *config)
void BlackBerryConfigurationManager::removeApiLevel(BlackBerryApiLevelConfiguration *config)
{
if (!config)
return;
......@@ -290,9 +335,9 @@ void BlackBerryConfigurationManager::removeConfiguration(BlackBerryConfiguration
if (config->isActive())
config->deactivate();
m_configs.removeAt(m_configs.indexOf(config));
m_apiLevels.removeAll(config);
if (defaultConfiguration() == config)
if (defaultApiLevel() == config)
setDefaultConfiguration(0);
delete config;
......@@ -300,15 +345,40 @@ void BlackBerryConfigurationManager::removeConfiguration(BlackBerryConfiguration
emit settingsChanged();
}
QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::configurations() const
bool BlackBerryConfigurationManager::addRuntime(BlackBerryRuntimeConfiguration *runtime)
{
return m_configs;
foreach (BlackBerryRuntimeConfiguration *rt, m_runtimes) {
if (runtime->path() == rt->path())
return false;
}
insertRuntimeByVersion(runtime);
return true;
}
void BlackBerryConfigurationManager::removeRuntime(BlackBerryRuntimeConfiguration *runtime)
{
if (!runtime)
return;
m_runtimes.removeAll(runtime);
delete runtime;
}
QList<BlackBerryApiLevelConfiguration *> BlackBerryConfigurationManager::apiLevels() const
{
return m_apiLevels;
}
QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::manualConfigurations() const
QList<BlackBerryRuntimeConfiguration *> BlackBerryConfigurationManager::runtimes() const
{
QList<BlackBerryConfiguration*> manuals;
foreach (BlackBerryConfiguration *config, m_configs) {
return m_runtimes;
}
QList<BlackBerryApiLevelConfiguration *> BlackBerryConfigurationManager::manualApiLevels() const
{
QList<BlackBerryApiLevelConfiguration*> manuals;
foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) {
if (!config->isAutoDetected())
manuals << config;
}
......@@ -316,10 +386,10 @@ QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::manualConfigura
return manuals;
}
QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::activeConfigurations() const
QList<BlackBerryApiLevelConfiguration *> BlackBerryConfigurationManager::activeApiLevels() const
{
QList<BlackBerryConfiguration*> actives;
foreach (BlackBerryConfiguration *config, m_configs) {
QList<BlackBerryApiLevelConfiguration*> actives;
foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) {
if (config->isActive())
actives << config;
}
......@@ -327,12 +397,13 @@ QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::activeConfigura
return actives;
}
BlackBerryConfiguration *BlackBerryConfigurationManager::configurationFromEnvFile(const Utils::FileName &envFile) const
BlackBerryApiLevelConfiguration *BlackBerryConfigurationManager::apiLevelFromEnvFile(
const Utils::FileName &envFile) const
{
if (envFile.isEmpty())
return 0;
foreach (BlackBerryConfiguration *config, m_configs) {
foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) {
if (config->ndkEnvFile() == envFile)
return config;
}
......@@ -340,21 +411,32 @@ BlackBerryConfiguration *BlackBerryConfigurationManager::configurationFromEnvFil
return 0;
}
BlackBerryConfiguration *BlackBerryConfigurationManager::defaultConfiguration() const
BlackBerryRuntimeConfiguration *BlackBerryConfigurationManager::runtimeFromFilePath(
const QString &path)
{
foreach (BlackBerryRuntimeConfiguration *runtime, m_runtimes) {
if (runtime->path() == path)
return runtime;
}
return 0;
}
BlackBerryApiLevelConfiguration *BlackBerryConfigurationManager::defaultApiLevel() const
{
if (m_configs.isEmpty())
if (m_apiLevels.isEmpty())
return 0;
// !m_defaultConfiguration means use newest configuration
if (!m_defaultConfiguration)
return m_configs.first();
return m_apiLevels.first();
return m_defaultConfiguration;
}
QList<Utils::EnvironmentItem> BlackBerryConfigurationManager::defaultConfigurationEnv() const
{
const BlackBerryConfiguration *config = defaultConfiguration();
const BlackBerryApiLevelConfiguration *config = defaultApiLevel();
if (config)
return config->qnxEnv();
......@@ -371,13 +453,14 @@ void BlackBerryConfigurationManager::loadSettings()
restoreConfigurations();
// For backward compatibility
loadManualConfigurations();
loadAutoDetectedConfigurations();
loadAutoDetectedApiLevels();
loadAutoDetectedRuntimes();
checkToolChainConfiguration();
// If no target was/is activated, activate one since it's needed by
// device connection and CSK code.
if (activeConfigurations().isEmpty() && !m_configs.isEmpty())
m_configs.first()->activate();
if (activeApiLevels().isEmpty() && !m_apiLevels.isEmpty())
m_apiLevels.first()->activate();
emit settingsLoaded();
emit settingsChanged();
......@@ -397,7 +480,8 @@ BlackBerryConfigurationManager &BlackBerryConfigurationManager::instance()
BlackBerryConfigurationManager::~BlackBerryConfigurationManager()
{
qDeleteAll(m_configs);
qDeleteAll(m_apiLevels);
qDeleteAll(m_runtimes);
delete m_writer;
}
......
......@@ -43,7 +43,8 @@ namespace Utils { class PersistentSettingsWriter; }
namespace Qnx {
namespace Internal {
class BlackBerryConfiguration;
class BlackBerryApiLevelConfiguration;
class BlackBerryRuntimeConfiguration;
class BlackBerryConfigurationManager : public QObject
{
......@@ -51,13 +52,17 @@ class BlackBerryConfigurationManager : public QObject
public:
static BlackBerryConfigurationManager &instance();
~BlackBerryConfigurationManager();
bool addConfiguration(BlackBerryConfiguration *config);
void removeConfiguration(BlackBerryConfiguration *config);
QList<BlackBerryConfiguration*> configurations() const;
QList<BlackBerryConfiguration*> manualConfigurations() const;
QList<BlackBerryConfiguration *> activeConfigurations() const;
BlackBerryConfiguration *configurationFromEnvFile(const Utils::FileName &envFile) const;
BlackBerryConfiguration *defaultConfiguration() const;