2013-09-12 18:46:35 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Tim Sander <tim@krieglstein.org>
|
|
|
|
|
** Copyright (C) 2016 Denis Shienkov <denis.shienkov@gmail.com>
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-09-12 18:46:35 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-09-12 18:46:35 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-09-12 18:46:35 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "baremetaldevice.h"
|
|
|
|
|
#include "baremetaldeviceconfigurationwidget.h"
|
2015-04-26 13:06:25 +03:00
|
|
|
#include "defaultgdbserverprovider.h"
|
|
|
|
|
#include "gdbserverprovidermanager.h"
|
2014-12-20 19:10:02 +00:00
|
|
|
#include "gdbserverproviderprocess.h"
|
|
|
|
|
|
2013-09-12 18:46:35 +02:00
|
|
|
#include <coreplugin/id.h>
|
2015-04-26 13:06:25 +03:00
|
|
|
|
|
|
|
|
#include <ssh/sshconnection.h>
|
2013-09-12 18:46:35 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2015-04-26 13:06:25 +03:00
|
|
|
|
2013-09-20 17:34:15 +02:00
|
|
|
#include <QCoreApplication>
|
2013-09-12 18:46:35 +02:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace BareMetal {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-12-20 19:10:02 +00:00
|
|
|
const char gdbServerProviderIdKeyC[] = "GdbServerProviderId";
|
2013-09-20 17:34:15 +02:00
|
|
|
|
2013-09-12 18:46:35 +02:00
|
|
|
BareMetalDevice::Ptr BareMetalDevice::create()
|
|
|
|
|
{
|
|
|
|
|
return Ptr(new BareMetalDevice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BareMetalDevice::Ptr BareMetalDevice::create(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
return Ptr(new BareMetalDevice(name, type, machineType, origin, id));
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-20 17:34:15 +02:00
|
|
|
BareMetalDevice::Ptr BareMetalDevice::create(const BareMetalDevice &other)
|
|
|
|
|
{
|
|
|
|
|
return Ptr(new BareMetalDevice(other));
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-20 19:10:02 +00:00
|
|
|
QString BareMetalDevice::gdbServerProviderId() const
|
|
|
|
|
{
|
|
|
|
|
return m_gdbServerProviderId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BareMetalDevice::setGdbServerProviderId(const QString &id)
|
|
|
|
|
{
|
|
|
|
|
m_gdbServerProviderId = id;
|
2017-03-17 10:36:50 +02:00
|
|
|
GdbServerProvider *provider = GdbServerProviderManager::findProvider(id);
|
2016-05-02 22:07:28 +03:00
|
|
|
QTC_ASSERT(provider, return);
|
|
|
|
|
const QString channel = provider->channel();
|
|
|
|
|
const int colon = channel.indexOf(QLatin1Char(':'));
|
|
|
|
|
if (colon < 0)
|
|
|
|
|
return;
|
|
|
|
|
QSsh::SshConnectionParameters sshParams = sshParameters();
|
|
|
|
|
sshParams.host = channel.left(colon);
|
|
|
|
|
sshParams.port = channel.mid(colon + 1).toUShort();
|
|
|
|
|
setSshParameters(sshParams);
|
2014-12-20 19:10:02 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-20 17:34:15 +02:00
|
|
|
void BareMetalDevice::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
IDevice::fromMap(map);
|
2015-04-26 13:06:25 +03:00
|
|
|
QString gdbServerProvider = map.value(QLatin1String(gdbServerProviderIdKeyC)).toString();
|
|
|
|
|
if (gdbServerProvider.isEmpty()) {
|
2015-08-20 08:48:06 +03:00
|
|
|
const QString name = displayName();
|
2017-03-17 10:36:50 +02:00
|
|
|
if (GdbServerProvider *provider = GdbServerProviderManager::findByDisplayName(name)) {
|
2015-08-20 08:48:06 +03:00
|
|
|
gdbServerProvider = provider->id();
|
|
|
|
|
} else {
|
|
|
|
|
const QSsh::SshConnectionParameters sshParams = sshParameters();
|
|
|
|
|
DefaultGdbServerProvider *newProvider = new DefaultGdbServerProvider;
|
|
|
|
|
newProvider->setDisplayName(name);
|
|
|
|
|
newProvider->m_host = sshParams.host;
|
|
|
|
|
newProvider->m_port = sshParams.port;
|
2017-03-17 10:36:50 +02:00
|
|
|
if (GdbServerProviderManager::registerProvider(newProvider))
|
2015-08-20 08:48:06 +03:00
|
|
|
gdbServerProvider = newProvider->id();
|
|
|
|
|
else
|
|
|
|
|
delete newProvider;
|
|
|
|
|
}
|
2015-04-26 13:06:25 +03:00
|
|
|
}
|
|
|
|
|
setGdbServerProviderId(gdbServerProvider);
|
2013-09-20 17:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap BareMetalDevice::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = IDevice::toMap();
|
2014-12-20 19:10:02 +00:00
|
|
|
map.insert(QLatin1String(gdbServerProviderIdKeyC), gdbServerProviderId());
|
2013-09-20 17:34:15 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-12 18:46:35 +02:00
|
|
|
BareMetalDevice::IDevice::Ptr BareMetalDevice::clone() const
|
|
|
|
|
{
|
|
|
|
|
return Ptr(new BareMetalDevice(*this));
|
2013-09-20 15:08:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeviceProcessSignalOperation::Ptr BareMetalDevice::signalOperation() const
|
|
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
return DeviceProcessSignalOperation::Ptr();
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BareMetalDevice::displayType() const
|
|
|
|
|
{
|
2013-09-20 17:34:15 +02:00
|
|
|
return QCoreApplication::translate("BareMetal::Internal::BareMetalDevice", "Bare Metal");
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
IDeviceWidget *BareMetalDevice::createWidget()
|
2013-09-12 18:46:35 +02:00
|
|
|
{
|
|
|
|
|
return new BareMetalDeviceConfigurationWidget(sharedFromThis());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Core::Id> BareMetalDevice::actionIds() const
|
|
|
|
|
{
|
2013-09-20 17:34:15 +02:00
|
|
|
return QList<Core::Id>(); // no actions
|
2013-09-12 18:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BareMetalDevice::displayNameForActionId(Core::Id actionId) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(actionIds().contains(actionId), return QString());
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BareMetalDevice::executeAction(Core::Id actionId, QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(actionIds().contains(actionId), return);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
DeviceProcess *BareMetalDevice::createProcess(QObject *parent) const
|
2014-12-20 19:10:02 +00:00
|
|
|
{
|
|
|
|
|
return new GdbServerProviderProcess(sharedFromThis(), parent);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-12 18:46:35 +02:00
|
|
|
BareMetalDevice::BareMetalDevice(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id)
|
|
|
|
|
: IDevice(type, origin, machineType, id)
|
|
|
|
|
{
|
|
|
|
|
setDisplayName(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BareMetalDevice::BareMetalDevice(const BareMetalDevice &other)
|
|
|
|
|
: IDevice(other)
|
|
|
|
|
{
|
2014-12-20 19:10:02 +00:00
|
|
|
setGdbServerProviderId(other.gdbServerProviderId());
|
2014-06-05 17:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-12 18:46:35 +02:00
|
|
|
} //namespace Internal
|
|
|
|
|
} //namespace BareMetal
|